From 572a853dff3cd32fdd193afc9356a7638f7b0c1f Mon Sep 17 00:00:00 2001 From: Martin Read Date: Tue, 21 Jan 2014 18:15:59 +0000 Subject: [PATCH] Added new files for the notification mechanism --- notify-local-tty.cc | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++ notify.hh | 75 +++++++++++++++ 2 files changed, 331 insertions(+) create mode 100644 notify-local-tty.cc create mode 100644 notify.hh diff --git a/notify-local-tty.cc b/notify-local-tty.cc new file mode 100644 index 0000000..9459bf8 --- /dev/null +++ b/notify-local-tty.cc @@ -0,0 +1,256 @@ +/*! \file notify-local-tty.cc + * \brief Notification backend + * + * This module provides an implementation of the API defined in notify.hh + * which emits messages in English prose. It should, at some point, be + * replaced with something that is more internationalized. + */ + +/* Copyright 2005-2014 Martin Read + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define NOTIFY_LOCAL_TTY_CC +#include "victrix-abyssi.hh" +#include "monsters.hh" +#include +#include +#include +#include +#include +#include + +/*! \brief The player has gained a level + */ +void notify_level_gain(void) +{ + status_updated = 1; + print_msg("You gained a level!\n"); +} + +/*! \brief The player has gained some Agility + * + * \param Amount of Agility gained + */ +void notify_agility_gain(int amount) +{ + status_updated = 1; + print_msg("You gained %d Agility.\n", amount); +} + +/*! \brief The player has gained some Body. + * + * \param Amount of Body gained. + */ +void notify_body_gain(int amount) +{ + status_updated = 1; + print_msg("You gained %d Body.\n", amount); +} + +void notify_hp_gain(int amount) +{ + status_updated = 1; + print_msg("You gained %d hit points.\n", amount); +} + +void notify_player_teleport(void) +{ + print_msg("You are whisked away!\n"); +} + +void notify_player_telefail(void) +{ + print_msg("You feel briefly dislocated.\n"); +} + +void notify_player_regen(void) +{ + print_msg("Your ring pulses soothingly.\n"); +} + +void notify_hunger_level(int severity) +{ + switch (severity) + { + case 0: + default: + break; + case 1: + print_msg("You are getting quite hungry.\n"); + break; + case 2: + print_msg("You are feeling hunger pangs, and will recover\nmore slowly from your injuries.\n"); + break; + } +} + +void notify_leadfoot_recovered(void) +{ + print_msg("You shed your feet of lead.\n"); +} + +void notify_armourmelt_recovered(void) +{ + print_msg("Your armour seems solid once more.\n"); +} + +void notify_wither_recovered(void) +{ + print_msg("Your limbs straighten.\n"); +} + +void notify_protection_lost(void) +{ + print_msg("You feel like you are no longer being helped.\n"); +} + +void notify_start_lavawalk(void) +{ + print_msg("You walk on the lava.\n"); +} + +void notify_blocked_lava(void) +{ + print_msg("The fierce heat of the molten rock repels you.\n"); +} + +void notify_start_waterwalk(void) +{ + print_msg("You walk on the water.\n"); +} + +void notify_blocked_water(void) +{ + print_msg("The idiot who raised you never taught you to swim.\n"); +} + +void notify_obj_at(Coord c) +{ + print_msg("You see here "); + print_obj_name(lvl.obj_at(c)); + print_msg(".\n"); +} + +void debug_move_oob(Coord c) +{ + print_msg("NOTICE: Attempted move out of bounds (dest %d, %d)\n", c.y, c.x); +} + +void notify_swing_bow(void) +{ + print_msg("You can't use that weapon in melee!\n"); +} + +void notify_cant_go(void) +{ + print_msg("You cannot go there.\n"); +} + +void notify_wasted_gain(void) +{ + print_msg("You feel disappointed.\n"); +} + +void notify_summon_help(int mon, bool success) +{ + /* Do the summoning... */ + print_mon_name(mon, 3); + print_msg(" calls for help...\n"); + if (success) + { + print_msg("... and gets it.\n"); + } + else + { + print_msg("... luckily for you, help wasn't listening.\n"); + } +} + +void notify_mon_disappear(int mon) +{ + print_mon_name(mon, 3); + print_msg(" vanishes in a puff of smoke.\n"); +} + +void notify_start_armourmelt(void) +{ + status_updated = 1; + print_msg("Your armour seems suddenly no stronger than dust!\n"); +} + +void notify_start_leadfoot(void) +{ + status_updated = 1; + print_msg("Your feet feel like lead!\n"); +} + +void notify_start_withering(void) +{ + status_updated = 1; + print_msg("Your limbs twist and wither!\n"); +} + +void notify_necrosmite_fail(void) +{ + print_msg("Darkness reaches towards you, but dissolves.\n"); +} + +void notify_necrosmite_hit(void) +{ + print_msg("Soul-chilling darkness engulfs you!\n"); +} + +void notify_moncurse_fail(void) +{ + print_msg("A malignant aura surrounds you briefly.\n"); +} + +void notify_hellfire_hit(bool resisted) +{ + print_msg("The fires of hell %s\n", resisted ? "lightly singe you." : "burn you!"); +} + +void notify_monster_cursing(int mon) +{ + print_mon_name(mon, 3); + print_msg(" points at you and curses horribly.\n"); +} + +void debug_bad_monspell(int spell) +{ + print_msg("BUG: Attempt by monster to cast bogus/unimplemented spell %d!\n", spell); +} + +void debug_agility_gain(int amount) +{ + print_msg("BUG: Attempt to cause negative agility gain %d\n", amount); +} + +void debug_body_gain(int amount) +{ + print_msg("BUG: Attempt to cause negative body gain %d\n", amount); +} + +/* display-nc.cc */ +// vim:cindent diff --git a/notify.hh b/notify.hh new file mode 100644 index 0000000..2bd58c3 --- /dev/null +++ b/notify.hh @@ -0,0 +1,75 @@ +/*! \file notify.hh + * \brief Notification-related definitions for Victrix Abyssi + */ + +/* Copyright 2014 Martin Read + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NOTIFY_HH +#define NOTIFY_HH + +/* Notification functions */ +void notify_level_gain(void); +void notify_agility_gain(int amount); +void notify_body_gain(int amount); +void notify_hp_gain(int amount); +void notify_player_teleport(void); +void notify_player_telefail(void); +void notify_player_regen(void); +void notify_hunger_level(int severity); +void notify_leadfoot_recovered(void); +void notify_armourmelt_recovered(void); +void notify_wither_recovered(void); +void notify_protection_lost(void); +void notify_start_lavawalk(void); +void notify_blocked_lava(void); +void notify_start_waterwalk(void); +void notify_blocked_water(void); +void notify_obj_at(Coord c); +void notify_swing_bow(void); +void notify_cant_go(void); +void notify_wasted_gain(void); + +/* Sorcery notifications */ +void notify_summon_help(int mon, bool success); +void notify_monster_cursing(int mon); +void notify_mon_disappear(int mon); +void notify_moncurse_fail(void); +void notify_start_armourmelt(void); +void notify_start_withering(void); +void notify_start_leadfoot(void); +void notify_necrosmite_fail(void); +void notify_necrosmite_hit(void); +void notify_hellfire_hit(bool resisted); + +/* Debugging notifications */ +void debug_move_oob(Coord c); +void debug_body_gain(int amount); +void debug_agility_gain(int amount); +void debug_bad_monspell(int spell); + +#endif + +/* notify.hh */ +// vim:cindent -- 2.11.0