I don't know what I'm doing and it rocks

This commit is contained in:
Ren Kararou 2023-08-19 13:56:48 -05:00
parent 62ce8d20c4
commit ca10e900c8
Signed by: spicywolf
GPG key ID: B0BA4EEC0714F8E6
3 changed files with 118 additions and 0 deletions

115
src/battle.rs Normal file
View file

@ -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<BattleUnit>; 3],
back: [Option<BattleUnit>; 3],
}
impl BattleTeam {
pub fn new(front: [Option<BattleUnit>; 3], back: [Option<BattleUnit>; 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
}

View file

@ -4,3 +4,4 @@ pub mod statistics;
pub mod unit; pub mod unit;
pub mod inventory; pub mod inventory;
pub mod status; pub mod status;
pub mod battle;

View file

@ -8,4 +8,6 @@ pub enum Status {
Confuse, // chance to hit random target (self included) Confuse, // chance to hit random target (self included)
Stop, // miss turn Stop, // miss turn
Haste, // speed is doubled Haste, // speed is doubled
Faint, // close to death
Dead, // dead, cannot be revived
} }