generated from GarandPLG/rust-flake-template
Initialize skirmish board and refactor states
- Create `GameStates` from a `&Cli` and initialize the skirmish board in `App::new`. - Move map dimensions to `SkirmishState` and add a `board_cells` vector populated by `CellWidget`s. - Refactor `SettingsState` to store only user‑specific settings (fields are cloned). - Update `BoardWidget` to hold a reference to the cell vector and use the new dimensions. - Adjust CLI defaults: map width to 50 and map height to 25.
This commit is contained in:
+12
-11
@@ -15,7 +15,7 @@ pub struct GameStates {
|
||||
}
|
||||
|
||||
impl GameStates {
|
||||
pub fn new(args: Cli) -> Self {
|
||||
pub fn new(args: &Cli) -> Self {
|
||||
Self {
|
||||
main_menu: MainMenuState {
|
||||
id: 0,
|
||||
@@ -27,6 +27,9 @@ impl GameStates {
|
||||
name: "Skirmish",
|
||||
vertical_offset: Offset::new(),
|
||||
horizontal_offset: Offset::new(),
|
||||
map_width: args.map_width as usize,
|
||||
map_height: args.map_height as usize,
|
||||
board_cells: Vec::new(),
|
||||
},
|
||||
perk_decks: PerkDecksState {
|
||||
id: 2,
|
||||
@@ -39,16 +42,14 @@ impl GameStates {
|
||||
selected_skill: 0,
|
||||
},
|
||||
settings: SettingsState {
|
||||
username: args.username,
|
||||
game_mode: args.game_mode,
|
||||
map_width: args.map_width,
|
||||
map_height: args.map_height,
|
||||
perk_deck: args.perk_deck,
|
||||
starting_wood: args.starting_wood,
|
||||
starting_iron: args.starting_iron,
|
||||
supply_limit: args.supply_limit,
|
||||
xp_modifier: args.xp_modifier,
|
||||
skill_points_limit: args.skill_points_limit,
|
||||
username: args.username.clone(),
|
||||
game_mode: args.game_mode.clone(),
|
||||
perk_deck: args.perk_deck.clone(),
|
||||
starting_wood: args.starting_wood.clone(),
|
||||
starting_iron: args.starting_iron.clone(),
|
||||
supply_limit: args.supply_limit.clone(),
|
||||
xp_modifier: args.xp_modifier.clone(),
|
||||
skill_points_limit: args.skill_points_limit.clone(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user