mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 16:42:41 +00:00
- Co-op: when a run wipes or completes, clear the 99-sentinel combat lock for participants and pin combat_actions_used to maxCombatActions. Previously the lock only released on the next midnight reset, so members were stuck unable to combat for the rest of the day after their run ended. - Holidays: !holidays now prints the full list. Previously it called the same featured-only formatter as TwinBee's morning auto-post, so users saw the same truncated message twice with a misleading "Use !holidays for the full list" hint that pointed at itself. - Forex: add currency conversion. Auto-detects when the first arg is numeric (`!fx 1500 USD EUR`) and also accepts an explicit `convert` subcommand. Tolerant parsing: "to"/"into"/"in"/"=" filters, comma and k/m suffix support, and any of `1500 USD EUR`, `1500 USD/EUR`, `USD/EUR 1500` orderings. Includes parser + comma-formatter tests. - Lottery: drop 2-match prize tier. At 1/16 odds × €25 it was +EV per ticket on its own and bled the community pot (~€775/wk recently), preventing jackpot rollover from accumulating. Removed from scoring, payout loops, draw announcement, !lottery odds, and !lottery history. Match2Winners DB column kept (history rows preserved); always written as 0 going forward. - Lottery: shift week boundary so Sat/Sun return next Monday. Friday's 23:59 draw used to leave players locked at their 100-ticket cap until next Monday rolled in; now the cap resets immediately after the draw. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
71 lines
2.2 KiB
Go
71 lines
2.2 KiB
Go
package plugin
|
|
|
|
import "testing"
|
|
|
|
func TestFxParseConvert(t *testing.T) {
|
|
cases := []struct {
|
|
in []string
|
|
amt float64
|
|
base string
|
|
quote string
|
|
shouldErr bool
|
|
}{
|
|
{[]string{"1500", "USD", "EUR"}, 1500, "USD", "EUR", false},
|
|
{[]string{"1500", "USD", "to", "EUR"}, 1500, "USD", "EUR", false},
|
|
{[]string{"1500", "USD", "into", "EUR"}, 1500, "USD", "EUR", false},
|
|
{[]string{"1,500.50", "USD", "EUR"}, 1500.50, "USD", "EUR", false},
|
|
{[]string{"1.5k", "USD", "EUR"}, 1500, "USD", "EUR", false},
|
|
{[]string{"1500", "USD/EUR"}, 1500, "USD", "EUR", false},
|
|
{[]string{"USD/EUR", "1500"}, 1500, "USD", "EUR", false},
|
|
{[]string{"1500", "EUR/USD"}, 1500, "EUR", "USD", false},
|
|
{[]string{"1500", "JPY", "USD"}, 1500, "JPY", "USD", false},
|
|
|
|
{[]string{"USD", "EUR"}, 0, "", "", true}, // no amount
|
|
{[]string{"1500", "USD"}, 0, "", "", true}, // missing quote
|
|
{[]string{"1500", "USD", "USD"}, 0, "", "", true}, // same currency
|
|
{[]string{"1500", "ZZZ", "EUR"}, 0, "", "", true}, // unknown currency
|
|
{[]string{"1500", "USD", "EUR", "JPY"}, 0, "", "", true}, // too many currencies
|
|
{[]string{"1500", "100", "USD", "EUR"}, 0, "", "", true}, // multiple amounts
|
|
{[]string{"-100", "USD", "EUR"}, 0, "", "", true}, // negative
|
|
}
|
|
|
|
for _, c := range cases {
|
|
amt, base, quote, err := fxParseConvert(c.in)
|
|
if c.shouldErr {
|
|
if err == nil {
|
|
t.Errorf("%v: expected error, got %v %s/%s", c.in, amt, base, quote)
|
|
}
|
|
continue
|
|
}
|
|
if err != nil {
|
|
t.Errorf("%v: unexpected error: %v", c.in, err)
|
|
continue
|
|
}
|
|
if amt != c.amt || base != c.base || quote != c.quote {
|
|
t.Errorf("%v: got %v %s/%s, want %v %s/%s", c.in, amt, base, quote, c.amt, c.base, c.quote)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFxAddCommas(t *testing.T) {
|
|
cases := []struct {
|
|
v float64
|
|
decimals int
|
|
want string
|
|
}{
|
|
{1500, 2, "1,500.00"},
|
|
{1500.5, 2, "1,500.50"},
|
|
{1234567.89, 2, "1,234,567.89"},
|
|
{100, 2, "100.00"},
|
|
{0, 2, "0.00"},
|
|
{232500, 0, "232,500"},
|
|
{-1500, 2, "-1,500.00"},
|
|
}
|
|
for _, c := range cases {
|
|
got := fxAddCommas(c.v, c.decimals)
|
|
if got != c.want {
|
|
t.Errorf("fxAddCommas(%v, %d) = %q, want %q", c.v, c.decimals, got, c.want)
|
|
}
|
|
}
|
|
}
|