fix awful mm bug with bots
This commit is contained in:
parent
14c779f484
commit
72f6e81d25
@ -257,9 +257,8 @@ class ItemList extends Phaser.Scene {
|
|||||||
} return false;
|
} return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.add.text(ITEM_WIDTH * 11, ITEM_HEIGHT * 1.1, `Scoreboard`, TEXT.HEADER);
|
this.add.text(ITEM_WIDTH * 11, ITEM_HEIGHT * 1.1, 'Scoreboard', TEXT.HEADER);
|
||||||
scores.forEach(([name, score], i) => {
|
scores.forEach(([name, score], i) => {
|
||||||
console.log(name);
|
|
||||||
const SCORE_X = ITEM_WIDTH * 11;
|
const SCORE_X = ITEM_WIDTH * 11;
|
||||||
const SCORE_Y = ITEM_HEIGHT * 1.1 * (i + 2);
|
const SCORE_Y = ITEM_HEIGHT * 1.1 * (i + 2);
|
||||||
this.add.text(SCORE_X, SCORE_Y, `${score.wins} - ${score.losses} | ${name}`, TEXT.NORMAL);
|
this.add.text(SCORE_X, SCORE_Y, `${score.wins} - ${score.losses} | ${name}`, TEXT.NORMAL);
|
||||||
|
|||||||
@ -16,10 +16,14 @@
|
|||||||
# WORK WORK
|
# WORK WORK
|
||||||
## NOW
|
## NOW
|
||||||
cryp vbox
|
cryp vbox
|
||||||
|
ensure all skills impl
|
||||||
constants
|
constants
|
||||||
change to ownership pattern
|
change to ownership pattern
|
||||||
|
|
||||||
## SOON
|
## SOON
|
||||||
|
* vbox drops chances
|
||||||
|
* 50% spec, 25% colour etc
|
||||||
|
* confirm cryp without skill ready
|
||||||
* iconography
|
* iconography
|
||||||
* aoe skills
|
* aoe skills
|
||||||
* combo skills
|
* combo skills
|
||||||
|
|||||||
@ -708,9 +708,9 @@ mod tests {
|
|||||||
|
|
||||||
cryp.apply_modifiers(&team_colours);
|
cryp.apply_modifiers(&team_colours);
|
||||||
|
|
||||||
assert_eq!(cryp.red_damage.value, cryp.red_damage.base + cryp.red_damage.base.pct(5));
|
assert!(cryp.red_damage.value == cryp.red_damage.base + cryp.red_damage.base.pct(10));
|
||||||
assert_eq!(cryp.green_damage.value, cryp.green_damage.base + cryp.green_damage.base.pct(15));
|
assert!(cryp.green_damage.value == cryp.green_damage.base + cryp.green_damage.base.pct(20));
|
||||||
assert_eq!(cryp.blue_damage.value, cryp.blue_damage.base + cryp.blue_damage.base.pct(20));
|
assert!(cryp.blue_damage.value == cryp.blue_damage.base + cryp.blue_damage.base.pct(65));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,14 +100,19 @@ impl Instance {
|
|||||||
|
|
||||||
self.players[i] = player.clone();
|
self.players[i] = player.clone();
|
||||||
|
|
||||||
|
if self.vbox_phase_finished() {
|
||||||
|
self.games_phase_start();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bot_vs_player_game(&self, player: &Player) -> Result<Game, Error> {
|
fn bot_vs_player_game(&self, player: &Player) -> Result<Game, Error> {
|
||||||
let current_round = self.current_round(player);
|
let current_round = self.current_round(player);
|
||||||
|
let bot_id = current_round.player_ids.iter().find(|id| **id != player.id).unwrap();
|
||||||
|
|
||||||
let plr = self.players.clone().into_iter().find(|p| p.id == player.id).unwrap();
|
let plr = self.players.clone().into_iter().find(|p| p.id == player.id).unwrap();
|
||||||
let bot = self.players.clone().into_iter().find(|p| p.id != player.id).unwrap();
|
let bot = self.players.clone().into_iter().find(|p| p.id == *bot_id).unwrap();
|
||||||
|
|
||||||
let mut game = Game::new();
|
let mut game = Game::new();
|
||||||
game.id = current_round.game_id;
|
game.id = current_round.game_id;
|
||||||
@ -217,6 +222,8 @@ impl Instance {
|
|||||||
|
|
||||||
if self.pve {
|
if self.pve {
|
||||||
let r = self.rounds.len() - 1;
|
let r = self.rounds.len() - 1;
|
||||||
|
// println!("round num {:?}", r);
|
||||||
|
// println!("{:?}", self.rounds[r]);
|
||||||
for mut round in self.rounds[r].iter_mut() {
|
for mut round in self.rounds[r].iter_mut() {
|
||||||
if self.players
|
if self.players
|
||||||
.iter()
|
.iter()
|
||||||
@ -226,17 +233,19 @@ impl Instance {
|
|||||||
let a = self.players.clone().into_iter().find(|p| p.id == round.player_ids[0]).unwrap();
|
let a = self.players.clone().into_iter().find(|p| p.id == round.player_ids[0]).unwrap();
|
||||||
let b = self.players.clone().into_iter().find(|p| p.id == round.player_ids[1]).unwrap();
|
let b = self.players.clone().into_iter().find(|p| p.id == round.player_ids[1]).unwrap();
|
||||||
|
|
||||||
|
// println!("{:?} vs {:?}", a.name, b.name);
|
||||||
|
|
||||||
let mut game = Game::new();
|
let mut game = Game::new();
|
||||||
game
|
game
|
||||||
.set_team_num(2)
|
.set_team_num(2)
|
||||||
.set_team_size(3);
|
.set_team_size(3);
|
||||||
|
|
||||||
// add the players
|
// add the players
|
||||||
let mut a_team = Team::new(a.id);
|
let mut a_team = Team::new(a.account);
|
||||||
a_team.set_cryps(a.cryps);
|
a_team.set_cryps(a.cryps);
|
||||||
a_team.set_bot();
|
a_team.set_bot();
|
||||||
|
|
||||||
let mut b_team = Team::new(b.id);
|
let mut b_team = Team::new(b.account);
|
||||||
b_team.set_cryps(b.cryps);
|
b_team.set_cryps(b.cryps);
|
||||||
b_team.set_bot();
|
b_team.set_bot();
|
||||||
|
|
||||||
@ -252,7 +261,7 @@ impl Instance {
|
|||||||
round.finished = true;
|
round.finished = true;
|
||||||
|
|
||||||
for team in game.teams.iter() {
|
for team in game.teams.iter() {
|
||||||
let mut player = self.players.iter_mut().find(|p| p.id == team.id).unwrap();
|
let mut player = self.players.iter_mut().find(|p| p.account == team.id).unwrap();
|
||||||
match team.id == winner.id {
|
match team.id == winner.id {
|
||||||
true => player.add_win(),
|
true => player.add_win(),
|
||||||
false => player.add_loss(),
|
false => player.add_loss(),
|
||||||
@ -281,7 +290,6 @@ impl Instance {
|
|||||||
// only set up for even player numbers atm
|
// only set up for even player numbers atm
|
||||||
// no byes
|
// no byes
|
||||||
let np = matched_players.len();
|
let np = matched_players.len();
|
||||||
println!("{:?} players in instance", np);
|
|
||||||
let current_round = matched_players[0..(np / 2)]
|
let current_round = matched_players[0..(np / 2)]
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
@ -408,8 +416,6 @@ pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account:
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{:?}", instance);
|
|
||||||
|
|
||||||
let cryps = params.cryp_ids
|
let cryps = params.cryp_ids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|id| cryp_get(tx, *id, account.id))
|
.map(|id| cryp_get(tx, *id, account.id))
|
||||||
@ -455,7 +461,7 @@ pub fn instance_ready_global(tx: &mut Transaction, _account: &Account, player: P
|
|||||||
Ok(game)
|
Ok(game)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instance_scores(params: InstanceReadyParams, tx: &mut Transaction, account: &Account) -> Result<Vec<(String, Score)>, Error> {
|
pub fn instance_scores(params: InstanceReadyParams, tx: &mut Transaction, _account: &Account) -> Result<Vec<(String, Score)>, Error> {
|
||||||
let scores = instance_get(tx, params.instance_id)?.scores();
|
let scores = instance_get(tx, params.instance_id)?.scores();
|
||||||
Ok(scores)
|
Ok(scores)
|
||||||
}
|
}
|
||||||
@ -468,18 +474,15 @@ pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut instance = instance_get(tx, params.instance_id)?;
|
let mut instance = instance_get(tx, params.instance_id)?;
|
||||||
let game_id = instance.current_round(&player).game_id;
|
|
||||||
|
|
||||||
// attempting to re-ready
|
// attempting to re-ready
|
||||||
// send game state
|
// send game state
|
||||||
match instance.player_ready(&mut player) {
|
match instance.player_ready(&mut player) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(_) => return game_get(tx, game_id),
|
Err(_) => return game_get(tx, instance.current_round(&player).game_id),
|
||||||
};
|
};
|
||||||
|
|
||||||
if instance.vbox_phase_finished() {
|
let game_id = instance.current_round(&player).game_id;
|
||||||
instance.games_phase_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
let game = match instance.pve {
|
let game = match instance.pve {
|
||||||
true => match game_get(tx, game_id) {
|
true => match game_get(tx, game_id) {
|
||||||
@ -565,7 +568,7 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:?}", instance_get(tx, instance_id)?);
|
// println!("{:?}", instance_get(tx, instance_id)?);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -578,24 +581,28 @@ mod tests {
|
|||||||
fn instance_pve_test() {
|
fn instance_pve_test() {
|
||||||
let mut instance = Instance::new().add_bots();
|
let mut instance = Instance::new().add_bots();
|
||||||
|
|
||||||
let player_id = Uuid::new_v4();
|
let player_account = Uuid::new_v4();
|
||||||
let cryps = instance_mobs(player_id);
|
let cryps = instance_mobs(player_account);
|
||||||
let player = Player::new(player_id, instance.id, &"test".to_string(), cryps).set_bot(true);
|
let mut player = Player::new(player_account, instance.id, &"test".to_string(), cryps).set_bot(true);
|
||||||
|
let player_id = player.id;
|
||||||
|
|
||||||
instance.add_player(player);
|
instance.add_player(player.clone());
|
||||||
assert!(instance.can_start());
|
assert!(instance.can_start());
|
||||||
|
|
||||||
instance.start();
|
instance.start();
|
||||||
assert_eq!(instance.rounds[0].len(), 8);
|
assert_eq!(instance.rounds[0].len(), 8);
|
||||||
|
|
||||||
let mut player = instance.players.clone().into_iter().find(|p| p.account == player_id).unwrap();
|
|
||||||
instance.player_ready(&mut player).unwrap();
|
instance.player_ready(&mut player).unwrap();
|
||||||
|
|
||||||
assert!(instance.vbox_phase_finished());
|
|
||||||
instance.games_phase_start();
|
|
||||||
|
|
||||||
// println!("{:#?}", instance);
|
|
||||||
|
|
||||||
assert!(instance.games_phase_finished());
|
assert!(instance.games_phase_finished());
|
||||||
|
instance.vbox_phase_start();
|
||||||
|
|
||||||
|
instance.player_ready(&mut player).unwrap();
|
||||||
|
|
||||||
|
instance.vbox_phase_start();
|
||||||
|
|
||||||
|
instance.player_ready(&mut player).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(instance.rounds.len(), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,8 +141,7 @@ pub fn player_update(tx: &mut Transaction, player: Player, ignore_phase: bool) -
|
|||||||
|
|
||||||
result.iter().next().ok_or(format_err!("player {:?} could not be written", player))?;
|
result.iter().next().ok_or(format_err!("player {:?} could not be written", player))?;
|
||||||
|
|
||||||
|
Ok(player)
|
||||||
return Ok(player)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
|
pub fn player_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user