commit 4d41a087c4be8e44c3d80c45458c182c2bd6bca2
Author: Spesk1 <spesk@pm.me>
Date: Sun Jun 2 14:19:34 2019 -0400
A few small tweaks
diff --git a/README.md b/README.md
index d66db27..9df6d11 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,8 @@
# dwars
-My attempt at writing something like the classic DOS game Drug Wars in Rust.
\ No newline at end of file
+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
+* Implement "head stash" to store money/drugs in case of arrest
diff --git a/src/main.rs b/src/main.rs
index 3f546c7..906a0bb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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);
}