fix: level <= 3 is free healing
authorxangelo <git@xangelo.ca>
Tue, 4 Jul 2023 15:18:23 +0000 (11:18 -0400)
committerxangelo <git@xangelo.ca>
Tue, 4 Jul 2023 15:18:23 +0000 (11:18 -0400)
src/events/healer/server.ts

index f621c41939af33dc7597bb0d97708fe4534ade69..43479544bfcf6768cb02f0db5414d1101d67d91a 100644 (file)
@@ -105,15 +105,21 @@ export const healer: SocketEvent = {
     text.push(`<p><b>${service.name}</b></p>`);
     text.push(`<p>"${getText('intro', service, city)}"</p>`);
 
+
     if(api.player.hp === maxHp(api.player.constitution, api.player.level)) {
       text.push(`<p>You're already at full health?</p>`);
     }
     else {
-      text.push(`<p><button type="button" class="city-emit-event" data-event="city:services:healer:heal" data-args="${service.id}">Heal for ${healCost}g!</button></p>`);
+      if(api.player.level <= 3) {
+        text.push(`<p>Since you still seem to be new around here, this one's on the house!</p>`);
+        text.push(`<p><button type="button" class="city-emit-event" data-event="city:services:healer:heal" data-args="${service.id}">Heal for free!</button></p>`);
+      }
+      else {
+        text.push(`<p><button type="button" class="city-emit-event" data-event="city:services:healer:heal" data-args="${service.id}">Heal for ${healCost}g!</button></p>`);
+      }
     }
 
 
-
     api.socket.emit('city:service:healer', {
       text: text.join("\n")
     });
@@ -139,7 +145,9 @@ export const heal: SocketEvent = {
 
     text.push(`<p><b>${service.name}</b></p>`);
 
-    if(api.player.gold < healCost) {
+    const cost = api.player.level <= 3 ? 0 : healCost;
+
+    if(api.player.gold < cost) {
       text.push(`<p>${getText('insufficient_money', service, city)}</p>`)
       api.socket.emit('city:service:healer', {
         text: text.join("\n")
@@ -148,7 +156,7 @@ export const heal: SocketEvent = {
     }
 
     api.player.hp = maxHp(api.player.constitution, api.player.level);
-    api.player.gold -= healCost;
+    api.player.gold -= cost;
 
     await updatePlayer(api.player);
     api.socket.emit('updatePlayer', api.player);