instance form and pve

This commit is contained in:
ntr 2019-04-25 22:21:13 +10:00
parent b5b2e95f34
commit 621676732d
7 changed files with 28 additions and 24 deletions

View File

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

View File

@ -15,6 +15,11 @@ const addState = connect(
ws.clearGameStateTimeout();
}
if (!instance) {
ws.clearInstanceStateTimeout();
}
return { game, instance, account };
}
);

View File

@ -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
</button>
);
const instanceJoin = (
<button
className={`menu-instance-btn right ${instanceJoinHidden ? 'hidden' : ''}`}
disabled={instanceJoinHidden}
onClick={() => sendInstanceNew()}>
Create New Instance
</button>
);
return (
<section className="menu-instance-list" >
{instancePanels}
{mmSet}
{instanceJoin}
<InstanceCreateForm />
</section>
);
}

View File

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

View File

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

View File

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

View File

@ -537,9 +537,15 @@ pub fn instance_get_open(tx: &mut Transaction) -> Result<Instance, Error> {
}
pub fn instance_new(params: InstanceLobbyParams, tx: &mut Transaction, account: &Account) -> Result<Instance, Error> {
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 };