Dodanie lepszego(?) modala i mozliwości zmiany nicków graczy.

This commit is contained in:
kplaczek
2017-10-07 22:52:37 +02:00
parent 198f0c1f49
commit 288b54df3e
7 changed files with 263 additions and 73 deletions

View File

@@ -8,6 +8,19 @@ function Bonus(group, value) {
this.group = group;
}
function modal() {
this.init = function () {
this.handleClose();
};
this.handleClose = function () {
document.querySelector('.modal .close').addEventListener('click', function () {
this.parentNode.classList.toggle('on');
});
};
}
function player(name, id) {
this.score = 0;
this.roundsWon = 0;
@@ -16,6 +29,7 @@ function player(name, id) {
this.name = name;
this.id = id;
this.selector = '.player.player' + id;
this.scoreSelector = '.player' + id + '_name';
this.hasCamelCoin = false;
@@ -34,6 +48,16 @@ function player(name, id) {
return this.score = score;
};
this.setName = function (name) {
this.name = name;
this.updateNames();
};
this.updateNames = function () {
document.querySelector(this.selector).innerText = this.name;
document.querySelector(this.scoreSelector).innerText = this.name;
};
this.wonRound = function () {
this.roundsWon += 1;
};
@@ -125,8 +149,15 @@ function game(player1, player2, board) {
this.initializeMenu = function () {
document.querySelector('#players').addEventListener('click', function () {
jaipur.playerNamesModal();
});
document.querySelector('#change_name').addEventListener('click', function () {
jaipur.player1.setName(document.querySelector('#player1_name').value);
jaipur.player2.setName(document.querySelector('#player2_name').value);
});
document.querySelector('#endturn').addEventListener('click', function () {
jaipur.endTurn();
});
@@ -139,6 +170,10 @@ function game(player1, player2, board) {
};
this.playerNamesModal = function () {
document.querySelector('#playerNames').classList.toggle('on');
};
this.initializePlayerButtons = function () {
document.querySelector('.player.player1').addEventListener('click', function () {
jaipur.setActivePlayer(1)
@@ -305,7 +340,7 @@ function game(player1, player2, board) {
};
this.showScoreBoard = function () {
document.querySelector('.scoreTable').classList.add('visible');
document.querySelector('#scoreTable').classList.add('visible');
};
this.showScore = function () {