spawning constructs (no mtx yet)
This commit is contained in:
parent
b72c819c63
commit
abd35b8bef
@ -64,7 +64,7 @@ function Team(args) {
|
|||||||
return setTeam(team);
|
return setTeam(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
const constructPanels = constructs.sort(idSort).map(construct => {
|
const constructPanels = constructs.map(construct => {
|
||||||
const colour = team.indexOf(construct.id);
|
const colour = team.indexOf(construct.id);
|
||||||
const selected = colour > -1;
|
const selected = colour > -1;
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,13 @@ function registerEvents(store) {
|
|||||||
setNav('list');
|
setNav('list');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setNewConstruct(construct) {
|
||||||
|
const { constructs } = store.getState();
|
||||||
|
constructs.push(construct);
|
||||||
|
store.dispatch(actions.setConstructs(constructs));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function setInstanceList(list) {
|
function setInstanceList(list) {
|
||||||
store.dispatch(actions.setInstanceList(list));
|
store.dispatch(actions.setInstanceList(list));
|
||||||
}
|
}
|
||||||
@ -226,6 +233,7 @@ function registerEvents(store) {
|
|||||||
setActiveItem,
|
setActiveItem,
|
||||||
setActiveSkill,
|
setActiveSkill,
|
||||||
setConstructList,
|
setConstructList,
|
||||||
|
setNewConstruct,
|
||||||
setGame,
|
setGame,
|
||||||
setInstance,
|
setInstance,
|
||||||
setInstanceList,
|
setInstanceList,
|
||||||
|
|||||||
@ -46,6 +46,10 @@ function createSocket(events) {
|
|||||||
send(['AccountInstances', {}]);
|
send(['AccountInstances', {}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendConstructSpawn() {
|
||||||
|
send(['MtxConstructBuy', {}]);
|
||||||
|
}
|
||||||
|
|
||||||
function sendGameState(id) {
|
function sendGameState(id) {
|
||||||
send(['GameState', { id }]);
|
send(['GameState', { id }]);
|
||||||
}
|
}
|
||||||
@ -150,6 +154,10 @@ function createSocket(events) {
|
|||||||
events.setConstructList(constructs);
|
events.setConstructList(constructs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onConstructSpawn(construct) {
|
||||||
|
events.setNewConstruct(construct);
|
||||||
|
}
|
||||||
|
|
||||||
function onGameState(game) {
|
function onGameState(game) {
|
||||||
events.setGame(game);
|
events.setGame(game);
|
||||||
}
|
}
|
||||||
@ -183,6 +191,7 @@ function createSocket(events) {
|
|||||||
AccountConstructs: onAccountConstructs,
|
AccountConstructs: onAccountConstructs,
|
||||||
AccountInstances: onAccountInstances,
|
AccountInstances: onAccountInstances,
|
||||||
AccountShop: onAccountShop,
|
AccountShop: onAccountShop,
|
||||||
|
ConstructSpawn: onConstructSpawn,
|
||||||
GameState: onGameState,
|
GameState: onGameState,
|
||||||
InstanceState: onInstanceState,
|
InstanceState: onInstanceState,
|
||||||
ItemInfo: onItemInfo,
|
ItemInfo: onItemInfo,
|
||||||
@ -272,6 +281,7 @@ function createSocket(events) {
|
|||||||
return {
|
return {
|
||||||
sendAccountConstructs,
|
sendAccountConstructs,
|
||||||
sendAccountInstances,
|
sendAccountInstances,
|
||||||
|
sendConstructSpawn,
|
||||||
sendGameState,
|
sendGameState,
|
||||||
sendGameReady,
|
sendGameReady,
|
||||||
sendGameSkill,
|
sendGameSkill,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use failure::Error;
|
|||||||
use failure::err_msg;
|
use failure::err_msg;
|
||||||
|
|
||||||
use pg::{Db};
|
use pg::{Db};
|
||||||
use construct::{Construct};
|
use construct::{Construct, construct_spawn};
|
||||||
use game::{Game, game_state, game_skill, game_ready};
|
use game::{Game, game_state, game_skill, game_ready};
|
||||||
use account::{Account, account_constructs, account_instances};
|
use account::{Account, account_constructs, account_instances};
|
||||||
use skill::{Skill, dev_resolve, Resolutions};
|
use skill::{Skill, dev_resolve, Resolutions};
|
||||||
@ -16,6 +16,9 @@ use instance::{Instance, instance_state, instance_list, instance_new, instance_r
|
|||||||
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
|
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip};
|
||||||
use item::{Item, ItemInfoCtr, item_info};
|
use item::{Item, ItemInfoCtr, item_info};
|
||||||
|
|
||||||
|
use names::{name as generate_name};
|
||||||
|
|
||||||
|
|
||||||
use mtx;
|
use mtx;
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
@ -27,6 +30,7 @@ pub enum RpcMessage {
|
|||||||
GameState(Game),
|
GameState(Game),
|
||||||
ItemInfo(ItemInfoCtr),
|
ItemInfo(ItemInfoCtr),
|
||||||
|
|
||||||
|
ConstructSpawn(Construct),
|
||||||
OpenInstances(Vec<Instance>),
|
OpenInstances(Vec<Instance>),
|
||||||
InstanceState(Instance),
|
InstanceState(Instance),
|
||||||
|
|
||||||
@ -44,6 +48,7 @@ enum RpcRequest {
|
|||||||
DevResolve { a: Uuid, b: Uuid, skill: Skill },
|
DevResolve { a: Uuid, b: Uuid, skill: Skill },
|
||||||
|
|
||||||
MtxConstructApply { mtx: mtx::MtxVariant, construct_id: Uuid, name: String },
|
MtxConstructApply { mtx: mtx::MtxVariant, construct_id: Uuid, name: String },
|
||||||
|
MtxConstructBuy { },
|
||||||
MtxAccountApply { mtx: mtx::MtxVariant },
|
MtxAccountApply { mtx: mtx::MtxVariant },
|
||||||
MtxBuy { mtx: mtx::MtxVariant },
|
MtxBuy { mtx: mtx::MtxVariant },
|
||||||
|
|
||||||
@ -148,6 +153,8 @@ pub fn receive(data: Vec<u8>, db: &Db, begin: Instant, account: &Option<Account>
|
|||||||
RpcRequest::VboxUnequip { instance_id, construct_id, target } =>
|
RpcRequest::VboxUnequip { instance_id, construct_id, target } =>
|
||||||
Ok(RpcMessage::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target)?)),
|
Ok(RpcMessage::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target)?)),
|
||||||
|
|
||||||
|
RpcRequest::MtxConstructBuy { } =>
|
||||||
|
Ok(RpcMessage::ConstructSpawn(construct_spawn(&mut tx, account.id, generate_name())?)),
|
||||||
|
|
||||||
RpcRequest::MtxConstructApply { mtx, construct_id, name } =>
|
RpcRequest::MtxConstructApply { mtx, construct_id, name } =>
|
||||||
Ok(RpcMessage::AccountConstructs(mtx::apply(&mut tx, account, mtx, construct_id, name)?)),
|
Ok(RpcMessage::AccountConstructs(mtx::apply(&mut tx, account, mtx, construct_id, name)?)),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user