diff --git a/client/cryps.css b/client/cryps.css index 54d77bf4..ac43f5c6 100644 --- a/client/cryps.css +++ b/client/cryps.css @@ -160,7 +160,7 @@ svg { flex-flow: column; } -.cryps input { +.cryps input, .cryps select { border-color: #444; background-color: #333; border-radius: 0; @@ -286,6 +286,10 @@ header { margin-right: 0.5em; } +.create-form button { + display: block; +} + /* INSTANCE */ diff --git a/client/src/components/body.component.jsx b/client/src/components/body.component.jsx index 99092d42..78d9ea4a 100644 --- a/client/src/components/body.component.jsx +++ b/client/src/components/body.component.jsx @@ -15,6 +15,11 @@ const addState = connect( ws.clearGameStateTimeout(); } + if (!instance) { + ws.clearInstanceStateTimeout(); + } + + return { game, instance, account }; } ); diff --git a/client/src/components/menu.component.jsx b/client/src/components/menu.component.jsx index 6342909a..366978d7 100644 --- a/client/src/components/menu.component.jsx +++ b/client/src/components/menu.component.jsx @@ -7,6 +7,8 @@ const { stringSort } = require('./../utils'); const molecule = require('./molecule'); const SpawnButton = require('./spawn.button'); +const InstanceCreateForm = require('./instance.create.form'); + const idSort = stringSort('id'); const COLOURS = [ @@ -24,7 +26,6 @@ function Menu(args) { sendInstanceState, sendPlayerMmCrypsSet, sendInstanceJoin, - sendInstanceNew, sendCrypSpawn, instances, } = args; @@ -64,20 +65,12 @@ function Menu(args) { Set Matchmaking Team ); - const instanceJoin = ( - - ); return (
{instancePanels} {mmSet} - {instanceJoin} +
); } diff --git a/client/src/components/menu.container.jsx b/client/src/components/menu.container.jsx index 66430e00..59e5af5b 100644 --- a/client/src/components/menu.container.jsx +++ b/client/src/components/menu.container.jsx @@ -14,13 +14,6 @@ const addState = connect( return false; } - function sendInstanceNew() { - if (selectedCryps.length) { - return ws.sendInstanceNew(selectedCryps); - } - return false; - } - function sendPlayerMmCrypsSet() { if (selectedCryps.length) { return ws.sendPlayerMmCrypsSet(selectedCryps); @@ -41,7 +34,6 @@ const addState = connect( cryps, selectedCryps, sendInstanceJoin, - sendInstanceNew, sendInstanceState, sendCrypSpawn, sendPlayerMmCrypsSet, diff --git a/client/src/events.jsx b/client/src/events.jsx index 44cca1cd..719971e2 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -20,6 +20,9 @@ function registerEvents(store) { function setGame(game) { const { game: currentGame, ws } = store.getState(); + + if (!game) ws.clearGameStateTimeout(); + if (game && currentGame) { if (game.resolved.length !== currentGame.resolved.length) { // stop fetching the game state til animations are done diff --git a/client/src/socket.jsx b/client/src/socket.jsx index 5bc1645b..9cbc225c 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -148,8 +148,8 @@ function createSocket(events) { send({ method: 'instance_join', params: { instance_id: instanceId, cryp_ids: cryps } }); } - function sendInstanceNew(cryps) { - send({ method: 'instance_new', params: { cryp_ids: cryps, name: 'dota pros onli', players: 2 } }); + function sendInstanceNew(cryps, name, players) { + send({ method: 'instance_new', params: { cryp_ids: cryps, name, players } }); } function sendInstanceReady(instanceId) { @@ -323,6 +323,7 @@ function createSocket(events) { return { clearGameStateTimeout, + clearInstanceStateTimeout, sendAccountLogin, sendAccountCreate, sendAccountDemo, diff --git a/server/src/instance.rs b/server/src/instance.rs index 763cc1ef..f0e83098 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -537,9 +537,15 @@ pub fn instance_get_open(tx: &mut Transaction) -> Result { } pub fn instance_new(params: InstanceLobbyParams, tx: &mut Transaction, account: &Account) -> Result { - let mut instance = Instance::new() - .set_max_players(params.players)? - .set_name(params.name)?; + let mut instance = match params.players { + 1 => Instance::new() + .set_max_players(16)? + .set_name(params.name)? + .add_bots(), + _ => Instance::new() + .set_max_players(params.players)? + .set_name(params.name)?, + }; instance = instance_create(tx, instance)?; let join_params = InstanceJoinParams { instance_id: instance.id, cryp_ids: params.cryp_ids };