pve enum
This commit is contained in:
+3
-3
@@ -22,9 +22,9 @@ pub struct CrypSkill {
|
||||
impl CrypSkill {
|
||||
pub fn new(skill: Skill) -> CrypSkill {
|
||||
CrypSkill {
|
||||
skill,
|
||||
self_targeting: skill.self_targeting(),
|
||||
cd: skill.base_cd(),
|
||||
skill,
|
||||
self_targeting: skill.self_targeting(),
|
||||
cd: skill.base_cd(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -18,6 +18,12 @@ use item::{item_drop};
|
||||
|
||||
pub type Log = Vec<String>;
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub enum PveMode {
|
||||
Boss,
|
||||
Normal,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct Team {
|
||||
id: Uuid,
|
||||
@@ -308,12 +314,6 @@ impl Game {
|
||||
.filter(|s| s.target_cryp_id.is_none() && s.target_team_id == mob_team_id)
|
||||
.enumerate()
|
||||
.map(|(i, s)| (i, s.id)) {
|
||||
// let target_id = match mobs.cryps.iter().find(|c| {
|
||||
// self.cryp_targetable(mob_team_id, c.id).is_ok()})
|
||||
// {
|
||||
// Some(c) => c.id,
|
||||
// None => panic!("could not find a targetable pve cryp"),
|
||||
// };
|
||||
let targets = mobs.cryps
|
||||
.iter()
|
||||
.filter(|c| self.cryp_targetable(mob_team_id, c.id).is_ok())
|
||||
@@ -753,30 +753,30 @@ fn generate_mob(lvl: u8) -> Cryp {
|
||||
|
||||
}
|
||||
|
||||
fn generate_mob_team(mode: String, cryps: &Vec<Cryp>) -> Team {
|
||||
|
||||
fn generate_mob_team(mode: PveMode, cryps: &Vec<Cryp>) -> Team {
|
||||
|
||||
let mut mob_team = Team::new(Uuid::nil());
|
||||
|
||||
|
||||
// Default settings
|
||||
let mut team_size = 1;
|
||||
let mut mob_lvl = 1;
|
||||
|
||||
// Modify the NPC cryps for game mode settings
|
||||
if (mode == "normal") {
|
||||
team_size = cryps.len();
|
||||
mob_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl;
|
||||
} else if (mode == "boss") {
|
||||
mob_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl + 2;
|
||||
}
|
||||
let mob_lvl = match mode {
|
||||
PveMode::Normal => {
|
||||
team_size = cryps.len();
|
||||
cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl
|
||||
},
|
||||
PveMode::Boss => cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl + 2,
|
||||
};
|
||||
|
||||
// Generate and return the NPC team based on settings
|
||||
let mobs = iter::repeat_with(|| generate_mob(mob_lvl).set_account(Uuid::nil()))
|
||||
.take(team_size)
|
||||
.collect::<Vec<Cryp>>();
|
||||
mob_team.set_cryps(mobs);
|
||||
|
||||
|
||||
return mob_team;
|
||||
|
||||
|
||||
}
|
||||
|
||||
pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||
@@ -800,7 +800,7 @@ pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account)
|
||||
|
||||
// create the mob team
|
||||
let mut mob_team = generate_mob_team(params.mode, &cryps);
|
||||
|
||||
|
||||
// add the players
|
||||
let mut plr_team = Team::new(account.id);
|
||||
plr_team
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ use failure::err_msg;
|
||||
|
||||
use net::Db;
|
||||
use cryp::{Cryp, cryp_spawn, cryp_learn, cryp_forget};
|
||||
use game::{Game, game_state, game_pve, game_pvp, game_join, game_joinable_list, game_skill, game_target};
|
||||
use game::{Game, PveMode, game_state, game_pve, game_pvp, game_join, game_joinable_list, game_skill, game_target};
|
||||
use account::{Account, account_create, account_login, account_from_token, account_cryps};
|
||||
use item::{Item, items_list, item_use};
|
||||
use skill::{Skill};
|
||||
@@ -395,7 +395,7 @@ struct GamePveMsg {
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct GamePveParams {
|
||||
pub cryp_ids: Vec<Uuid>,
|
||||
pub mode: String,
|
||||
pub mode: PveMode,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
|
||||
+2
-2
@@ -834,8 +834,8 @@ fn empower(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> R
|
||||
}
|
||||
|
||||
// TODO put overhealing back
|
||||
fn heal(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
|
||||
let amount = cryp.phys_dmg();
|
||||
fn heal(cryp: &mut Cryp, _target: &mut Cryp, resolution: Resolution) -> Resolution {
|
||||
let _amount = cryp.phys_dmg();
|
||||
return resolution;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user