mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
webpack
This commit is contained in:
38
client/src/scripts/create.js
Normal file
38
client/src/scripts/create.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { defaultCards } from "../config/defaultCards.js";
|
||||
import { customCards } from "../config/customCards.js";
|
||||
import { DeckStateManager } from "../modules/DeckStateManager.js";
|
||||
import { GameCreationStepManager } from "../modules/GameCreationStepManager.js";
|
||||
|
||||
const create = () => {
|
||||
let deckManager = new DeckStateManager();
|
||||
let gameCreationStepManager = new GameCreationStepManager(deckManager);
|
||||
loadDefaultCards(deckManager);
|
||||
loadCustomRoles(deckManager);
|
||||
gameCreationStepManager.renderStep("creation-step-container", 1);
|
||||
}
|
||||
|
||||
function loadDefaultCards(deckManager) {
|
||||
defaultCards.sort((a, b) => {
|
||||
return a.role.localeCompare(b.role);
|
||||
});
|
||||
let deck = [];
|
||||
for (let i = 0; i < defaultCards.length; i ++) {
|
||||
let card = defaultCards[i];
|
||||
card.quantity = 0;
|
||||
deck.push(card);
|
||||
}
|
||||
deckManager.deck = deck;
|
||||
}
|
||||
|
||||
function loadCustomRoles(deckManager) {
|
||||
customCards.sort((a, b) => {
|
||||
return a.role.localeCompare(b.role);
|
||||
});
|
||||
deckManager.customRoleOptions = customCards;
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
module.exports = create;
|
||||
} else {
|
||||
create();
|
||||
}
|
||||
Reference in New Issue
Block a user