diff options
author | Guillaume Pasquet <dev@etenil.net> | 2019-07-05 21:03:55 +0100 |
---|---|---|
committer | Guillaume Pasquet <dev@etenil.net> | 2019-07-05 21:03:55 +0100 |
commit | 7abfab104ffa052d885eb7d333f0569dc61ab74c (patch) | |
tree | 6ee0a9d1743de49cbcb36b2fdc6e6e9024013f33 /src/computer.rs |
Start generating game world
Diffstat (limited to 'src/computer.rs')
-rw-r--r-- | src/computer.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/computer.rs b/src/computer.rs new file mode 100644 index 0000000..a8b9b3e --- /dev/null +++ b/src/computer.rs @@ -0,0 +1,36 @@ +pub struct Computer {
+ level: i32,
+ difficulty: i32,
+}
+
+pub trait Enemy {
+ fn new(level: i32, difficulty: i32) -> Self;
+
+ fn action(&self) -> (i32, i32);
+
+ fn level_up(&mut self);
+
+ fn stats(&self) -> String;
+}
+
+impl Enemy for Computer {
+ fn new(level: i32, difficulty: i32) -> Computer {
+ Computer {
+ level: level,
+ difficulty: difficulty
+ }
+ }
+
+ fn action(&self) -> (i32, i32) {
+ (self.level, self.difficulty)
+ }
+
+ fn level_up(&mut self) {
+ self.level += 1;
+ self.difficulty += 3;
+ }
+
+ fn stats(&self) -> String {
+ format!("level: {} difficulty: {}", self.level, self.difficulty)
+ }
+}
|