nie można wybrać więcej niż 7 monet na raz
This commit is contained in:
@@ -10,9 +10,10 @@ Do zrobienia:
|
||||
- [x] wyświetlenie żetonu wielbłąda
|
||||
- [x] przydzielenie żetonu wielbłąda przed wyświetleniem wyniku
|
||||
- [ ] rozwiązywanie sprawy z remisem
|
||||
- [ ] przydzielanie bonusów nawet jak nie żetonów danej karty
|
||||
- [x] przydzielanie bonusów nawet jak nie żetonów danej karty
|
||||
- [x] pobieranie żetonów po kliknięciu na żetonu
|
||||
- [x] losowanie wartości bonusowych żetonów kart
|
||||
- [x] zliczanie punków
|
||||
- [x] informowanie o zakończeniu rundy
|
||||
- [x] przydzielanie żetonu Maharadży
|
||||
- [x] nie można wybrać więcej niż 7 monet na raz
|
||||
21
js/script.js
21
js/script.js
@@ -131,7 +131,17 @@ function game(player1, player2, board) {
|
||||
};
|
||||
|
||||
this.showAcceptButton = function () {
|
||||
if (!!jaipur.activePlayer && !!document.querySelector('.coin.selected')) {
|
||||
|
||||
console.info(jaipur.selectedCointType);
|
||||
if (!!jaipur.activePlayer && !!document.querySelector('.coin.selected') &&
|
||||
((document.querySelectorAll('.coin.selected').length >= 2 &&
|
||||
!!['silver', 'gold', 'diamond'].indexOf(jaipur.selectedCointType)
|
||||
) || (
|
||||
document.querySelectorAll('.coin.selected').length >= 1 &&
|
||||
!!['fabric', 'spice', 'leather'].indexOf(jaipur.selectedCointType)
|
||||
)
|
||||
)
|
||||
) {
|
||||
document.querySelector('.accept').style.visibility = 'visible';
|
||||
}
|
||||
};
|
||||
@@ -170,6 +180,8 @@ function game(player1, player2, board) {
|
||||
jaipur.selectedCointType = this.dataset.group;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (jaipur.selectedCointType == this.dataset.group) {
|
||||
|
||||
//ustawienie active inactive na wszystkich grupach
|
||||
@@ -197,6 +209,10 @@ function game(player1, player2, board) {
|
||||
jaipur.removeBlankCoin(jaipur.selectedCointType);
|
||||
|
||||
} else {
|
||||
//jesli jest już wybranych 7 lub więcej monet to nie można więcej bo to max
|
||||
if(document.querySelectorAll('.coin.selected.'+jaipur.selectedCointType).length >=7 ){
|
||||
return false;
|
||||
}
|
||||
//ustawienie selected na elemencie z kliniętej grupy
|
||||
var coinsFromRow = document.querySelectorAll('.coin.' + this.dataset.group + ':not(.selected)');
|
||||
[].slice.call(coinsFromRow).pop().classList.add('selected');
|
||||
@@ -219,13 +235,14 @@ function game(player1, player2, board) {
|
||||
blankCoin.classList.add(groupName);
|
||||
blankCoin.classList.add('blank');
|
||||
blankCoin.innerText = '0';
|
||||
blankCoin.dataset.group=groupName;
|
||||
blankCoin.dataset.group = groupName;
|
||||
blankCoin.addEventListener('click', jaipur.coinClick);
|
||||
var firstElementInGroup = document.querySelector('.coin.' + groupName);
|
||||
document.querySelector('.group.' + groupName).insertBefore(blankCoin, firstElementInGroup);
|
||||
};
|
||||
|
||||
this.removeBlankCoin = function (groupName) {
|
||||
if (!!document.querySelector('.coin.blank.' + groupName))
|
||||
document.querySelector('.coin.blank.' + groupName).remove();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user