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!");
            }
        }
Пример #2
0
 private void PrintFinalMatchDetails()
 {
     GameOutput.Report("=== BATTLE FINALE ===");
     GameOutput.Report($"~~~ {_stillStanding[0].Name} VS. {_stillStanding[1].Name} ~~~");
     GameOutput.Report("");
     AttackHandler.ReportFinalBattle = true;
 }
Пример #3
0
        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();
        }
Пример #4
0
        public void AddWarriors(params Warrior[] warriors)
        {
            _participants = warriors;

            foreach (var warrior in warriors)
            {
                GameOutput.Report($"Adding warrior {warrior.Name} to arena!");
            }
        }
Пример #5
0
        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}! ");
            }
        }
Пример #6
0
        public void Start()
        {
            GameOutput.Report("GameSimulator is starting...");
            GameOutput.Report("============================");

            _arena.Begin();
            _arena.Fight();

            while (!_arena.LastManStanding)
            {
                _arena.NextRound();
                _arena.Fight();
            }

            PrintGameDetails();
        }
Пример #7
0
 public void NextRound()
 {
     GameOutput.Report("");
     GameOutput.Report("Next round begins!");
     Thread.Sleep(1000);
 }
Пример #8
0
 public void Begin()
 {
     GameOutput.Report("Let the game begin!");
     _stillStanding = _participants;
 }
Пример #9
0
 public GameArena()
 {
     GameOutput.Report("GameSimulator arena created");
 }