mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
import { defaultCards } from "../config/defaultCards.js";
|
|
import { customCards } from "../config/customCards.js";
|
|
import { DeckStateManager } from "../modules/DeckStateManager.js";
|
|
import { XHRUtility } from "../modules/XHRUtility.js";
|
|
import { Game } from "../model/Game.js";
|
|
import { GameCreationStepManager } from "../modules/GameCreationStepManager.js";
|
|
|
|
export const create = () => {
|
|
let deckManager = new DeckStateManager();
|
|
let gameCreationStepManager = new GameCreationStepManager(deckManager);
|
|
loadDefaultCards(deckManager);
|
|
loadCustomRoles(deckManager);
|
|
gameCreationStepManager.renderStep("creation-step-container", 1);
|
|
}
|
|
|
|
// Display a widget for each default card that allows copies of it to be added/removed. Set initial deck state.
|
|
function loadDefaultCards(deckManager) {
|
|
defaultCards.sort((a, b) => {
|
|
return a.role.localeCompare(b.role);
|
|
});
|
|
let deck = [];
|
|
for (let i = 0; i < defaultCards.length; i ++) { // each dropdown should include every
|
|
let card = defaultCards[i];
|
|
card.quantity = 0;
|
|
deck.push(card);
|
|
}
|
|
deckManager.deck = deck;
|
|
}
|
|
|
|
/* Display a dropdown containing all the custom roles. Adding one will add it to the game deck and
|
|
create a widget for it */
|
|
function loadCustomRoles(deckManager) {
|
|
customCards.sort((a, b) => {
|
|
return a.role.localeCompare(b.role);
|
|
});
|
|
deckManager.customRoleOptions = customCards;
|
|
}
|