various instance fixs
This commit is contained in:
parent
f4e1c368e0
commit
228d64d73d
@ -141,7 +141,7 @@ function createSocket(events) {
|
||||
}
|
||||
|
||||
function sendInstanceJoin(cryps) {
|
||||
send({ method: 'instance_join', params: { cryp_ids: cryps, pve: false } });
|
||||
send({ method: 'instance_join', params: { cryp_ids: cryps, pve: true } });
|
||||
}
|
||||
|
||||
function sendInstanceReady(instanceId) {
|
||||
@ -255,7 +255,7 @@ function createSocket(events) {
|
||||
|
||||
if (!account) events.loginPrompt();
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
|
||||
send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -85,9 +85,9 @@ impl Instance {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
fn player_ready(mut self, mut player: Player) -> Result<Instance, Error> {
|
||||
fn player_ready(&mut self, mut player: Player) -> Result<&mut Instance, Error> {
|
||||
if self.phase != InstancePhase::Vbox {
|
||||
panic!("instance not in vbox phase");
|
||||
return Err(err_msg("instance not in vbox phase"));
|
||||
}
|
||||
|
||||
let i = self.players
|
||||
@ -113,7 +113,8 @@ impl Instance {
|
||||
game
|
||||
.set_pve(true)
|
||||
.set_team_num(2)
|
||||
.set_team_size(3);
|
||||
.set_team_size(3)
|
||||
.set_instance(self.id);
|
||||
|
||||
// add the players
|
||||
let mut plr_team = Team::new(plr.account);
|
||||
@ -141,13 +142,13 @@ impl Instance {
|
||||
|
||||
fn start(&mut self) -> &mut Instance {
|
||||
// self.players.sort_unstable_by_key(|p| p.id);
|
||||
self.generate_rounds();
|
||||
self.open = false;
|
||||
self.vbox_phase_start()
|
||||
}
|
||||
|
||||
fn vbox_phase_start(&mut self) -> &mut Instance {
|
||||
self.phase = InstancePhase::Vbox;
|
||||
self.generate_rounds();
|
||||
self.bot_vbox_phase();
|
||||
|
||||
self
|
||||
@ -405,11 +406,20 @@ pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account:
|
||||
pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||
let player = player_get(tx, account.id, params.instance_id)?;
|
||||
|
||||
let instance = instance_get(tx, params.instance_id)?
|
||||
.player_ready(player.clone())?;
|
||||
|
||||
let mut instance = instance_get(tx, params.instance_id)?;
|
||||
let game_id = instance.current_round(&player).game_id;
|
||||
|
||||
// attempting to re-ready
|
||||
// send game state
|
||||
match instance.player_ready(player.clone()) {
|
||||
Ok(_) => (),
|
||||
Err(_) => return game_get(tx, game_id),
|
||||
};
|
||||
|
||||
if instance.vbox_phase_finished() {
|
||||
instance.games_phase_start();
|
||||
}
|
||||
|
||||
let game = match instance.pve {
|
||||
true => match game_get(tx, game_id) {
|
||||
Ok(g) => g,
|
||||
@ -490,7 +500,7 @@ mod tests {
|
||||
assert_eq!(instance.rounds[0].len(), 8);
|
||||
|
||||
let player = instance.players.clone().into_iter().find(|p| p.account == player_id).unwrap();
|
||||
let mut instance = instance.player_ready(player).unwrap();
|
||||
instance.player_ready(player).unwrap();
|
||||
|
||||
assert!(instance.vbox_phase_finished());
|
||||
instance.games_phase_start();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user