var EHDI = EHDI || Object.create(null); EHDI.GAME = EHDI.GAME || Object.create(null); EHDI.GAME.components = EHDI.GAME.components || Object.create(null); EHDI.GAME.components.Player = function(cardBoard) { EHDI.GAME.components.CardPlayer.call(this, cardBoard); this.boardPositionY = 400; } EHDI.GAME.components.Player.prototype = Object.create(EHDI.GAME.components.CardPlayer.prototype); EHDI.GAME.components.Player.prototype.nextMove = function(card, callback) { EHDI.GAME.components.CardPlayer.prototype.nextMove.call(this, card, callback); EHDI.GAME.utils.bringToFront(card); // this.points += this.effectCalculator.calculate(card, this.boardCards, this.enemyBoardCards); } EHDI.GAME.components.Player.prototype.addCardToBoardAnim = function(card, callback, setOnBoard) { var positionsY = [260]; var positionsX = [700]; var xIndex = 0; var yIndex = 0; var nextX; var lastCard = (setOnBoard == undefined)? this.handCards.length <= 0 : setOnBoard; if(card) { this.timeline.eventCallback("onComplete", callback, [this.boardCards[this.boardCards.length-1], lastCard]); } else this.timeline.eventCallback("onComplete", null); EHDI.GAME.utils.resetTimeline(this.timeline); // if(callback) // this.timeline = new TimelineLite({onComplete: callback.bind(this, this.boardCards[this.boardCards.length-1], lastCard)}); // else // var timeline = new TimelineLite(); if(this.boardCards.length > 3) { if(this.boardCards.length > 6) { positionsY = [200, 260, 320]; positionsX = [700, 650, 600]; } else { positionsY = [200, 320]; positionsX = [700, 650]; } } nextX = positionsX[xIndex]; for(var i = 0; i < this.boardCards.length; i++) { this.timeline.to(this.boardCards[i].position, 0.3, {x: nextX, y: positionsY[yIndex], onStart: EHDI.GAME.soundManager.playSFX, onStartParams: ["card_place"], onComplete: EHDI.GAME.CardInteractions.setOnBoardListeners.bind(this, this.boardCards[i], lastCard)}, "addToBoard"); if(i == this.boardCards.length-1 && card) this.boardCards[i].setFacedDown(); nextX += 110; if((i+1) % 3 == 0) { xIndex++; nextX = positionsX[xIndex]; yIndex++; } } EHDI.GAME.TimelineManager.add(this.timeline); } EHDI.GAME.components.Player.prototype.getHandCardWithIndex = function(index) { for(var i = 0; i < this.handCards.length; i++) { if(index == this.handCards[i].handIndex) return this.handCards[i]; } }