export default class Style { constructor(gameInstanz) { this._game = gameInstanz; this._cardOnDeck = null; this._drawCardRunnig = false; this._firstDraw = $('#first-draw'); this._firstPut = $('#first-put'); this._firstPutAnim = $('#first-put-anim'); $('#drawCard').on('click', () => { this.game.currentPlayerInstanz.drawCard(1, true, true); this.refreshDebug(); }); this.firstDraw.on('mouseenter', () => { this.drawCardAnim(true, false); }); this.firstDraw.on('mouseleave', () => { this.drawCardAnim(false, false); }); this.firstDraw.on('click', () => { let playerInstanz = this.game.currentPlayerInstanz; this.drawCardAnim(false, true); playerInstanz.drawCard(1, true, true); }); } refreshHtml() { this.refreshCardOnDeck(); this.showPlayerDeck(this.game.currentPlayerInstanz, true, false, true) this.refreshDebug(); } refreshCardOnDeck(){ if (this._cardOnDeck !== this.game.cardOnDeck) { console.log(" ewfw") this.putCardAnim(); this._cardOnDeck = this.game.cardOnDeck; } else { this.firstPut.attr('src', './img/stackCards/' + this.game.cardOnDeck.color + '/' + this.game.cardOnDeck.name + '.png'); this.firstPutAnim.attr('src', './img/stackCards/' + this.game.cardOnDeck.color + '/' + this.game.cardOnDeck.name + '.png'); } } refreshDebug() { $('#drawCard').css('background-color', 'white'); $("#player").html("Spieler: " + this.game.currentPlayerInstanz.name); $("#playerCards").html("Karten: "); for (let i = 0; i < this.game.currentPlayerInstanz.hand.length; i++) { $('#playerCards').append(this.game.currentPlayerInstanz.hand[i].name + " - " + this.game.currentPlayerInstanz.hand[i].color); $('#playerCards').append(' | '); $('#button' + i).on('click', () => { this.game.currentPlayerInstanz.putCard(i); setTimeout(() => { this.showPlayerDeck(this.game.currentPlayerInstanz, false, true, false); }, 100); }); if (this.game.currentPlayerInstanz.hand[i].canPut) $('#button' + i).css('background-color', 'green'); } $('#playerCards').append("" + this.game.currentPlayerInstanz.hand.length) $("#cardOnDeck").html("Karte auf dem Tisch: " + this.game.cardOnDeck.name + " - " + this.game.cardOnDeck.color); $("#playerInGame").html("Spieler im Spiel: " + this.game.players.length); if (!this.game.currentPlayerInstanz.canPlay) $('#drawCard').css('background-color', 'red'); } putCardAnim() { this.firstPutAnim.attr('src', './img/stackCards/' + this.game.cardOnDeck.color + '/' + this.game.cardOnDeck.name + '.png'); this.firstPutAnim.css('transition', 'top 0.5s, opacity 0.3s'); this.firstPutAnim.css('top', '47vh'); this.firstPutAnim.css('opacity', '1'); setTimeout(() => { this.firstPutAnim.css('transition', ''); this.firstPutAnim.css('top', '30vh'); this.firstPutAnim.css('opacity', '0'); this.firstPut.attr('src', './img/stackCards/' + this.game.cardOnDeck.color + '/' + this.game.cardOnDeck.name + '.png'); this.firstPut.css('opacity', '1'); }, 500); } showPlayerDeck(player, click, lastDraw, anim) { $('#playerDeck').html(""); let currentPlayerHand = player.hand; let width = window.innerWidth; let height = window.innerHeight; let percent = 0; let top = window.innerHeight * 0.68; let cardAmount = currentPlayerHand.length; for (let i = 0; i < cardAmount; i++) { currentPlayerHand.xPos = 0; currentPlayerHand.yPos = 0; $('#playerDeck').append('