Browse Source

UnoButton implementiert

main
Nicolas Fritz 2 years ago
parent
commit
ab95c96896
  1. 1
      uno/css/uno.css
  2. 9
      uno/web/Game.js
  3. 16
      uno/web/Style.js

1
uno/css/uno.css

@ -72,6 +72,7 @@ body
bottom: 0vh; bottom: 0vh;
left: 3vh; left: 3vh;
width: 100%; width: 100%;
opacity: 0;
} }
.uno{ .uno{
position: absolute; position: absolute;

9
uno/web/Game.js

@ -136,6 +136,7 @@ export default class Game {
//Beendet den Zug des aktuellen Spielers und beginnt den Zug des nächsten Spielers //Beendet den Zug des aktuellen Spielers und beginnt den Zug des nächsten Spielers
nextTurn() { nextTurn() {
let delay = 0; let delay = 0;
//Testet, ob Spiel Gewonnen //Testet, ob Spiel Gewonnen
@ -162,6 +163,9 @@ export default class Game {
this.players[this.currentPlayer].turn = false; this.players[this.currentPlayer].turn = false;
} }
this.style.hideUnoButton();
setTimeout(() => { setTimeout(() => {
@ -244,7 +248,10 @@ export default class Game {
//Uno sagen testen //Uno sagen testen
if (this.currentPlayerInstanz.hand.length <= 2 && this.currentPlayerInstanz.canPlay) this.currentPlayerInstanz.mustSayUno = true;
if (this.currentPlayerInstanz.hand.length === 2 && this.currentPlayerInstanz.canPlay){
this.currentPlayerInstanz.mustSayUno = true;
this.style.showUnoButton();
}
} }

16
uno/web/Style.js

@ -42,6 +42,10 @@ export default class Style {
}) })
$('#drawCard').on('click', () => { $('#drawCard').on('click', () => {
if(this.game.currentPlayerInstanz.mustSayUno){
this.game.currentPlayerInstanz.mustSayUno = false;
console.log(this.game.currentPlayerInstanz.mustSayUno)
}
this.game.currentPlayerInstanz.drawCard(1, true, true); this.game.currentPlayerInstanz.drawCard(1, true, true);
this.refreshDebug(); this.refreshDebug();
}); });
@ -53,6 +57,10 @@ export default class Style {
this.drawCardAnim(false, false); this.drawCardAnim(false, false);
}); });
this.firstDraw.on('click', () => { this.firstDraw.on('click', () => {
if(this.game.currentPlayerInstanz.mustSayUno){
this.game.currentPlayerInstanz.mustSayUno = false;
this.game.style.hideUnoButton();
}
let playerInstanz = this.game.currentPlayerInstanz; let playerInstanz = this.game.currentPlayerInstanz;
@ -109,15 +117,17 @@ export default class Style {
} }
showUnoButton(){ showUnoButton(){
$('#uno').css('opacity', 1);
$('.uno').css('transition', 'width ease-in-out 0.5s');
$('#sayUno-glow').css('transition', 'width ease-in-out 0.5s, opacity 0.5s');
$('.uno').css('filter', 'grayscale(0%)');
$('#sayUno').css('opacity', 1);
this.unoHover = false; this.unoHover = false;
this._unoClicked = false; this._unoClicked = false;
this.startUnoLoop(); this.startUnoLoop();
} }
hideUnoButton(){ hideUnoButton(){
$('#uno').css('opacity', 0);
$('#sayUno').css('opacity', 0);
} }
startUnoLoop() { startUnoLoop() {

Loading…
Cancel
Save