61624e95e34b205988bc53559a917e3de0e906c6
commit 61624e95e34b205988bc53559a917e3de0e906c6
Author: spesk1 <spesk@pm.me>
Date: Sat Jun 1 23:32:24 2019 -0400

Beginnings of basic frame

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..ce249fa
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "dwars"
+version = "0.1.0"
+
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..384acfd
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "dwars"
+version = "0.1.0"
+authors = ["spesk1 <spesk@pm.me>"]
+edition = "2018"
+
+[dependencies]
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..3f4b8b3
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,72 @@
+use std::io;
+use std::io::Read;
+
+// Objects
+
+struct Player {
+ health: u32,
+ money: u32,
+ debt: u32,
+ weed: u32,
+ location: String,
+}
+
+impl Player {
+ pub fn new(health: u32, money: u32, debt: u32, weed: u32, location: String) -> Self {
+ Player { health, money, debt, weed, location }
+ }
+
+ pub fn add_weed(&mut self, add_amount: u32) {
+ self.weed += add_amount;
+ }
+
+ pub fn dump(&mut self) {
+ println!("Health: {}", self.health);
+ println!("Money: {}", self.money);
+ println!("Debt: {}", self.debt);
+ println!("Weed: {}", self.weed);
+ println!("Location: {}", self.location);
+ }
+
+ pub fn change_location(&mut self, new_location: String) {
+ self.location = new_location;
+ }
+}
+
+// "Low-level" Fuctions, called by "Top-level" functions
+
+fn prompt(prompt_text: String) -> io::Result<String> {
+ println!("$ {}",prompt_text);
+ let mut input = String::new();
+ std::io::stdin().read_line(&mut input);
+
+ let value: String = input.trim().parse().unwrap();
+ println!("Got value: {}", value);
+ Ok(value)
+}
+
+// "Top-level" Functions, called by main
+
+fn go_to_location(target_location: String, player: &mut Player) {
+
+ let new_location = prompt("Select a new location, locations are\n\tBrooklyn\n\tManhatten".to_string()).unwrap();
+ player.change_location(new_location);
+
+}
+
+fn main() {
+ let mut player = Player::new(100,2000,2050,0,"Brooklyn".to_string());
+ let mut objects = [player];
+ let mut done = false;
+ while ! done {
+ objects[0].dump();
+ let input = prompt("Enter quit to quit".to_string()).unwrap();
+
+ if input == "quit".to_string() {
+ done = true;
+ } else if input == "change location".to_string() {
+ go_to_location(input, &mut objects[0]);
+
+ }
+ }
+}