Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 3e54cf49 authored by deuce's avatar deuce

Implement healing.

parent b9820dd0
......@@ -31,6 +31,7 @@ C translation Copyright 2009 Stephen Hurd
#include "IO.h"
#include "Config.h"
#include "Status.h"
#include "macros.h"
#include "files.h"
......@@ -55,7 +56,7 @@ static void Failed_Quest(int level)
BAD("Oh No! You have failed the test! You may try again tomorrow...");
nl();
player->allowed=false;
reduce_player_resurrections(player, true);
Reduce_Player_Resurrections(player, true);
upause();
halt();
}
......
......@@ -312,11 +312,11 @@ static bool HealingMenu(struct player *pl)
switch(ch) {
case 'Q':
quick_healing(pl);
Quick_Healing(pl);
upause();
break;
case 'H':
healing(pl);
Healing(pl);
upause();
break;
case 'D':
......
......@@ -49,36 +49,16 @@ int rand_num(int limit)
return(limit-1);
}
void reduce_player_resurrections(struct player *pl, bool doit)
{
DL("REDUCE PLAYER RESURRECTIONS");
}
void objekt_affect(int i, uint16_t index, enum objtype type, struct player *pl, bool loud)
{
DL("OBJEKT AFFECT");
}
void decplayermoney(struct player *pl, int amount)
{
pl->gold -= amount;
}
void user_save(struct player *pl)
{
DL(lred, "SAVING USER");
}
void quick_healing(struct player *pl)
{
DL(lred,"QUICK HEALING");
}
void healing(struct player *pl)
{
DL(lred,"HEALING");
}
void inventory_display(struct player *pl)
{
DL(lred,"INVENTORY DISPLAY");
......@@ -94,9 +74,9 @@ void Display_Member(struct player *pl, bool doit)
DL(lred,"DISPLAY MEMBER");
}
void Display_Members(const char *team, bool doit)
void Display_Members(const char *team, bool topbar)
{
DL(lred,"DISPLAY MEMBERS");
DL(lred, "DISPLAY MEMBERS");
}
void inventory_sort(struct player *pl)
......
......@@ -49,13 +49,6 @@ void newsy(bool, ...);
*/
int rand_num(int limit);
/*
* Display status for specified player
*/
void status(struct player *);
void reduce_player_resurrections(struct player *, bool);
void objekt_affect(int, uint16_t, enum objtype, struct player *player, bool loud);
/*
......@@ -64,8 +57,6 @@ void objekt_affect(int, uint16_t, enum objtype, struct player *player, bool loud
*/
void user_save(struct player *player);
void decplayermoney(struct player *player, int amount);
extern char *uplc; // Colour string for player name in messages
extern char *uitemc; // Colour string for items in messages
......
......@@ -46,6 +46,16 @@ void Display_Menu(bool force, bool terse, bool *refresh, const char *name, const
}
}
void Reduce_Player_Resurrections(struct player *pl, bool typeinfo)
{
if(pl->resurrections > 0)
pl->resurrections--;
if(pl->resurrections < 0)
pl->allowed=false;
if(typeinfo)
DL(config.textcolor, "You have ", white, commastr(pl->resurrections), config.textcolor, " resurrection", pl->resurrections>1?"s":"", " left today.");
}
long level_raise(int level, long exp)
{
if(levels[level].xpneed <= exp)
......@@ -112,3 +122,82 @@ const char *immunity(int val)
return "very poor";
}
void decplayermoney(struct player *pl, long coins)
{
pl->gold -= coins;
if(pl->gold < 0)
pl->gold=0;
}
void Quick_Healing(struct player *pl)
{
int quaff;
int regain;
nl();
if(pl->hps >= pl->maxhps)
DL(yellow, "You don't need healing.");
if(pl->hps < pl->maxhps && pl->healing==0)
DL(lred, "You need healing, but don't have any potions!");
if(pl->hps < pl->maxhps && pl->healing > 0) {
quaff=(pl->maxhps-pl->hps)/5;
regain=quaff*5;
if(pl->hps + regain < pl->maxhps)
quaff++;
DL(config.textcolor, "You need ", yellow, commastr(quaff), config.textcolor, quaff==1?" potion.":" potions.");
if(quaff>pl->healing)
quaff=pl->healing;
pl->healing -= quaff;
regain=quaff*5;
if(pl->hps+regain > pl->maxhps)
regain=pl->maxhps-pl->hps;
pl->hps += regain;
DL(config.textcolor, "You quaffed ", white, commastr(quaff), config.textcolor, quaff==1?" potion":" potions", " and regained ",white,commastr(regain), config.textcolor, " hitpoints.");
DL(config.textcolor, "You have ", white, commastr(pl->healing), pl->healing==1?" potion":" potions", " left.");
}
}
void Healing(struct player *pl)
{
int quaff, regain;
nl();
if(pl->hps == pl->maxhps)
DL(config.textcolor, "Yoy don't need healing.");
if(pl->hps < pl->maxhps) {
DL(config.textcolor, "You have ",white,commastr(pl->healing),config.textcolor, " healing potions.");
DL(config.textcolor, "Quaff how many potions");
D(config.textcolor, ":");
quaff=get_number(0,pl->healing);
if(quaff <= pl->healing && quaff > 0) {
regain=quaff*5;
if(regain+pl->hps > pl->maxhps) {
if(regain+pl->hps > pl->maxhps+4) {
quaff=(pl->maxhps - pl->hps)/5;
regain=quaff*5;
if(pl->hps+regain < pl->maxhps) {
quaff++;
}
regain=quaff*5;
DL(lred, "You only need ", white, commastr(quaff), lred, quaff==1?" potion.":" potions.");
}
if(regain+pl->hps > pl->maxhps)
regain=pl->maxhps - pl->hps;
}
pl->healing -= quaff;
pl->hps += regain;
DL(config.textcolor, "You quaffed ",white,commastr(quaff),config.textcolor, quaff==1?" potion":" potions");
DL(config.textcolor, "You regained ",white,commastr(regain),config.textcolor, regain==1?" hitpoint (":" hitpoints (",commastr(pl->hps),"/",commastr(pl->maxhps),")");
DL(config.textcolor, "You have ",white,commastr(pl->healing),config.textcolor, pl->healing==1?" potion left":"potions left");
}
}
}
......@@ -7,5 +7,9 @@ void Display_Menu(bool force, bool terse, bool *refresh, const char *name, const
long level_raise(int level, long exp);
struct object *items(enum objtype type);
const char *immunity(int val);
void Reduce_Player_Resurrections(struct player *pl, bool typeinfo);
void decplayermoney(struct player *pl, long coins);
void Quick_Healing(struct player *pl);
void Healing(struct player *pl);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment