cooldowns and statuses
This commit is contained in:
parent
17a1132700
commit
7ff281c140
@ -24,7 +24,9 @@ impl CrypSkill {
|
||||
let turns = match skill {
|
||||
Skill::Attack => None,
|
||||
Skill::Block => Some(1),
|
||||
Skill::Dodge => Some(1),
|
||||
Skill::Heal => Some(2),
|
||||
Skill::Stun => Some(2),
|
||||
};
|
||||
|
||||
CrypSkill {
|
||||
@ -32,26 +34,42 @@ impl CrypSkill {
|
||||
cd: turns,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_usable(&self, cryp: &Cryp) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Status {
|
||||
Stunned,
|
||||
Silenced,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub struct CrypStatus {
|
||||
status: Status,
|
||||
turns: u8,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Stat {
|
||||
Str,
|
||||
Agi,
|
||||
Int,
|
||||
Hp,
|
||||
Stam,
|
||||
Str,
|
||||
Agi,
|
||||
Int,
|
||||
Hp,
|
||||
Stam,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone)]
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub struct Roll {
|
||||
pub base: u64,
|
||||
pub result: u64,
|
||||
pub kind: Stat,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub struct CrypStat {
|
||||
pub value: u64,
|
||||
pub stat: Stat,
|
||||
@ -63,29 +81,6 @@ impl CrypStat {
|
||||
self
|
||||
}
|
||||
|
||||
// fn roll(&self, c: &Cryp, log: &mut Vec<String>) -> Roll {
|
||||
// let mut rng = thread_rng();
|
||||
// let base: u64 = rng.gen();
|
||||
|
||||
// let mut roll = Roll { kind: self.kind, base, result: base };
|
||||
|
||||
// log.push(format!("{:?}", self.kind));
|
||||
// log.push(format!("{:064b} <- base roll", base));
|
||||
|
||||
// // apply skills
|
||||
// roll = c.skills.iter().fold(roll, |roll, s| s.apply(roll));
|
||||
|
||||
// // finally combine with CrypStat
|
||||
// log.push(format!("{:064b} <- finalised", roll.result));
|
||||
// roll.result = roll.result & self.value;
|
||||
|
||||
// log.push(format!("{:064b} & <- attribute roll", self.value));
|
||||
// log.push(format!("{:064b} = {:?}", roll.result, roll.result));
|
||||
// log.push(format!(""));
|
||||
|
||||
// return roll;
|
||||
// }
|
||||
|
||||
pub fn reduce(&mut self, dmg: u64) -> &mut CrypStat {
|
||||
self.value = self.value.saturating_sub(dmg);
|
||||
self
|
||||
@ -110,6 +105,7 @@ pub struct Cryp {
|
||||
pub xp: u64,
|
||||
pub lvl: u8,
|
||||
pub skills: Vec<CrypSkill>,
|
||||
pub statuses: Vec<CrypStatus>,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
@ -132,6 +128,7 @@ impl Cryp {
|
||||
lvl: 0,
|
||||
xp: 0,
|
||||
skills: vec![CrypSkill::new(Skill::Attack)],
|
||||
statuses: vec![],
|
||||
name: String::new()
|
||||
};
|
||||
}
|
||||
@ -188,34 +185,14 @@ impl Cryp {
|
||||
self
|
||||
}
|
||||
|
||||
// pub fn assign_str(&mut self, opp: &Cryp, plr_t: &mut Turn, opp_t: &Turn) -> &mut Cryp {
|
||||
// // let final_str = opp_t.str.result.saturating_sub(plr_t.agi.result);
|
||||
// // let blocked = opp_t.str.result.saturating_sub(final_str);
|
||||
|
||||
// let final_str = opp_t.str.result & !plr_t.agi.result;
|
||||
// let blocked = opp_t.str.result & plr_t.agi.result;
|
||||
|
||||
// plr_t.log.push(format!("{:064b} <- attacking roll {:?}", opp_t.str.result, opp_t.str.result));
|
||||
// // plr_t.log.push(format!("{:064b} <- blocking roll {:?}", plr_t.agi.result, plr_t.agi.result));
|
||||
// plr_t.log.push(format!("{:064b} <- final str {:?} ({:?} blocked)", final_str, final_str, blocked));
|
||||
|
||||
// self.hp.reduce(final_str);
|
||||
|
||||
// plr_t.log.push(format!("{:?} deals {:?} str to {:?} ({:?} blocked / {:?} hp remaining)"
|
||||
// ,opp.name
|
||||
// ,final_str
|
||||
// ,self.name
|
||||
// ,blocked
|
||||
// ,self.hp.value));
|
||||
|
||||
// plr_t.log.push(format!(""));
|
||||
// self
|
||||
// }
|
||||
|
||||
pub fn is_ko(&self) -> bool {
|
||||
self.hp.value == 0
|
||||
}
|
||||
|
||||
pub fn available_skills(&self) -> Vec<&CrypSkill> {
|
||||
self.skills.iter().filter(|s| s.is_usable(self)).collect()
|
||||
}
|
||||
|
||||
pub fn knows(&self, skill: Skill) -> bool {
|
||||
self.skills.iter().any(|s| s.skill == skill)
|
||||
}
|
||||
@ -312,3 +289,51 @@ mod tests {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// pub fn assign_str(&mut self, opp: &Cryp, plr_t: &mut Turn, opp_t: &Turn) -> &mut Cryp {
|
||||
// // let final_str = opp_t.str.result.saturating_sub(plr_t.agi.result);
|
||||
// // let blocked = opp_t.str.result.saturating_sub(final_str);
|
||||
|
||||
// let final_str = opp_t.str.result & !plr_t.agi.result;
|
||||
// let blocked = opp_t.str.result & plr_t.agi.result;
|
||||
|
||||
// plr_t.log.push(format!("{:064b} <- attacking roll {:?}", opp_t.str.result, opp_t.str.result));
|
||||
// // plr_t.log.push(format!("{:064b} <- blocking roll {:?}", plr_t.agi.result, plr_t.agi.result));
|
||||
// plr_t.log.push(format!("{:064b} <- final str {:?} ({:?} blocked)", final_str, final_str, blocked));
|
||||
|
||||
// self.hp.reduce(final_str);
|
||||
|
||||
// plr_t.log.push(format!("{:?} deals {:?} str to {:?} ({:?} blocked / {:?} hp remaining)"
|
||||
// ,opp.name
|
||||
// ,final_str
|
||||
// ,self.name
|
||||
// ,blocked
|
||||
// ,self.hp.value));
|
||||
|
||||
// plr_t.log.push(format!(""));
|
||||
// self
|
||||
// }
|
||||
|
||||
// fn roll(&self, c: &Cryp, log: &mut Vec<String>) -> Roll {
|
||||
// let mut rng = thread_rng();
|
||||
// let base: u64 = rng.gen();
|
||||
|
||||
// let mut roll = Roll { kind: self.kind, base, result: base };
|
||||
|
||||
// log.push(format!("{:?}", self.kind));
|
||||
// log.push(format!("{:064b} <- base roll", base));
|
||||
|
||||
// // apply skills
|
||||
// roll = c.skills.iter().fold(roll, |roll, s| s.apply(roll));
|
||||
|
||||
// // finally combine with CrypStat
|
||||
// log.push(format!("{:064b} <- finalised", roll.result));
|
||||
// roll.result = roll.result & self.value;
|
||||
|
||||
// log.push(format!("{:064b} & <- attribute roll", self.value));
|
||||
// log.push(format!("{:064b} = {:?}", roll.result, roll.result));
|
||||
// log.push(format!(""));
|
||||
|
||||
// return roll;
|
||||
// }
|
||||
|
||||
@ -30,6 +30,10 @@ impl Team {
|
||||
};
|
||||
}
|
||||
|
||||
fn skills_required(&self) -> usize {
|
||||
self.cryps.iter().filter(|c| c.available_skills().len() > 0).collect::<Vec<&Cryp>>().len()
|
||||
}
|
||||
|
||||
pub fn set_cryps(&mut self, cryps: Vec<Cryp>) -> &mut Team {
|
||||
self.cryps = cryps;
|
||||
self
|
||||
@ -224,7 +228,7 @@ impl Game {
|
||||
}
|
||||
|
||||
fn skill_phase_finished(&self) -> bool {
|
||||
self.teams.iter().all(|t| t.skills.len() == self.team_size)
|
||||
self.teams.iter().all(|t| t.skills.len() == t.skills_required())
|
||||
}
|
||||
|
||||
// move all skills into their target team's targets list
|
||||
|
||||
@ -11,9 +11,11 @@ pub struct Roll {
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Skill {
|
||||
Attack,
|
||||
Block,
|
||||
Heal,
|
||||
Attack,
|
||||
Block,
|
||||
Heal,
|
||||
Stun,
|
||||
Dodge,
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +48,8 @@ impl Turn {
|
||||
let stat = match self.skill {
|
||||
Skill::Attack => &c.str,
|
||||
Skill::Block => &c.str,
|
||||
Skill::Stun => &c.str,
|
||||
Skill::Dodge => &c.agi,
|
||||
Skill::Heal => &c.int,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user