b17e763f1bfa0db29d58f9c7c1737aad1b61cae2
commit b17e763f1bfa0db29d58f9c7c1737aad1b61cae2
Author: spesk1 <spesk@pm.me>
Date: Mon Jun 3 16:29:57 2019 -0400

Fixed enter advancing main loop

diff --git a/README.md b/README.md
index 091ca9a..bc3ffa5 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@ My attempt at writing something like the classic DOS game Drug Wars in Rust.

TODO:
* Add price fluctuation events
-* -Get arrested by the cops, lose money/drugs- DONE
-* -Implement "head stash" to store money/drugs in case of arrest- DONE
+* ~~Get arrested by the cops, lose money/drugs~~ DONE
+* ~~Implement "head stash" to store money/drugs in case of arrest~~ DONE

Bugs:
-* Hitting enter advances the main loop, not intended behavior
+* Need to find some more
diff --git a/src/main.rs b/src/main.rs
index bac87fe..f780454 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -397,7 +397,6 @@ fn cops_event(player: &mut Player) {
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);
@@ -432,6 +431,9 @@ fn cops_event(player: &mut Player) {
}
}
}
+
+ thread::sleep(one_second);
+ thread::sleep(one_second);
}

////////////////////////////////////////
@@ -659,20 +661,6 @@ fn main() {
while ! main_loop {
clear_term();

- let mut rng = rand::thread_rng();
- let event_chance = rng.gen_range(0,9);
- if event_chance == 2 {
- trenchcoat_event(&mut player);
- }
-
- if event_chance == 1 {
- body_armor_event(&mut player);
- }
-
- if event_chance == 0 {
- cops_event(&mut player);
- }
-
if player.health == 0 {
println!("You died! Game over!");
main_loop = true;
@@ -706,6 +694,27 @@ fn main() {
go_to_location(&mut player, &mut market);
player.debt_interest();
player.decrease_loan_timer(1);
+
+ // Only have events trigger after 'jetting'
+ let mut rng = rand::thread_rng();
+ let event_chance = rng.gen_range(0,9);
+ if event_chance == 2 {
+ trenchcoat_event(&mut player);
+ }
+
+ if event_chance == 1 {
+ body_armor_event(&mut player);
+ }
+
+ if event_chance == 0 {
+ cops_event(&mut player);
+ }
+
+ if player.health == 0 {
+ println!("You died! Game over!");
+ main_loop = true;
+ }
+
} else if action.contains("loanshark") {
loan_shark(&mut player);
} else if action.contains("headstash") {