Fix a bug with a procedural effect, remove the shortbow from starting player inventory

This commit is contained in:
Timothy Warren 2022-02-04 10:34:11 -05:00
parent 9b5adaad9c
commit 0c5cec84e9
3 changed files with 13 additions and 11 deletions

View File

@ -22,7 +22,7 @@ build-wasm: $(call print-help, build-wasm, Build the webassembly version of the
wasm-bindgen target/wasm32-unknown-unknown/release/roguelike_tutorial.wasm --out-dir wasm --no-modules --no-typescript
build-wasm-dev: $(call print-help, build-wasm-dev, Build the webassembly version of the game (dev version))
cargo build --target wasm32-unknown-unknown --features wasm
cargo build --target wasm32-unknown-unknown --features wasm,debug
wasm-bindgen target/wasm32-unknown-unknown/debug/roguelike_tutorial.wasm --out-dir wasm --no-modules --no-typescript
clean: $(call print-help, clean, Removes save file and compilation artifacts)

View File

@ -41,14 +41,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
.build();
// Starting equipment
let starting_equipment_carried = ["Dried Sausage", "Beer", "Shortbow"];
let starting_equipment_equipped = [
"Rusty Longsword",
"Stained Tunic",
"Torn Trousers",
"Old Boots",
];
for equipment in starting_equipment_carried.iter() {
for equipment in ["Dried Sausage", "Beer"].iter() {
spawn_named_entity(
&RAWS.lock().unwrap(),
ecs,
@ -56,7 +49,14 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
SpawnType::Carried { by: player },
);
}
for equipment in starting_equipment_equipped.iter() {
for equipment in [
"Rusty Longsword",
"Stained Tunic",
"Torn Trousers",
"Old Boots",
]
.iter()
{
spawn_named_entity(
&RAWS.lock().unwrap(),
ecs,

View File

@ -170,7 +170,9 @@ impl<'a> System<'a> for MeleeCombatSystem {
// Proc effects
if let Some(chance) = &weapon_info.proc_chance {
if roll_dice(1, 100) <= (chance * 100.0) as i32 {
let effect_target = if weapon_info.proc_target.unwrap() == "Self" {
let effect_target = if weapon_info.proc_target.is_some()
&& weapon_info.proc_target.unwrap() == "Self"
{
Targets::Single { target: entity }
} else {
Targets::Single {