Skip to content

Commit 9ba83cf

Browse files
committed
Fix VLD_100: Global Bans do not prevent Snipes
1 parent 64dbd2b commit 9ba83cf

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/__tests__/models/Validator.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,20 @@ it('Execute parallel turn: Regular order (2)', () => {
404404
expect(errors).toEqual([]);
405405
});
406406

407+
it('Snipe globally banned civ', () => {
408+
let preset = new Preset("test", Civilisation.ALL, [
409+
new Turn(Player.HOST, Action.PICK, Exclusivity.GLOBAL),
410+
new Turn(Player.HOST, Action.BAN, Exclusivity.GLOBAL),
411+
new Turn(Player.GUEST, Action.SNIPE, Exclusivity.GLOBAL),
412+
]);
413+
const validator = new Validator(prepareReadyStore(preset, [
414+
new PlayerEvent(Player.HOST, ActionType.PICK, Civilisation.AZTECS),
415+
new PlayerEvent(Player.HOST, ActionType.BAN, Civilisation.AZTECS),
416+
]));
417+
const errors: ValidationId[] = validator.validateAndApply(DRAFT_ID, new PlayerEvent(Player.GUEST, ActionType.SNIPE, Civilisation.AZTECS));
418+
expect(errors).toEqual([]);
419+
});
420+
407421

408422
const prepareStore = (preset: Preset, events: DraftEvent[] = []): DraftsStore => {
409423
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
@@ -52,7 +52,7 @@ export class Validation {
5252
if (!draft.hasNextAction()) {
5353
return true;
5454
}
55-
if (Util.isPlayerEvent(draftEvent)) {
55+
if (Util.isPlayerEvent(draftEvent) && !(draftEvent.actionType === ActionType.SNIPE)) {
5656
const playerEvent = draftEvent as PlayerEvent;
5757
const globalBans: Civilisation[] = draft.getGlobalBans();
5858
if (Validation.includes(globalBans, playerEvent.civilisation)) {

0 commit comments

Comments
 (0)