using System;
using System.Text.RegularExpressions;
namespace Balloons_Pops_Game_Variant_Four
{
class BallonsPopsTest
{
static void SetConsoleSettings()
{
Console.Title = "Balloons Pops";
Console.ResetColor();
Console.Clear();
}
static void Main(string[] args)
{
SetConsoleSettings();
GameInitialization game = new GameInitialization();
game.Start();
string gameBoardPattern = @"^[0-4] [0-9]$";
Regex regex = new Regex(gameBoardPattern);
while (true)
{
string comand = Console.ReadLine();
switch (comand)
{
case "top": ScoreboardInitialization.Plot();
ConfigurateEmptyLinesOfMessages.Write(
GameMessages.enterRowAndColumn);
break;
case "exit": ConfigurateEmptyLinesOfMessages.WriteWithEmptyLine(
GameMessages.goodbyeMessage);
return;
case "restart":
game = new GameInitialization();
game.Start();
break;
default:
if (regex.Match(comand).Success)
{
Move move = new Move();
move.Row = Convert.ToInt32(comand.Substring(0, 1));
move.Col = Convert.ToInt32(comand.Substring(2, 1));
if (game.GameBoard.IsMoveAllowed(move))
{
game.Player.Score++;
game.GameBoard.Refresh(move);
if (game.GameBoard.IsEmpty())
{
ConfigurateEmptyLinesOfMessages.WriteWithEmptyLine(string.Format
(GameMessages.congratulationsMessage, game.Player.Score));
if (ScoreboardInitialization.ShouldBeRefreshed(game.Player))
{
ConfigurateEmptyLinesOfMessages.Write(
GameMessages.enterNameForTopScoreboard);
game.Player.Name = Console.ReadLine();
ScoreboardInitialization.Refresh(game.Player);
ScoreboardInitialization.Plot();
}
game = new GameInitialization();
game.Start();
}
else
{
game.GameBoard.GeneratePlot();
ConfigurateEmptyLinesOfMessages.Write(
GameMessages.enterRowAndColumn);
}
}
else
{
ConfigurateEmptyLinesOfMessages.WriteWithEmptyLine(
GameMessages.illegalMove);
ConfigurateEmptyLinesOfMessages.Write(
GameMessages.enterRowAndColumn);
}
}
else
{
ConfigurateEmptyLinesOfMessages.WriteWithEmptyLine(
GameMessages.invalidMoveOrCommand);
ConfigurateEmptyLinesOfMessages.Write(
GameMessages.enterRowAndColumn);
}
break;
}
}
}
}
}