/// <summary> /// Returns a rank from -4 to 7 /// </summary> /// <param name="e"></param> /// <param name="lastAction"></param> /// <returns></returns> private int getRecoverChance(BattlePokemon e, LastBattleAction lastAction) { BattlePokemon you = this; int hpThreshold = 40; //Percent of health at which to conisder recovering. int chance = 0; if (you.getHPPercentage() <= hpThreshold) { chance += 3; } else if (you.getHPPercentage() > (100 - hpThreshold)) { chance -= 2; } if (e.checkKOChance(you) < 0.3f) { chance += 2; //heal if the opponent cannot ohko us. } if (you.status != Status.STATE_HEALTHY && lastAction != LastBattleAction.ACTION_SLEEPTALK) { chance += 2; } if (lastAction == LastBattleAction.ACTION_RECOVER) { chance -= 2; } return(chance); }
/// <summary> /// /// </summary> /// <param name="you"></param> /// <param name="e"></param> /// <param name="m"></param> /// <returns></returns> private int getStatusChance(BattlePokemon you, BattlePokemon e, Move m, List <BattlePokemon> enemyTeam) { int max = GlobalConstants.MAX_MOVE_RANK; if (e.status != Status.STATE_HEALTHY) { return(-max); } if (e.mon.hasAbility("magic bounce")) { return(-max); } if (e.mon.hasAbility("poison heal") && m.statuseffect == "tox") { return(-max); } if (e.mon.hasAbility("limber") && m.statuseffect == "par") { return(-max); } if (m.statuseffect == "tox" && (e.hasType(types["poison"]) || e.hasType(types["steel"]))) { return(-max); } if (m.statuseffect == "par" && (e.hasType(types["ground"]) || e.hasType(types["electric"]))) { return(-max); } int chance = 0; if (m.statuseffect == "brn" && e.mon.getRole().physical) { chance += 2; } else if (m.statuseffect == "par" && (e.getStat("spe") >= you.getStat("spe"))) { chance += 2; } else if (m.statuseffect == "slp" && (you.getStat("spe") >= e.getStat("spe"))) { foreach (BattlePokemon bp in enemyTeam) { if (bp.status == Status.STATE_SLP) { return(-max); //abide by sleep clause } } chance += 2; } chance += (int)Math.Round(10 * e.checkKOChance(you)); //Increase chance if enemy is too strong and needs to be weakened. return(chance); }
private int getBoostChance(BattlePokemon you, BattlePokemon e, Move m, LastBattleAction lastAction) { int chance = 0; int minHP = 30; float enemyTolerance = 0.5f; List <String> boosts = m.whatBoosts(); //lower rank if already maxed out. foreach (string s in boosts) { if (this.getBoostModifier(s) == 4f) { chance -= 1; } } if (you.getHPPercentage() <= minHP) { chance -= 2; //too weak, should focus efforts elsewhere } if (e.checkKOChance(you) < enemyTolerance) { chance += 2; //enemy does not threaten us } else if (e.checkKOChance(you) - 0.2f < enemyTolerance) { chance += 2; //if boosting will make us survive, do it. } else { chance -= 2; //otherwise too risky } if (you.mon.getRole().setup) { chance += 4; //if the mon is a setup sweeper, etc, } if (lastAction == LastBattleAction.ACTION_BOOST) { chance -= 1; //Be careful not to boost forever. } return(chance); }
private int getBoostChance(BattlePokemon you, BattlePokemon e, Move m, LastBattleAction lastAction) { int chance = 0; int minHP = 30; float enemyTolerance = 0.5f; List<String> boosts = m.whatBoosts(); //lower rank if already maxed out. foreach (string s in boosts) { if (this.getBoostModifier(s) == 4f) chance -= 1; } if (you.getHPPercentage() <= minHP) chance -= 2; //too weak, should focus efforts elsewhere if (e.checkKOChance(you) < enemyTolerance) chance += 2; //enemy does not threaten us else if (e.checkKOChance(you) - 0.2f < enemyTolerance) chance += 2; //if boosting will make us survive, do it. else chance -= 2; //otherwise too risky if (you.mon.getRole().setup) chance += 4; //if the mon is a setup sweeper, etc, if (lastAction == LastBattleAction.ACTION_BOOST) chance -= 1; //Be careful not to boost forever. return chance; }
/// <summary> /// /// </summary> /// <param name="you"></param> /// <param name="e"></param> /// <param name="m"></param> /// <returns></returns> private int getStatusChance(BattlePokemon you, BattlePokemon e, Move m, List<BattlePokemon> enemyTeam) { int max = GlobalConstants.MAX_MOVE_RANK; if (e.status != Status.STATE_HEALTHY) return -max; if (e.mon.hasAbility("magic bounce")) return -max; if (e.mon.hasAbility("poison heal") && m.statuseffect == "tox") return -max; if (e.mon.hasAbility("limber") && m.statuseffect == "par") return -max; if (m.statuseffect == "tox" && (e.hasType(types["poison"]) || e.hasType(types["steel"]))) return -max; if (m.statuseffect == "par" && (e.hasType(types["ground"]) || e.hasType(types["electric"]))) return -max; int chance = 0; if (m.statuseffect == "brn" && e.mon.getRole().physical) chance += 2; else if (m.statuseffect == "par" && (e.getStat("spe") >= you.getStat("spe"))) chance += 2; else if (m.statuseffect == "slp" && (you.getStat("spe") >= e.getStat("spe"))) { foreach (BattlePokemon bp in enemyTeam) { if (bp.status == Status.STATE_SLP) return -max; //abide by sleep clause } chance += 2; } chance += (int)Math.Round(10 * e.checkKOChance(you)); //Increase chance if enemy is too strong and needs to be weakened. return chance; }
/// <summary> /// Returns a rank from -4 to 7 /// </summary> /// <param name="e"></param> /// <param name="lastAction"></param> /// <returns></returns> private int getRecoverChance(BattlePokemon e, LastBattleAction lastAction) { BattlePokemon you = this; int hpThreshold = 40; //Percent of health at which to conisder recovering. int chance = 0; if (you.getHPPercentage() <= hpThreshold) chance += 3; else if (you.getHPPercentage() > (100 - hpThreshold)) chance -= 2; if (e.checkKOChance(you) < 0.3f) chance += 2; //heal if the opponent cannot ohko us. if (you.status != Status.STATE_HEALTHY && lastAction != LastBattleAction.ACTION_SLEEPTALK) chance += 2; if (lastAction == LastBattleAction.ACTION_RECOVER) chance -= 2; return chance; }