diff --git a/server/src/game.rs b/server/src/game.rs index 306ef06d..a6197a87 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -86,7 +86,7 @@ impl Game { player.forfeit(); } - let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::>().join(", "); + // let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::>().join(", "); // self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description)); player.constructs.sort_unstable_by_key(|c| c.id); @@ -138,10 +138,10 @@ impl Game { && self.players.iter().all(|t| t.constructs.len() == self.player_constructs) } - pub fn start(mut self) -> Game { + pub fn start(self) -> Game { // self.log.push("Game starting...".to_string()); - // forfeit + // both forfeit ddue to no skills if self.finished() { return self.finish(); } @@ -828,97 +828,6 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou Ok(game) } -// pub fn game_pve_new(construct_ids: Vec, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result { -// if construct_ids.len() == 0 { -// return Err(err_msg("no constructs selected")); -// } - -// let constructs = construct_ids -// .iter() -// .map(|id| construct_get(tx, *id, account.id)) -// .collect::, Error>>()?; - -// if constructs.len() > 3 { -// return Err(err_msg("player size too large (3 max)")); -// } - -// // create the game -// let mut game = Game::new(); -// // let game_id = game.id; - -// game; -// .set_player_num(2) -// .set_player_constructs(constructs.len()) -// .set_mode(mode); - -// // create the mob player -// let mob_player = generate_mob_player(mode, &constructs); - -// // add the players -// let mut plr_player = Player::new(account.id); -// plr_player -// .set_constructs(constructs); - - -// game -// .player_add(plr_player)? -// .player_add(mob_player)?; - -// game.start(); - -// return Ok(game); -// } - -// pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result { -// let game = game_pve_new(params.construct_ids, GameMode::Normal, tx, account)?; - -// // persist -// game_write(tx, &game)?; - -// Ok(game) -// } - -pub fn game_instance_new(tx: &mut Transaction, players: Vec, game_id: Uuid, instance_id: Uuid) -> Result { - // create the game - let mut game = Game::new(); - game.id = game_id; - - game - .set_player_num(2) - .set_player_constructs(3) - .set_instance(instance_id); - - // create the initiators player - for player in players { - game.player_add(player)?; - } - - if game.can_start() { - game = game.start(); - } - - // persist - game_write(tx, &game)?; - - Ok(game) -} - -// pub fn game_instance_join(tx: &mut Transaction, player: Player, game_id: Uuid) -> Result { -// let mut game = game_get(tx, game_id)?; - -// game.player_add(player)?; - -// if game.can_start() { -// game = game.start(); -// } - -// info!("{:?} game joined", game.id); - -// game_update(tx, &game)?; - -// Ok(game) -// } - #[cfg(test)] mod tests { use game::*; diff --git a/server/src/skill.rs b/server/src/skill.rs index f22931d6..82f7acda 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -384,10 +384,11 @@ impl Cast { pub type Disable = Vec; pub type Immunity = Vec; +// used to show the progress of a construct +// while the resolutions are animating #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] -pub struct LogConstruct { +pub struct EventConstruct { pub id: Uuid, - pub name: String, pub red: u64, pub green: u64, pub blue: u64, @@ -407,8 +408,8 @@ pub enum LogStages { #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] pub struct Resolution { - pub source: LogConstruct, - pub target: LogConstruct, + pub source: EventConstruct, + pub target: EventConstruct, pub event: Event, pub stages: u8, } @@ -416,16 +417,14 @@ pub struct Resolution { impl Resolution { fn new(source: &Construct, target: &Construct) -> Resolution { Resolution { - source: LogConstruct { + source: EventConstruct { id: source.id, - name: source.name.clone(), red: source.red_life(), green: source.green_life(), blue: source.blue_life(), }, - target: LogConstruct { + target: EventConstruct { id: target.id, - name: target.name.clone(), red: target.red_life(), green: target.green_life(), blue: target.blue_life(),