instance finish fix
This commit is contained in:
parent
ac29473471
commit
cd26efb42d
@ -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
|
||||
|
||||
@ -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)?,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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, Error> {
|
||||
instance_get(tx, params.instance_id)
|
||||
}
|
||||
|
||||
pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||
let mut player = player_get(tx, account.id, params.instance_id)?;
|
||||
|
||||
|
||||
@ -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<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||
let msg = from_slice::<InstanceReadyMsg>(&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<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||
let msg = from_slice::<PlayerStateMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||
@ -400,6 +413,7 @@ pub enum RpcResult {
|
||||
Account(Account),
|
||||
CrypList(Vec<Cryp>),
|
||||
GameState(Game),
|
||||
InstanceScore(Instance),
|
||||
// ZoneState(Zone),
|
||||
// ZoneClose(()),
|
||||
|
||||
|
||||
@ -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),
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user