|
|
|
@ -158,6 +158,7 @@ class Board{
|
|
|
|
let colourId = cardData[itemKey].colour;
|
|
|
|
let colourId = cardData[itemKey].colour;
|
|
|
|
if(colourId == 0){ fill = '#EEE'; }
|
|
|
|
if(colourId == 0){ fill = '#EEE'; }
|
|
|
|
else if(colourId == 1){ fill = '#0033EE'; }
|
|
|
|
else if(colourId == 1){ fill = '#0033EE'; }
|
|
|
|
|
|
|
|
else if(colourId == 2){ fill = '#ED344A'; }
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
fill = '#B0B0B0';
|
|
|
|
fill = '#B0B0B0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -541,7 +542,7 @@ class Board{
|
|
|
|
alert('Hand full '+elementLength+'/'+maxHandSize);
|
|
|
|
alert('Hand full '+elementLength+'/'+maxHandSize);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.addFromBoardElement(playerId, 0, 'deck', 'hand', null, null);
|
|
|
|
this.addFromBoardElement(playerId, 1, 'deck', 'hand', null, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -841,12 +842,12 @@ let board = new Board;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: TEMP!! Replace soon
|
|
|
|
// TODO: TEMP!! Replace soon
|
|
|
|
createDeck();
|
|
|
|
createDeck();
|
|
|
|
createDeckList(playerDeck, deckCount, 0);
|
|
|
|
//createDeckList(playerDeck, deckCount, 0);
|
|
|
|
createDeckList(opponentDeck, deckCountOpponent, 1);
|
|
|
|
//createDeckList(opponentDeck, deckCountOpponent, 1);
|
|
|
|
|
|
|
|
|
|
|
|
// Play 4 shield from top (0) of each players deck
|
|
|
|
// Play 4 shield from top (0) of each players deck
|
|
|
|
for(let currentPlayer = 0; currentPlayer <= players-1; currentPlayer++){
|
|
|
|
for(let currentPlayer = 0; currentPlayer <= players-1; currentPlayer++){
|
|
|
|
board.playShield(0, 'deck', currentPlayer, 4);
|
|
|
|
board.playShield(1, 'deck', currentPlayer, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
board.drawBoard(true);
|
|
|
|
board.drawBoard(true);
|
|
|
|
@ -1047,43 +1048,40 @@ function createDeck(){
|
|
|
|
itemCount++;
|
|
|
|
itemCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log(item.length); // createDeckList will need to continue from here, not 0
|
|
|
|
// Loop again and create the deckLists
|
|
|
|
}
|
|
|
|
for(let i = 0; i < players; i++){
|
|
|
|
// TEMP: Create a deck of X different cards that can be drawn/played
|
|
|
|
createDeckList(i);
|
|
|
|
// for UI development, will be done on server and not shown to clients
|
|
|
|
}
|
|
|
|
// TODO: Randomly create a deck from objects stored in file (for now) then DB
|
|
|
|
|
|
|
|
// 3 of each card max, and likely one colour too for time being
|
|
|
|
|
|
|
|
function createDeckList(deck, deckCount, playerId){
|
|
|
|
|
|
|
|
let i = item.length; // Continue from the last item, don't overwrite
|
|
|
|
|
|
|
|
deckCount = deckCount + i;
|
|
|
|
|
|
|
|
for(i; i < deckCount; i++){
|
|
|
|
|
|
|
|
// Randomise colour
|
|
|
|
|
|
|
|
let colour = Math.floor(Math.random() * 2);
|
|
|
|
|
|
|
|
let effect = Math.floor(Math.random() * 5);
|
|
|
|
|
|
|
|
if(effect == 0){ effect = 'effect here'; } else{ effect = null }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: USE DATABASE FOR THIS!!!
|
|
|
|
|
|
|
|
function createDeckList(playerId){
|
|
|
|
|
|
|
|
// TODO:Create the deckList by loading the deckDB
|
|
|
|
|
|
|
|
// For now pulling from a deckList array that uses a cardArray
|
|
|
|
|
|
|
|
let deckList = null;
|
|
|
|
|
|
|
|
if(playerId == 0){ deckList = deckListPlayer; }
|
|
|
|
|
|
|
|
if(playerId == 1){ deckList = deckListOpponent; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(let deckItem = 0; deckItem < deckList.length; deckItem++){
|
|
|
|
|
|
|
|
// Create new item for ECS
|
|
|
|
item.push(itemCount);
|
|
|
|
item.push(itemCount);
|
|
|
|
|
|
|
|
// Set card data for new item
|
|
|
|
|
|
|
|
// Use the ID from the deckList of player, and return the card of that ID from cardList/DB
|
|
|
|
|
|
|
|
cardData[itemCount] = cardArray[deckList[deckItem]];
|
|
|
|
|
|
|
|
// Set to base position of 'deck'
|
|
|
|
boardElement[itemCount] = 'deck';
|
|
|
|
boardElement[itemCount] = 'deck';
|
|
|
|
cardData[itemCount] = {
|
|
|
|
// Set Attack, ManaCost, ManaColours TODO: When these are implemented seperately
|
|
|
|
'name':'CardName '+(i+1)
|
|
|
|
|
|
|
|
, 'cost':1
|
|
|
|
// Set the player
|
|
|
|
, 'atk':1
|
|
|
|
|
|
|
|
, 'def':1
|
|
|
|
|
|
|
|
, 'rarity': 'common'
|
|
|
|
|
|
|
|
, 'effect':effect
|
|
|
|
|
|
|
|
, 'type':'human'
|
|
|
|
|
|
|
|
, 'colour':colour
|
|
|
|
|
|
|
|
, 'tapped':false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
player[itemCount] = playerId;
|
|
|
|
player[itemCount] = playerId;
|
|
|
|
listPosition[itemCount] = i;
|
|
|
|
// Set the position in the deck (as was added), will be shuffled on game start
|
|
|
|
// Previous iteration, kept to prevent errors for now
|
|
|
|
listPosition[itemCount] = deckItem+1;
|
|
|
|
deck.push(cardData[itemCount]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Increment the itemCount to prevent overwriting stuff
|
|
|
|
itemCount++;
|
|
|
|
itemCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let cardsInDeck = board.ECSLoop(null, playerId);
|
|
|
|
|
|
|
|
|
|
|
|
// Shuffle the deck straight away after generating/loading it in
|
|
|
|
|
|
|
|
shuffleDeck(playerId);
|
|
|
|
shuffleDeck(playerId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1102,7 +1100,6 @@ function shuffleDeck(playerId){
|
|
|
|
[ tempDeck[i], tempDeck[shuffle] ] = [ tempDeck[shuffle], tempDeck[i] ];
|
|
|
|
[ tempDeck[i], tempDeck[shuffle] ] = [ tempDeck[shuffle], tempDeck[i] ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log(getCurrentPositionAndLength('deck', playerId)[1]);
|
|
|
|
|
|
|
|
// For each item in the actual deck, set the listPosition to the random number from tempDeck
|
|
|
|
// For each item in the actual deck, set the listPosition to the random number from tempDeck
|
|
|
|
let items = board.ECSLoop('deck', playerId, null, null);
|
|
|
|
let items = board.ECSLoop('deck', playerId, null, null);
|
|
|
|
for(let item = 0; item < items.length; item++){
|
|
|
|
for(let item = 0; item < items.length; item++){
|
|
|
|
@ -1114,7 +1111,6 @@ function shuffleDeck(playerId){
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('NEW LIST POSITION: '+listPosition[itemKey]);
|
|
|
|
//console.log('NEW LIST POSITION: '+listPosition[itemKey]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(getCurrentPositionAndLength('deck', playerId)[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1312,4 +1308,19 @@ function printECSData(items){
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function echoCards(){
|
|
|
|
|
|
|
|
console.log(cardArray);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function echoCardsInDeck(playerId){
|
|
|
|
|
|
|
|
// Get all the cards that belong to player
|
|
|
|
|
|
|
|
let cardsInDeck = board.ECSLoop(null, playerId);
|
|
|
|
|
|
|
|
let deckList = [];
|
|
|
|
|
|
|
|
for(let i = 0; i < cardsInDeck.length; i++){
|
|
|
|
|
|
|
|
// If it's a card TODO: Change this to check 'card' from some ECS element
|
|
|
|
|
|
|
|
if(cardData[i] !== null && cardData[i] !== undefined){
|
|
|
|
|
|
|
|
deckList.push(cardData[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(deckList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|