fix instance start

This commit is contained in:
ntr 2019-07-17 19:14:53 +10:00
parent 328bdf533a
commit 9633e4f4c6
5 changed files with 12 additions and 16 deletions

View File

@ -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

View File

@ -65,6 +65,7 @@ function Game(props) {
if (!game) return <div>...</div>;
console.log('running game');
const otherTeams = game.players.filter(t => t.id !== account.id);
const playerTeam = game.players.find(t => t.id === account.id);

View File

@ -129,7 +129,7 @@ function List(args) {
.sort(idSort)
.map(construct => {
const constructName = constructRename === construct.id
? <input id='renameInput' type="text" style="text-align: center" placeholder={construct.name}></input>
? <input id='renameInput' type="text" style="text-align: center" placeholder="enter a new name"></input>
: <h2>{construct.name}</h2>;
const confirm = constructRename === construct.id

View File

@ -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<Instance, Error> {
pub fn instance_ready(tx: &mut Transaction, account: &Account, instance_id: Uuid) -> Result<RpcMessage, Error> {
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<RpcMessage, Error> {

View File

@ -122,8 +122,10 @@ pub fn receive(data: Vec<u8>, 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)?),