Refactor MeleeWeapon to handle both melee and ranged weapons
This commit is contained in:
parent
92316bde1b
commit
b514eec669
@ -150,7 +150,8 @@ pub struct Equipped {
|
||||
}
|
||||
|
||||
#[derive(Component, ConvertSaveload, Clone)]
|
||||
pub struct MeleeWeapon {
|
||||
pub struct Weapon {
|
||||
pub range: Option<i32>,
|
||||
pub attribute: WeaponAttribute,
|
||||
pub damage_n_dice: i32,
|
||||
pub damage_die_type: i32,
|
||||
|
@ -115,7 +115,7 @@ fn init_state() -> State {
|
||||
LootTable,
|
||||
MagicItem,
|
||||
MagicMapper,
|
||||
MeleeWeapon,
|
||||
Weapon,
|
||||
MoveMode,
|
||||
MyTurn,
|
||||
Name,
|
||||
|
@ -3,8 +3,8 @@ use ::specs::prelude::*;
|
||||
|
||||
use crate::colors;
|
||||
use crate::components::{
|
||||
Attributes, EquipmentSlot, Equipped, HungerClock, HungerState, MeleeWeapon, Name,
|
||||
NaturalAttackDefense, Pools, Skill, Skills, WantsToMelee, WeaponAttribute, Wearable,
|
||||
Attributes, EquipmentSlot, Equipped, HungerClock, HungerState, Name, NaturalAttackDefense,
|
||||
Pools, Skill, Skills, WantsToMelee, Weapon, WeaponAttribute, Wearable,
|
||||
};
|
||||
use crate::effects::{add_effect, EffectType, Targets};
|
||||
use crate::game_log::GameLog;
|
||||
@ -25,7 +25,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||
ReadStorage<'a, Pools>,
|
||||
WriteExpect<'a, RandomNumberGenerator>,
|
||||
ReadStorage<'a, Equipped>,
|
||||
ReadStorage<'a, MeleeWeapon>,
|
||||
ReadStorage<'a, Weapon>,
|
||||
ReadStorage<'a, Wearable>,
|
||||
ReadStorage<'a, NaturalAttackDefense>,
|
||||
);
|
||||
@ -65,7 +65,8 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||
let target_name = names.get(wants_melee.target).unwrap();
|
||||
|
||||
// Define the basic unarmed attack -- overridden by wielding check below if a weapon is equipped
|
||||
let mut weapon_info = MeleeWeapon {
|
||||
let mut weapon_info = Weapon {
|
||||
range: None,
|
||||
attribute: WeaponAttribute::Might,
|
||||
hit_bonus: 0,
|
||||
damage_n_dice: 1,
|
||||
|
@ -534,7 +534,8 @@ pub fn spawn_named_item(
|
||||
slot: EquipmentSlot::Melee,
|
||||
});
|
||||
let (n_dice, die_type, bonus) = parse_dice_string(&weapon.base_damage);
|
||||
let mut wpn = MeleeWeapon {
|
||||
let mut wpn = Weapon {
|
||||
range: None,
|
||||
attribute: WeaponAttribute::Might,
|
||||
damage_n_dice: n_dice,
|
||||
damage_die_type: die_type,
|
||||
|
@ -94,7 +94,7 @@ pub fn save_game(ecs: &mut World) {
|
||||
LootTable,
|
||||
MagicItem,
|
||||
MagicMapper,
|
||||
MeleeWeapon,
|
||||
Weapon,
|
||||
MoveMode,
|
||||
MyTurn,
|
||||
Name,
|
||||
@ -228,7 +228,7 @@ pub fn load_game(ecs: &mut World) {
|
||||
LootTable,
|
||||
MagicItem,
|
||||
MagicMapper,
|
||||
MeleeWeapon,
|
||||
Weapon,
|
||||
MoveMode,
|
||||
MyTurn,
|
||||
Name,
|
||||
|
Loading…
Reference in New Issue
Block a user