|
@@ -6,24 +6,59 @@ export default function GameCreationDivPage(element, listener) {
|
|
|
const className=GameCreationDivPage.name;
|
|
|
|
|
|
let div = element.getChildByID(id);
|
|
|
+ let divSelectDeckMode = element.getChildByID("deck-mode-select");
|
|
|
let connectButton = element.getChildByName('loginButton');
|
|
|
let username = element.getChildByName('username');
|
|
|
let connectionStatus = element.getChildByID('connectionStatus');
|
|
|
let onlineGame = element.getChildByName('onlineGame');
|
|
|
+ let createGameButton = element.getChildByName('validGameCreation');
|
|
|
|
|
|
- let eventListener = function(event) {
|
|
|
+ let deckModeSelected = null;
|
|
|
+ let advancedOptions = [];
|
|
|
+
|
|
|
+ let clickEventListener = function(event) {
|
|
|
let eventName = event.target.name;
|
|
|
switch (eventName) {
|
|
|
case "backToPrev":
|
|
|
listener.onGoPreviousPage(gameCreationDivPage);
|
|
|
break;
|
|
|
|
|
|
+ case "validGameCreation":
|
|
|
+ console.log(deckModeSelected);
|
|
|
+ console.log(advancedOptions);
|
|
|
+ listener.onValidGameCreation(deckModeSelected, advancedOptions);
|
|
|
+ break;
|
|
|
+ case "discard":
|
|
|
+ case "popularity":
|
|
|
+ if(event.target.checked){
|
|
|
+ advancedOptions.push(eventName);
|
|
|
+ } else {
|
|
|
+ let index = advancedOptions.indexOf(eventName);
|
|
|
+ if (index !== -1){
|
|
|
+ advancedOptions.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- div.addEventListener('click',eventListener);
|
|
|
+ let changeDeckEventListener = function(event) {
|
|
|
+ let eventValue = event.target.value;
|
|
|
+ if (eventValue !== 0) {
|
|
|
+ createGameButton.disabled = false;
|
|
|
+ deckModeSelected = event.target.value;
|
|
|
+ } else {
|
|
|
+ createGameButton.disabled = true;
|
|
|
+ deckModeSelected = event.target.value;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ div.addEventListener('click',clickEventListener);
|
|
|
+
|
|
|
+ divSelectDeckMode.addEventListener('change',changeDeckEventListener);
|
|
|
|
|
|
let onShow = function() {
|
|
|
|