static void DrawInitialGameField(GameField matrix)
 {
     GameField.SetConsoleDimensions();
     GameField.SetMatrixContent(matrix);
     GameField.PlayerCoordinates(matrix);
     GameField.PrintMatrix(matrix);
 }
        public static void PrintField(GameField field, bool isRedraw, bool fillTrail)
        {
            for (int col = 0; col < field.gameField.GetLength(1); col++)
            {
                for (int row = 0; row < field.gameField.GetLength(0); row++)
                {
                    if (!isRedraw && field.gameField[row, col] == CellStatus.Filled)
                    {
                        PrintOnPosition(row, col, CellColor(CellStatus.Filled));
                    }
                    else if (field.gameField[row, col] == CellStatus.Head)
                    {
                        PrintStringOnPosition(row, col, ((char)2).ToString(), CellColor(CellStatus.Head));
                    }
                    else if (!fillTrail && field.gameField[row, col] == CellStatus.Trail)
                    {
                        PrintStringOnPosition(row, col, ((char)46).ToString(), CellColor(CellStatus.Trail));
                        //PrintOnPosition(row, col, CellColor(CellStatus.Trail));
                    }
                    else if (fillTrail && field.gameField[row, col] == CellStatus.Trail)
                    {
                        //PrintStringOnPosition(row, col, ((char)46).ToString(), CellColor(CellStatus.Filled));
                        //field.gameField[row, col] = CellStatus.Filled;
                    }
                    else if (field.gameField[row, col] == CellStatus.Ball)
                    {

                    }
                }
            }
        }
Пример #3
0
        public void TestDrawPlayingFiel_WithTenRowsAndTenCols()
        {
            GameField gameField = new GameField(10, 10);
            char[,] board = gameField.Create();

            StringBuilder expectedOutput = new StringBuilder();

            expectedOutput.AppendFormat("    0 1 2 3 4 5 6 7 8 9{0}", Environment.NewLine);
            expectedOutput.AppendFormat("   ---------------------{0}", Environment.NewLine);
            expectedOutput.AppendFormat("0 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("1 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("2 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("3 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("4 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("5 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("6 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("7 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("8 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("9 | ? ? ? ? ? ? ? ? ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("   ---------------------{0}", Environment.NewLine);

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);
                Draw.PlayingField(board);
                Assert.AreEqual<string>(expectedOutput.ToString(), sw.ToString());
            }
        }
Пример #4
0
        public void TestGameField_Correct()
        {
            GameField gameField = new GameField(10, 10);

            Assert.AreEqual(10, gameField.FieldCols);
            Assert.AreEqual(10, gameField.FieldRows);
        }
Пример #5
0
        public void DrawGamefieldSizeFiveTest()
        {
            string consoleFile = "GameFieldConsoleOutput.txt";

            GameField field = new GameField(5);

            StreamWriter consoleResult = new StreamWriter(consoleFile);

            using (consoleResult)
            {
                Console.SetOut(consoleResult);
                field.DrawField();
            }

            StreamReader readerResult = new StreamReader(consoleFile);

            string gameFieldFirstLine = string.Empty;

            using (readerResult)
            {
                gameFieldFirstLine = readerResult.ReadLine();
            }

            string expectedResult = "   0 1 2 3 4 ";
            Assert.AreEqual(expectedResult, gameFieldFirstLine);
        }
Пример #6
0
        public void TestExecuteCommand_WithRestartCommand()
        {
            Engine game = new Engine();
            GameField gameField = new GameField(2, 2);

            char[,] fieldWithQuestionMarks = gameField.Create();
            char[,] fieldWithBombs = gameField.PlaceBombs();

            int maxScore = (gameField.FieldCols * gameField.FieldCols) -
                           (gameField.FieldCols + gameField.FieldCols);

            string inputCommand = "restart";

            StringBuilder expectedOutput = new StringBuilder();
            expectedOutput.AppendFormat("    0 1 2 3 4 5 6 7 8 9{0}", Environment.NewLine);
            expectedOutput.AppendFormat("   ---------------------{0}", Environment.NewLine);
            expectedOutput.AppendFormat("0 | ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("1 | ? ? |{0}", Environment.NewLine);
            expectedOutput.AppendFormat("   ---------------------{0}", Environment.NewLine);

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);
                game.ExecuteCommand(inputCommand, gameField, fieldWithQuestionMarks, fieldWithBombs, maxScore);
                Assert.AreEqual<string>(expectedOutput.ToString(), sw.ToString());
            }
        }
Пример #7
0
        public void TestExecuteCommand_WithTopCommand()
        {
            Engine game = new Engine();
            GameField gameField = new GameField(10, 10);

            char[,] fieldWithQuestionMarks = gameField.Create();
            char[,] fieldWithBombs = gameField.PlaceBombs();

            int maxScore = (gameField.FieldCols * gameField.FieldCols) -
                           (gameField.FieldCols + gameField.FieldCols);

            string inputCommand = "top";

            List<Player> topPlayers = new List<Player>();

            StringBuilder expectedOutput = new StringBuilder();
            expectedOutput.AppendLine("Points:");
            expectedOutput.AppendLine("Empty score board.");

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);
                game.ExecuteCommand(inputCommand, gameField, fieldWithQuestionMarks, fieldWithBombs, maxScore);
                Assert.AreEqual<string>(expectedOutput.ToString(), sw.ToString());
            }
        }
    static void Main()
    {
        Console.CursorVisible = false;
        GameField matrix = new GameField();
        saveStartTime = DateTime.Now;

        GameID.PrintGameName();
        GameField.DrawBorderLines();
        for (int i = 0; i < 7; i++)
        {
            GameField.EnemyCoordinates(matrix);

        }
        while (true)
        {
            DrawInitialGameField(matrix);
            Player.MovePlayer(matrix);

            Enemy.MoveEnemies(matrix);
            //Collisions.EatenByEnemy(matrix, Enemy.enemyCoords, CrazyRusher.saveStartTime);
            if (GameScores.gameOver == true)
            {
                break;
            }
        }
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="GameBoardDrawingLogic" /> class.
        /// Uses the game field rows and cols. 
        /// </summary>
        /// <param name="gameField">The field of the game.</param>
        public GameBoardDrawingLogic(GameField gameField)
        {
            this.Board = new string[(gameField.FieldRows + 3), (gameField.FieldCols + 4)];
            this.Field = gameField.GetField();

            this.DrawGameBoard();
        }
Пример #10
0
        public void GameFieldPrintToConsole()
        {
            StreamWriter writer = new StreamWriter("..\\..\\out.txt");
            Console.SetOut(writer);

            GameField gameField = new GameField();
            gameField.PrintToConsole();
            writer.Close();

            StreamReader reader = new StreamReader("..\\..\\out.txt");
            //StringBuilder actual = new StringBuilder();
            string actual = string.Empty;
            string line;
            //do
            //{
                line = reader.ReadToEnd();
                actual += (line);
            //} while (line != null);

            reader.Close();

            string expected =
            @"    0 1 2 3 4 5 6 7 8 9
               ---------------------
            0 | O O O O O O O O O O |
            1 | O O O O O O O O O O |
            2 | O O O O O O O O O O |
            3 | O O O O O O O O O O |
            4 | O O O O O O O O O O |
               ---------------------
            ";

            Assert.AreEqual(expected, actual.ToString());
        }
Пример #11
0
 public void ContainsMinesTest_TrueResult()
 {
     int size = 5;
     GameField field = new GameField(size);
     bool result = field.ContainsMines();
     Assert.AreEqual(true, result);
 }
Пример #12
0
 public GameEngine()
 {
     this.gameField = new GameField();
     this.playerMoveCount = 0;
     this.highScore = new HighScore();
     this.userInput = string.Empty;
     this.menuCommands = new string[] { "top", "restart", "exit" };
 }
Пример #13
0
 internal GameFacade()
 {
     this.players = new TxtFileRepository<Player>(GlobalConstants.TopScorePath);
     this.games = new TxtFileRepository<Game>(GlobalConstants.GamesPath);
     this.field = new GameField(GlobalConstants.DefaultLevelRows, GlobalConstants.DefaultLevelCols);
     this.reader = ConsoleReader.Instance;
     this.printer = ConsoleGamePrinter.Instance;
 }
Пример #14
0
        public void GameFieldPopBalloonTest()
        {
            GameField gameField = new GameField();
            gameField.Balloons[2, 2].Pop();

            bool expected = gameField.Balloons[2, 2].IsPopped;
            Assert.IsTrue(expected);
        }
Пример #15
0
        public void GameFieldIsPoppedTest()
        {
            GameField gameField = new GameField();
            gameField.Balloons[2, 2].Pop();

            bool expected = gameField.Balloons[2, 2].GetBalloonChar() == ' ';
            Assert.IsTrue(expected);
        }
 public static void FillNew(GameField theField)
 {
     List<List<int>> newValues = theField.tmpList;
     foreach (List<int> val in newValues)
     {
         PrintOnPosition(val[0], val[1], CellColor(CellStatus.Filled));
     }
     theField.tmpList = new List<List<int>>();
 }
Пример #17
0
        static void Main(string[] args)
        {
            var game = new GameField();

            game.Init();
            game.Start();
            System.Console.WriteLine("\nGame Over!");
            System.Console.ReadLine();
        }
Пример #18
0
        public void RestoreMemento_ShouldSetGamesFieldToMementosField()
        {
            var field = new GameField(3, 3);
            int shootCounter = 5;
            int remainingBalloons = 10;
            var memento = new GameMemento(field, shootCounter, remainingBalloons);

            this.game.RestoreMemento(memento);

            Assert.AreSame(memento.Field, this.game.Field);
        }
        /// <summary>
        /// Initializes a game.
        /// </summary>
        /// <param name="field">The game field.</param>
        public void Init(GameField field)
        {
            this.field = field;
            this.MovesCount = 0;
            this.renderer.InputPosition += (rendererObj, positionArg) =>
            {
                this.UpdateField(positionArg.Position);
            };

            this.renderer.ShowGameField(field);
        }
    public static void SetEnemyCoordinates(GameField matrix)
    {
        enemyRow = generator.Next(2, 21);
        enemyCol = generator.Next(1,21);
        if (matrix[enemyRow, enemyCol] != '#' && matrix[enemyRow, enemyCol] != Player.playerChar)
        {
            matrix[enemyRow, enemyCol] = enemyChar;
        }

        enemyCoords.Add((new int[] { enemyRow, enemyCol }).ToList());
    }
 public GameEngineTests()
 {
     this.field = new GameField(GlobalConstants.DefaultLevelRows, GlobalConstants.DefaultLevelCols);
     this.game = new Game(this.field);
     this.gameLogic = new GameLogicProvider(this.game);
     this.mockPrinter = new MockIPrinter().MockPrinter.Object;
     this.topScoreController = new MockITopScoreController().MockTopScoreController.Object;
     this.gamesController = new MockIGamesController().MockGamesController.Object;
     this.gamesRepo = new MockIGenericRepository<Game>(this.GenerateFakeCollectionOfGames());
     this.playersRepo = new MockIGenericRepository<Player>(this.GenerateFakeCollectionOfPlayers());
     this.db = new BalloonsData(this.playersRepo.MockedRepo.Object, this.gamesRepo.MockedRepo.Object);
 }
        public IGameField Create()
        {
            IGameField gameField = new GameField();

            for (int row = 0; row < gameField.Board.GetLength(0); row++)
            {
                for (int col = 0; col < gameField.Board.GetLength(1); col++)
                {
                    gameField.Board[row, col] = '?';
                }
            }

            return gameField;
        }
Пример #23
0
 public void ContainsMinesTest_FalseResult2()
 {
     int size = 5;
     GameField field = new GameField(size);
     for (int row = 0; row < size; row++)
     {
         for (int col = 0; col < size; col++)
         {
             field.Field[row, col] = 'X';
         }
     }
     bool result = field.ContainsMines();
     Assert.AreEqual(false, result);
 }
Пример #24
0
 public void ContainsMinesTest_TrueResult2()
 {
     int size = 8;
     GameField field = new GameField(size);
     for (int row = 0; row < size; row++)
     {
         for (int col = 0; col < size; col++)
         {
             field.Field[row, col] = '-';
         }
     }
     field.Field[3, 4] = '4';
     bool result = field.ContainsMines();
     Assert.AreEqual(true, result);
 }
 public ExplodeCommand createExplodeCommand(GameField field, CellType type)
 {
     switch (type)
     {
         case CellType.GIANTMINE: return new SquareExplodeCommand(field, 2);
         case CellType.HUGEMINE: return new HugeExplodeCommand(field);
         case CellType.BIGMINE: return new BigExplodeCommand(field);
         case CellType.SMALLMINE: return new SquareExplodeCommand(field, 1);
         case CellType.TINYMINE: return new TinyExplodeCommand(field);
         default:
             {
                 throw new NotSupportedException();
             }
     }
 }
        public void GameBoardDrawingLogic_ShouldDrowCorectBoard12x12()
        {
            var manualFieldBefor = new char[,]
            {
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
                { '1', '3', '3', '1', '3', '3', '1', '3', '3', '1', '3', '3' },
            };

            var manualFieldAfter = "     0  1  2  3  4  5  6  7  8  9 10 11\r\n -  -  -  -  -  -  -  -  -  -  -  -  - \r\n 0 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 1 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 2 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 3 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 4 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 5 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 6 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 7 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 8 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n 9 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n10 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n11 | 1  3  3  1  3  3  1  3  3  1  3  3 |\r\n -  -  -  -  -  -  -  -  -  -  -  -  - \r\n";

            var gameFieldXLen = manualFieldBefor.GetLength(0);
            var gameFieldYLen = manualFieldBefor.GetLength(1);
            GameField gameField = new GameField(gameFieldXLen, gameFieldYLen);

            // fill the field with the manual chars
            for (int i = 0; i < gameFieldXLen; i++)
            {
                for (int j = 0; j < gameFieldYLen; j++)
                {
                    gameField[i, j] = manualFieldBefor[i, j];
                }
            }

            var board = new GameBoardDrawingLogic(gameField);

            var boardAsString = new StringBuilder();
            for (int i = 0; i < board.Board.GetLength(0); i++)
            {
                for (int j = 0; j < board.Board.GetLength(1); j++)
                {
                    boardAsString.Append(board.Board[i, j]);
                }

                boardAsString.AppendLine();
            }

            Assert.IsTrue(manualFieldAfter.Equals(boardAsString.ToString()));
        }
Пример #27
0
 protected override void Form1_Load(object sender, EventArgs e)
 {
     _gameTetris = new GameField<SimpleCubePicBox>(12, 10);
     Button startButt = new Button();
     startButt.Width = this.Width / 2;
     startButt.Height = startButt.Width / 4;
     startButt.Top = this.Height / 4;
     startButt.Left = this.Width / 4;
     startButt.Text = "PLAY";
     startButt.BackColor = Color.Crimson;
     this.Controls.Add(startButt);
     startButt.Click += startButt_Click;
     this.gameInfo.IsInGame = true;
     _gameSpeedTimer = new Timer();
     this.KeyPress += Form2_KeyPress;
 }
Пример #28
0
 public string Prepare(int player, GameField field)
 {
     disposition = new DispositionRobot(player);
     InitialPoint = field.GetInitialPoint(player);
     planning = new TownPlanning(field);
     var forbid = planning.ForbidPoint(new Point { X = 6, Y = 6 }, field);
     int max = forbid.Max(p => p.SpendRobot);
     var maxPlans = planning.Where(p => p.SpendRobot == max);
     foreach (Point point in field.NearIterator(InitialPoint, player))
     {
         if (!maxPlans.Any(p => p.Excavator == point)) continue;
         plan = maxPlans.First(p => p.Excavator == point);
         break;
     }
     return "B_head:Colonize";
 }
    public static void MoveEnemies(GameField matrix)
    {
        for (int i = 0; i < enemyCoords.Count; i++)
        {
            int direction = generator.Next(1, 5); // 1 - left; 2 - right; 3 - up; 4 - down;
            enemyRow = enemyCoords[i][0];
            enemyCol = enemyCoords[i][1];
            listiIndex = i;
            if (direction == 1)
            {
                if (matrix[enemyRow, enemyCol - 1] != GameField.wallChar && enemyCol - 1 >= 1)
                {
                   matrix[enemyRow, enemyCol] = ' ';
                   matrix[enemyRow, enemyCol - 1] = enemyChar;
                   enemyCoords[i][1] = enemyCol - 1;
                }
            }
            else if (direction == 2)
            {
                if (matrix[enemyRow, enemyCol + 1] != GameField.wallChar && enemyCol + 1 < matrix.Cols - 1)
                {
                   matrix[enemyRow, enemyCol] = ' ';
                   matrix[enemyRow, enemyCol + 1] = enemyChar;
                   enemyCoords[i][1] = enemyCol + 1;
                }
            }
            else if (direction == 3)
            {
                if (matrix[enemyRow - 1, enemyCol] != GameField.wallChar && enemyRow - 1 >= 1)
                {
                   matrix[enemyRow, enemyCol] = ' ';
                   matrix[enemyRow - 1, enemyCol] = enemyChar;
                   enemyCoords[i][0] = enemyRow - 1;
                }
            }
            else if (direction == 4)
            {
                if (enemyRow + 1 < matrix.Rows - 1 && matrix[enemyRow + 1, enemyCol] != GameField.wallChar)
                {
                    matrix[enemyRow, enemyCol] = ' ';
                    matrix[enemyRow + 1, enemyCol] = enemyChar;
                    enemyCoords[i][0] = enemyRow + 1;
                }
            }

        }
    }
    public static void EnemyShot(GameField matrix, List<List<int>> enemyCoords, DateTime saveStartTime)
    {
        bool shot;
        int row = 0;
        int col = 0;
        for (int i = 0; i < enemyCoords.Count; i++)
        {
            row = enemyCoords[i][0];
            col = enemyCoords[i][1];

            if ((row == Player.row - 1 && col == Player.col) ||
             (row == Player.row - 2 && col == Player.col))
            {

                matrix[Enemy.enemyRow, Enemy.enemyCol] = ' ';
                enemyCoords.RemoveAt(i);
                shot = true;
                GameScores.CollisionScores(shot, saveStartTime);

            }
            else if ((row == Player.row + 1 && col == Player.col) ||
                (row == Player.row + 2 && col == Player.col))
            {
                matrix[Enemy.enemyRow, Enemy.enemyCol] = ' ';
                enemyCoords.RemoveAt(i);
                shot = true;
                GameScores.CollisionScores(shot, saveStartTime);
            }
            else if ((col == Player.col + 1 && row == Player.row) ||
                (Enemy.enemyCol == Player.col + 2 && Enemy.enemyCol == Player.col))
            {
                matrix[Enemy.enemyRow, Enemy.enemyCol] = ' ';
                enemyCoords.RemoveAt(i);
                shot = true;
                GameScores.CollisionScores(shot, saveStartTime);
            }
            else if ((col == Player.col - 1 && row == Player.row) ||
                (col == Player.col - 2 && row == Player.row))
            {
                matrix[Enemy.enemyRow, Enemy.enemyCol] = ' ';
                enemyCoords.RemoveAt(i);
                shot = true;
                GameScores.CollisionScores(shot, saveStartTime);
            }
        }
    }
Пример #31
0
 protected override void Activate(Player owner, Player opponent, int damageTaken, GameField game)
 {
 }
Пример #32
0
 void StartFirstLevel()
 {
     nextLevelField    = null;
     currentLevelField = Instantiate <GameField>(levels[currentLevel].GameFieldPrototype);
     currentLevelField.OnLevelStart(levels[currentLevel]);
 }
Пример #33
0
 public SmartBot(Player player, GameField field)
 {
     this.player = player;
     this.field  = field;
     Console.WriteLine($"field size {this.field.size}");
 }
Пример #34
0
 private void NGame_Click(object sender, EventArgs e)
 {
     Game1.NewGame(ChFirst);
     MessageField.Text = String.Empty;
     GameField.Invalidate();
 }
Пример #35
0
 public bool CanCast(GameField game, Player caster, Player opponent)
 {
     return(true);
 }
Пример #36
0
        public void Start()
        {
            DateTime currentTime = DateTime.Now;

            while (Win.IsOpen)
            {
                Win.DispatchEvents();

                double elapsed = (DateTime.Now - currentTime).TotalSeconds;

                if (elapsed < 1.0 / FPS)
                {
                    continue;
                }

                currentTime = DateTime.Now;

                Win.Clear(BackColor);

                if (!Stopped)
                {
                    Snakes.RemoveAll(snake => snake.Dead);

                    GameField.Update(Snakes);
                    Snakes.ForEach(snake => snake.Update(GameField, Snakes));

                    foreach (DividingStudentSnake created in CreatedSnakes)
                    {
                        Snakes.Add(created);
                    }
                    CreatedSnakes.Clear();
                }

                Win.Draw(GameField);
                Snakes.ForEach(snake => snake.Draw(Win, RenderStates.Default, GameField.CellWidthPixel, GameField.CellHeightPixel));

                for (int i = 0; i < Snakes.Count; ++i)
                {
                    DividingStudentSnake snake = Snakes[i];
                    BRAIN_SHAPE.Size = new Vector2f(
                        snake.Brain.BrainWidth * GameField.CellWidthPixel,
                        snake.Brain.BrainHeight * GameField.CellHeightPixel
                        );

                    BRAIN_SHAPE.Position = new Vector2f(
                        (snake.Head.Position.X - snake.Brain.BrainWidth / 2) * GameField.CellWidthPixel,
                        (snake.Head.Position.Y - snake.Brain.BrainHeight / 2) * GameField.CellHeightPixel
                        );

                    Win.Draw(BRAIN_SHAPE);

                    Text score = new Text($"{i + 1}) size = {snake.Body.Count + 1}; energy = {snake.CurrentEnergy}; " +
                                          $"daughters = {snake.TotalCreated}; mutations = {snake.Brain.Mutations}", FONT)
                    {
                        FillColor     = Color.Black,
                        CharacterSize = 24
                    };

                    score.Position = new Vector2f(GameField.Width * GameField.CellWidthPixel + 60, i * 25 + 20);
                    Win.Draw(score);

                    RectangleShape colorIndicator = new RectangleShape(new Vector2f(20, 20))
                    {
                        OutlineColor = Color.Black,
                        FillColor    = snake.BodyColor
                    };

                    colorIndicator.Position = new Vector2f(GameField.Width * GameField.CellWidthPixel + 30, i * 25 + 25);
                    Win.Draw(colorIndicator);
                }

                DrawExtra();
                Win.Display();
            }
        }
Пример #37
0
 public bool CanCast(GameField game, Player caster, Player opponent)
 {
     return(Targeting.GetPossibleTargetsFromMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard, name).Count > 0);
 }
Пример #38
0
 public GameFieldFrameworkElement(GameField aGameField, double aItemSize) :
     this(aGameField)
 {
     this.ItemSize = aItemSize;
 }
Пример #39
0
 public Simulator(int h, int w)
 {
     _field    = new GameField();
     _baseCost = new Map <ushort>(h, w);
     _inflMap  = new SimInflMap(_field, _baseCost, h, w);
 }
Пример #40
0
        public static PokemonCard AskForTargetFromTargetingMode(TargetingMode targetingMode, GameField game, Player caster, Player opponent, PokemonCard pokemonOwner, string info = "", string nameFilter = "")
        {
            PokemonCard    target;
            NetworkMessage message;
            NetworkId      selectedId;
            IDeckFilter    filter = !string.IsNullOrEmpty(nameFilter) ? new PokemonWithNameOrTypeFilter(nameFilter, EnergyTypes.All) : null;

            switch (targetingMode)
            {
            case TargetingMode.Self:
                target = pokemonOwner;
                break;

            case TargetingMode.YourActive:
                target = caster.ActivePokemonCard;
                break;

            case TargetingMode.YourBench:
                if (caster.BenchedPokemon.Count == 0)
                {
                    return(null);
                }
                else if (caster.BenchedPokemon.Count == 1)
                {
                    return(caster.BenchedPokemon.GetFirst());
                }
                message = new SelectFromYourBenchMessage(1)
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.YourPokemon:
                message = new SelectFromYourPokemonMessage()
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.OpponentActive:
                target = opponent.ActivePokemonCard;
                break;

            case TargetingMode.OpponentBench:
                if (opponent.BenchedPokemon.Count == 0)
                {
                    return(null);
                }
                else if (opponent.BenchedPokemon.Count == 1)
                {
                    return(opponent.BenchedPokemon.GetFirst());
                }

                message = new SelectFromOpponentBenchMessage(1)
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.OpponentPokemon:
                message = new SelectOpponentPokemonMessage(1)
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.LastEffectTarget:
                target = game.LastTarget;
                break;

            case TargetingMode.AnyPokemon:
                throw new NotImplementedException("TargetingMode.AnyPokemon not implemented in Targeting");

            default:
                target = caster.ActivePokemonCard;
                break;
            }

            if (game != null)
            {
                game.LastTarget = target;
            }

            return(target);
        }
Пример #41
0
 public MoveRangeFinder(IGameAction gameAction, FDCreature creature)
 {
     this.gameAction = gameAction;
     this.gameField  = gameAction.GetField();
     this.creature   = creature;
 }
Пример #42
0
        public static List <PokemonCard> GetPossibleTargetsFromMode(TargetingMode targetingMode, GameField game, Player caster, Player opponent, PokemonCard pokemonOwner, string nameFilter = "")
        {
            var pokemons = new List <PokemonCard>();

            switch (targetingMode)
            {
            case TargetingMode.YourActive:
                pokemons.Add(caster.ActivePokemonCard);
                break;

            case TargetingMode.YourBench:
                pokemons = caster.BenchedPokemon.ValidPokemonCards.ToList();
                break;

            case TargetingMode.YourPokemon:
                pokemons = caster.GetAllPokemonCards();
                break;

            case TargetingMode.OpponentActive:
            {
                if (game.CurrentDefender != null && game.CurrentDefender.Owner.Id.Equals(opponent.Id))
                {
                    pokemons.Add(game.CurrentDefender);
                }
                else
                {
                    pokemons.Add(opponent.ActivePokemonCard);
                }
                break;
            }

            case TargetingMode.OpponentBench:
                pokemons = opponent.BenchedPokemon.ValidPokemonCards.ToList();
                break;

            case TargetingMode.OpponentPokemon:
                pokemons = opponent.GetAllPokemonCards();
                break;

            case TargetingMode.AnyPokemon:
                pokemons = caster.GetAllPokemonCards();
                pokemons.AddRange(opponent.GetAllPokemonCards());
                break;

            case TargetingMode.AttachedTo:
                pokemons.Add(pokemonOwner);
                break;

            case TargetingMode.Self:
                pokemons.Add(pokemonOwner);
                break;

            default:
                pokemons.Add(pokemonOwner);
                break;
            }

            if (!string.IsNullOrEmpty(nameFilter))
            {
                return(pokemons.Where(p => p.Name.ToLower().Contains(nameFilter.ToLower())).ToList());
            }

            return(pokemons);
        }
Пример #43
0
 public void PerformGameAction(ActionType actionType, GameField gameField, IPlayer player)
 {
     _actionPerformer.Perform(actionType, gameField, player);
 }
Пример #44
0
        public override Damage GetDamage(Player owner, Player opponent, GameField game)
        {
            int coins = DamageOnSelf ? owner.ActivePokemonCard.DamageCounters / 10 : opponent.ActivePokemonCard.DamageCounters / 10;

            return(game.FlipCoins(coins) * Damage);
        }
Пример #45
0
        public void MoveHacker(Direction dir, string id)
        {
            GameField  moveFrom = new GameField();
            GameField  moveTo   = new GameField();
            SimpleType type;
            Player     player       = _players.FirstOrDefault(p => p.Id == id);
            int        playerToMove = player.PositionIndex;

            switch (dir)
            {
            case Direction.up:
                moveFrom = GameBoard[PlayerPositions[playerToMove].FieldIndex()];
                type     = moveFrom.SimpleType;
                moveFrom.SetType(FieldType.playerup);
                moveFrom.Position.Row--;
                moveTo = GameBoard[PlayerPositions[playerToMove].FieldAbove()];
                if (moveTo.Type == FieldType.bitcoin)
                {
                    player.Bitcoins++;
                }
                if (type == SimpleType.thing)
                {
                    moveTo.SetType(FieldType.laptop);
                }
                else
                {
                    moveTo.SetType(FieldType.empty);
                }
                moveTo.Position.Row++;
                GameBoard[PlayerPositions[playerToMove].FieldIndex()] = moveTo;
                GameBoard[PlayerPositions[playerToMove].FieldAbove()] = moveFrom;
                PlayerPositions[playerToMove].Row--;
                break;

            case Direction.down:
                moveFrom = GameBoard[PlayerPositions[playerToMove].FieldIndex()];
                type     = moveFrom.SimpleType;
                moveFrom.SetType(FieldType.playerdown);
                moveFrom.Position.Row++;
                moveTo = GameBoard[PlayerPositions[playerToMove].FieldBelow()];
                if (moveTo.Type == FieldType.bitcoin)
                {
                    player.Bitcoins++;
                }
                if (type == SimpleType.thing)
                {
                    moveTo.SetType(FieldType.laptop);
                }
                else
                {
                    moveTo.SetType(FieldType.empty);
                }
                moveTo.Position.Row--;
                GameBoard[PlayerPositions[playerToMove].FieldIndex()] = moveTo;
                GameBoard[PlayerPositions[playerToMove].FieldBelow()] = moveFrom;
                PlayerPositions[playerToMove].Row++;
                break;

            case Direction.left:
                moveFrom = GameBoard[PlayerPositions[playerToMove].FieldIndex()];
                type     = moveFrom.SimpleType;
                moveFrom.SetType(FieldType.playerleft);
                moveFrom.Position.Column--;
                moveTo = GameBoard[PlayerPositions[playerToMove].FieldLeft()];
                if (moveTo.Type == FieldType.bitcoin)
                {
                    player.Bitcoins++;
                }
                if (type == SimpleType.thing)
                {
                    moveTo.SetType(FieldType.laptop);
                }
                else
                {
                    moveTo.SetType(FieldType.empty);
                }
                moveTo.Position.Column++;
                GameBoard[PlayerPositions[playerToMove].FieldIndex()] = moveTo;
                GameBoard[PlayerPositions[playerToMove].FieldLeft()]  = moveFrom;
                PlayerPositions[playerToMove].Column--;
                break;

            case Direction.right:
                moveFrom = GameBoard[PlayerPositions[playerToMove].FieldIndex()];
                type     = moveFrom.SimpleType;
                moveFrom.SetType(FieldType.playerright);
                moveFrom.Position.Column++;
                moveTo = GameBoard[PlayerPositions[playerToMove].FieldRight()];
                if (moveTo.Type == FieldType.bitcoin)
                {
                    player.Bitcoins++;
                }
                if (type == SimpleType.thing)
                {
                    moveTo.SetType(FieldType.laptop);
                }
                else
                {
                    moveTo.SetType(FieldType.empty);
                }
                moveTo.Position.Column--;
                GameBoard[PlayerPositions[playerToMove].FieldIndex()] = moveTo;
                GameBoard[PlayerPositions[playerToMove].FieldRight()] = moveFrom;
                PlayerPositions[playerToMove].Column++;
                break;

            default: break;
            }
        }
Пример #46
0
 public bool CanCast(GameField game, Player caster, Player opponent) => true;
        protected override void Activate(Player owner, Player opponent, int damageTaken, GameField game)
        {
            IEnumerable <Card> energyCards;
            Player             activator = GetActivator(game.ActivePlayer);

            if (energyType != EnergyTypes.All)
            {
                energyCards = activator.Hand.OfType <EnergyCard>().Where(card => energyType == card.EnergyType);
            }
            else
            {
                energyCards = activator.Hand.OfType <EnergyCard>();
            }

            var message  = new PickFromListMessage(energyCards.ToList(), 1).ToNetworkMessage(owner.Id);
            var response = owner.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message);

            var energyCard = game.Cards[response.Cards.First()];

            var selectPokemonMessage = new SelectFromYourPokemonMessage(energyType).ToNetworkMessage(owner.Id);

            response = owner.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(selectPokemonMessage);
            var selectedId = response.Cards.First();

            var pokemon = owner.ActivePokemonCard.Id.Equals(selectedId) ? owner.ActivePokemonCard : owner.BenchedPokemon.ValidPokemonCards.First(x => x.Id.Equals(selectedId));

            pokemon.AttachEnergy((EnergyCard)energyCard, game);
        }
Пример #48
0
 public void OnAttachedTo(PokemonCard attachedTo, bool fromHand, GameField game)
 {
     attachedTo.DealDamage(Amount, game, attachedTo, false);
 }
Пример #49
0
 public Player(GameField field, CellLocation location, Facing facing) : base(field, location, facing)
 {
 }
Пример #50
0
        public override Damage GetDamage(Player owner, Player opponent, GameField game)
        {
            var reduction = (owner.ActivePokemonCard.DamageCounters / 10) * reductionPerDamageCounter;

            return(Math.Max(0, Damage - reduction));
        }
    /// <summary>
    ///
    /// </summary>
    ///
    static void Main()
    {
        // This size was choosen to fit in 1024x768 screen size
        Console.SetWindowSize(40, 24);
        Console.Clear();
        Console.OutputEncoding = System.Text.Encoding.Unicode;

        int       level     = 1;
        GameField gameField = new GameField(25, 23);

        gameField.LoadLevel(level);
        gameField.DisplayField();
        gameField.DisplayGameData();

        PacMan         pacMan   = new PacMan(gameField);
        List <Monster> monsters = new List <Monster>();

        monsters.Add(new Monster(gameField, ConsoleColor.Red));
        monsters.Add(new Monster(gameField, ConsoleColor.Red));
        monsters.Add(new Monster(gameField, ConsoleColor.Red));
        monsters.Add(new Monster(gameField, ConsoleColor.Red));

        GameState gameState   = GameState.WaitingToStart;
        int       counterDown = 4;

        gameField.DisplayWaitingToStart();

        for (; ;)
        {
            while (Console.KeyAvailable)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                switch (keyInfo.Key)
                {
                case ConsoleKey.Escape:
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Clear();
                    return;

                case ConsoleKey.LeftArrow:
                    if (pacMan.MovingDirection == ' ')
                    {
                        pacMan.MovingDirection = 'L';
                    }
                    else
                    {
                        pacMan.NextMovingDirection = 'L';
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (pacMan.MovingDirection == ' ')
                    {
                        pacMan.MovingDirection = 'R';
                    }
                    else
                    {
                        pacMan.NextMovingDirection = 'R';
                    }
                    break;

                case ConsoleKey.UpArrow:
                    if (pacMan.MovingDirection == ' ')
                    {
                        pacMan.MovingDirection = 'U';
                    }
                    else
                    {
                        pacMan.NextMovingDirection = 'U';
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (pacMan.MovingDirection == ' ')
                    {
                        pacMan.MovingDirection = 'D';
                    }
                    else
                    {
                        pacMan.NextMovingDirection = 'D';
                    }
                    break;

                case ConsoleKey.Spacebar:
                    if (gameState == GameState.WaitingToStart)
                    {
                        counterDown = 4;
                        gameState   = GameState.Starting;
                    }
                    break;
                }
            }
            if (gameState == GameState.WaitingToStart)
            {
                continue;
            }
            if (gameState == GameState.Starting)
            {
                gameField.DisplayStarting(ref counterDown, level);
                if (counterDown == 0)
                {
                    gameField.DisplayField();
                    gameField.DisplayGameData();
                    gameState = GameState.Playing;
                }
                continue;
            }
            if (gameState == GameState.GameOver)
            {
                continue;
            }
            if (gameState == GameState.Win)
            {
                continue;
            }
            pacMan.MovePacMan(gameField);
            foreach (Monster monster in monsters)
            {
                if (monster.IsMonsterOverPacMan(pacMan))
                {
                    if (gameField.TakeOneLive())
                    {
                        pacMan.ResetPacMan(gameField, true);
                        foreach (var monsterToReset in monsters)
                        {
                            monsterToReset.ResetMonster(gameField, true);
                        }
                        break;
                    }
                    else
                    {
                        gameField.DisplayGameOver();
                        gameState = GameState.GameOver;
                        continue;
                    }
                }
                monster.MoveMonster(gameField);
                if (monster.IsMonsterOverPacMan(pacMan))
                {
                    if (gameField.TakeOneLive())
                    {
                        pacMan.ResetPacMan(gameField, true);
                        foreach (var monsterToReset in monsters)
                        {
                            monsterToReset.ResetMonster(gameField, true);
                        }
                        break;
                    }
                    else
                    {
                        gameField.DisplayGameOver();
                        gameState = GameState.GameOver;
                        continue;
                    }
                }
            }
            if (gameField.EatCount <= 0)
            {
                level++;
                if (level > 2)
                {
                    gameField.DisplayWinner();
                    gameState = GameState.Win;
                    continue;
                }

                gameField.LoadLevel(level);
                gameField.DisplayField();
                gameField.DisplayGameData();

                pacMan = new PacMan(gameField);
                monsters.Clear();
                monsters.Add(new Monster(gameField, ConsoleColor.Red));
                monsters.Add(new Monster(gameField, ConsoleColor.Red));
                monsters.Add(new Monster(gameField, ConsoleColor.Red));
                monsters.Add(new Monster(gameField, ConsoleColor.Red));

                counterDown = 4;
                gameState   = GameState.Starting;
            }
        }
    }
Пример #52
0
        private void UpdateScreen(object sender, EventArgs e)
        {
            if (Settings.gameover == true && Settings1.gameover == true)
            {
                if (Input.KeyPressed(Keys.Enter))
                {
                    StartGame();
                }
            }
            else
            {
                if (Input.KeyPressed(Keys.Right) && Settings.direction != Direction.Left)
                {
                    Settings.direction = Direction.Right;
                    if (Input.KeyPressed(Keys.D) && Settings1.direction != Direction.Left)
                    {
                        Settings1.direction = Direction.Right;
                    }
                }
                else if (Input.KeyPressed(Keys.Left) && Settings.direction != Direction.Right)
                {
                    Settings.direction = Direction.Left;
                    if (Input.KeyPressed(Keys.A) && Settings1.direction != Direction.Right)
                    {
                        Settings1.direction = Direction.Left;
                    }
                }
                else if (Input.KeyPressed(Keys.Up) && Settings.direction != Direction.Down)
                {
                    Settings.direction = Direction.Up;
                    if (Input.KeyPressed(Keys.W) && Settings1.direction != Direction.Down)
                    {
                        Settings1.direction = Direction.Up;
                    }
                }
                else if (Input.KeyPressed(Keys.Down) && Settings.direction != Direction.Up)
                {
                    Settings.direction = Direction.Down;
                    if (Input.KeyPressed(Keys.S) && Settings1.direction != Direction.Up)
                    {
                        Settings1.direction = Direction.Down;
                    }
                }


                else if (Input.KeyPressed(Keys.D) && Settings1.direction != Direction.Left)
                {
                    Settings1.direction = Direction.Right;
                }
                else if (Input.KeyPressed(Keys.A) && Settings1.direction != Direction.Right)
                {
                    Settings1.direction = Direction.Left;
                }
                else if (Input.KeyPressed(Keys.W) && Settings1.direction != Direction.Down)
                {
                    Settings1.direction = Direction.Up;
                }
                else if (Input.KeyPressed(Keys.S) && Settings1.direction != Direction.Up)
                {
                    Settings1.direction = Direction.Down;
                }

                MoveSnake();
                MoveSnake1();
            }

            GameField.Invalidate();
        }
Пример #53
0
        public override Damage GetDamage(Player owner, Player opponent, GameField game)
        {
            int count = OpponentsBench ? opponent.BenchedPokemon.Count : owner.BenchedPokemon.Count;

            return(game.FlipCoins(count) * Damage);
        }
Пример #54
0
 public ListViewColumnProperty(GameField field)
 {
     Field = field;
 }
Пример #55
0
 public void OnAttachedTo(PokemonCard attachedTo, bool fromHand, GameField game)
 {
 }
Пример #56
0
        public void InitializeMap(string mapName)
        {
            Vector2 mapSize;
            var     tiles   = MapManager.ReadMapLayer(mapName, "ground", new Vector2(cellSize), out mapSize);
            var     walls   = MapManager.ReadMapLayer(mapName, "walls", new Vector2(cellSize), out mapSize);
            var     objects = MapManager.ReadMapLayer(mapName, "objects", new Vector2(cellSize), out mapSize);

            gameField = new GameField((int)mapSize.X, (int)mapSize.Y);

            factory.Initialize(gameField);
            factory.CreateCamera(mapSize * cellSize);
            factory.CreateGame();
            factory.CreateHud();

            foreach (var tile in tiles)
            {
                var g = Ground.Ground;
                if (tile.GID >= 108)
                {
                    g = Ground.Asphalt;
                }
                else if (tile.GID >= 84)
                {
                    g = Ground.Sand;
                }

                var tileEntity = factory.CreateTile(tile.X, tile.Y, tile.GID, g);
                gameField.SetCell(tile.Position, g, tileEntity);
            }

            foreach (var wall in walls)
            {
                switch (wall.Type)
                {
                case CellType.Wall:      factory.CreateWall(wall.X, wall.Y); break;

                case CellType.SteelWall: factory.CreateSteelWall(wall.X, wall.Y, 420, wall.Type); break;

                case CellType.TitanWall: factory.CreateSteelWall(wall.X, wall.Y, 450, wall.Type); break;

                case CellType.ArmorWall: factory.CreateSteelWall(wall.X, wall.Y, 480, wall.Type); break;

                case CellType.Tree:      factory.CreateTree(wall.X, wall.Y); break;

                case CellType.Obstacle:  factory.CreateObstacle(wall.X, wall.Y); break;
                }
            }

            foreach (var o in objects)
            {
                switch (o.Type)
                {
                case CellType.GreenTank: factory.CreatePlayer(o.X, o.Y); break;

                case CellType.RedTank: factory.CreateTank(o.X, o.Y); break;

                case CellType.GreenSpawner: factory.CreateRedSpawner(o.X, o.Y); break;

                case CellType.RedSpawner: factory.CreateRedSpawner(o.X, o.Y); break;

                case CellType.Tower: factory.CreateTower(o.X, o.Y, 4); break;
                }
            }
        }
Пример #57
0
        private int minMax(GameField field, int depth, bool isMax)
        {
            count++;
            if (count > perv + 99999)
            {
                Console.WriteLine(count);
                perv = count;
            }
            int score = evaluateGameField(field);

            if (score == WINING_FIELD_SCORE)
            {
                return(score);
            }
            else if (score == LOSING_FIELD_SCORE)
            {
                return(score);
            }
            else if (!field.isMovesLeft())
            {
                return(0);
            }

            if (isMax)
            {
                int best = Int32.MinValue;

                for (int i = 0; i < field.size; i++)
                {
                    for (int j = 0; j < field.size; j++)
                    {
                        if (field.getCellStatus(i, j) == Player.NULL)
                        {
                            GameField fieldCopy = field.colne();

                            fieldCopy.makeMove(new Move(player, new CellCoordinats(i, j)));

                            best = Math.Max(best, minMax(fieldCopy, depth + 1, !isMax));
                        }
                    }
                }
                return(best);
            }
            else
            {
                int best = Int32.MaxValue;

                for (int i = 0; i < field.size; i++)
                {
                    for (int j = 0; j < field.size; j++)
                    {
                        if (field.getCellStatus(i, j) == Player.NULL)
                        {
                            GameField fieldCopy = field.colne();

                            fieldCopy.makeMove(new Move(Player.PLAYER, new CellCoordinats(i, j)));

                            best = Math.Min(best, minMax(fieldCopy, depth + 1, !isMax));
                        }
                    }
                }
                return(best);
            }
        }
Пример #58
0
        public bool Place(GameField gameField, Position position)
        {
            gameField[position].Entities.Add(this);

            return(true);
        }
Пример #59
0
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            if (Targeting.GetPossibleTargetsFromMode(TargetingMode, game, caster, opponent, pokemonSource).Count == 0)
            {
                return;
            }

            string yesNoInfo = EnergyToDiscard > 0 ? "Discard energy card?" : "Deal damage to a benched pokemon?";

            if (askYesNo && !game.AskYesNo(caster, yesNoInfo))
            {
                return;
            }

            if (energyToDiscard > 0)
            {
                var choices = pokemonSource.AttachedEnergy
                              .Where(e => EnergyType == EnergyTypes.All || EnergyType == EnergyTypes.None || e.EnergyType == EnergyType)
                              .OfType <Card>()
                              .ToList();

                var response = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(new PickFromListMessage(choices, energyToDiscard).ToNetworkMessage(game.Id));

                foreach (var id in response.Cards)
                {
                    var card = game.Cards[id];
                    pokemonSource.DiscardEnergyCard((EnergyCard)card, game);
                }
            }

            if (!CoinflipConditional.IsOk(game, caster))
            {
                return;
            }

            var target = Targeting.AskForTargetFromTargetingMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard);

            if (target == null)
            {
                return;
            }

            int damage;

            if (DamageModifier != null)
            {
                damage = DamageModifier.NewDamage;
            }
            else
            {
                damage = Amount;
            }

            if (ApplyWeaknessResistance)
            {
                damage = DamageCalculator.GetDamageAfterWeaknessAndResistance(damage, pokemonSource, target, null, game.FindResistanceModifier());
            }
            else
            {
                damage = Amount;
            }

            target.DealDamage(damage, game, pokemonSource, true);
        }
Пример #60
0
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            Player target;

            if (AskYesNoToTargetOpponent && game.AskYesNo(caster, "Put Pokémon from opponents discard onto their bench?"))
            {
                target = opponent;
            }
            else
            {
                target = caster;
            }

            if (TargetsOpponent)
            {
                target = opponent;
            }

            var pokemons = target.DiscardPile.OfType <PokemonCard>().Where(pokemon => pokemon.Stage == 0).OfType <Card>().ToList();

            if (pokemons.Count == 0 || target.BenchedPokemon.Count == GameField.BenchMaxSize)
            {
                return;
            }

            var message  = new PickFromListMessage(pokemons, 1).ToNetworkMessage(game.Id);
            var response = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();

            var card = game.Cards[response];

            var pokemonCard = (PokemonCard)card;

            int index = target.BenchedPokemon.GetNextFreeIndex();

            target.BenchedPokemon.Add(pokemonCard);
            target.DiscardPile.Remove(card);

            if (WithRemainingHealth > 0 && WithRemainingHealth < 1)
            {
                var health = (int)Math.Ceiling(pokemonCard.Hp * WithRemainingHealth);

                if (health.ToString().Last() == '5')
                {
                    health += 5;
                }

                pokemonCard.DamageCounters = health;
            }
            else if (WithRemainingHealth > 1)
            {
                pokemonCard.DamageCounters = pokemonCard.Hp - (int)WithRemainingHealth;
            }
            else
            {
                pokemonCard.DamageCounters = 0;
            }

            game.SendEventToPlayers(new PokemonAddedToBenchEvent()
            {
                Pokemon = pokemonCard, Player = target.Id, Index = index
            });
        }