mobs use defensive spells properly

This commit is contained in:
ntr 2019-01-06 17:48:03 +11:00
parent badd7a8aba
commit 1d9a057775
5 changed files with 40 additions and 8 deletions

View File

@ -151,10 +151,10 @@ class Background extends Phaser.Scene {
this.customPipeline = game.renderer.addPipeline('Custom', new CustomPipeline(game)); this.customPipeline = game.renderer.addPipeline('Custom', new CustomPipeline(game));
this.customPipeline.setFloat2('resolution', 1600, 1000); this.customPipeline.setFloat2('resolution', 1600, 1000);
const sprite = this.add.sprite(0, 0); const sprite = this.add.sprite(800, 500);
sprite.setPipeline('Custom'); sprite.setPipeline('Custom');
sprite.displayWidth = 3200; sprite.displayWidth = 1600 * window.devicePixelRatio;
sprite.displayHeight = 2000; sprite.displayHeight = 1000 * window.devicePixelRatio;
} }
update() { update() {

View File

@ -10,7 +10,11 @@ strangle
## NOW ## NOW
* reduce inventory * mobs heal own team
* clean up categories
* cryp speed
* modifies skill base speed
## SOON ## SOON
* aoe skills * aoe skills

View File

@ -209,7 +209,6 @@ impl Game {
let mobs = self.team_by_id(mob_team_id).clone(); let mobs = self.team_by_id(mob_team_id).clone();
let player_team = self.teams.iter().find(|t| t.id != mob_team_id).unwrap().clone(); let player_team = self.teams.iter().find(|t| t.id != mob_team_id).unwrap().clone();
let player_len = player_team.cryps.len();
for mob in mobs.cryps.iter() { for mob in mobs.cryps.iter() {
let skill = mob.mob_select_skill(); let skill = mob.mob_select_skill();
@ -217,10 +216,22 @@ impl Game {
match skill { match skill {
Some(s) => { Some(s) => {
let mut rng = thread_rng(); let mut rng = thread_rng();
let mut target = &player_team.cryps[rng.gen_range(0, player_len)];
// the mut marks it as being able to be called
// more than once
let mut find_target = || {
match s.defensive() {
true => &mobs.cryps[rng.gen_range(0, mobs.cryps.len())],
false => &player_team.cryps[rng.gen_range(0, player_team.cryps.len())],
}
};
let mut target = find_target();
while target.is_ko() { while target.is_ko() {
target = &player_team.cryps[rng.gen_range(0, player_len)]; target = find_target();
} }
match self.add_skill(mob_team_id, mob.id, Some(target.id), s) { match self.add_skill(mob_team_id, mob.id, Some(target.id), s) {
Ok(_) => (), Ok(_) => (),
Err(e) => println!("{:?} could not add pve skill", e), Err(e) => println!("{:?} could not add pve skill", e),
@ -284,7 +295,7 @@ impl Game {
// check here as well so uncastable spells don't go on the stack // check here as well so uncastable spells don't go on the stack
let check = cryp.disabled(skill); let check = cryp.disabled(skill);
if check.disabled { if check.disabled {
return Err(format_err!("cryp cannot cast that skill ({:?})", check.effects)); return Err(format_err!("cryp cannot cast that skill {:?}", check.effects));
} }
} }

View File

@ -107,6 +107,7 @@ fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Cryp> {
.named(&"coinage".to_string()) .named(&"coinage".to_string())
.level(player_lvl) .level(player_lvl)
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::Evade)
.learn(Skill::Block) .learn(Skill::Block)
.create(); .create();
@ -123,6 +124,7 @@ fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Cryp> {
.named(&"quarry".to_string()) .named(&"quarry".to_string())
.level(player_lvl) .level(player_lvl)
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::Evade)
.learn(Skill::Stun) .learn(Skill::Stun)
.create(); .create();

View File

@ -757,6 +757,21 @@ impl Skill {
_ => false, _ => false,
} }
} }
pub fn defensive(&self) -> bool {
match self {
Skill::Heal |
Skill::Triage |
Skill::Empower |
Skill::Purify |
Skill::Calm |
Skill::Evasion |
Skill::Parry |
Skill::Block |
Skill::Evade => true,
_ => false,
}
}
} }
fn attack(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { fn attack(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {