aboutsummaryrefslogtreecommitdiff
path: root/internal/game
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-04 19:32:05 -0400
committerhistoria <[not public]>2026-07-04 19:32:05 -0400
commit7b009e904524f30cbff6346730e8d8fe4b046a6b (patch)
tree2e1b364f9efc4f82ebf67c492642951dfcc13b4b /internal/game
parenta5d4ead1795882d25da7eda53680d2a84590693d (diff)
downloadthehouseoficarus-7b009e904524f30cbff6346730e8d8fe4b046a6b.tar.gz
feat: add casino chips, change drops to chips
Diffstat (limited to 'internal/game')
-rw-r--r--internal/game/cmd_bank.go57
-rw-r--r--internal/game/cmd_color.go1
-rw-r--r--internal/game/cmd_score.go3
-rw-r--r--internal/game/core_utils.go10
-rw-r--r--internal/game/render_prompt.go1
5 files changed, 69 insertions, 3 deletions
diff --git a/internal/game/cmd_bank.go b/internal/game/cmd_bank.go
index bbf600f..06ae828 100644
--- a/internal/game/cmd_bank.go
+++ b/internal/game/cmd_bank.go
@@ -3,6 +3,7 @@ package game
import (
"fmt"
"sort"
+ "strconv"
"strings"
"thehouseoficarus/internal/behavior"
@@ -35,6 +36,8 @@ func (g *Game) handleBankInput(sess *net.Session, input string) {
case "deposit":
if len(parts) < 2 {
sess.WriteLine("Deposit what?")
+ } else if parts[1] == "credits" {
+ g.doBankDepositCredits(sess, parts)
} else if parts[1] == "all" {
g.doBankDepositAll(sess)
} else {
@@ -43,6 +46,8 @@ func (g *Game) handleBankInput(sess *net.Session, input string) {
case "withdraw":
if len(parts) < 2 {
sess.WriteLine("Withdraw what?")
+ } else if parts[1] == "credits" {
+ g.doBankWithdrawCredits(sess, parts)
} else {
g.doBankWithdraw(sess, strings.Join(parts[1:], " "))
}
@@ -52,7 +57,7 @@ func (g *Game) handleBankInput(sess *net.Session, input string) {
g.leaveBank(sess)
return
default:
- sess.WriteLine("Commands: deposit <item>, deposit all, withdraw <item>, browse, leave")
+ sess.WriteLine("Commands: deposit <item>, deposit credits <n>, deposit all, withdraw <item>, withdraw credits <n>, browse, leave")
}
g.writeBankPrompt(sess)
}
@@ -92,7 +97,7 @@ func (g *Game) showBankBrowse(sess *net.Session) {
entries = append(entries, bankEntry{slot: i, name: itemName, id: slot.ItemID, qty: slot.Quantity})
}
- if len(entries) == 0 {
+ if len(entries) == 0 && p.BankedCredits <= 0 {
sess.WriteLine("Your bank is empty.")
return
}
@@ -113,6 +118,10 @@ func (g *Game) showBankBrowse(sess *net.Session) {
for _, line := range t.Render(unicode, p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
+
+ if p.BankedCredits > 0 {
+ sess.WriteLine(g.colorize(sess, "credits_pickup", fmt.Sprintf("Banked credits: %s", formatInt(p.BankedCredits))))
+ }
}
func (g *Game) doBankDeposit(sess *net.Session, input string) {
@@ -326,6 +335,50 @@ func (g *Game) withdrawBankItem(sess *net.Session, p *player.Player, bankSlotIdx
}
}
+func (g *Game) doBankDepositCredits(sess *net.Session, parts []string) {
+ p := sess.Player
+ if len(parts) < 3 {
+ sess.WriteLine("Usage: deposit credits <amount>")
+ return
+ }
+ amount, err := strconv.Atoi(parts[2])
+ if err != nil || amount <= 0 {
+ sess.WriteLine("Invalid amount.")
+ return
+ }
+ if p.Credits < amount {
+ sess.WriteLine("You don't have that many credits.")
+ return
+ }
+ p.Credits -= amount
+ p.BankedCredits += amount
+ g.AccountStore.SaveCharacter(p)
+ sess.WriteLine(g.colorize(sess, "credits_pickup", fmt.Sprintf("You deposit %s credits. (Banked: %s)", formatInt(amount), formatInt(p.BankedCredits))))
+ g.showBankBrowse(sess)
+}
+
+func (g *Game) doBankWithdrawCredits(sess *net.Session, parts []string) {
+ p := sess.Player
+ if len(parts) < 3 {
+ sess.WriteLine("Usage: withdraw credits <amount>")
+ return
+ }
+ amount, err := strconv.Atoi(parts[2])
+ if err != nil || amount <= 0 {
+ sess.WriteLine("Invalid amount.")
+ return
+ }
+ if p.BankedCredits < amount {
+ sess.WriteLine("You don't have that many banked credits.")
+ return
+ }
+ p.BankedCredits -= amount
+ p.Credits += amount
+ g.AccountStore.SaveCharacter(p)
+ sess.WriteLine(g.colorize(sess, "credits_pickup", fmt.Sprintf("You withdraw %s credits.", formatInt(amount))))
+ g.showBankBrowse(sess)
+}
+
func (g *Game) canUseBank(p *player.Player) bool {
instances := g.World.FindObjInstances(p.RoomID, "bank booth")
return len(instances) > 0
diff --git a/internal/game/cmd_color.go b/internal/game/cmd_color.go
index f7041df..a2ec2c4 100644
--- a/internal/game/cmd_color.go
+++ b/internal/game/cmd_color.go
@@ -163,6 +163,7 @@ var colorCategoryOrder = []string{
"eat_food",
"drop_message",
"credits_pickup",
+ "chips_pickup",
"map_at",
"map_blocked",
diff --git a/internal/game/cmd_score.go b/internal/game/cmd_score.go
index 0554f32..b493e80 100644
--- a/internal/game/cmd_score.go
+++ b/internal/game/cmd_score.go
@@ -98,9 +98,10 @@ func (g *Game) doScore(sess *net.Session) {
content(row1)
creditsStr := g.colorize(sess, "credits_pickup", formatInt(p.Credits))
+ chipsStr := g.colorize(sess, "chips_pickup", formatInt(countChips(p)))
styleStr := color.Render(mode, color.Parse("4B"), fmt.Sprintf("Style: %s", p.AttackStyle))
invStr := fmt.Sprintf("Inv: %d/28", 28-p.FreeSlots())
- row2 := padded("Credits: "+creditsStr, 20) + padded(styleStr, 24) + invStr
+ row2 := padded("Credits: "+creditsStr, 19) + padded("Chips: "+chipsStr, 16) + padded(styleStr, 22) + invStr
content(row2)
gap()
diff --git a/internal/game/core_utils.go b/internal/game/core_utils.go
index 2855bcf..71d0acb 100644
--- a/internal/game/core_utils.go
+++ b/internal/game/core_utils.go
@@ -149,3 +149,13 @@ func (g *Game) newInventorySlot(itemID string, qty int) *player.InventorySlot {
}
return slot
}
+
+func countChips(p *player.Player) int {
+ total := 0
+ for _, slot := range p.Inventory {
+ if slot != nil && slot.ItemID == "chips" {
+ total += slot.Quantity
+ }
+ }
+ return total
+}
diff --git a/internal/game/render_prompt.go b/internal/game/render_prompt.go
index 68f1a9a..ad1ba9c 100644
--- a/internal/game/render_prompt.go
+++ b/internal/game/render_prompt.go
@@ -37,6 +37,7 @@ func (g *Game) expandPromptVars(sess *net.Session, text string) string {
text = strings.ReplaceAll(text, "%b", fmt.Sprintf("%.1f", p.Battery))
text = strings.ReplaceAll(text, "%B", fmt.Sprintf("%.0f", p.MaxBattery()))
text = strings.ReplaceAll(text, "%c", fmt.Sprint(p.Credits))
+ text = strings.ReplaceAll(text, "%k", fmt.Sprint(countChips(p)))
text = strings.ReplaceAll(text, "%i", fmt.Sprint(p.FreeSlots()))
text = strings.ReplaceAll(text, "%s", attackStyleShort(p.AttackStyle))
text = strings.ReplaceAll(text, "%S", attackStyleLong(p.AttackStyle))