public static ConsoleColor allianceColor(IEngageable engageable) { return (engageable.getParty().isUser()) ? ConsoleColor.Cyan : ConsoleColor.Red; }
/// <summary> /// Damage is dealt from one Fighter to another. /// </summary> /// <param name="attacker">Attacking Fighter</param> /// <param name="receiver">Defending Fighter</param> private static void attack(IEngageable attacker, IEngageable receiver) { Console.WriteLine(); Text.color(attacker.ToString(), Text.allianceColor(attacker)); if (!(attacker is Cleric)) { Console.Write(" attacks "); } else { Console.Write(" heals "); } Text.color( ((receiver.getName().Equals(attacker.getName())) ? "themselves" : receiver.getName()) + "\n", Text.allianceColor(receiver)); int newHP = (!(attacker is Cleric)) ? (receiver.getHP() - damage(attacker.getAttack(), receiver.getDefense(), attacker.getCritChance())) : (receiver.getHP() + damage(attacker.getAttack(), 0, 0)); if (newHP <= 0) { newHP = 0; } if (newHP >= receiver.getMaxHP()) { newHP = receiver.getMaxHP(); } Text.color(receiver.ToString(), Text.allianceColor(receiver)); Console.Write("'s health goes from "); Text.color(receiver.getHP().ToString(), Text.healthColor(receiver)); Console.Write(" to "); receiver.setHP(newHP); Text.color(newHP.ToString(), Text.healthColor(receiver)); if (attacker.getParty().isUser()) { Console.WriteLine(); Console.Write(attacker + " earned "); Text.color(attacker.earnEXP(receiver).ToString(), ConsoleColor.Yellow); } Text.userRead(); }
/// <summary> /// Decision is made whether this party is the user's party or an AI party before target select phase. /// </summary> /// <param name="member">Party memeber currently seeking an attack target.</param> /// <param name="receiver">Enemy party</param> /// <returns>string: Target's name.</returns> private static string attackCommand(IEngageable member, Party receiver) { if (member.getParty().isUser()) { return playerCommandSelect(member, receiver); } else { return aiTargetSelect(receiver); } }