fix bot instance join

This commit is contained in:
ntr 2019-03-18 12:43:00 +11:00
parent 0d37444b73
commit 9b8dc12ddd
2 changed files with 10 additions and 9 deletions

View File

@ -55,6 +55,7 @@ impl Instance {
fn add_bots(mut self) -> Instance { fn add_bots(mut self) -> Instance {
self.pve = true; self.pve = true;
self.open = false;
self.players = iter::repeat_with(|| { self.players = iter::repeat_with(|| {
let bot_id = Uuid::new_v4(); let bot_id = Uuid::new_v4();
let cryps = instance_mobs(bot_id); let cryps = instance_mobs(bot_id);
@ -304,13 +305,13 @@ pub fn instance_create(tx: &mut Transaction, instance: Instance) -> Result<Insta
let instance_bytes = to_vec(&instance)?; let instance_bytes = to_vec(&instance)?;
let query = " let query = "
INSERT INTO instances (id, data) INSERT INTO instances (id, data, open)
VALUES ($1, $2) VALUES ($1, $2, $3)
RETURNING id; RETURNING id;
"; ";
let result = tx let result = tx
.query(query, &[&instance.id, &instance_bytes])?; .query(query, &[&instance.id, &instance_bytes, &instance.open])?;
result.iter().next().ok_or(format_err!("no instances written"))?; result.iter().next().ok_or(format_err!("no instances written"))?;

View File

@ -35,7 +35,7 @@ pub enum Var {
// specs // specs
Damage, Damage,
Hp, Hp,
Speed, SpeedI,
LifeI, LifeI,
LRSI, LRSI,
@ -118,7 +118,7 @@ impl Var {
Var::Damage => 3, Var::Damage => 3,
Var::Hp => 3, Var::Hp => 3,
Var::Speed => 3, Var::SpeedI => 3,
_ => { _ => {
let combos = get_combos(); let combos = get_combos();
@ -173,7 +173,7 @@ impl Var {
fn into_spec(&self) -> Option<Spec> { fn into_spec(&self) -> Option<Spec> {
match *self { match *self {
Var::Speed => Some(Spec::SpeedI), Var::SpeedI => Some(Spec::SpeedI),
Var::RedDamageI => Some(Spec::RedDamageI), Var::RedDamageI => Some(Spec::RedDamageI),
Var::BlueDamageI => Some(Spec::BlueDamageI), Var::BlueDamageI => Some(Spec::BlueDamageI),
@ -231,7 +231,7 @@ impl From<Skill> for Var {
impl From<Spec> for Var { impl From<Spec> for Var {
fn from(spec: Spec) -> Var { fn from(spec: Spec) -> Var {
match spec { match spec {
Spec::SpeedI => Var::Speed, Spec::SpeedI => Var::SpeedI,
Spec::RedDamageI => Var::RedDamageI, Spec::RedDamageI => Var::RedDamageI,
Spec::BlueDamageI => Var::BlueDamageI, Spec::BlueDamageI => Var::BlueDamageI,
@ -330,7 +330,7 @@ impl Vbox {
Var::Hp, Var::Hp,
Var::Green, Var::Green,
Var::Attack, Var::Attack,
Var::Speed, Var::SpeedI,
Var::Blue, Var::Blue,
Var::Attack, Var::Attack,
Var::Damage, Var::Damage,
@ -383,7 +383,7 @@ impl Vbox {
let specs = vec![ let specs = vec![
(Var::Damage, 1), (Var::Damage, 1),
(Var::Hp, 1), (Var::Hp, 1),
(Var::Speed, 1), (Var::SpeedI, 1),
]; ];
let mut rng = thread_rng(); let mut rng = thread_rng();