Skip to content

Commit

Permalink
remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
fgandellini committed Jun 9, 2024
1 parent cc51a94 commit 363a2bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 54 deletions.
22 changes: 0 additions & 22 deletions packages/game-engine/src/board.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,26 +632,4 @@ describe('Board', () => {
[null, null, null, null, null, null],
])
})

// it('Debug', () => {
// let board = createEmptyBoard(3)
// board = setTile(board, { x: 0, y: 2 }, { value: 1 })

// // prettier-ignore
// expect(boardToMatrix(board)).toEqual([
// [null, null, null],
// [null, null, null],
// [1 , null, null],
// ])

// board = move(board, 'up')
// board = setTile(board, { x: 0, y: 1 }, { value: 1 })

// // prettier-ignore
// expect(boardToMatrix(board)).toEqual([
// [1 , 1 , null],
// [null, null, null],
// [null, null, null],
// ])
// })
})
7 changes: 6 additions & 1 deletion packages/game-engine/src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export type Coords = { x: number; y: number }
*/
export type Tile = { value: number }

/**
* An obstacle is a cell in the board that won't move
*/
export type Obstacle = { obstacle: true }

/**
* A Board is a grid of tiles
*
Expand All @@ -64,7 +69,7 @@ export type Tile = { value: number }
*/
export type Board = {
size: number
grid: ReadonlyArray<Tile | null>
grid: ReadonlyArray<Tile | Obstacle | null>
}

/**
Expand Down
30 changes: 0 additions & 30 deletions packages/game-engine/src/game-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,4 @@ describe('Game Manager', () => {
expect(lostGame.state).toBe('lost')
expect(isBoardEqual(lostGame.board, game.board)).toBe(true)
})

// it('Play a game', () => {
// console.log('init --------------------------------------------')
// let state = startGame(2)
// console.table(boardToMatrix(state.board))

// console.log('up --------------------------------------------')
// state = transition(state, { type: 'move', direction: 'up' })
// console.table(boardToMatrix(state.board))

// console.log('right --------------------------------------------')
// state = transition(state, { type: 'move', direction: 'right' })
// console.table(boardToMatrix(state.board))

// console.log('up --------------------------------------------')
// state = transition(state, { type: 'move', direction: 'up' })
// console.table(boardToMatrix(state.board))

// console.log('right --------------------------------------------')
// state = transition(state, { type: 'move', direction: 'right' })
// console.table(boardToMatrix(state.board))

// console.log('right --------------------------------------------')
// state = transition(state, { type: 'move', direction: 'right' })
// console.table(boardToMatrix(state.board))

// console.log('up --------------------------------------------')
// state = transition(state, { type: 'move', direction: 'up' })
// console.table(boardToMatrix(state.board))
// })
})
2 changes: 1 addition & 1 deletion packages/game-engine/src/game-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Action = { type: 'move'; direction: Direction }
* @returns the initial game state
* @note the game starts with a tile of value 2 placed randomly on the board
*/
export const startGame = (size: number): GameState => ({
export const startGame = (size: number, obstacles: number): GameState => ({
board: setRandomTile(b.createEmptyBoard(size), b.createTile(2))!,
state: 'playing',
})
Expand Down

0 comments on commit 363a2bb

Please sign in to comment.