示例#1
0
        public static bool TryCreateField(GameField oldField, GameTurn turn, out GameField newField)
        {
            newField = oldField;

            if (turn == null ||
                turn.IsSimple && GameTurnUtils.FindRequiredJumps(oldField, turn.Side).Any())
            {
                return(false);
            }

            var newCells  = new List <CellState>(oldField.Cells);
            var cellState = newCells[turn.Steps.First()];

            foreach (var step in turn.Steps)
            {
                newCells[step] = CellState.Empty;
            }

            newCells[turn.Steps.Last()] = turn.IsLevelUp ? cellState.LevelUp() : cellState;

            newField = new GameField(newCells, oldField.Dimension);

            return(true);
        }
示例#2
0
 private static bool AnyTurnsPossible(GameField field, PlayerSide side) =>
     field.Cells.SelectMany((cell, idx) => cell.IsSameSide(side)
         ? GameTurnUtils.FindTurnsForCell(field, idx)
         : Enumerable.Empty<GameTurn>())
     .Any();