diff options
| author | historia <[not public]> | 2026-07-04 19:32:05 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-04 19:32:05 -0400 |
| commit | 7b009e904524f30cbff6346730e8d8fe4b046a6b (patch) | |
| tree | 2e1b364f9efc4f82ebf67c492642951dfcc13b4b /internal/game/cmd_bank.go | |
| parent | a5d4ead1795882d25da7eda53680d2a84590693d (diff) | |
| download | thehouseoficarus-7b009e904524f30cbff6346730e8d8fe4b046a6b.tar.gz | |
feat: add casino chips, change drops to chips
Diffstat (limited to 'internal/game/cmd_bank.go')
| -rw-r--r-- | internal/game/cmd_bank.go | 57 |
1 files changed, 55 insertions, 2 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 |
