From cd26efb42d21fd2baa8f919c197d615e39c9734a Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 19 Mar 2019 16:49:23 +1100 Subject: [PATCH] instance finish fix --- server/WORKLOG.md | 6 ++++++ server/src/game.rs | 4 ++-- server/src/instance.rs | 14 ++++++++++++++ server/src/rpc.rs | 16 +++++++++++++++- server/src/spec.rs | 16 ++++++++++------ 5 files changed, 47 insertions(+), 9 deletions(-) diff --git a/server/WORKLOG.md b/server/WORKLOG.md index 2fde6f31..4b042252 100644 --- a/server/WORKLOG.md +++ b/server/WORKLOG.md @@ -6,6 +6,12 @@ * red_shield is restored, not gained * players can feel aggressive +- build archtypes + fast blue + slow blue + red + aggro green + blue + defensive green + # WORK WORK ## NOW diff --git a/server/src/game.rs b/server/src/game.rs index aca69a74..e4e14b8f 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -754,8 +754,8 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> { if game.finished() { if let Some(i) = game.instance { match i == Uuid::nil() { - true => instance_game_finished(tx, &game, i)?, - false => global_game_finished(tx, &game)?, + true => global_game_finished(tx, &game)?, + false => instance_game_finished(tx, &game, i)?, } } } diff --git a/server/src/instance.rs b/server/src/instance.rs index 8a757cdf..da21c6f3 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -194,6 +194,16 @@ impl Instance { fn bot_vbox_phase(&mut self) -> &mut Instance { for bot in self.players.iter_mut().filter(|p| p.bot) { bot.vbox.fill(); + + // paths for what to do + // use a spec + // craft a spec + // craft a skill + // check for cryps w/ no skills + // create a skill() + // find base + // pick 2 random colours + bot.set_ready(true); } @@ -435,6 +445,10 @@ pub fn instance_ready_global(tx: &mut Transaction, _account: &Account, player: P Ok(game) } +pub fn instance_score(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result { + instance_get(tx, params.instance_id) +} + pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result { let mut player = player_get(tx, account.id, params.instance_id)?; diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 227807fe..9a5ab257 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -22,7 +22,7 @@ use skill::{Skill}; // use zone::{Zone, zone_create, zone_join, zone_close}; use spec::{Spec}; use player::{player_state, player_cryps_set, Player}; -use instance::{instance_join, instance_ready}; +use instance::{Instance, instance_join, instance_ready, instance_score}; use vbox::{Var, vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip}; pub struct Rpc; @@ -79,6 +79,7 @@ impl Rpc { "instance_join" => Rpc::instance_join(data, &mut tx, account.unwrap(), client), "instance_ready" => Rpc::instance_ready(data, &mut tx, account.unwrap(), client), + "instance_score" => Rpc::instance_score(data, &mut tx, account.unwrap(), client), "player_state" => Rpc::player_state(data, &mut tx, account.unwrap(), client), "player_cryps_set" => Rpc::player_cryps_set(data, &mut tx, account.unwrap(), client), @@ -282,6 +283,18 @@ impl Rpc { return Ok(response); } + fn instance_score(data: Vec, tx: &mut Transaction, account: Account, _client: &mut WebSocket) -> Result { + let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; + + let response = RpcResponse { + method: "instance_score".to_string(), + params: RpcResult::InstanceScore(instance_score(msg.params, tx, &account)?) + }; + + return Ok(response); + } + + fn player_state(data: Vec, tx: &mut Transaction, account: Account, _client: &mut WebSocket) -> Result { let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; @@ -400,6 +413,7 @@ pub enum RpcResult { Account(Account), CrypList(Vec), GameState(Game), + InstanceScore(Instance), // ZoneState(Zone), // ZoneClose(()), diff --git a/server/src/spec.rs b/server/src/spec.rs index c0960df4..e0e5f0a2 100644 --- a/server/src/spec.rs +++ b/server/src/spec.rs @@ -56,11 +56,12 @@ impl Spec { let i_max = 64; match *self { - Spec::RedDamageI => modified + match team_colours.red { - 0...5 => base.pct(5), - 6...10 => base.pct(10), - 11...15 => base.pct(15), - _ => base.pct(20) + Spec::RedDamageI => modified + { + let mut pct = 5; + if team_colours.red >= 5 { pct += 5 }; + if team_colours.red >= 10 { pct += 10 }; + if team_colours.red >= 20 { pct += 20 }; + base.pct(pct) }, Spec::GreenDamageI => modified + match team_colours.green { 0...5 => base.pct(5), @@ -80,7 +81,10 @@ impl Spec { Spec::LifeI => modified + base.pct(5), Spec::RedShieldI => modified + rng.gen_range(i_min, i_max), Spec::BlueShieldI => modified + rng.gen_range(i_min, i_max), - Spec::LRSI => modified + base.pct(5), + Spec::LRSI => modified + { + if team_colours.red > 5 && team_colours.green > 5 { base.pct(10) } + else { base.pct(5) } + }, Spec::LBSI => modified + base.pct(5), Spec::RBSI => modified + base.pct(5), }