adventure: let a player leave town from the web, not only read about it
W5a gave the web two verbs that cost nothing. These are the three that take arguments and spend coins: set out for a zone with a supply loadout, walk back into the run you extracted from, hire the pet sitter for a week or a month. Between them they cover the most common thing anybody does in the game, which until now could only be typed into Matrix. Arguments are the new surface, so they are the thing to be careful with. Nothing in a request is trusted: every zone, loadout and duration is looked up in the offer list gogobee pushed onto that owner's own private row, and the order stores what was found there rather than what was sent. A forged zone resolves to nothing and never becomes an order. gogobee then re-resolves all of it anyway, because an offer is a quote and a quote is not a permission. The money confirm is the equip panel's, lifted: cost, balance, and the balance it leaves. When it does not cover, it says so instead of printing a negative. Verified in a browser rather than only in tests, which is where both real defects came from: the confirm box was appending to the whole panel and so appeared at the bottom of the section instead of under the button that raised it, and button prices printed as EUR45000 above a dialog reading EUR45,000. Claude-Session: https://claude.ai/code/session_012bxpQQJDjC1mTtLN3VVtBQ
This commit is contained in:
@@ -713,6 +713,44 @@ var funcs = template.FuncMap{
|
||||
}
|
||||
return m
|
||||
},
|
||||
// euro formats a whole-euro price with thousands separators. The money confirm
|
||||
// in the browser already does this via toLocaleString, and a button reading
|
||||
// "€45000" above a dialog reading "€45,000" looks like two different prices.
|
||||
"euro": func(n int) string {
|
||||
s := strconv.Itoa(n)
|
||||
neg := strings.HasPrefix(s, "-")
|
||||
if neg {
|
||||
s = s[1:]
|
||||
}
|
||||
for i := len(s) - 3; i > 0; i -= 3 {
|
||||
s = s[:i] + "," + s[i:]
|
||||
}
|
||||
if neg {
|
||||
s = "-" + s
|
||||
}
|
||||
return s
|
||||
},
|
||||
// untilUnix is timeAgo's mirror: how long is LEFT, for a deadline the reader
|
||||
// can still act on. Rounded down deliberately — a window with 47 hours in it
|
||||
// says "1 day left", which is the safe way to be wrong about a deadline.
|
||||
"untilUnix": func(unix int64) string {
|
||||
if unix <= 0 {
|
||||
return ""
|
||||
}
|
||||
d := time.Until(time.Unix(unix, 0))
|
||||
switch {
|
||||
case d <= 0:
|
||||
return "closed"
|
||||
case d < time.Hour:
|
||||
return "less than an hour left"
|
||||
case d < 24*time.Hour:
|
||||
return fmt.Sprintf("%dh left", int(d.Hours()))
|
||||
case d < 48*time.Hour:
|
||||
return "1 day left"
|
||||
default:
|
||||
return fmt.Sprintf("%d days left", int(d.Hours())/24)
|
||||
}
|
||||
},
|
||||
"timeAgo": func(t time.Time) string {
|
||||
d := time.Since(t)
|
||||
switch {
|
||||
|
||||
Reference in New Issue
Block a user