public static void Execute(Warrior warrior, Warrior target) { if (!target.IsAlive()) { return; } if (!warrior.IsAlive()) { return; } var targetHealth = target.CurrentHealth; var result = _currentAttackStrategy.Execute(warrior, target); UpdateDamageDealers(warrior, result); if (true) { GameOutput.Report( $"{warrior.Name} ({warrior.CurrentHealth}hp) attacks " + $"{target.Name} ({targetHealth}hp) with " + $"{result.DamageDealt} damage!"); } }
private void PrintFinalMatchDetails() { GameOutput.Report("=== BATTLE FINALE ==="); GameOutput.Report($"~~~ {_stillStanding[0].Name} VS. {_stillStanding[1].Name} ~~~"); GameOutput.Report(""); AttackHandler.ReportFinalBattle = true; }
public void Fight() { GameOutput.Report(""); GameOutput.Report("Fight!"); var stillStandingCount = _stillStanding.Length; var shuffle = CreateShuffle(stillStandingCount); if (stillStandingCount == 2) { PrintFinalMatchDetails(); } for (var i = 0; i < stillStandingCount - 1; i += 2) { var warrior1 = _stillStanding[shuffle[i]]; var warrior2 = _stillStanding[shuffle[i + 1]]; var battleCage = new GameBattleCage(); battleCage.Fight(warrior1, warrior2); } _stillStanding = _participants.Where(x => x.IsAlive()).ToArray(); GameOutput.Report("Fight ended!"); GameOutput.Report($"{_stillStanding.Length}/{_participants.Length} warriors left!"); CheckLastManStanding(); }
public void AddWarriors(params Warrior[] warriors) { _participants = warriors; foreach (var warrior in warriors) { GameOutput.Report($"Adding warrior {warrior.Name} to arena!"); } }
private void PrintGameDetails() { var lastManStanding = _arena.GetLastManStanding(); GameOutput.Report($"The last man standing is {lastManStanding.Name} !!!"); GameOutput.Report($"{lastManStanding.GetDescription()}"); GameOutput.Report(""); GameOutput.Report("Top damage dealers"); GameOutput.Report("=================="); foreach (var damageDealer in AttackHandler.GetDamageDealers().OrderByDescending(x => x.Value)) { GameOutput.Report($"{damageDealer.Value} damage dealt from {damageDealer.Key.Name}! "); } }
public void Start() { GameOutput.Report("GameSimulator is starting..."); GameOutput.Report("============================"); _arena.Begin(); _arena.Fight(); while (!_arena.LastManStanding) { _arena.NextRound(); _arena.Fight(); } PrintGameDetails(); }
public void NextRound() { GameOutput.Report(""); GameOutput.Report("Next round begins!"); Thread.Sleep(1000); }
public void Begin() { GameOutput.Report("Let the game begin!"); _stillStanding = _participants; }
public GameArena() { GameOutput.Report("GameSimulator arena created"); }