dont let players heal while at full health
authorxangelo <git@xangelo.ca>
Tue, 6 Jun 2023 15:13:57 +0000 (11:13 -0400)
committerxangelo <git@xangelo.ca>
Tue, 6 Jun 2023 15:14:01 +0000 (11:14 -0400)
src/server/api.ts

index 82992c12e31b77e5b45aa6f662f08d8726cb6e0f..29e556792150b7a70a59c2449f31156ec091319f 100644 (file)
@@ -161,13 +161,18 @@ io.on('connection', async socket => {
 
   socket.on('city:services:healer', async () => {
     let text: string[] = [`Welcome to the <b>Healer</b>`];
-    if(player.gold < 10) {
-      text.push(`Oh wow.. you sure dont have any money on you... I guess I'll heal you for free this time.`);
+    if(player.hp < maxHp(player.constitution, player.level)) {
+      if(player.gold < 10) {
+        text.push(`Oh wow.. you sure dont have any money on you... I guess I'll heal you for free this time.`);
+      }
+      else {
+        text.push('Healing to full health will cost you 10G.');
+      }
+      text.push(`<br><button type="button" class="city-emit-event" data-event="city:service:healer:heal">Heal!</button>`);
     }
     else {
-      text.push('Healing to full health will cost you 10G.');
+      text.push(`You seem like you're in pretty good health right now, not sure I can do anything...`);
     }
-    text.push(`<br><button type="button" class="city-emit-event" data-event="city:service:healer:heal">Heal!</button>`);
 
     socket.emit('city:service:healer', {
       text: text.join("<br>")