public Trainer(string Nick, int ID, Pokedex Pokedex) { this.Nick = Nick; this.Pokemon = new Pokemon(ID, Pokedex); }
/** * Note: * The reason why the skill calculation for * trainers and the AI is seperated is that * we want to be able to treat them differently. * Here's why: * The trainer's pokemon will probably NOT be recovered * after every fight, and recovering it costs cash. * Therefore, pokemons of trainers will often be hurt * before battle. Thus, the challengers have to be * way weaker or have to be calculated differently, therefore * we have decided to seperate their calculations * although it is actually way more complex than it * has to be. (It would be a lot easier to just write * one function for Skill-Castings) * To cut it down: For flexibility. */ public int[] DoTurn(Pokedex Pokedex, Pokemon Opponent) { int[] FResult = new int[]{0,0,0,0}; int Rand = this.Random.Next(0, 10); PokedexAbility Skill; switch (Rand) { // Buff itself case 0: case 1: case 2: Skill = this.Pokemon.getAbility(4); int Buff = Convert.ToInt32(Skill.Value * ((this.Pokemon.Intelligence + this.Pokemon.Dexterity) / 5)); this.Pokemon.Strength += Buff; this.Pokemon.Dexterity += Buff; this.Pokemon.BStrength += Buff; this.Pokemon.BDexterity += Buff; FResult[0] = 2; FResult[1] = Buff; break; default: { // Heal itself if ((this.Pokemon.Health < this.Pokemon.GetHealthFromSta()) && Rand < 5) { Skill = this.Pokemon.getAbility(2); int FirstHealing = Convert.ToInt32(Skill.Value * (this.Pokemon.Intelligence / 2)); int FinalHealing = Convert.ToInt32(FirstHealing + (this.Pokemon.GetHealthFromSta() / 20)); this.Pokemon.Health += FinalHealing; // Make sure HP is maximally 100% now if (this.Pokemon.Health > this.Pokemon.GetHealthFromSta()) this.Pokemon.Health = this.Pokemon.GetHealthFromSta(); FResult[0] = 1; FResult[1] = FinalHealing; } // Attack else { int Weakness = Opponent.getWeakness(); if (Weakness == this.Pokemon.Type.Type) Skill = this.Pokemon.getAbility(3); else Skill = this.Pokemon.getAbility(1); int Efficiency = Skill.Type.isEfficientAgainst(Opponent.Type.Type); double Amplifier = this.Pokedex.getAmplifierFromEfficiency(Efficiency); int FirstDamage = Convert.ToInt32(Skill.Value * Amplifier); int SecondDamage = Convert.ToInt32((FirstDamage * this.Pokemon.Strength) / 2); int FinalDamage = SecondDamage - (Opponent.Defense * 3); // At least 1 Damage will be dealt. (this essentially prevents attacks from healing opponent) if (FinalDamage < 1) FinalDamage = 1; // Fight is won if (FinalDamage >= Opponent.Health) { FResult[1] = 1; } FResult[2] = FinalDamage; FResult[3] = Efficiency; Opponent.Health = Opponent.Health - FinalDamage; } } break; } return FResult; }