EOL
This commit is contained in:
parent
94ba4b698c
commit
505aed8138
307
src/sheet.rs
307
src/sheet.rs
@ -1,183 +1,192 @@
|
|||||||
use eframe::egui::Ui;
|
|
||||||
use eframe::egui::widgets::DragValue;
|
use eframe::egui::widgets::DragValue;
|
||||||
|
use eframe::egui::Ui;
|
||||||
|
|
||||||
use crate::gui::SheetGui;
|
use crate::gui::SheetGui;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Classe {
|
pub enum Classe {
|
||||||
Warrior,
|
Warrior,
|
||||||
Cautious,
|
Cautious,
|
||||||
Farmer,
|
Farmer,
|
||||||
Resourceful,
|
Resourceful,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum CharacteristicType {
|
enum CharacteristicType {
|
||||||
Address,
|
Address,
|
||||||
Stamina,
|
Stamina,
|
||||||
Luck,
|
Luck,
|
||||||
Skill,
|
Skill,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CharacterSheet {
|
pub struct CharacterSheet {
|
||||||
character_class: Classe,
|
character_class: Classe,
|
||||||
/// Field to write the personality/
|
/// Field to write the personality/
|
||||||
pub character: String,
|
pub character: String,
|
||||||
address: Characteristic,
|
address: Characteristic,
|
||||||
stamina: Characteristic,
|
stamina: Characteristic,
|
||||||
luck: Characteristic,
|
luck: Characteristic,
|
||||||
skill: Characteristic,
|
skill: Characteristic,
|
||||||
health: u32,
|
health: u32,
|
||||||
armor: u32,
|
armor: u32,
|
||||||
damage: u32,
|
damage: u32,
|
||||||
glory: u32,
|
glory: u32,
|
||||||
money: u32,
|
money: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterSheet {
|
impl CharacterSheet {
|
||||||
pub fn character_class(&self) -> &Classe {
|
pub fn character_class(&self) -> &Classe {
|
||||||
&self.character_class
|
&self.character_class
|
||||||
}
|
}
|
||||||
pub fn character(&self) -> &str {
|
pub fn character(&self) -> &str {
|
||||||
&self.character
|
&self.character
|
||||||
}
|
}
|
||||||
pub fn address(&self) -> &Characteristic {
|
pub fn address(&self) -> &Characteristic {
|
||||||
&self.address
|
&self.address
|
||||||
}
|
}
|
||||||
pub fn stamina(&self) -> &Characteristic {
|
pub fn stamina(&self) -> &Characteristic {
|
||||||
&self.stamina
|
&self.stamina
|
||||||
}
|
}
|
||||||
pub fn luck(&self) -> &Characteristic {
|
pub fn luck(&self) -> &Characteristic {
|
||||||
&self.luck
|
&self.luck
|
||||||
}
|
}
|
||||||
pub fn skill(&self) -> &Characteristic {
|
pub fn skill(&self) -> &Characteristic {
|
||||||
&self.skill
|
&self.skill
|
||||||
}
|
}
|
||||||
pub fn health(&self) -> u32 {
|
pub fn health(&self) -> u32 {
|
||||||
self.health
|
self.health
|
||||||
}
|
}
|
||||||
pub fn armor(&self) -> u32 {
|
pub fn armor(&self) -> u32 {
|
||||||
self.armor
|
self.armor
|
||||||
}
|
}
|
||||||
pub fn damage(&self) -> u32 {
|
pub fn damage(&self) -> u32 {
|
||||||
self.damage
|
self.damage
|
||||||
}
|
}
|
||||||
pub fn glory(&self) -> u32 {
|
pub fn glory(&self) -> u32 {
|
||||||
self.glory
|
self.glory
|
||||||
}
|
}
|
||||||
pub fn money(&self) -> u32 {
|
pub fn money(&self) -> u32 {
|
||||||
self.money
|
self.money
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SheetGui for CharacterSheet {
|
impl SheetGui for CharacterSheet {
|
||||||
fn shortcut(&self, ui: &mut Ui, category: &str, character_field: &Characteristic) -> (u32, u32, u32) {
|
fn shortcut(
|
||||||
let mut base = character_field.base;
|
&self,
|
||||||
let mut carac = character_field.carac;
|
ui: &mut Ui,
|
||||||
let mut materiel = character_field.materiel;
|
category: &str,
|
||||||
ui.heading(category);
|
character_field: &Characteristic,
|
||||||
ui.columns(2, |columns| {
|
) -> (u32, u32, u32) {
|
||||||
let mut ui_column = &mut columns[0];
|
let mut base = character_field.base;
|
||||||
ui_column.label("Base");
|
let mut carac = character_field.carac;
|
||||||
ui_column.label("Carac.");
|
let mut materiel = character_field.materiel;
|
||||||
ui_column.label("Matériel");
|
ui.heading(category);
|
||||||
|
ui.columns(2, |columns| {
|
||||||
|
let mut ui_column = &mut columns[0];
|
||||||
|
ui_column.label("Base");
|
||||||
|
ui_column.label("Carac.");
|
||||||
|
ui_column.label("Matériel");
|
||||||
|
|
||||||
ui_column = &mut columns[1];
|
ui_column = &mut columns[1];
|
||||||
ui_column.add(DragValue::new(&mut base));
|
ui_column.add(DragValue::new(&mut base));
|
||||||
ui_column.add(DragValue::new(&mut carac));
|
ui_column.add(DragValue::new(&mut carac));
|
||||||
ui_column.add(DragValue::new(&mut materiel));
|
ui_column.add(DragValue::new(&mut materiel));
|
||||||
});
|
});
|
||||||
return (base, carac, materiel);
|
return (base, carac, materiel);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gui_address(&mut self, ui: &mut Ui) {
|
fn gui_address(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround: &CharacterSheet = self;
|
||||||
(self.address.base, self.address.carac, self.address.materiel) = self.shortcut(ui, "Habileté", workaround.address());
|
(self.address.base, self.address.carac, self.address.materiel) =
|
||||||
ui.label("Ne peut dépasser 5");
|
self.shortcut(ui, "Habileté", workaround.address());
|
||||||
}
|
ui.label("Ne peut dépasser 5");
|
||||||
|
}
|
||||||
|
|
||||||
fn gui_stamina(&mut self, ui: &mut Ui) {
|
fn gui_stamina(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround: &CharacterSheet = self;
|
||||||
(self.stamina.base, self.stamina.carac, self.stamina.materiel) = self.shortcut(ui, "Endurance", workaround.stamina());
|
(self.stamina.base, self.stamina.carac, self.stamina.materiel) =
|
||||||
}
|
self.shortcut(ui, "Endurance", workaround.stamina());
|
||||||
|
}
|
||||||
|
|
||||||
fn gui_luck(&mut self, ui: &mut Ui) {
|
fn gui_luck(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround: &CharacterSheet = self;
|
||||||
(self.luck.base, self.luck.carac, self.luck.materiel) = self.shortcut(ui, "Chance", workaround.luck());
|
(self.luck.base, self.luck.carac, self.luck.materiel) =
|
||||||
}
|
self.shortcut(ui, "Chance", workaround.luck());
|
||||||
|
}
|
||||||
|
|
||||||
fn gui_skill(&mut self, ui: &mut Ui) {
|
fn gui_skill(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround: &CharacterSheet = self;
|
||||||
(self.skill.base, self.skill.carac, self.skill.materiel) = self.shortcut(ui, "Habileté", workaround.skill());
|
(self.skill.base, self.skill.carac, self.skill.materiel) =
|
||||||
}
|
self.shortcut(ui, "Habileté", workaround.skill());
|
||||||
|
}
|
||||||
|
|
||||||
fn secondary_stats(&mut self, ui: &mut Ui) {
|
fn secondary_stats(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround: &CharacterSheet = self;
|
||||||
ui.heading("Stat. secondaires");
|
ui.heading("Stat. secondaires");
|
||||||
ui.columns(2, |columns| {
|
ui.columns(2, |columns| {
|
||||||
columns[0].vertical_centered_justified(|ui| {
|
columns[0].vertical_centered_justified(|ui| {
|
||||||
ui.label("Dégâts");
|
ui.label("Dégâts");
|
||||||
ui.label("Armure");
|
ui.label("Armure");
|
||||||
ui.label("Critique");
|
ui.label("Critique");
|
||||||
});
|
});
|
||||||
columns[1].vertical_centered_justified(|ui| {
|
columns[1].vertical_centered_justified(|ui| {
|
||||||
let mut damage = workaround.damage;
|
let mut damage = workaround.damage;
|
||||||
let mut armor = workaround.armor;
|
let mut armor = workaround.armor;
|
||||||
ui.add(DragValue::new(&mut damage));
|
ui.add(DragValue::new(&mut damage));
|
||||||
ui.add(DragValue::new(&mut armor));
|
ui.add(DragValue::new(&mut armor));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Characteristic {
|
pub struct Characteristic {
|
||||||
characteristic_type: CharacteristicType,
|
characteristic_type: CharacteristicType,
|
||||||
pub base: u32,
|
pub base: u32,
|
||||||
pub carac: u32,
|
pub carac: u32,
|
||||||
pub materiel: u32,
|
pub materiel: u32,
|
||||||
pub additional: u32,
|
pub additional: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CharacterSheet {
|
impl Default for CharacterSheet {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
character_class: Classe::Warrior,
|
character_class: Classe::Warrior,
|
||||||
character: "Billy".to_string(),
|
character: "Billy".to_string(),
|
||||||
address: Characteristic {
|
address: Characteristic {
|
||||||
characteristic_type: CharacteristicType::Address,
|
characteristic_type: CharacteristicType::Address,
|
||||||
base: 0,
|
base: 0,
|
||||||
carac: 0,
|
carac: 0,
|
||||||
materiel: 0,
|
materiel: 0,
|
||||||
additional: 1,
|
additional: 1,
|
||||||
},
|
},
|
||||||
stamina: Characteristic {
|
stamina: Characteristic {
|
||||||
characteristic_type: CharacteristicType::Stamina,
|
characteristic_type: CharacteristicType::Stamina,
|
||||||
base: 2,
|
base: 2,
|
||||||
carac: 0,
|
carac: 0,
|
||||||
materiel: 0,
|
materiel: 0,
|
||||||
additional: 0,
|
additional: 0,
|
||||||
},
|
},
|
||||||
luck: Characteristic {
|
luck: Characteristic {
|
||||||
characteristic_type: CharacteristicType::Luck,
|
characteristic_type: CharacteristicType::Luck,
|
||||||
base: 3,
|
base: 3,
|
||||||
carac: 0,
|
carac: 0,
|
||||||
materiel: 0,
|
materiel: 0,
|
||||||
additional: 0,
|
additional: 0,
|
||||||
},
|
},
|
||||||
skill: Characteristic {
|
skill: Characteristic {
|
||||||
characteristic_type: CharacteristicType::Skill,
|
characteristic_type: CharacteristicType::Skill,
|
||||||
base: 2,
|
base: 2,
|
||||||
carac: 0,
|
carac: 0,
|
||||||
materiel: 0,
|
materiel: 0,
|
||||||
additional: 0,
|
additional: 0,
|
||||||
},
|
},
|
||||||
health: 0,
|
health: 0,
|
||||||
armor: 0,
|
armor: 0,
|
||||||
damage: 0,
|
damage: 0,
|
||||||
glory: 0,
|
glory: 0,
|
||||||
money: 0,
|
money: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user