From 9633e4f4c64d560335146b114703ba210f8629e9 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 17 Jul 2019 19:14:53 +1000 Subject: [PATCH] fix instance start --- WORKLOG.md | 15 +++------------ client/src/components/game.jsx | 1 + client/src/components/list.jsx | 2 +- server/src/instance.rs | 6 ++++-- server/src/rpc.rs | 4 +++- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/WORKLOG.md b/WORKLOG.md index d12a7d2b..00e78a3b 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -31,7 +31,6 @@ *$$$* * rename costs 1cr -* invader set * new construct costs 5cr @@ -89,21 +88,11 @@ do not allow vbox actions for finished instances ## LATER -* redis for game events - -* store instances / games in redis? - * not sure hwo to get sets of player games - * set joined_games_$account [game_id] - -* move player -> player - * chat -* notifications * elo + leaderboards * constants * change to ownership pattern - $$$ * Items * Colour scheme @@ -116,9 +105,11 @@ $$$ # Art Styles * illusions +* vaporwave +* sacred geometry +* skulls / day of the dead * Aztec * youkai -* Pixel * Industrial # notables diff --git a/client/src/components/game.jsx b/client/src/components/game.jsx index eddde654..9c00c291 100644 --- a/client/src/components/game.jsx +++ b/client/src/components/game.jsx @@ -65,6 +65,7 @@ function Game(props) { if (!game) return
...
; + console.log('running game'); const otherTeams = game.players.filter(t => t.id !== account.id); const playerTeam = game.players.find(t => t.id === account.id); diff --git a/client/src/components/list.jsx b/client/src/components/list.jsx index 5a5450a9..98f18453 100644 --- a/client/src/components/list.jsx +++ b/client/src/components/list.jsx @@ -129,7 +129,7 @@ function List(args) { .sort(idSort) .map(construct => { const constructName = constructRename === construct.id - ? + ? :

{construct.name}

; const confirm = constructRename === construct.id diff --git a/server/src/instance.rs b/server/src/instance.rs index 4d7a07dc..57440456 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -745,15 +745,17 @@ pub fn instance_join(tx: &mut Transaction, account: &Account, instance_id: Uuid, instance_update(tx, instance) } -pub fn instance_ready(tx: &mut Transaction, account: &Account, instance_id: Uuid) -> Result { +pub fn instance_ready(tx: &mut Transaction, account: &Account, instance_id: Uuid) -> Result { let mut instance = instance_get(tx, instance_id)?; let player_id = instance.account_player(account.id)?.id; if let Some(game) = instance.player_ready(player_id)? { game_write(tx, &game)?; + instance_update(tx, instance)?; + return Ok(RpcMessage::GameState(game)); } - instance_update(tx, instance) + Ok(RpcMessage::InstanceState(instance_update(tx, instance)?)) } pub fn instance_state(tx: &mut Transaction, _account: &Account, instance_id: Uuid) -> Result { diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 48e6f98b..897f459d 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -122,8 +122,10 @@ pub fn receive(data: Vec, db: &Db, _client: &mut Ws, begin: Instant, account Ok(RpcMessage::InstanceState(instance_new(&mut tx, account, construct_ids, name, pve, password)?)), RpcRequest::InstanceJoin { instance_id, construct_ids } => Ok(RpcMessage::InstanceState(instance_join(&mut tx, account, instance_id, construct_ids)?)), + + // these two can return GameState or InstanceState RpcRequest::InstanceReady { instance_id } => - Ok(RpcMessage::InstanceState(instance_ready(&mut tx, account, instance_id)?)), + Ok(instance_ready(&mut tx, account, instance_id)?), RpcRequest::InstanceState { instance_id } => Ok(instance_state(&mut tx, account, instance_id)?),