more drops

This commit is contained in:
ntr 2019-03-04 13:12:22 +11:00
parent 9dcb21eefa
commit 8b18e7aa20
2 changed files with 33 additions and 10 deletions

View File

@ -57,7 +57,6 @@ class LineBox extends Phaser.GameObjects.Graphics {
return delta[j]; return delta[j];
}); });
} }
console.log(this.lineCoord);
this.lineStyle(5, 0xFF00FF, 1); this.lineStyle(5, 0xFF00FF, 1);
this.lineBetween(this.lineCoord[0], horizY, this.lineCoord[1], horizY); this.lineBetween(this.lineCoord[0], horizY, this.lineCoord[1], horizY);

View File

@ -19,16 +19,24 @@ use cryp::{cryp_get, cryp_write};
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Var { pub enum Var {
// colours
Blue, Blue,
Green, Green,
Red, Red,
// base skills
Attack, Attack,
Block, Block,
Stun, Stun,
Buff, Buff,
Debuff, Debuff,
// specs
Damage,
Protection,
Healing,
Hp,
Amplify, Amplify,
Banish, Banish,
Blast, Blast,
@ -134,11 +142,13 @@ impl Vbox {
} }
pub fn fill(&mut self) -> &mut Vbox { pub fn fill(&mut self) -> &mut Vbox {
let vars = vec![ let colours = vec![
(Var::Red, 1), (Var::Red, 1),
(Var::Green, 1), (Var::Green, 1),
(Var::Blue, 1), (Var::Blue, 1),
];
let skills = vec![
(Var::Attack, 1), (Var::Attack, 1),
(Var::Block, 1), (Var::Block, 1),
(Var::Buff, 1), (Var::Buff, 1),
@ -146,14 +156,28 @@ impl Vbox {
(Var::Stun, 1), (Var::Stun, 1),
]; ];
self.free = iter:: let specs = vec![
repeat_with(|| { (Var::Damage, 1),
let mut rng = thread_rng(); (Var::Protection, 1),
let dist = WeightedIndex::new(vars.iter().map(|item| item.1)).unwrap(); (Var::Healing, 1),
return vars[dist.sample(&mut rng)].0; (Var::Hp, 1),
}) ];
.take(8)
.collect::<Vec<Var>>(); let mut free = vec![];
let mut rng = thread_rng();
for i in 0..18 {
let vars = match i {
0...5 => &colours,
6...11 => &skills,
12...17 => &specs,
_ => panic!("vars oor"),
};
let dist = WeightedIndex::new(vars.iter().map(|item| item.1)).unwrap();
free.push(vars[dist.sample(&mut rng)].0);
}
self.free = free;
self self
} }