Minor updates

Fix mark (ribbon) read for index > 64
Heal party stats on set detail import
Wipe HT Language for eggs/untraded
Extract BST total color logic
This commit is contained in:
Kurt
2019-11-25 17:32:10 -08:00
parent 4a40d8c08f
commit 5435a5d93e
5 changed files with 9 additions and 5 deletions

View File

@@ -377,7 +377,7 @@ public static void ApplySetDetails(this PKM pk, ShowdownSet Set)
b.ResetCalculatedValues();
}
}
if (pk is IGigantamax c)
c.CanGigantamax = Set.CanGigantamax;
@@ -387,6 +387,7 @@ public static void ApplySetDetails(this PKM pk, ShowdownSet Set)
var legal = new LegalityAnalysis(pk);
if (legal.Parsed && legal.Info.Relearn.Any(z => !z.Valid))
pk.SetRelearnMoves(legal.GetSuggestedRelearnMoves());
pk.ResetPartyStats();
pk.RefreshChecksum();
}

View File

@@ -600,7 +600,7 @@ public void FixMemories()
{
if (IsEgg) // No memories if is egg.
{
HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling =
HT_Language = HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling =
/* OT_Friendship */ OT_Affection = OT_TextVar = OT_Memory = OT_Intensity = OT_Feeling = 0;
// Clear Handler
@@ -609,7 +609,7 @@ public void FixMemories()
}
if (IsUntraded)
HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling = 0;
HT_Language = HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling = 0;
if (GenNumber < 6)
{
/* OT_Affection = */
@@ -673,6 +673,7 @@ public int GetRibbonByte(int index)
throw new ArgumentOutOfRangeException(nameof(index));
if (index < 64)
return 0x34 + (index >> 3);
index -= 64;
return 0x40 + (index >> 3);
}
}

View File

@@ -229,6 +229,8 @@ public static Color ColorBaseStat(int v)
return Blend(Color.FromArgb((int)red, (int)green, 0), Color.White, 0.4);
}
public static Color ColorBaseStatTotal(int tot) => ColorBaseStat((int) (Math.Max(0, tot - 175) / 3f));
public static Color Blend(Color color, Color backColor, double amount)
{
byte r = (byte)((color.R * amount) + (backColor.R * (1 - amount)));

View File

@@ -340,7 +340,7 @@ private void LoadBST(PersonalInfo pi)
}
var bst = pi.BST;
TB_BST.Text = bst.ToString("000");
TB_BST.BackColor = ImageUtil.ColorBaseStat((int)(Math.Max(0, bst - 175) / 3f));
TB_BST.BackColor = ImageUtil.ColorBaseStatTotal(bst);
}
public void UpdateRandomIVs(object sender, EventArgs e)

View File

@@ -52,7 +52,7 @@ private void PopEntry(int index)
row.Cells[r++].Value = SpriteUtil.GetSprite(s, f, 0, 0, false, false, SAV.Generation);
row.Cells[r++].Value = species[index];
row.Cells[r++].Value = GetIsNative(p, s);
row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStat((int)((Math.Max(p.BST - 175, 0)) / 3f));
row.Cells[r].Style.BackColor = ImageUtil.ColorBaseStatTotal(p.BST);
row.Cells[r++].Value = p.BST.ToString("000");
row.Cells[r++].Value = SpriteUtil.GetTypeSprite(p.Type1, SAV.Generation);
row.Cells[r++].Value = p.Type1 == p.Type2 ? SpriteUtil.Spriter.Transparent : SpriteUtil.GetTypeSprite(p.Type2, SAV.Generation);