|
@@ -192,6 +192,14 @@ impl Player {
|
|
|
return stash_fill;
|
|
|
}
|
|
|
|
|
|
+ pub fn holding(&self) -> bool {
|
|
|
+ if self.stash_fill() == 0 {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
@@ -295,29 +303,36 @@ fn body_armor_event(player: &mut Player) {
|
|
|
fn cops_event(player: &mut Player) {
|
|
|
|
|
|
let one_second = time::Duration::from_secs(1);
|
|
|
- println!("The cops found you! Run!");
|
|
|
- thread::sleep(one_second);
|
|
|
- let mut rng = rand::thread_rng();
|
|
|
- let mut escape: u32;
|
|
|
- let mut hit: u32;
|
|
|
- let mut done = false;
|
|
|
- while ! done {
|
|
|
- escape = rng.gen_range(0,5);
|
|
|
- hit = rng.gen_range(0,10);
|
|
|
- if escape == 0 {
|
|
|
- println!("You got away!");
|
|
|
- thread::sleep(one_second);
|
|
|
- done = true;
|
|
|
- } else {
|
|
|
- println!("You cant get away, the cops are firing!");
|
|
|
- thread::sleep(one_second);
|
|
|
- if hit == 0 {
|
|
|
- println!("You're hit for 2 damage!");
|
|
|
- player.take_damage(2);
|
|
|
+ if ! player.holding() {
|
|
|
+ println!("The cops found you, but you're not holding so it's chill.");
|
|
|
+ thread::sleep(one_second);
|
|
|
+ thread::sleep(one_second);
|
|
|
+ thread::sleep(one_second);
|
|
|
+ } else {
|
|
|
+ println!("The cops found you! Run!");
|
|
|
+ thread::sleep(one_second);
|
|
|
+ let mut rng = rand::thread_rng();
|
|
|
+ let mut escape: u32;
|
|
|
+ let mut hit: u32;
|
|
|
+ let mut done = false;
|
|
|
+ while ! done {
|
|
|
+ escape = rng.gen_range(0,5);
|
|
|
+ hit = rng.gen_range(0,10);
|
|
|
+ if escape == 0 {
|
|
|
+ println!("You got away!");
|
|
|
thread::sleep(one_second);
|
|
|
+ done = true;
|
|
|
} else {
|
|
|
- println!("They miss and you keep running!");
|
|
|
+ println!("You cant get away, the cops are firing!");
|
|
|
thread::sleep(one_second);
|
|
|
+ if hit == 0 {
|
|
|
+ println!("You're hit for 2 damage!");
|
|
|
+ player.take_damage(4);
|
|
|
+ thread::sleep(one_second);
|
|
|
+ } else {
|
|
|
+ println!("They miss and you keep running!");
|
|
|
+ thread::sleep(one_second);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -476,7 +491,6 @@ fn main() {
|
|
|
|
|
|
let mut rng = rand::thread_rng();
|
|
|
let event_chance = rng.gen_range(0,9);
|
|
|
- println!("Event chance is: {}",event_chance);
|
|
|
if event_chance == 2 {
|
|
|
trenchcoat_event(&mut player);
|
|
|
}
|