aboutsummaryrefslogtreecommitdiff
path: root/internal/game/render_crypto.go
blob: 899f83bdf97ee5fdf5acfc9814c177328df66e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package game

import (
	"thehouseoficarus/internal/casino"
	"thehouseoficarus/internal/net"
)

// Use the same contextual command columns and casino_hints policy as the
// prediction counter and casino tables. Rules are opt-in, never an entry screen.
func (g *Game) cryptoCommands(s *net.Session) []casino.MenuCommand {
	if s.CryptoBusy {
		return []casino.MenuCommand{{Command: "stop", Desc: "Leave and cancel the update"}}
	}
	commands := []casino.MenuCommand{}
	if !s.CryptoUnavailable {
		symbol := s.CryptoSelected
		if symbol == "" {
			symbol = "SYMBOL"
		}
		switch s.CryptoScreen {
		case "view":
			commands = append(commands,
				casino.MenuCommand{Command: "buy " + symbol + " AMOUNT", Desc: "Buy coins"},
				casino.MenuCommand{Command: "short " + symbol + " AMOUNT", Desc: "Back a falling price"},
				casino.MenuCommand{Command: "contracts", Desc: "Trade calls and puts"},
				casino.MenuCommand{Command: "back", Desc: "Return to the currencies"})
		case "contracts":
			commands = append(commands,
				casino.MenuCommand{Command: "quote TYPE " + symbol + " AMOUNT PRICE DAYS", Desc: "Preview a call, put, write-call or write-put"},
				casino.MenuCommand{Command: "option TYPE " + symbol + " AMOUNT PRICE DAYS", Desc: "Buy a call or put"},
				casino.MenuCommand{Command: "write TYPE " + symbol + " AMOUNT PRICE DAYS", Desc: "Write a call or put; risk of debt"},
				casino.MenuCommand{Command: "back", Desc: "Return to the currencies"})
		case "active":
			commands = append(commands, casino.MenuCommand{Command: "close ID", Desc: "Close a whole position"}, casino.MenuCommand{Command: "view SYMBOL", Desc: "View a currency's chart"})
		default:
			commands = append(commands, casino.MenuCommand{Command: "view SYMBOL", Desc: "Choose a currency"})
		}
		commands = append(commands, casino.MenuCommand{Command: "active", Desc: "Your open positions"}, casino.MenuCommand{Command: "closed", Desc: "Your completed trades"})
	}
	if s.Player.Crypto.Balance < 0 {
		commands = append(commands, casino.MenuCommand{Command: "repay CREDITS", Desc: "Pay your exchange debt"})
	} else {
		commands = append(commands, casino.MenuCommand{Command: "fund CREDITS", Desc: "Add trading funds"}, casino.MenuCommand{Command: "withdraw CREDITS", Desc: "Take out available credits"})
	}
	return append(commands, casino.MenuCommand{Command: "rules", Desc: "How to trade"}, casino.MenuCommand{Command: "refresh", Desc: "Update this screen"}, casino.MenuCommand{Command: "stop", Desc: "Leave the counter"})
}
func (g *Game) cryptoHints(s *net.Session, force ...bool) {
	forced := len(force) > 0 && force[0]
	show := g.casinoHintsVisible(s, &casino.MenuView{ShowHints: s.CryptoShowHints})
	s.CryptoShowHints = false
	if !forced && !show {
		return
	}
	s.WriteLine("")
	s.WriteLine(g.renderCasinoCommands(s, "", "", g.cryptoCommands(s)))
}
func (g *Game) cryptoOptions(s *net.Session) {
	s.CryptoScreen = "contracts"
	g.predictionFrame(s, "OPTIONS", []string{
		"Choose a call for a rising price, or a put for a falling price. Preview with quote before buying or writing.",
		"AMOUNT is coins, PRICE is your target, and DAYS is 1, 7 or 30. Writing options can leave you owing credits.",
	})
}