Пример #1
0
        private IWarrior GetWarriorAfterCollision(IWarrior warrior, IPiece piece)
        {
            if (piece is IFruit)
            {
                warrior.Eat((IFruit)piece);
                return(warrior);
            }
            else if (piece is IWarrior)
            {
                IWarrior defendingWarrrior = (IWarrior)piece;

                this.winner = warrior;

                if (warrior.Power > defendingWarrrior.Power)
                {
                    this.winner         = warrior;
                    this.gameIsFinished = true;
                }
                else if (warrior.Power < defendingWarrrior.Power)
                {
                    this.winner         = defendingWarrrior;
                    this.gameIsFinished = true;
                }
                else
                {
                    this.gameIsDraw     = true;
                    this.gameIsFinished = true;
                }
            }

            return(this.winner);
        }