Compare commits
1 Commits
master
...
feature/sh
Author | SHA1 | Date | |
---|---|---|---|
![]() |
188608bf84 |
@ -36,6 +36,8 @@ class Game {
|
||||
this.blackPlayer = new Player('black');
|
||||
this.chosenFigure = new Figure(0,0);
|
||||
this.fields = [];
|
||||
this.currentPlayer = 'white';
|
||||
this.otherPlayer = (this.currentPlayer == 'white') ? 'black' : 'white';
|
||||
}
|
||||
drawGamePanel(x,y, widthAndHeight) {
|
||||
var boxes = new Array();
|
||||
@ -93,6 +95,10 @@ class Game {
|
||||
}
|
||||
|
||||
handleClick(item) {
|
||||
if(!item.classList.contains(this.currentPlayer) && !item.classList.contains('possibleMove')) {
|
||||
alert(this.otherPlayer + ' ist nicht dran');
|
||||
return;
|
||||
}
|
||||
if(item.classList.contains('shogun') || item.classList.contains('farmer')) {
|
||||
this.chosenFigure.setX(item.getAttribute('data-x'));
|
||||
this.chosenFigure.setY(item.getAttribute('data-y'));
|
||||
@ -353,6 +359,13 @@ class Game {
|
||||
this.showPossibleMoves();
|
||||
this.chosenFigure.reset();
|
||||
game.updateLists();
|
||||
this.switchPlayers();
|
||||
}
|
||||
|
||||
switchPlayers() {
|
||||
var currentPlayer = this.currentPlayer;
|
||||
this.currentPlayer = this.otherPlayer;
|
||||
this.otherPlayer = currentPlayer;
|
||||
}
|
||||
|
||||
removeIndicator() {
|
||||
@ -364,8 +377,6 @@ class Game {
|
||||
updateLists() {
|
||||
var whiteList = document.querySelector('.whitePlayer');
|
||||
var blackList = document.querySelector('.blackPlayer');
|
||||
console.log(whiteList)
|
||||
console.log(blackList)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user