Skip to content

Commit 5c74403

Browse files
committed
implement chest randomizer
1 parent 7256e39 commit 5c74403

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/randomizer.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,33 @@ impl Randomizer for DefaultRandomizer {
133133
}
134134

135135
fn gold_chest(&self, distance: &location::Distance) -> bool {
136-
todo!();
136+
let mut rng = rand::thread_rng();
137+
138+
match distance {
139+
location::Distance::Near(_) => rng.gen_ratio(5, 20),
140+
location::Distance::Mid(_) => rng.gen_ratio(6, 20),
141+
location::Distance::Far(_) => rng.gen_ratio(3, 20),
142+
}
137143
}
138144

139145
fn equipment_chest(&self, distance: &location::Distance) -> bool {
140-
todo!();
146+
let mut rng = rand::thread_rng();
147+
148+
match distance {
149+
location::Distance::Near(_) => false,
150+
location::Distance::Mid(_) => rng.gen_ratio(3, 20),
151+
location::Distance::Far(_) => rng.gen_ratio(5, 20),
152+
}
141153
}
142154

143155
fn item_chest(&self, distance: &location::Distance) -> bool {
144-
todo!();
156+
let mut rng = rand::thread_rng();
157+
158+
match distance {
159+
location::Distance::Near(_) => rng.gen_ratio(3, 20),
160+
location::Distance::Mid(_) => rng.gen_ratio(8, 20),
161+
location::Distance::Far(_) => rng.gen_ratio(14, 20),
162+
}
145163
}
146164
}
147165

0 commit comments

Comments
 (0)