Exemple #1
0
        static void Main(string[] args)
        {
            Trifon trifon    = new Trifon(long.Parse(Console.ReadLine()));
            var    field     = GetPlayField();
            bool   completed = true;

            int currentTurns = 0;
            int cellsToWin   = field[0].Count * field.Count;
            int cellsMoved   = 0;


            AffectTrifon(trifon, field[0][0], currentTurns);


            while (cellsMoved != cellsToWin)
            {
                if (trifon.IsAlive)
                {
                    currentTurns++;
                    if (!trifon.CanMove)
                    {
                        trifon.turnsToWait--;
                    }
                    else
                    {
                        trifon.Move(field);
                        cellsMoved++;
                        try
                        {
                            AffectTrifon(trifon, field[trifon.Position.Y][trifon.Position.X], currentTurns);
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            //The Position.X goes +1 after the end of the field on some occasions
                        }
                    }
                }
                else
                {
                    completed = false;
                    break;
                }
            }

            if (completed)
            {
                Console.WriteLine("Quest completed!");
                Console.WriteLine($"Health: {trifon.Health}");
                Console.WriteLine($"Turns: {currentTurns}");
            }
            else
            {
                Console.WriteLine($"Died at: [{trifon.Position.Y}, {trifon.Position.X}]");
            }
        }
Exemple #2
0
        public static void AffectTrifon(Trifon trifon, char tile, int currentTurns)
        {
            switch (tile)
            {
            case 'F':
                trifon.Health -= (int)(currentTurns / 2);
                break;

            case 'H':
                trifon.Health += (int)(currentTurns / 3);
                break;

            case 'T':
                trifon.turnsToWait = 2;
                break;
            }
        }