refactor: update boop implementation
This commit is contained in:
+14
-20
@@ -130,23 +130,23 @@ describe('Boop - helper functions', () => {
|
||||
const state = getState(ctx);
|
||||
|
||||
placePiece(state, 0, 0, 'white', 'kitten');
|
||||
expect(state.value.players.white.kitten.supply).toBe(7);
|
||||
expect(state.value.players.black.kitten.supply).toBe(8);
|
||||
expect(state.value.players.white.value.kitten.supply).toBe(7);
|
||||
expect(state.value.players.black.value.kitten.supply).toBe(8);
|
||||
|
||||
placePiece(state, 0, 1, 'black', 'kitten');
|
||||
expect(state.value.players.white.kitten.supply).toBe(7);
|
||||
expect(state.value.players.black.kitten.supply).toBe(7);
|
||||
expect(state.value.players.white.value.kitten.supply).toBe(7);
|
||||
expect(state.value.players.black.value.kitten.supply).toBe(7);
|
||||
});
|
||||
|
||||
it('should decrement the correct player cat supply', () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
state.produce(s => {
|
||||
s.players.white.cat.supply = 3;
|
||||
s.players.white.value.cat.supply = 3;
|
||||
});
|
||||
|
||||
placePiece(state, 0, 0, 'white', 'cat');
|
||||
expect(state.value.players.white.cat.supply).toBe(2);
|
||||
expect(state.value.players.white.value.cat.supply).toBe(2);
|
||||
});
|
||||
|
||||
it('should add piece to board region children', () => {
|
||||
@@ -211,7 +211,7 @@ describe('Boop - helper functions', () => {
|
||||
|
||||
expect(getParts(state).length).toBe(1);
|
||||
expect(getParts(state)[0].value.player).toBe('black');
|
||||
expect(state.value.players.white.kitten.supply).toBe(8);
|
||||
expect(state.value.players.white.value.kitten.supply).toBe(8);
|
||||
});
|
||||
|
||||
it('should not boop piece if target cell is occupied', () => {
|
||||
@@ -367,7 +367,7 @@ describe('Boop - helper functions', () => {
|
||||
processGraduation(state, 'white', lines);
|
||||
|
||||
expect(getParts(state).length).toBe(0);
|
||||
expect(state.value.players.white.cat.supply).toBe(3);
|
||||
expect(state.value.players.white.value.cat.supply).toBe(3);
|
||||
});
|
||||
|
||||
it('should only graduate pieces on the winning lines', () => {
|
||||
@@ -384,7 +384,7 @@ describe('Boop - helper functions', () => {
|
||||
|
||||
expect(getParts(state).length).toBe(1);
|
||||
expect(getParts(state)[0].value.position).toEqual([3, 3]);
|
||||
expect(state.value.players.white.cat.supply).toBe(3);
|
||||
expect(state.value.players.white.value.cat.supply).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -537,9 +537,7 @@ describe('Boop - game flow', () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
state.produce(s => {
|
||||
s.players.white.kitten.supply = 0;
|
||||
});
|
||||
state.value.players.white.value.kitten.supply = 0;
|
||||
|
||||
const promptPromise = waitForPrompt(ctx);
|
||||
const runPromise = ctx.commands.run<{winner: WinnerType}>('turn white');
|
||||
@@ -598,16 +596,14 @@ describe('Boop - game flow', () => {
|
||||
processGraduation(state, 'white', lines);
|
||||
|
||||
expect(getParts(state).length).toBe(0);
|
||||
expect(state.value.players.white.cat.supply).toBe(3);
|
||||
expect(state.value.players.white.value.cat.supply).toBe(3);
|
||||
});
|
||||
|
||||
it('should accept placing a cat via play command', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
state.produce(s => {
|
||||
s.players.white.cat.supply = 3;
|
||||
});
|
||||
state.value.players.white.value.cat.supply = 3;
|
||||
|
||||
const promptPromise = waitForPrompt(ctx);
|
||||
const runPromise = ctx.commands.run<{winner: WinnerType}>('turn white');
|
||||
@@ -621,16 +617,14 @@ describe('Boop - game flow', () => {
|
||||
expect(getParts(state).length).toBe(1);
|
||||
expect(getParts(state)[0].id).toBe('white-cat-1');
|
||||
expect(getParts(state)[0].value.pieceType).toBe('cat');
|
||||
expect(state.value.players.white.cat.supply).toBe(2);
|
||||
expect(state.value.players.white.value.cat.supply).toBe(2);
|
||||
});
|
||||
|
||||
it('should reject placing a cat when supply is empty', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
state.produce(s => {
|
||||
s.players.white.cat.supply = 0;
|
||||
});
|
||||
state.value.players.white.value.cat.supply = 0;
|
||||
|
||||
const promptPromise = waitForPrompt(ctx);
|
||||
const runPromise = ctx.commands.run<{winner: WinnerType}>('turn white');
|
||||
|
||||
Reference in New Issue
Block a user