public static void Attack(ICreature attacker, ICreature deffender, int answer) { //Chance of armor deflecting the attack //If armor doesnt stop the attack. if (RandomChance.Success(100 - deffender.Armor)) { //Chance of dealing damage. int damageDealth = attacker.Attack(attacker.AttackChance[answer], attacker.AttackPower[answer]); //If any damage dealth if (damageDealth != 0) { deffender.HP -= damageDealth; //If defender is dead. if (deffender.HP > 0) { Console.WriteLine($"{attacker.Name} dealth {damageDealth} damage. {deffender.Name} now has {deffender.HP}HP"); } else { Console.WriteLine("{1} dealth {0} damage.", damageDealth, attacker.Name); } } //No damage dealth. else { //Attack failed Console.WriteLine("{1} couldn't perform {0}.", attacker.AttackNames[answer], attacker.Name); } } else { //armor blocked Console.WriteLine("{0}'s armor stopped {1} attack.", deffender.Name, attacker.Name); } }
//methods public int Attack(int chance, double multiplier) { //80% chance for a strike if (RandomChance.Success(chance)) { return(Convert.ToInt32(this.Damage * multiplier)); } else { return(0); } }
public int StrongAttack() { //55% chance for a strike if (RandomChance.Success(55)) { return(this.Damage); } else { return(0); } }
public int UltimateAttack() { //30% chance for a strike if (RandomChance.Success(30)) { return(this.Damage * 2); } else { return(0); } }
public int WeakAttack() { //80% chance for a strike if (RandomChance.Success(80)) { return(this.Damage / 2); } else { return(0); } }