Add 'components' mod + add empty comps. to roomGen

Create a components module to be used as the overseeing list/build
of components to be used through-out the code-base.

Added the components in said module to roomGeneration, but they
are not used at current
develop^2
Nathan Steel 1 year ago
parent c04b7f0b6c
commit 06b3fe6da0

@ -0,0 +1,95 @@
// A seperate list for components, so they're easy to recall
// Done as object, so it can be added to different rooms with components = NEW component?
const component = {
// Entity Stuff
//item : [],
//itemCount : 0,
// Card Stuff
cardData : {},
cardFace : {},
cardStatus : {
tapped : {},
attacking : {},
inspected : {},
},
cardAttack : {},
cardColours : {}, // Replace with colour
colour : {
white : {}, // entityId, amountOfColour
blue : {},
red : {},
},
cardManaColour : {},
cardEffect : {}, // TODO: Split this into effect, trigger, step, targets.
cardCost : {},
cardSprite : {}, // id, position in spritesheet [0,4] e.g.
//cardPlayer = {},
// Deck Stuff?
deckIn : {},
deckData : {},
// UI (so users know what's been targetted)
selected : {},
selectable : {},
// Effect (break it up?)
effect : {},
effectTrigger : {},
// etc, etc.
// Board Elements
// loop component.shield for shield items
boardElement : {},
// Replace with following
realDeck : {},
inDeck : {},
hand : {},
board : {},
shield : {},
mana : {},
grave : {},
void : {},
//
listPosition : {},
// position (clientside)
// size (clientside)
// Passives
// component.passive.flight ?
passive : {
flight : {},
reach : {},
taunt : {},
},
type : {
unit : {},
spell : {},
token : {},
},
classes : {
orc : {},
human : {},
spirit : {},
},
};
// For front-end
// position, size
// These should be used as such (Not 100% as yet)
// For onBoard()... for player()... for passive.flight()...
// Check the board, items belonging to playerX, for flight passive?
module.exports = {
component
}

@ -1,41 +1,32 @@
// Build a room, fill will players, etc.
const cardGen = require('./cardGen');
const components = require('./components');
// Room should, setPlayers, add them to correct team (TODO), build their decks, and first shuffle
function startItemCount(){
let item = [];
let itemCount = 0;
returns = {'item': item, 'itemCount': itemCount};
return(returns);
}
function setPlayers(playerCount = 2, itemData){
// Add new item attribute for 'players'
// TODO: Maybe check if exists, and add to in that case (for replacing people?)
// Doubt that would ever make it into the game, but could still be worth
itemData.player = {}; //let player = {}; // Player item belongs to
itemData.players = []; // List of the players (an associated playerItem?)
//itemData.
// Can be done with just referring to itemData[x], but less readable
// Will likely redefine vars each new function. For now will keep this as-is
let playerNo = 0 + itemData['itemCount']; // Start loop from current itemCount
playerCount = playerCount + itemData['itemCount']; // End at playerCount diff from itemCount
for(playerNo; playerNo < playerCount; playerNo++){
// REMOVED PLAYERS AS ITEM, BECAUSE THEY WERE BORKING
// TODO: Add back at some point, or don't bother
//itemData['item'].push(playerNo);
//itemData['player'][itemData['itemCount']] = playerNo; // The player belongs to itself
//itemData['itemCount']++;
itemData['players'].push(playerNo); // Add player no to array so can be looped
}
// Return related item and item attributes
//returns = {'item': item, 'itemCount': itemCount, 'player': player};
return itemData;
//return([item, itemCount, player]);
}
// For future, when 2v2s, and 5v1 Raids, etc.
@ -48,10 +39,13 @@ function roomGeneration(playerCount, teamCount = null, playerTeams = null){
(async () => {
let itemData = startItemCount();
// Create 2 players for the room
itemData = setPlayers(2, itemData);
// Add players for the room
itemData = setPlayers(playerCount, itemData);
// TODO: Get their selected decks (will need to pass somewhere)
// Add all the empty components to the room itemData
itemData.component = components.component;
// Generate the decks, and card within the deck cardLists
[itemData] = await Promise.all([ cardGen.requestDeck(itemData) ]);

Loading…
Cancel
Save