Skip to content

Commit f11937c

Browse files
fix(scuttle/execute): scrap all jacks when scuttling
1 parent eef8686 commit f11937c

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

api/helpers/game-states/moves/scuttle/execute.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ module.exports = {
4646

4747
// remove target card from opponent points
4848
const targetPlayedIndex = opponent.points.findIndex(({ id }) => id === targetId);
49-
const [ targetCard ]= opponent.points.splice(targetPlayedIndex, 1);
49+
const [ targetCard ] = opponent.points.splice(targetPlayedIndex, 1);
5050

5151
// move both cards into scrap
52-
result.scrap.push(targetCard, playedCard );
52+
result.scrap.push(playedCard, ...targetCard.attachments, targetCard);
53+
targetCard.attachments = [];
5354

5455
result.turn++;
5556

tests/e2e/specs/in-game/basicMoves.spec.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,55 @@ describe('Game Basic Moves - P0 Perspective', () => {
170170
cy.log('Scuttling is disabled with specific message when opponent has no points');
171171
});
172172

173+
it('Scuttles a card with two jacks on it', () => {
174+
cy.loadGameFixture(0, {
175+
p0Hand: [ Card.JACK_OF_CLUBS, Card.TEN_OF_SPADES ],
176+
p0Points: [ Card.TEN_OF_HEARTS ],
177+
p0FaceCards: [ ],
178+
p1Hand: [ Card.JACK_OF_DIAMONDS ],
179+
p1Points: [ Card.FOUR_OF_DIAMONDS ],
180+
p1FaceCards: [],
181+
});
182+
183+
cy.get('[data-player-hand-card=11-0]').click();
184+
cy.get('[data-move-choice=jack]').click();
185+
cy.get('[data-opponent-point-card=4-1]').click();
186+
187+
assertGameState(0, {
188+
p0Hand: [ Card.TEN_OF_SPADES ],
189+
p0Points: [ Card.TEN_OF_HEARTS, Card.FOUR_OF_DIAMONDS ],
190+
p0FaceCards: [ ],
191+
p1Hand: [ Card.JACK_OF_DIAMONDS ],
192+
p1Points: [],
193+
p1FaceCards: [],
194+
});
195+
196+
cy.playJackOpponent(Card.JACK_OF_DIAMONDS, Card.FOUR_OF_DIAMONDS);
197+
198+
assertGameState(0, {
199+
p0Hand: [ Card.TEN_OF_SPADES ],
200+
p0Points: [ Card.TEN_OF_HEARTS ],
201+
p0FaceCards: [ ],
202+
p1Hand: [],
203+
p1Points: [ Card.FOUR_OF_DIAMONDS ],
204+
p1FaceCards: [],
205+
});
206+
207+
cy.get('[data-player-hand-card=10-3]').click();
208+
cy.get('[data-move-choice=scuttle]').click();
209+
cy.get('[data-opponent-point-card=4-1]').click({ force: true });
210+
211+
assertGameState(0, {
212+
p0Hand: [],
213+
p0Points: [ Card.TEN_OF_HEARTS ],
214+
p0FaceCards: [ ],
215+
p1Hand: [],
216+
p1Points: [],
217+
p1FaceCards: [],
218+
scrap: [ Card.FOUR_OF_DIAMONDS, Card.TEN_OF_SPADES, Card.JACK_OF_CLUBS, Card.JACK_OF_DIAMONDS ],
219+
});
220+
});
221+
173222
it('Plays Kings', () => {
174223
// Setup
175224
cy.loadGameFixture(0, {

0 commit comments

Comments
 (0)