more types

This commit is contained in:
Daniel Løvbrøtte Olsen 2019-05-08 01:36:04 +02:00
parent f813c1681e
commit 164cf5886d
6 changed files with 93 additions and 41 deletions

View File

@ -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
}

11
game/carrier.rs Normal file
View File

@ -0,0 +1,11 @@
enum Order {
NOTHING
}
pub struct Carrier {
OwnerID: u8,
name: String,
ships: u16,
location: (u16, u16),
orders: Vec<Order>
}

13
game/mod.rs Normal file
View File

@ -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<Player>,
stars: Vec<Star>,
carriers: Vec<Carrier>
}

52
game/player.rs Normal file
View File

@ -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()
}
}
}

15
game/star.rs Normal file
View File

@ -0,0 +1,15 @@
struct Infrastructre {
factory: u16,
lab: u16,
bank: u16
}
pub struct Star {
ownerID: Option<u8>,
location: (u16, u16),
name: String,
natural_resources: u16,
infrastructre: Infrastructre,
hypergate: bool,
ships: u16
}

View File

@ -3,6 +3,8 @@
#[macro_use] extern crate rocket; #[macro_use] extern crate rocket;
#[macro_use] extern crate rocket_contrib; #[macro_use] extern crate rocket_contrib;
mod game;
use rocket_contrib::serve::StaticFiles; use rocket_contrib::serve::StaticFiles;
fn main() { fn main() {