Exemplo n.º 1
0
        public Warrior GetWarrior(BattleSimulator simulator)
        {
            var result = _current ?? (_current = GetRandomWarrior());

            if (HanSoloDied)
            {
                HanSoloDied = false;
                if (_current.Name == "Luke Skywalker")
                {
                    _current.DecreasePower(simulator, -5);
                }
            }
            result?.OnJoinBattle(simulator);
            return(result);
        }
Exemplo n.º 2
0
        public Warrior RunSimulation()
        {
            Warrior light = null, dark = null;

            while ((light = LightSide.GetWarrior()) != null &&
                   (dark = DarkSide.GetWarrior()) != null)
            {
                light.PreCombatEffect();
                dark.PreCombatEffect();
                if (light.IsStrongerThan(dark))
                {
                    light.DecreasePower(dark.Power);
                    if (light.Power <= 0)
                    {
                        LightSide.KillWarrior();
                    }
                    DarkSide.KillWarrior();
                }
                else if (dark.IsStrongerThan(light))
                {
                    dark.DecreasePower(light.Power);
                    if (dark.Power <= 0)
                    {
                        DarkSide.KillWarrior();
                    }
                    LightSide.KillWarrior();
                }
                else
                {
                    LightSide.KillWarrior();
                    DarkSide.KillWarrior();
                }
                light.PostCombatEffect();
                dark.PostCombatEffect();
            }

            return(light ?? dark);
        }