public PK1 convertToPK1() { PK1 pk1 = new PK1(null, Identifier, Japanese); Array.Copy(Data, 0x1, pk1.Data, 0x7, 0x1A); pk1.Species = Species; // This will take care of Typing :) pk1.Stat_HPCurrent = Stat_HPCurrent; pk1.Stat_Level = Stat_Level; // Status = 0 Array.Copy(otname, 0, pk1.otname, 0, otname.Length); Array.Copy(nick, 0, pk1.nick, 0, nick.Length); int[] newMoves = pk1.Moves; for (int i = 0; i < 4; i++) { if (newMoves[i] > 165) // not present in Gen 1 { newMoves[i] = 0; } } pk1.Moves = newMoves; pk1.FixMoves(); return(pk1); }
/// <summary> /// Gets the Tradeback status depending on the <see cref="PK1.Catch_Rate"/> /// </summary> /// <param name="pkm">Pokémon to guess the tradeback status from.</param> private static TradebackType GetTradebackStatusRBY(PK1 pkm) { if (!ParseSettings.AllowGen1Tradeback) { return(TradebackType.Gen1_NotTradeback); } // Detect tradeback status by comparing the catch rate(Gen1)/held item(Gen2) to the species in the pkm's evolution chain. var catch_rate = pkm.Catch_Rate; if (catch_rate == 0) { return(TradebackType.WasTradeback); } var table = EvolutionTree.GetEvolutionTree(1); var lineage = table.GetValidPreEvolutions(pkm, maxLevel: pkm.CurrentLevel); var gen1 = lineage.Select(evolution => evolution.Species); bool matchAny = GetCatchRateMatchesPreEvolution(pkm, catch_rate, gen1); if (!matchAny) { return(TradebackType.WasTradeback); } if (HeldItems_GSC.Contains((ushort)catch_rate)) { return(TradebackType.Any); } return(TradebackType.Gen1_NotTradeback); }
public PokemonList1(byte[] d, CapacityType c = CapacityType.Single, bool jp = false) { Japanese = jp; Data = d ?? getEmptyList(c, Japanese); Capacity = getCapacity(c); Entry_Size = getEntrySize(c); if (Data.Length != DataSize) { Array.Resize(ref Data, DataSize); } Pokemon = new PK1[Capacity]; for (int i = 0; i < Capacity; i++) { int base_ofs = 2 + Capacity; byte[] dat = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray(); Pokemon[i] = new PK1(dat, null, jp) { otname = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * i).Take(StringLength).ToArray(), nick = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * Capacity + StringLength * i) .Take(StringLength).ToArray() }; } }
public override PKM Clone() { PK1 new_pk1 = new PK1(Data, Identifier, Japanese); Array.Copy(otname, 0, new_pk1.otname, 0, otname.Length); Array.Copy(nick, 0, new_pk1.nick, 0, nick.Length); return(new_pk1); }
private const int SIZE_RESERVED = 0x8000; // unpacked box data public override byte[] Write(bool DSV) { for (int i = 0; i < BoxCount; i++) { PokemonList1 boxPL = new PokemonList1(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese); int slot = 0; for (int j = 0; j < boxPL.Pokemon.Length; j++) { PK1 boxPK = (PK1)getPKM(getData(getBoxOffset(i) + j * SIZE_STORED, SIZE_STORED)); if (boxPK.Species > 0) { boxPL[slot++] = boxPK; } } if (i < BoxCount / 2) { boxPL.GetBytes().CopyTo(Data, 0x4000 + i * SIZE_STOREDBOX); } else { boxPL.GetBytes().CopyTo(Data, 0x6000 + (i - BoxCount / 2) * SIZE_STOREDBOX); } if (i == CurrentBox) { boxPL.GetBytes().CopyTo(Data, Japanese ? 0x302D : 0x30C0); } } PokemonList1 partyPL = new PokemonList1(PokemonList1.CapacityType.Party, Japanese); int pSlot = 0; for (int i = 0; i < 6; i++) { PK1 partyPK = (PK1)getPKM(getData(getPartyOffset(i), SIZE_STORED)); if (partyPK.Species > 0) { partyPL[pSlot++] = partyPK; } } partyPL.GetBytes().CopyTo(Data, Japanese ? 0x2ED5 : 0x2F2C); // Daycare is read-only, but in case it ever becomes editable, copy it back in. byte[] rawDC = getData(getDaycareSlotOffset(loc: 0, slot: 0), SIZE_STORED); byte[] dc = new byte[1 + 2 * StringLength + PKX.SIZE_1STORED]; dc[0] = rawDC[0]; Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY + StringLength, dc, 1, StringLength); Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY, dc, 1 + StringLength, StringLength); Array.Copy(rawDC, 2 + 1, dc, 1 + 2 * StringLength, PKX.SIZE_1STORED); dc.CopyTo(Data, Japanese ? 0x2CA7 : 0x2CF4); setChecksums(); byte[] outData = new byte[Data.Length - SIZE_RESERVED]; Array.Copy(Data, outData, outData.Length); return(outData); }
internal static int GetRequiredMoveCount(PK1 pk, IReadOnlyList <int> moves, LegalInfo info, IReadOnlyList <int> initialmoves) { if (!pk.Gen1_NotTradeback) // No Move Deleter in Gen 1 { return(1); // Move Deleter exits, slots from 2 onwards can always be empty } int required = GetRequiredMoveCount(pk, moves, info.EncounterMoves.LevelUpMoves, initialmoves); if (required >= 4) { return(4); } // tm, hm and tutor moves replace a free slots if the pokemon have less than 4 moves // Ignore tm, hm and tutor moves already in the learnset table var learn = info.EncounterMoves.LevelUpMoves; var tmhm = info.EncounterMoves.TMHMMoves; var tutor = info.EncounterMoves.TutorMoves; var union = initialmoves.Union(learn[1]); required += moves.Count(m => m != 0 && union.All(t => t != m) && (tmhm[1].Any(t => t == m) || tutor[1].Any(t => t == m))); return(Math.Min(4, required)); }
private PKM preparePK1() { PK1 pk1 = pkm as PK1; if (pk1 == null) { return(null); } pk1.Species = Util.getIndex(CB_Species); pk1.TID = Util.ToInt32(TB_TID.Text); pk1.EXP = Util.ToUInt32(TB_EXP.Text); pk1.EV_HP = Util.ToInt32(TB_HPEV.Text); pk1.EV_ATK = Util.ToInt32(TB_ATKEV.Text); pk1.EV_DEF = Util.ToInt32(TB_DEFEV.Text); pk1.EV_SPE = Util.ToInt32(TB_SPEEV.Text); pk1.EV_SPC = Util.ToInt32(TB_SPAEV.Text); if (CHK_Nicknamed.Checked) { pk1.Nickname = TB_Nickname.Text; } else { pk1.setNotNicknamed(); } pk1.Move1 = Util.getIndex(CB_Move1); pk1.Move2 = Util.getIndex(CB_Move2); pk1.Move3 = Util.getIndex(CB_Move3); pk1.Move4 = Util.getIndex(CB_Move4); pk1.Move1_PP = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; pk1.Move2_PP = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; pk1.Move3_PP = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; pk1.Move4_PP = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; pk1.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; pk1.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; pk1.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; pk1.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; pk1.IV_HP = Util.ToInt32(TB_HPIV.Text); pk1.IV_ATK = Util.ToInt32(TB_ATKIV.Text); pk1.IV_DEF = Util.ToInt32(TB_DEFIV.Text); pk1.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pk1.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pk1.OT_Name = TB_OT.Text; // Toss in Party Stats Array.Resize(ref pk1.Data, pk1.SIZE_PARTY); pk1.Stat_Level = Util.ToInt32(TB_Level.Text); pk1.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); pk1.Stat_HPMax = Util.ToInt32(Stat_HP.Text); pk1.Stat_ATK = Util.ToInt32(Stat_ATK.Text); pk1.Stat_DEF = Util.ToInt32(Stat_DEF.Text); pk1.Stat_SPE = Util.ToInt32(Stat_SPE.Text); pk1.Stat_SPA = Util.ToInt32(Stat_SPA.Text); pk1.Stat_SPD = Util.ToInt32(Stat_SPD.Text); if (HaX) { pk1.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } // Fix Moves if a slot is empty pk1.FixMoves(); pk1.RefreshChecksum(); return(pk1); }
private void populateFieldsPK1() { PK1 pk1 = pkm as PK1; if (pk1 == null) { return; } // Do first pk1.Stat_Level = HaX ? pk1.Stat_Level : PKX.getLevel(pk1.Species, pk1.EXP); if (!HaX && pk1.Stat_Level == 100) { pk1.EXP = PKX.getEXP(pk1.Stat_Level, pk1.Species); } CB_Species.SelectedValue = pk1.Species; if (HaX) { MT_Level.Text = pk1.Stat_Level.ToString(); } TB_Level.Text = pk1.Stat_Level.ToString(); TB_EXP.Text = pk1.EXP.ToString(); // Load rest TB_TID.Text = pk1.TID.ToString("00000"); CHK_Nicknamed.Checked = pk1.IsNicknamed; TB_Nickname.Text = pk1.Nickname; TB_OT.Text = pk1.OT_Name; GB_OT.BackgroundImage = null; // Reset Label and ComboBox visibility, as well as non-data checked status. Label_PKRS.Visible = false; Label_PKRSdays.Visible = false; TB_HPIV.Text = pk1.IV_HP.ToString(); TB_ATKIV.Text = pk1.IV_ATK.ToString(); TB_DEFIV.Text = pk1.IV_DEF.ToString(); TB_SPEIV.Text = pk1.IV_SPE.ToString(); TB_SPAIV.Text = pk1.IV_SPA.ToString(); TB_HPEV.Text = pk1.EV_HP.ToString(); TB_ATKEV.Text = pk1.EV_ATK.ToString(); TB_DEFEV.Text = pk1.EV_DEF.ToString(); TB_SPEEV.Text = pk1.EV_SPE.ToString(); TB_SPAEV.Text = pk1.EV_SPA.ToString(); CB_Move1.SelectedValue = pk1.Move1; CB_Move2.SelectedValue = pk1.Move2; CB_Move3.SelectedValue = pk1.Move3; CB_Move4.SelectedValue = pk1.Move4; CB_PPu1.SelectedIndex = pk1.Move1_PPUps; CB_PPu2.SelectedIndex = pk1.Move2_PPUps; CB_PPu3.SelectedIndex = pk1.Move3_PPUps; CB_PPu4.SelectedIndex = pk1.Move4_PPUps; TB_PP1.Text = pk1.Move1_PP.ToString(); TB_PP2.Text = pk1.Move2_PP.ToString(); TB_PP3.Text = pk1.Move3_PP.ToString(); TB_PP4.Text = pk1.Move4_PP.ToString(); CB_Language.SelectedIndex = pk1.Japanese ? 0 : 1; updateStats(); TB_EXP.Text = pk1.EXP.ToString(); }
public PokemonList1(PK1 pk) : this(CapacityType.Single, pk.Japanese) { this[0] = pk; Count = 1; }
public PokemonList1(byte[] d, CapacityType c = CapacityType.Single, bool jp = false) { Japanese = jp; Data = d ?? getEmptyList(c, Japanese); Capacity = getCapacity(c); Entry_Size = getEntrySize(c); if (Data.Length != DataSize) { Array.Resize(ref Data, DataSize); } Pokemon = new PK1[Capacity]; for (int i = 0; i < Capacity; i++) { int base_ofs = 2 + Capacity; byte[] dat = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray(); Pokemon[i] = new PK1(dat, null, jp) { otname = Data.Skip(base_ofs + Capacity*Entry_Size + StringLength*i).Take(StringLength).ToArray(), nick = Data.Skip(base_ofs + Capacity*Entry_Size + StringLength*Capacity + StringLength*i) .Take(StringLength).ToArray() }; } }
public override PKM Clone() { PK1 new_pk1 = new PK1(Data, Identifier, Japanese); Array.Copy(otname, 0, new_pk1.otname, 0, otname.Length); Array.Copy(nick, 0, new_pk1.nick, 0, nick.Length); return new_pk1; }
public PK1 convertToPK1() { PK1 pk1 = new PK1(null, Identifier, Japanese); Array.Copy(Data, 0x1, pk1.Data, 0x7, 0x1A); pk1.Species = Species; // This will take care of Typing :) pk1.Stat_HPCurrent = Stat_HPCurrent; pk1.Stat_Level = Stat_Level; // Status = 0 Array.Copy(otname, 0, pk1.otname, 0, otname.Length); Array.Copy(nick, 0, pk1.nick, 0, nick.Length); int[] newMoves = pk1.Moves; for (int i = 0; i < 4; i++) if (newMoves[i] > 165) // not present in Gen 1 newMoves[i] = 0; pk1.Moves = newMoves; pk1.FixMoves(); return pk1; }