Add independent alignment for custom roles (#217)

* Initial plan

* Add independent alignment: constants, validation, UI, and CSS

Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com>

* Add unit tests for independent alignment validation

Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com>

* Fix remaining binary alignment checks in role display

Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com>

* Add independent player container and game-role-independent CSS

Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com>

* fix a couple bugs, tweak colors

* remove import

* remove duplicate tag

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlecM33 <24642328+AlecM33@users.noreply.github.com>
Co-authored-by: AlecM33 <leohfx@gmail.com>
This commit is contained in:
Copilot
2026-01-24 23:55:11 -05:00
committed by GitHub
parent b328bfffe5
commit 0449e33b40
13 changed files with 203 additions and 54 deletions

View File

@@ -0,0 +1,104 @@
const GameCreationRequest = require('../../../../server/model/GameCreationRequest');
const { ALIGNMENT } = require('../../../../server/config/globals');
describe('GameCreationRequest', () => {
describe('#deckIsValid', () => {
it('should accept a deck with good, evil, and independent roles', () => {
const deck = [
{
role: 'Villager',
team: ALIGNMENT.GOOD,
description: 'A simple villager',
custom: false,
quantity: 2
},
{
role: 'Werewolf',
team: ALIGNMENT.EVIL,
description: 'A werewolf',
custom: false,
quantity: 1
},
{
role: 'Tanner',
team: ALIGNMENT.INDEPENDENT,
description: 'An independent role',
custom: true,
quantity: 1
}
];
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
});
it('should accept a deck with only good roles', () => {
const deck = [
{
role: 'Villager',
team: ALIGNMENT.GOOD,
description: 'A simple villager',
custom: false,
quantity: 3
}
];
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
});
it('should accept a deck with only evil roles', () => {
const deck = [
{
role: 'Werewolf',
team: ALIGNMENT.EVIL,
description: 'A werewolf',
custom: false,
quantity: 2
}
];
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
});
it('should accept a deck with only independent roles', () => {
const deck = [
{
role: 'Tanner',
team: ALIGNMENT.INDEPENDENT,
description: 'An independent role',
custom: true,
quantity: 1
}
];
expect(GameCreationRequest.deckIsValid(deck)).toBe(true);
});
it('should reject a deck with invalid team values', () => {
const deck = [
{
role: 'InvalidRole',
team: 'invalid',
description: 'Invalid team',
custom: true,
quantity: 1
}
];
expect(GameCreationRequest.deckIsValid(deck)).toBe(false);
});
it('should reject a deck with missing required fields', () => {
const deck = [
{
role: 'Villager',
// missing team
description: 'A simple villager',
custom: false,
quantity: 1
}
];
expect(GameCreationRequest.deckIsValid(deck)).toBe(false);
});
});
});