Add score for touching/whipping monsters

This commit is contained in:
Alex Page 2022-02-01 02:56:45 -05:00
parent b2672904c8
commit b62f2759de
3 changed files with 11 additions and 3 deletions

View file

@ -70,4 +70,8 @@ impl Stats {
true
}
}
pub fn add_score(&mut self, score: u32) {
self.score += score;
}
}

View file

@ -144,6 +144,7 @@ impl State {
} else {
if let Some(e) = map.get_tile_content_at(destination) {
if let Some(monster) = monsters.get(e) {
stats.add_score(damage_for_kind(monster.kind));
stats.take_gems(damage_for_kind(monster.kind));
sound_output.play_sound(sound_effect_for_kind(
monster.kind,

View file

@ -4,8 +4,8 @@ use bracket_lib::prelude::*;
use specs::prelude::*;
use crate::{
components::{Monster, Position, WantsToWhip},
resources::{Map, SoundEffects, SoundOutput, StopClock},
components::{monster::damage_for_kind, Monster, Position, WantsToWhip},
resources::{Map, SoundEffects, SoundOutput, Stats, StopClock},
};
pub struct WhipSystem {}
@ -17,6 +17,7 @@ impl<'a> System<'a> for WhipSystem {
WriteExpect<'a, StopClock>,
WriteExpect<'a, SoundOutput>,
ReadExpect<'a, SoundEffects>,
WriteExpect<'a, Stats>,
ReadStorage<'a, Position>,
WriteStorage<'a, WantsToWhip>,
WriteStorage<'a, Monster>,
@ -29,6 +30,7 @@ impl<'a> System<'a> for WhipSystem {
mut stop_clock,
mut sound_output,
sound_effects,
mut stats,
positions,
mut wants_to_whips,
monsters,
@ -93,7 +95,8 @@ impl<'a> System<'a> for WhipSystem {
if let Some(dest) = destination {
if let Some(e) = map.get_tile_content_at(dest) {
if let Some(_monster) = monsters.get(e) {
if let Some(monster) = monsters.get(e) {
stats.add_score(damage_for_kind(monster.kind));
let _ = entities.delete(e);
map.clear_tile_content_at(dest);
if let Some(sound) = &mut wants_to_whip.sound {