Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Problem_4.Trifon_s_Quest
- {
- class Program
- {
- static void Main(string[] args)
- {
- long hp = Math.Abs(int.Parse(Console.ReadLine()));
- // long maxhp = hp; // дали да има нещо като максимално hp което не може да преминава ??? // Оказва се че не иска да има максималнo hp
- string[] matrix = Console.ReadLine().Split(' ');
- string[,] gamematrix = new string[int.Parse(matrix[0]), int.Parse(matrix[1])];
- for (int rows = 0; rows < int.Parse(matrix[0]); rows++)
- {
- string lineMap = Console.ReadLine(); // FFFF
- for (int cols = 0; cols < int.Parse(matrix[1]); cols++)
- {
- gamematrix[rows, cols] = lineMap[cols].ToString();
- }
- }
- int countTurn = 0; // отчита броя на входовете
- for (int cols = 0; cols < int.Parse(matrix[1]); cols++)
- {
- if (cols % 2 == 0)
- {
- for (int rows = 0; rows < int.Parse(matrix[0]); rows++)
- {
- switch (gamematrix[rows, cols])
- {
- case "F":
- hp -= countTurn / 2; /*if (hp <= 0) { hp = 0; */ // не е нужно да се изписва накрая hp
- if (hp <= 0)
- {
- Console.WriteLine($"Died at: [{rows}, {cols}]");
- //Environment.Exit(0); // спира цялата програма
- return;
- }
- ; break;
- case "H": hp += countTurn / 3/* ; if (hp > maxhp) { hp = maxhp; }*/; break;
- case "T": countTurn += 2; if (countTurn <= 0) { countTurn = 1; }; break;
- }
- // Console.WriteLine($"Current turn: [{rows}][{cols}] => {gamematrix[rows, cols]} -> {hp} hp left : turn -> {countTurn}");
- countTurn++;
- }
- }
- if (cols % 2 == 1)
- {
- for (int rows = int.Parse(matrix[0]) - 1; rows >= 0; rows--)
- {
- switch (gamematrix[rows, cols])
- {
- case "F":
- hp -= countTurn / 2; /*if (hp <= 0) { hp = 0; */
- if (hp <= 0)
- {
- Console.WriteLine($"Died at: [{rows}, {cols}]");
- //Environment.Exit(0); // спира цялата програма
- return;
- }
- ; break;
- case "H": hp += countTurn / 3/* ; if (hp > maxhp) { hp = maxhp; }*/; break;
- case "T": countTurn += 2; if (countTurn <= 0) { countTurn = 1; }; break;
- }
- // Console.WriteLine($"Current turn: [{rows}][{cols}] => {gamematrix[rows, cols]} -> {hp} hp left : turn -> {countTurn}");
- countTurn++;
- }
- }
- }
- // Output :
- if (hp > 0)
- {
- Console.WriteLine("Quest completed!");
- Console.WriteLine($"Health: {hp}");
- Console.WriteLine($"Turns: {countTurn}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement