// Get outcome of battle, depending on other fighter's weapon public int GetOutcome(Fighter fighter2) { if (fighter2.GetWeapon().Equals("Crossbow")) { return(Weapon.OutcomeBow()); } else if (fighter2.GetWeapon().Equals("Spear")) { return(Weapon.OutcomeSpear()); } else if (fighter2.GetWeapon().Equals("Sword & Shield")) { return(Weapon.OutcomeSword()); } else if (fighter2.GetWeapon().Equals("Warhammer")) { return(Weapon.OutcomeHammer()); } else { return(Weapon.OutcomeDagger()); } }
// display and get the outcome of a battle public static void DetermineOutcome(Fighter fighter1, Fighter fighter2, // int index1, int index2, List <Fighter> TeamA, List <Fighter> TeamB) { // variables int outcome = fighter1.GetOutcome(fighter2); // find out the outcome depending on their weapons // tell what the weapons Console.WriteLine($"\n{fighter1.GetName()} fights with a {fighter1.GetWeapon()}," + $" {fighter2.GetName()} attacks with a {fighter2.GetWeapon()}!"); // take action depending on the outcome if (outcome == 0) // if it's a tie { // tell players the outcome Console.WriteLine("They have both met their match! The fighters battle to the death, nobody wins."); // remove fighters from both lists TeamA.Remove(fighter1); TeamB.Remove(fighter2); } else if (outcome == 1) // if fighter 1 wins { // tell players the outcome Console.WriteLine($"The {fighter2.GetWeapon()} is no match for the {fighter1.GetWeapon()}. " + $"{fighter1.GetName()} wins, {fighter2.GetName()} dies!"); // remove the losing fighter TeamB.Remove(fighter2); } else // otherwise the outcome must be 2 - fighter 2 wins { // tell players the outcome Console.WriteLine($"The {fighter1.GetWeapon()} is no match for the {fighter2.GetWeapon()}. " + $"{fighter2.GetName()} wins, {fighter1.GetName()} dies!"); // remove the losing fighter TeamA.Remove(fighter1); } }