void Experience(Pokemon p) { //Experience calculation and award code. Right now there's a flat 300 experience threshold per level, soon to change. double multiplier = 1; //This is a band-aid multiplier that simply makes trainer battles give more experience. if (encounterType == "trainer") multiplier = 1.30; /* The amount of experience actually awarded for defeating another Pokemon. * This is actually an expression of percentage for the current level. * I.E., if an enemy Pokemon would yield 1.5 expYield experience, it would award * the current Pokemon 450 exp using the 300 exp / level formula, so 1.5 level. * In a system with incremental experience thresholds per level, it would still be * 450 exp, which would amount to less than 1.5 level this time around. */ double expYield; if (p.level <= enemyPokemon.level) expYield = (((double)enemyPokemon.level - (double)p.level) * 0.33) + 0.45; else expYield = (((double)enemyPokemon.level - (double)p.level) * 0.05) + 0.45; //Program.Log("Exp yield was " + expYield.ToString(), 1); //The above log code helped me test exp yield, keeping it here in case it comes in handy. //If expYield would amount to less than 10% of a level (0.1), it instead becomes 0.1. if (expYield < 0.1) expYield = 0.1; p.experience += Convert.ToInt32(expYield * 300.0 * multiplier / 1.3); Program.Log(p.name + " received " + Convert.ToInt32(expYield * 300.0 * multiplier / 1.4) + " experience.", 1); //This is a while loop to facilitate for the case that a Pokemon gains more than 1 level at a time. while (p.experience >= 300) { Program.Log(p.name + " levelled up.", 0); p.LevelUp(); } }