From ca10e900c8469ed1e07ec08304c48a198ac8f1e1 Mon Sep 17 00:00:00 2001 From: Ren Kararou Date: Sat, 19 Aug 2023 13:56:48 -0500 Subject: [PATCH] I don't know what I'm doing and it rocks --- src/battle.rs | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + src/status.rs | 2 + 3 files changed, 118 insertions(+) create mode 100644 src/battle.rs diff --git a/src/battle.rs b/src/battle.rs new file mode 100644 index 0000000..0ca9995 --- /dev/null +++ b/src/battle.rs @@ -0,0 +1,115 @@ +use crate::unit::Unit; +use crate::statistics::StatBlock; + +pub enum Field { + City, + Forest, + Plains, + Building, + Volcano, + BrokenLands, + Void, + Chaos, + NOWHERE, +} + +pub enum Weather { + Sun, + Rain, + Sleet, + Hail, + Meteor, + BrokenSky, + Void, + NONE, +} + +pub struct BattleUnit { + unit: Unit, + bufs: StatBlock, + debufs: StatBlock, +} +impl BattleUnit { + pub fn new(unit: Unit) -> Self { + Self { + unit, + bufs: StatBlock::new_zero(), + debufs: StatBlock::new_zero(), + } + } +} + +pub struct BattleTeam { + front: [Option; 3], + back: [Option; 3], +} +impl BattleTeam { + pub fn new(front: [Option; 3], back: [Option; 3]) -> Self { + Self { + front, + back, + } + } +} + +pub struct Battle { + view_team: BattleTeam, + oppose_team: BattleTeam, + field: Field, + weather: Weather, +} +impl Battle { + pub fn new(view_team: BattleTeam, oppose_team: BattleTeam, field: Field, weather: Weather) -> Self { + Self { + view_team, + oppose_team, + field, + weather, + } + } + pub fn bufs(&self) -> StatBlock { + let mut sb = StatBlock::new_zero(); + match self.weather { + Weather::BrokenSky => sb.add_magick(3), + _ => (), + }; + match self.field { + Field::BrokenLands => sb.add_strength(3), + Field::Chaos => { + sb.add_intellect(5); + sb.add_magick(5); + }, + _ => () + }; + sb + } + pub fn debufs(&self) -> StatBlock { + let mut sb = StatBlock::new_zero(); + match self.weather { + Weather::Rain => sb.add_agility(-2), + Weather::Sleet => sb.add_agility(-5), + Weather::Hail => sb.add_defense(-2), + Weather::Meteor => { + sb.add_strength(-5); + sb.add_defense(-5); + sb.add_intellect(-5); + }, + Weather::Sun => sb.add_magick(-1), + _ => (), + }; + match self.field { + Field::Forest => sb.add_dexterity(-2), + Field::Building => sb.add_agility(-2), + Field::BrokenLands => sb.add_vitality(-5), + Field::Chaos => { + sb.add_defense(-10); + sb.add_vitality(-10); + sb.add_strength(-10); + sb.add_dexterity(-10); + }, + _ => (), + }; + sb + } + //TODO: how to handle moves, move order, etc +} diff --git a/src/lib.rs b/src/lib.rs index 8115822..78fa3bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,3 +4,4 @@ pub mod statistics; pub mod unit; pub mod inventory; pub mod status; +pub mod battle; diff --git a/src/status.rs b/src/status.rs index 199db50..756163a 100644 --- a/src/status.rs +++ b/src/status.rs @@ -8,4 +8,6 @@ pub enum Status { Confuse, // chance to hit random target (self included) Stop, // miss turn Haste, // speed is doubled + Faint, // close to death + Dead, // dead, cannot be revived }