Redo basics of inspect item

develop
Nathan Steel 1 year ago
parent 6f3ae033ac
commit 9890f5302b

@ -48,6 +48,8 @@ let opponentManaZone = [];
// To disable drawing each time something changes // To disable drawing each time something changes
let drawEachEvent = true; let drawEachEvent = true;
let yourPlayerId = 0; // To compare click events of your/opponents cards
let viewingPlayerId = 0; // To show the board from your/opponent/teammates perspective, etc. without play permission
let deckCount = 60; let deckCount = 60;
let deckCountOpponent = 60; let deckCountOpponent = 60;
@ -57,7 +59,6 @@ const maxHandSize = 4;
const maxBoardSize = 3; const maxBoardSize = 3;
const maxShield = 4; const maxShield = 4;
let inspectCard = null;
let attackingCard = null; let attackingCard = null;
// Gonna need lots of refactoring, and sorting // Gonna need lots of refactoring, and sorting
@ -92,7 +93,7 @@ class Board{
this.drawWin(); this.drawWin();
} }
this.drawInspectedCard(); //this.drawInspectedCard();
} }
checkGameWin(){ checkGameWin(){
@ -665,21 +666,15 @@ class Board{
this.drawBoard(); this.drawBoard();
} }
inspectOpponentBoard(index){ inspectCard(cardToInspect){
// Get the card data // Set inspectedCard (for now) to the card itemKey
inspectCard = [opponentBoard, index]; inEvent = ['inspect', cardToInspect];
this.drawBoard(); this.drawBoard();
} }
drawInspectedCard(){ cancelInspect(){
if(inspectCard != null){ if(inEvent && inEvent[0] == 'inspect'){
let positionX = canvas.width/2 - cardWidth; inEvent = null;
let positionY = canvas.height/2 - cardHeight; this.drawBoard();
let width = cardWidth*2;
let height = cardHeight*2;
this.drawCard(inspectCard[0], inspectCard[1], name, positionX, positionY, width, height, '#D1D100');
console.log('inspect');
} }
} }
@ -999,20 +994,29 @@ canvas.addEventListener('click', function(event) {
// Can attack // Can attack
console.log(inEvent); console.log(inEvent);
console.log(cardStatus[itemKey] != 'tapped'); console.log(cardStatus[itemKey] != 'tapped');
if(!inEvent && cardStatus[itemKey] != 'tapped'){ // yourPlayerId in for now to prevent using opponents card
// however in future the cards may be used to attack, there will be another
// check like 'canUseOpponentsBoard' or something
if(!inEvent && cardStatus[itemKey] != 'tapped' && playerId == yourPlayerId){
board.startAttack(itemKey); board.startAttack(itemKey);
} }
// opponentBoard // opponentBoard
// If there's an attack event, target other cards // If there's an attack event, target other cards
if(inEvent && inEvent[0] == 'attack' && inEvent[1] != itemKey){ // Again yourPlayerId check for now, this time so your can't hit your own
if(inEvent && inEvent[0] == 'attack' && inEvent[1] != itemKey && playerId != yourPlayerId){
// Make attack on the card clicked, with card in inEvent[1] // Make attack on the card clicked, with card in inEvent[1]
board.makeAttack(itemKey); board.makeAttack(itemKey);
} }
// If no event, and clicked an OPPONENT CARD (for now) // If no event, and clicked an OPPONENT CARD (for now)
// Wants to be on option on r/l click maybe
// left click inspects then you choose play from there?
// inspect the card (zoom in on it) // inspect the card (zoom in on it)
if(!inEvent){ if(!inEvent && playerId != yourPlayerId){
board.inspectOpponentBoard(itemKey); board.inspectCard(itemKey);
}
else if(inEvent && inEvent[0] == 'inspect' && inEvent[1] == itemKey){
board.cancelInspect();
} }
board.drawBoard(); board.drawBoard();
@ -1289,6 +1293,17 @@ function calculateItemSizePosition(itemKey){
height = cHeight; height = cHeight;
} }
// Inspected Card
// May need to make a new itemKey for inspectedCard to loop through
if(inEvent && inEvent[0] == 'inspect' && inEvent[1] == itemKey){
positionX = canvas.width/2 - cardWidth;
positionY = canvas.height/2 - cardHeight;
width = cardWidth*2;
height = cardHeight*2;
}
//console.log('cardName: '+cardData[itemKey].name+', i/listPosition: '+i+', listPosition Length: '+itemListLength); //console.log('cardName: '+cardData[itemKey].name+', i/listPosition: '+i+', listPosition Length: '+itemListLength);
// Set the size/position of the item // Set the size/position of the item

Loading…
Cancel
Save