Add player/opponent Id to data and client UI
parent
08df4d4552
commit
993f68636b
@ -1,21 +0,0 @@
|
||||
// 0,1,2 = white,blue,red (for now)
|
||||
// TODO: Use a DB in future, this is just for testing
|
||||
let cardArray =
|
||||
[
|
||||
{ id: 1, name: 'Red1', colour: 2, cost: 1, type: 'Goblin', atk: 500, rarity: 'common', effect:'[[Sneak]] 500'},
|
||||
{ id: 2, name: 'Red2', colour: 2, cost: 1, type: 'Goblin', atk: 1500, rarity: 'common', effect:'Cannot attack direct'},
|
||||
{ id: 3, name: 'Red3', colour: 2, cost: 2, type: 'Goblin', atk: 1000, rarity: 'common', effect:'[[DEATH]] deal 1500 extra to killer'},
|
||||
{ id: 4, name: 'Red4', colour: 2, cost: 2, type: 'Goblin', atk: 2000, rarity: 'common', effect:null},
|
||||
{ id: 5, name: 'White1', colour: 0, cost: 1, type: 'Weapon', atk: 500, rarity: 'common', effect:'[[Equip]]'},
|
||||
{ id: 6, name: 'White2', colour: 0, cost: 2, type: 'Human', atk: 1500, rarity: 'common', effect:null},
|
||||
{ id: 7, name: 'White3', colour: 0, cost: 2, type: 'Human', atk: 2000, rarity: 'common', effect:'[[TAUNT]]'},
|
||||
{ id: 8, name: 'White5', colour: 0, cost: 2, type: 'Human', atk: 1500, rarity: 'common', effect:'[[REACH]]'},
|
||||
{ id: 9, name: 'Blue1', colour: 1, cost: 2, type: 'Spirit', atk: 1000, rarity: 'common', effect:null},
|
||||
{ id: 10, name: 'Blue3', colour: 1, cost: 2, type: 'Spirit', atk: 1000, rarity: 'common', effect:'[[DRAW]] 1'},
|
||||
{ id: 11, name: 'Blue4', colour: 1, cost: 2, type: 'Spirit', atk: 1500, rarity: 'common', effect:null},
|
||||
{ id: 12, name: 'Blue5', colour: 1, cost: 3, type: 'Spirit', atk: 2500, rarity: 'common', effect:'[[FLIGHT]]'}
|
||||
]
|
||||
|
||||
let deckListPlayer = [5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10];
|
||||
let deckListOpponent = [1,1,1,1,2,2,3,3,4,4,7,7,7,7,5,5,5,3,3,8,8];
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
// Should mostly match server's components.js
|
||||
// Misc. game data required
|
||||
let gameData = {
|
||||
playerId : null,
|
||||
opponentId : null,
|
||||
roomId : null,
|
||||
turn : 0,
|
||||
playerTurn : 0,
|
||||
players : null,
|
||||
|
||||
// Real components from here?
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
// To set the server data to related client data
|
||||
|
||||
// Update all the relevent game data from the server's data response
|
||||
function updateGameData(data){
|
||||
console.log(data);
|
||||
|
||||
updatePlayers(data.players);
|
||||
updatePlayerId(data.playerId);
|
||||
updateOpponentId(data.opponentId);
|
||||
updateRoomId(data.roomId);
|
||||
updateTurn(data.component.turn, data.component.playerTurn);
|
||||
|
||||
console.log(gameData);
|
||||
}
|
||||
|
||||
// Individual or minor updates
|
||||
// This will ideally be how each game function updates the data
|
||||
// e.g. drawACard() would update the hand, deck, cardData, effects?
|
||||
function updatePlayers(players = null){
|
||||
gameData.players = players;
|
||||
}
|
||||
function updatePlayerId(playerId = null){
|
||||
gameData.playerId = playerId;
|
||||
}
|
||||
function updateOpponentId(opponentId = null){
|
||||
gameData.opponentId = opponentId;
|
||||
}
|
||||
function updateRoomId(roomId = null){
|
||||
gameData.roomId = roomId;
|
||||
}
|
||||
function updateTurn(turn = null, playersTurn = null){
|
||||
gameData.turn = turn;
|
||||
gameData.playerTurn = playersTurn;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue