fix: 2 bots handling
This commit is contained in:
parent
2fe2f66c13
commit
447ec8cc58
|
|
@ -58,8 +58,10 @@ impl Bot {
|
||||||
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
|
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
|
||||||
let game = self.strategy.get_mut_game();
|
let game = self.strategy.get_mut_game();
|
||||||
game.consume(event);
|
game.consume(event);
|
||||||
// println!("bot game {:?}", self.game);
|
// println!(
|
||||||
// println!("bot player_id {:?}", self.player_id);
|
// "bot player_id {:?} (active player_id {:?})",
|
||||||
|
// self.player_id, game.active_player_id
|
||||||
|
// );
|
||||||
if game.active_player_id == self.player_id {
|
if game.active_player_id == self.player_id {
|
||||||
return match game.turn_stage {
|
return match game.turn_stage {
|
||||||
TurnStage::MarkAdvPoints => Some(GameEvent::Mark {
|
TurnStage::MarkAdvPoints => Some(GameEvent::Mark {
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,12 @@ impl GameRunner {
|
||||||
let bot_events: Vec<GameEvent> = self
|
let bot_events: Vec<GameEvent> = self
|
||||||
.bots
|
.bots
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|bot| Some(bot.player_id) != event.player_id())
|
|
||||||
.filter_map(|bot| bot.handle_event(event))
|
.filter_map(|bot| bot.handle_event(event))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut next_event = None;
|
let mut next_event = None;
|
||||||
for bot_event in bot_events {
|
for bot_event in bot_events {
|
||||||
|
println!("bot event {:?}", bot_event);
|
||||||
let bot_result_event = self.handle_event(&bot_event);
|
let bot_result_event = self.handle_event(&bot_event);
|
||||||
if let Some(bot_id) = bot_event.player_id() {
|
if let Some(bot_id) = bot_event.player_id() {
|
||||||
next_event = if self.bot_needs_dice_roll(bot_id) {
|
next_event = if self.bot_needs_dice_roll(bot_id) {
|
||||||
|
|
|
||||||
10
devenv.nix
10
devenv.nix
|
|
@ -4,13 +4,14 @@
|
||||||
# https://devenv.sh/basics/
|
# https://devenv.sh/basics/
|
||||||
# env.GREET = "devenv";
|
# env.GREET = "devenv";
|
||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
# for bevy
|
# for bevy
|
||||||
pkgs.alsaLib
|
pkgs.alsaLib
|
||||||
pkgs.udev
|
pkgs.udev
|
||||||
|
|
||||||
# bevy fast compile
|
# bevy fast compile
|
||||||
pkgs.clang pkgs.lld
|
pkgs.clang
|
||||||
|
pkgs.lld
|
||||||
|
|
||||||
# copié de https://github.com/mmai/Hyperspeedcube/blob/develop/devenv.nix
|
# copié de https://github.com/mmai/Hyperspeedcube/blob/develop/devenv.nix
|
||||||
# TODO : retirer ce qui est inutile
|
# TODO : retirer ce qui est inutile
|
||||||
|
|
@ -27,7 +28,8 @@
|
||||||
pkgs.xorg.libXi
|
pkgs.xorg.libXi
|
||||||
pkgs.xorg.libX11
|
pkgs.xorg.libX11
|
||||||
|
|
||||||
pkgs.vulkan-headers pkgs.vulkan-loader
|
pkgs.vulkan-headers
|
||||||
|
pkgs.vulkan-loader
|
||||||
# ------------ fin copie
|
# ------------ fin copie
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
@ -44,7 +46,7 @@
|
||||||
# scripts.hello.exec = "echo hello from $GREET";
|
# scripts.hello.exec = "echo hello from $GREET";
|
||||||
|
|
||||||
# https://devenv.sh/pre-commit-hooks/
|
# https://devenv.sh/pre-commit-hooks/
|
||||||
pre-commit.hooks.shellcheck.enable = true;
|
# pre-commit.hooks.shellcheck.enable = true;
|
||||||
|
|
||||||
# https://devenv.sh/processes/
|
# https://devenv.sh/processes/
|
||||||
# processes.ping.exec = "ping example.com";
|
# processes.ping.exec = "ping example.com";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue