public Trainer(string n, Pokemon[] m, Bitmap b, TrainerType t) { this.name = n; this.party.AddRange(m); for (int i = 0; i < this.party.Count; i++) { this.party[i].OTid = this.id; this.party[i].OTsecretid = this.secretID; this.party[i].OTname = this.name; } this.img = b; this.type = t; }
private static bool catcher(Pokemon target, byte i) { ushort A = target.MaxHP; ushort B = target.HP; byte C = target.baseStats.catchRate; if (i == 1) C = (byte)(target.baseStats.catchRate * 1.5); else if (i == 2) C = (byte)(target.baseStats.catchRate * 2); else if (i == 3) C = 255; double D = 1; if (target.NonVolStatus == NonVolatileAilment.Poison) D = 1.5; else if (target.NonVolStatus == NonVolatileAilment.Burn) D = 1.5; else if (target.NonVolStatus == NonVolatileAilment.Sleep) D = 2; else if (target.NonVolStatus == NonVolatileAilment.Freeze) D = 2; else if (target.NonVolStatus == NonVolatileAilment.Paralyze) D = 1.5; uint X = (uint)((((A * 3) - (B * 2)) * C) / A * 3 * D); if (X == 0) X = 1; if (X > 255) return true; else return false; }
public static Move calculateHiddenPower(Pokemon target, Pokemon user) { int a = (user.hpIV % 2); int b = ((user.attackIV % 2) * 2); int c = ((user.defenseIV % 2) * 4); int d = ((user.speedIV % 2) * 8); int e = ((user.specialAttackIV % 2) * 16); int f = ((user.specialDefenseIV % 2) * 32); int elementint = ((a + b + c + d + e + f) * 15 / 63); Types element = Types.Normal; switch (elementint) { case 0: element = Types.Fighting; break; case 1: element = Types.Flying; break; case 2: element = Types.Poison; break; case 3: element = Types.Ground; break; case 4: element = Types.Rock; break; case 5: element = Types.Bug; break; case 6: element = Types.Ghost; break; case 7: element = Types.Steel; break; case 8: element = Types.Fire; break; case 9: element = Types.Water; break; case 10: element = Types.Grass; break; case 11: element = Types.Electric; break; case 12: element = Types.Psychic; break; case 13: element = Types.Ice; break; case 14: element = Types.Dragon; break; case 15: element = Types.Dark; break; } int u = (user.hpIV % 4 < 2 ? 1 : 0); int v = ((user.attackIV % 4 < 2 ? 1 : 0) * 2); int w = ((user.defenseIV % 4 < 2 ? 1 : 0) * 4); int x = ((user.speedIV % 4 < 2 ? 1 : 0) * 8); int y = ((user.specialAttackIV % 4 < 2 ? 1 : 0) * 16); int z = ((user.specialDefenseIV % 4 < 2 ? 1 : 0) * 32); byte power = (byte)((u + v + w + x + y + z) * 40 / 63 + 30); return new Move("Hidden Power", element, DamageCategory.Special, 15, power, 100, false); }
public PokemonStatus(Pokemon pokemon) { this.InitializeComponent(); this.lblName.Text = (string.IsNullOrEmpty(pokemon.nickname) ? pokemon.nickname : pokemon.baseStats.name); this.lblLevel.Text = "Lv." + pokemon.Level; this.pbox.Image = pokemon.FrontImage; this.lblItemName.Text = ((pokemon.heldItem == null) ? "None" : pokemon.heldItem.name); this.lblPokedexNo.Text = pokemon.baseStats.id.ToString(); this.lblSpecies.Text = pokemon.baseStats.name; this.lblType.Text = pokemon.baseStats.types.ToString(); this.lblOT.Text = pokemon.OTname; this.lblIDNo.Text = pokemon.OTid.ToString(); this.lblExpPoints.Text = pokemon.Exp.ToString(); switch (pokemon.baseStats.growthRate) { case GrowthRate.MediumFast: this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) - pokemon.Exp).ToString(); break; case GrowthRate.Erratic: if (pokemon.Level <= 50) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * (double)(100 - pokemon.Level) * 0.02 - pokemon.Exp).ToString(); } else { if (pokemon.Level <= 68) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * (double)(150 - pokemon.Level) * 0.01 - pokemon.Exp).ToString(); } else { if (pokemon.Level <= 98) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * (double)(1911 - (int)(10 * pokemon.Level / 3)) * 0.02 - pokemon.Exp).ToString(); } else { if (pokemon.Level <= 100) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * (double)(160 - pokemon.Level) * 0.01 - pokemon.Exp).ToString(); } } } } break; case GrowthRate.Fluctuating: if (pokemon.Level <= 15) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * ((double)((pokemon.Level + 1) / 3 + 24) * 0.02) - pokemon.Exp).ToString(); } else { if (pokemon.Level <= 36) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * ((double)(pokemon.Level + 14) * 0.02) - pokemon.Exp).ToString(); } else { if (pokemon.Level <= 100) { this.lblToNextLv.Text = (Math.Pow((double)pokemon.Level, 3.0) * ((double)((pokemon.Level >> 1) + 32) * 0.02) - pokemon.Exp).ToString(); } } } break; case GrowthRate.MediumSlow: this.lblToNextLv.Text = (1.2 * Math.Pow((double)pokemon.Level, 3.0) - 15.0 * Math.Pow((double)pokemon.Level, 2.0) + (double)(100 * pokemon.Level) - 140.0 - pokemon.Exp).ToString(); break; case GrowthRate.Fast: this.lblToNextLv.Text = (0.8 * Math.Pow((double)pokemon.Level, 3.0) - pokemon.Exp).ToString(); break; case GrowthRate.Slow: this.lblToNextLv.Text = (1.25 * Math.Pow((double)pokemon.Level, 3.0) - pokemon.Exp).ToString(); break; } this.pbEXP.Value = (int)((ulong)pokemon.Exp / (ulong)((long)int.Parse(this.lblToNextLv.Text) + (long)((ulong)pokemon.Exp))) * 100; this.lblNature.Text = pokemon.nature + " nature."; this.lblDateMet.Text = pokemon.dateMet.ToString(); this.lblMetLocation.Text = pokemon.metLocation.name; this.lblMetLevel.Text = "Met at Lv." + pokemon.metLevel + '.'; byte[] array = new byte[] { pokemon.hpIV, pokemon.attackIV, pokemon.defenseIV, pokemon.speedIV, pokemon.specialAttackIV, pokemon.specialDefenseIV }; Array.Sort<byte>(array); byte b = 0; if (array[array.Length - 1] == array[array.Length - 2]) { int num = (int)(pokemon.personality % 6u); for (int i = 0; i < array.Length; i++) { if (array[num] == array[array.Length - 1]) { b = array[array.Length - 1]; break; } if (array[num] == array[array.Length - 2]) { b = array[array.Length - 2]; break; } if (++num == 6) { num = 0; } } } else { b = array[array.Length - 1]; } if (b == pokemon.hpIV) { switch (pokemon.hpIV % 5) { case 0: this.lblChar.Text = "Loves to eat."; break; case 1: this.lblChar.Text = "Often dozes off."; break; case 2: this.lblChar.Text = "Often scatters things."; break; case 3: this.lblChar.Text = "Scatters things often."; break; case 4: this.lblChar.Text = "Likes to relax."; break; } } else { if (b == pokemon.attackIV) { switch (pokemon.attackIV % 5) { case 0: this.lblChar.Text = "Proud of its power."; break; case 1: this.lblChar.Text = "Likes to thrash about."; break; case 2: this.lblChar.Text = "A little quick tempered."; break; case 3: this.lblChar.Text = "Likes to fight."; break; case 4: this.lblChar.Text = "Quick tempered."; break; } } else { if (b == pokemon.defenseIV) { switch (pokemon.defenseIV % 5) { case 0: this.lblChar.Text = ""; break; case 1: this.lblChar.Text = ""; break; case 2: this.lblChar.Text = ""; break; case 3: this.lblChar.Text = ""; break; case 4: this.lblChar.Text = ""; break; } } else { if (b == pokemon.specialAttackIV) { switch (pokemon.specialAttackIV % 5) { case 0: this.lblChar.Text = ""; break; case 1: this.lblChar.Text = ""; break; case 2: this.lblChar.Text = ""; break; case 3: this.lblChar.Text = ""; break; case 4: this.lblChar.Text = ""; break; } } else { if (b == pokemon.specialDefenseIV) { switch (pokemon.specialDefenseIV % 5) { case 0: this.lblChar.Text = ""; break; case 1: this.lblChar.Text = ""; break; case 2: this.lblChar.Text = ""; break; case 3: this.lblChar.Text = ""; break; case 4: this.lblChar.Text = ""; break; } } else { if (b == pokemon.speedIV) { switch (pokemon.speedIV % 5) { case 0: this.lblChar.Text = ""; break; case 1: this.lblChar.Text = ""; break; case 2: this.lblChar.Text = ""; break; case 3: this.lblChar.Text = ""; break; case 4: this.lblChar.Text = ""; break; } } } } } } } this.lblFlavour.Text = "NYI"; this.lblHP.Text = pokemon.HP + "/" + pokemon.MaxHP; this.pbHP.Value = (int)(pokemon.HP / pokemon.MaxHP * 100); this.lblAttack.Text = pokemon.Attack.ToString(); this.lblDefense.Text = pokemon.Defense.ToString(); this.lblSpAtk.Text = pokemon.SpecialAttack.ToString(); this.lblSpDef.Text = pokemon.SpecialDefense.ToString(); this.lblSpeed.Text = pokemon.Speed.ToString(); this.lblAbilityName.Text = pokemon.ability.name; if (pokemon.ability.desc.Length > 22) { this.lblAbilityDesc1.Text = pokemon.ability.desc.Substring(0, pokemon.ability.desc.IndexOf(' ', 17)); this.lblAbilityDesc2.Text = pokemon.ability.desc.Substring(pokemon.ability.desc.IndexOf(' ', 17)); } else { this.lblAbilityDesc1.Text = pokemon.ability.desc; } Label[] array2 = new Label[] { this.lblMove1, this.lblMove2, this.lblMove3, this.lblMove4 }; Label[] array3 = new Label[] { this.lblPP1, this.lblPP2, this.lblPP3, this.lblPP4 }; for (int i = 0; i < pokemon.moveSet.Length; i++) { if (pokemon.moveSet[i] != null) { array2[i].Text = pokemon.moveSet[i].name; array3[i].Text = string.Concat(new object[] { "PP ", pokemon.PP[i], '/', (double)pokemon.moveSet[i].basePP + (double)pokemon.moveSet[i].basePP * 0.2 * (double)pokemon.PPbonuses[i] }); } else { array2[i].Text = "---"; array3[i].Text = "---"; } } }
public void Use(Pokemon target, byte i, bool battle) { if (battle) battleEffect(target, i); else fieldEffect(target, i); }
public static Pokemon breed(Pokemon father, Pokemon mother) { int compat; if (father.gender == mother.gender || father.baseStats.eggGroups.HasFlag(EggGroups.NoEgg) || mother.baseStats.eggGroups.HasFlag(EggGroups.NoEgg)) return null; foreach (EggGroups group in Enum.GetValues(typeof(EggGroups))) { if ((mother.baseStats.eggGroups & group) != group) return null; } compat = father.baseStats == mother.baseStats ? (father.OTid == mother.OTid ? 50 : 70) : (father.OTid == mother.OTid ? 20 : 50); int chance = PRNG.Instance.Next(100); if (chance < compat) { Pokemon child; child = mother.baseStats.eggGroups == EggGroups.Ditto ? new Pokemon(father.baseStats) : new Pokemon(mother.baseStats); int i = 0; foreach (LearnableMove m in child.baseStats.learnset) { if (father.moveSet.Contains(m.move) && mother.moveSet.Contains(m.move)) { child.moveSet[i] = m.move; i = i == 3 ? 0 : i + 1; } } //hm //tm //egg moves return child; } else return null; }
public bool givePokemon(Pokemon mon) { bool result; if (this.party.Count < 6) { mon.OTid = this.id; mon.OTsecretid = this.secretID; mon.OTname = this.name; this.party.Add(mon); if (new TextWindow(new[] { "Give a nickname to " + mon.baseStats.name + "?" }, new[] { "Yes", "No" }).Show() == 0) { //mon.nickname = new NameEntry(mon.FrontImage).enterName(); } result = true; } else { if (this.depositPokemon(mon)) { mon.OTid = this.id; mon.OTsecretid = this.secretID; mon.OTname = this.name; if (new TextWindow(new[] { "Give a nickname to " + mon.baseStats.name + "?" }, new[] { "Yes", "No" }).Show() == 0) { //mon.nickname = new NameEntry(mon.FrontImage).enterName(); } new TextWindow(new[] { mon.nickname + " was sent to BILL'S PC." }).Show(); result = true; } else { result = false; } } return result; }
public void GiveItem(Item i, Pokemon p) { this.DropItem(i); p.heldItem = i; }
public bool depositPokemon(Pokemon p) { bool result; if (this.boxes.Count > 240) { result = false; } else { this.boxes.Add(p); result = true; } return result; }