Es 03 Rogue Game

- init of structures
- not done
- tests not done
This commit is contained in:
2024-04-30 19:09:54 +02:00
parent 03ccf0e733
commit a5a6045ee3
8 changed files with 429 additions and 0 deletions

53
src/es03_game/game.rs Normal file
View File

@@ -0,0 +1,53 @@
use std::fmt::Display;
use rand::{RngCore, SeedableRng};
use rand_pcg::Pcg32;
use serde::{Deserialize, Serialize};
use super::{config::Config, entities::{Action, Entity}, floor::Floor, generator::Generator};
/**
* Struttura del gioco generico che implementa un RogueLike.
*/
#[derive(Deserialize, Serialize)]
pub struct Rogue {
floor: Floor,
rng: Pcg32,
config: Config,
}
impl Display for Rogue {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
impl Rogue {
pub fn new() -> Self {
let config = Config::default();
let mut rng = Pcg32::seed_from_u64(config.game_seed);
let floor = Floor::new(Generator::new(rng.next_u64(), 0, &config));
Self { rng, config, floor }
}
pub fn current_floor(&mut self) -> &mut Floor {
&mut self.floor
}
pub fn build_new_floor(&mut self) {
let level = self.floor.get_level();
let floor_seed = self.rng.next_u64();
let generator = Generator::new(floor_seed, level + 1, &self.config);
self.floor = Floor::new(generator);
}
pub fn input_action(&self, entity: &Entity) -> Action {
todo!()
}
pub fn compute_turn(&mut self) {
todo!();
}
}