diff --git a/src/doors/u32rr/Alchemisty.c b/src/doors/u32rr/Alchemisty.c index 44457341e176cf3a6d7d36fc5e632f70d128170d..b92d1bc17fed2cea193452c522f24864cd620736 100644 --- a/src/doors/u32rr/Alchemisty.c +++ b/src/doors/u32rr/Alchemisty.c @@ -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(); } diff --git a/src/doors/u32rr/Status.c b/src/doors/u32rr/Status.c index a5b1d62213d49d49e432e51be98d8c38c11c2126..f2e831cdd365d00d612f671e7e348effbd887bb4 100644 --- a/src/doors/u32rr/Status.c +++ b/src/doors/u32rr/Status.c @@ -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': diff --git a/src/doors/u32rr/testmain.c b/src/doors/u32rr/testmain.c index 007b2cfc75c37c6292e4e2e6875474bf48d45b3c..2b0d2df846eaac67551dc35d462bb7d013f064c0 100644 --- a/src/doors/u32rr/testmain.c +++ b/src/doors/u32rr/testmain.c @@ -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) diff --git a/src/doors/u32rr/todo.h b/src/doors/u32rr/todo.h index b4859edaaba894cba3075ea8adeb80ecb180b8ce..0414a8b8a124f67184a43bbd1dbc25294c3041d4 100644 --- a/src/doors/u32rr/todo.h +++ b/src/doors/u32rr/todo.h @@ -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 diff --git a/src/doors/u32rr/various.c b/src/doors/u32rr/various.c index d702c1e0ab288b79772f8306db45eaff23d7d79a..fab2155b6813fddda7116d68742eec29c77e484e 100644 --- a/src/doors/u32rr/various.c +++ b/src/doors/u32rr/various.c @@ -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"); + } + } +} diff --git a/src/doors/u32rr/various.h b/src/doors/u32rr/various.h index b27eb02334db3d52b41fc6c1172a2d8deacf5bb1..c549ebc299f61e00c4775649ae157b99deeb3e02 100644 --- a/src/doors/u32rr/various.h +++ b/src/doors/u32rr/various.h @@ -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