Skip to content

Commit

Permalink
Fix bug making upgrades always playable (#611)
Browse files Browse the repository at this point in the history
Fixed #593 . We just didn't have a check in the path that enforced a
legal attach target
  • Loading branch information
AMMayberry1 authored Feb 17, 2025
1 parent e25d830 commit caee255
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/game/actions/PlayUpgradeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export class PlayUpgradeAction extends PlayCardAction {
) {
return 'restriction';
}

if (!this.hasSomeLegalTarget(context)) {
return 'attachTarget';
}

return super.meetsRequirements(context, ignoredRequirements);
}

Expand Down
14 changes: 14 additions & 0 deletions test/server/core/card/Upgrade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,19 @@ describe('Upgrade cards', function() {
expect(context.entrenched).toBeInZone('discard', context.player2);
});
});

it('When an upgrade is in hand and has no legal target, it should not be clickable', async function() {
await contextRef.setupTestAsync({
phase: 'action',
player1: {
hand: ['academy-training', 'wampa'],
}
});

const { context } = contextRef;

expect(context.player1).not.toBeAbleToSelect(context.academyTraining);
expect(context.academyTraining).not.toHaveAvailableActionWhenClickedBy(context.player1);
});
});
});

0 comments on commit caee255

Please sign in to comment.