From 164cf5886d27d9847614b74c80c676fccc53e37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Wed, 8 May 2019 01:36:04 +0200 Subject: [PATCH] more types --- Player.rs | 41 -------------------------------------- game/carrier.rs | 11 +++++++++++ game/mod.rs | 13 +++++++++++++ game/player.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ game/star.rs | 15 ++++++++++++++ main.rs | 2 ++ 6 files changed, 93 insertions(+), 41 deletions(-) delete mode 100644 Player.rs create mode 100644 game/carrier.rs create mode 100644 game/mod.rs create mode 100644 game/player.rs create mode 100644 game/star.rs diff --git a/Player.rs b/Player.rs deleted file mode 100644 index 7577942..0000000 --- a/Player.rs +++ /dev/null @@ -1,41 +0,0 @@ -enum Race { - Griffin, - Catte -} -impl Default for Race { - fn default() -> Self { - Race::Catte - } -} - -struct ResearchItem { - levels: u8, - points: u16 -} -impl Default for ResearchItem { - fn default() -> Self { - ResearchItem{ - levels: 1, - points: 0 - } - } -} - -#[derive(Default)] -struct Research { - Weapons: ResearchItem, - Banking: ResearchItem, - Manufactoring: ResearchItem, - Terraforming: ResearchItem, - Hyperspace: ResearchItem, - Experimentation: ResearchItem, - Scanning: ResearchItem -} - -#[derive(Default)] -struct Player { - Name: String, - Color: (u8, u8, u8), - Race: Race, - Research: Research -} diff --git a/game/carrier.rs b/game/carrier.rs new file mode 100644 index 0000000..b4cd340 --- /dev/null +++ b/game/carrier.rs @@ -0,0 +1,11 @@ +enum Order { + NOTHING +} + +pub struct Carrier { + OwnerID: u8, + name: String, + ships: u16, + location: (u16, u16), + orders: Vec +} \ No newline at end of file diff --git a/game/mod.rs b/game/mod.rs new file mode 100644 index 0000000..5ee1334 --- /dev/null +++ b/game/mod.rs @@ -0,0 +1,13 @@ +mod player; +mod star; +mod carrier; + +use game::player::Player; +use game::star::Star; +use game::carrier::Carrier; + +struct Game { + players: Vec, + stars: Vec, + carriers: Vec +} \ No newline at end of file diff --git a/game/player.rs b/game/player.rs new file mode 100644 index 0000000..e48aa19 --- /dev/null +++ b/game/player.rs @@ -0,0 +1,52 @@ +enum Race { + Griffin, + Catte +} +impl Default for Race { + fn default() -> Self { + Race::Catte + } +} + +struct ResearchItem { + levels: u8, + points: u16 +} +impl Default for ResearchItem { + fn default() -> Self { + ResearchItem{ + levels: 1, + points: 0 + } + } +} + +#[derive(Default)] +struct Research { + weapons: ResearchItem, + banking: ResearchItem, + manufactoring: ResearchItem, + terraforming: ResearchItem, + hyperspace: ResearchItem, + experimentation: ResearchItem, + scanning: ResearchItem +} + +//#[derive(Default)] +pub struct Player { + name: String, + color: (u8, u8, u8), + race: Race, + research: Research +} +impl Default for Player { + fn default() -> Self { + Player{ + name: String::default(), + //Color: (rand::thread_rng().gen(), rand::thread_rng().gen(), rand::thread_rng().gen()), + color: (0,0,0), + race: Race::default(), + research: Research::default() + } + } +} \ No newline at end of file diff --git a/game/star.rs b/game/star.rs new file mode 100644 index 0000000..23e54fd --- /dev/null +++ b/game/star.rs @@ -0,0 +1,15 @@ +struct Infrastructre { + factory: u16, + lab: u16, + bank: u16 +} + +pub struct Star { + ownerID: Option, + location: (u16, u16), + name: String, + natural_resources: u16, + infrastructre: Infrastructre, + hypergate: bool, + ships: u16 +} \ No newline at end of file diff --git a/main.rs b/main.rs index dbec9c6..7f57396 100644 --- a/main.rs +++ b/main.rs @@ -3,6 +3,8 @@ #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; +mod game; + use rocket_contrib::serve::StaticFiles; fn main() {