slowly getting work done
This commit is contained in:
parent
ca10e900c8
commit
929e92769c
|
@ -9,8 +9,8 @@ pub struct Bullet {
|
||||||
impl Bullet {
|
impl Bullet {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: "BULLET_BLANK",
|
id: String::from("BULLET_BLANK"),
|
||||||
name: "BLANK",
|
name: String::from("BLANK"),
|
||||||
attack: 0,
|
attack: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ impl Bullet {
|
||||||
|
|
||||||
pub fn normal() -> Self {
|
pub fn normal() -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: "BULLET_NORMAL",
|
id: String::from("BULLET_NORMAL"),
|
||||||
name: "Normal Bullet",
|
name: String::from("Normal Bullet"),
|
||||||
attack: 5,
|
attack: 5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ pub struct Gun {
|
||||||
stat_mods: StatBlock,
|
stat_mods: StatBlock,
|
||||||
attack: u8,
|
attack: u8,
|
||||||
bullets: Option<Bullet>,
|
bullets: Option<Bullet>,
|
||||||
|
ammo_count: u8,
|
||||||
mag_size: u8,
|
mag_size: u8,
|
||||||
description: String,
|
description: String,
|
||||||
flavor: String,
|
flavor: String,
|
||||||
|
@ -52,6 +53,7 @@ impl Gun {
|
||||||
stat_mods: StatBlock::new_zero(),
|
stat_mods: StatBlock::new_zero(),
|
||||||
attack: 0,
|
attack: 0,
|
||||||
bullets: None,
|
bullets: None,
|
||||||
|
ammo_count: 0,
|
||||||
mag_size: 0,
|
mag_size: 0,
|
||||||
description: String::from("A cheap toy."),
|
description: String::from("A cheap toy."),
|
||||||
flavor: String::from("Don't walk into a gun fight with this."),
|
flavor: String::from("Don't walk into a gun fight with this."),
|
||||||
|
@ -60,6 +62,12 @@ impl Gun {
|
||||||
pub fn attack(self) -> u8 {
|
pub fn attack(self) -> u8 {
|
||||||
self.attack
|
self.attack
|
||||||
}
|
}
|
||||||
|
pub fn bullets(self) -> Option<Bullet> {
|
||||||
|
self.bullets
|
||||||
|
}
|
||||||
|
pub fn ammo_count(self) -> u8 {
|
||||||
|
self.ammo_count
|
||||||
|
}
|
||||||
pub fn stat_mods(self) -> StatBlock {
|
pub fn stat_mods(self) -> StatBlock {
|
||||||
self.stat_mods
|
self.stat_mods
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
mod comp;
|
pub mod comp;
|
||||||
mod gun;
|
pub mod gun;
|
||||||
mod hat;
|
pub mod hat;
|
||||||
mod pants;
|
pub mod pants;
|
||||||
mod shirt;
|
pub mod shirt;
|
||||||
mod shoes;
|
pub mod shoes;
|
||||||
mod sword;
|
pub mod sword;
|
||||||
|
|
||||||
use crate::statistics::StatBlock;
|
use crate::statistics::StatBlock;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ impl EquipmentBlock {
|
||||||
pub fn bonuses(self) -> StatBlock {
|
pub fn bonuses(self) -> StatBlock {
|
||||||
let mut stats = StatBlock::new_zero();
|
let mut stats = StatBlock::new_zero();
|
||||||
stats += self.sword.unwrap_or(sword::Sword::new()).stat_mods();
|
stats += self.sword.unwrap_or(sword::Sword::new()).stat_mods();
|
||||||
stats += self.gun.uwrap_or(gun::Gun::new()).stat_mods();
|
stats += self.gun.unwrap_or(gun::Gun::new()).stat_mods();
|
||||||
stats += self.comp.unwrap_or(comp::Comp::new()).stat_mods();
|
stats += self.comp.unwrap_or(comp::Comp::new()).stat_mods();
|
||||||
stats += self.head.unwrap_or(hat::Hat::new()).stat_mods();
|
stats += self.head.unwrap_or(hat::Hat::new()).stat_mods();
|
||||||
stats += self.chest.unwrap_or(shirt::Shirt::new()).stat_mods();
|
stats += self.chest.unwrap_or(shirt::Shirt::new()).stat_mods();
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::equipment::{sword::Sword, gun::Gun, comp::Comp, hat::Hat, shirt::Shir
|
||||||
|
|
||||||
struct BagEquipment {
|
struct BagEquipment {
|
||||||
swords: Option<Vec<Sword>>,
|
swords: Option<Vec<Sword>>,
|
||||||
guns: Option<Vec<Guns>>,
|
guns: Option<Vec<Gun>>,
|
||||||
comps: Option<Vec<Comp>>,
|
comps: Option<Vec<Comp>>,
|
||||||
hats: Option<Vec<Hat>>,
|
hats: Option<Vec<Hat>>,
|
||||||
shirts: Option<Vec<Shirt>>,
|
shirts: Option<Vec<Shirt>>,
|
||||||
|
|
34
src/unit.rs
34
src/unit.rs
|
@ -1,4 +1,4 @@
|
||||||
use crate::equipment::EquipmentBlock;
|
use crate::equipment::{EquipmentBlock, sword::Sword, gun::Gun};
|
||||||
use crate::statistics::StatBlock;
|
use crate::statistics::StatBlock;
|
||||||
use crate::status::Status;
|
use crate::status::Status;
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
|
@ -60,6 +60,38 @@ impl Unit {
|
||||||
pub fn gender(self) -> Gender {
|
pub fn gender(self) -> Gender {
|
||||||
self.gender
|
self.gender
|
||||||
}
|
}
|
||||||
|
pub fn strike(self) -> u32 {
|
||||||
|
// accuracy and crit chance are calculated in the battle engine
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
let extra: u32 = rng.gen_range(1..3);
|
||||||
|
let stren: u32 = self.clone().stats().strength().try_into().unwrap_or(0);
|
||||||
|
let equipment: EquipmentBlock = self.clone().equipment().unwrap_or(EquipmentBlock::new());
|
||||||
|
let swdam = equipment.sword().unwrap_or(Sword::new()).damage();
|
||||||
|
(extra * stren) + u32::from(swdam)
|
||||||
|
}
|
||||||
|
pub fn shoot(&mut self) -> u32 {
|
||||||
|
let equipment = self.clone().equipment().unwrap_or(EquipmentBlock::new());
|
||||||
|
match equipment.gun() {
|
||||||
|
Some(g) => {
|
||||||
|
match g.clone().bullets() {
|
||||||
|
Some(b) => {
|
||||||
|
match g.ammo_count() {
|
||||||
|
0 => 0, // TODO: Reload mechanics
|
||||||
|
_ => {
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
let extra: u32 = rng.gen_range(5..25);
|
||||||
|
// TODO: Decrement ammo by one
|
||||||
|
let dmg: u32 = b.attack().try_into().unwrap_or(0);
|
||||||
|
dmg + extra
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn stats(self) -> StatBlock {
|
pub fn stats(self) -> StatBlock {
|
||||||
self.base_stats + self.stat_bonus()
|
self.base_stats + self.stat_bonus()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue