Skip to content

Commit d437a82

Browse files
committed
Fix VLD_301 for multiple snipes in a row
Resolves #31
1 parent 74838ce commit d437a82

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/__tests__/models/Validator.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,24 @@ it('Snipe globally banned civ', () => {
418418
expect(errors).toEqual([]);
419419
});
420420

421+
it('Double Snipe', () => {
422+
let preset = new Preset("test", Civilisation.ALL, [
423+
new Turn(Player.HOST, Action.PICK, Exclusivity.GLOBAL),
424+
new Turn(Player.HOST, Action.PICK, Exclusivity.GLOBAL),
425+
new Turn(Player.HOST, Action.PICK, Exclusivity.GLOBAL),
426+
new Turn(Player.GUEST, Action.SNIPE, Exclusivity.GLOBAL),
427+
new Turn(Player.GUEST, Action.SNIPE, Exclusivity.GLOBAL),
428+
]);
429+
const validator = new Validator(prepareReadyStore(preset, [
430+
new PlayerEvent(Player.HOST, ActionType.PICK, Civilisation.AZTECS),
431+
new PlayerEvent(Player.HOST, ActionType.PICK, Civilisation.BRITONS),
432+
new PlayerEvent(Player.HOST, ActionType.PICK, Civilisation.CHINESE),
433+
new PlayerEvent(Player.GUEST, ActionType.SNIPE, Civilisation.BRITONS),
434+
]));
435+
const errors: ValidationId[] = validator.validateAndApply(DRAFT_ID, new PlayerEvent(Player.GUEST, ActionType.SNIPE, Civilisation.CHINESE));
436+
expect(errors).toEqual([]);
437+
});
438+
421439

422440
const prepareStore = (preset: Preset, events: DraftEvent[] = []): DraftsStore => {
423441
const draft = new Draft(NAME_HOST, NAME_GUEST, preset);

src/models/Validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class Validation {
170170
return false;
171171
}
172172
const index = Validation.indexOfSnipe(picksByOpponent, sniped);
173-
picksByOpponent.splice(index);
173+
picksByOpponent.splice(index, 1);
174174
}
175175
}
176176
}

0 commit comments

Comments
 (0)