Merge branch 'develop' of ssh://git.mnml.gg:40022/~/mnml into develop
This commit is contained in:
@@ -322,6 +322,17 @@ impl Game {
|
||||
return Ok(self);
|
||||
}
|
||||
|
||||
fn clear_skill(&mut self, player_id: Uuid) -> Result<&mut Game, Error> {
|
||||
self.player_by_id(player_id)?;
|
||||
if self.phase != Phase::Skill {
|
||||
return Err(err_msg("game not in skill phase"));
|
||||
}
|
||||
let mut game_state = self.clone();
|
||||
self.stack.retain(|s| game_state.construct_by_id(s.source_construct_id).unwrap().account == player_id);
|
||||
|
||||
return Ok(self);
|
||||
}
|
||||
|
||||
fn player_ready(&mut self, player_id: Uuid) -> Result<&mut Game, Error> {
|
||||
if self.phase != Phase::Skill {
|
||||
return Err(err_msg("game not in skill phase"));
|
||||
@@ -877,6 +888,20 @@ pub fn game_skill(tx: &mut Transaction, account: &Account, game_id: Uuid, constr
|
||||
Ok(game)
|
||||
}
|
||||
|
||||
pub fn game_skill_clear(tx: &mut Transaction, account: &Account, game_id: Uuid) -> Result<Game, Error> {
|
||||
let mut game = game_get(tx, game_id)?;
|
||||
|
||||
game.clear_skill(account.id)?;
|
||||
|
||||
if game.skill_phase_finished() {
|
||||
game = game.resolve_phase_start();
|
||||
}
|
||||
|
||||
game_update(tx, &game)?;
|
||||
|
||||
Ok(game)
|
||||
}
|
||||
|
||||
pub fn game_ready(tx: &mut Transaction, account: &Account, id: Uuid) -> Result<Game, Error> {
|
||||
let mut game = game_get(tx, id)?;
|
||||
|
||||
|
||||
+5
-1
@@ -20,7 +20,7 @@ use account::{Account};
|
||||
use account;
|
||||
use construct::{Construct};
|
||||
use events::{Event};
|
||||
use game::{Game, game_state, game_skill, game_ready};
|
||||
use game::{Game, game_state, game_skill, game_skill_clear, game_ready};
|
||||
use instance::{Instance, instance_state, instance_practice, instance_ready};
|
||||
use item::{Item, ItemInfoCtr, item_info};
|
||||
use mtx;
|
||||
@@ -75,6 +75,7 @@ enum RpcRequest {
|
||||
GameState { id: Uuid },
|
||||
GameReady { id: Uuid },
|
||||
GameSkill { game_id: Uuid, construct_id: Uuid, target_construct_id: Option<Uuid>, skill: Skill },
|
||||
GameSkillClear { game_id: Uuid },
|
||||
|
||||
AccountState {},
|
||||
AccountShop {},
|
||||
@@ -169,6 +170,9 @@ impl Connection {
|
||||
RpcRequest::GameSkill { game_id, construct_id, target_construct_id, skill } =>
|
||||
Ok(RpcMessage::GameState(game_skill(&mut tx, account, game_id, construct_id, target_construct_id, skill)?)),
|
||||
|
||||
RpcRequest::GameSkillClear { game_id } =>
|
||||
Ok(RpcMessage::GameState(game_skill_clear(&mut tx, account, game_id)?)),
|
||||
|
||||
RpcRequest::GameReady { id } =>
|
||||
Ok(RpcMessage::GameState(game_ready(&mut tx, account, id)?)),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user