package antiaddiction
import "github.com/nsgo-dev/game/pkg/online/antiaddiction"Overview
Package antiaddiction is experimental: its API and documented formats may change in a minor release. See the API stability policy. contains server-side age-window and spending rules for mainland China publishing compliance. It has no clock or platform dependency: the server passes its own authoritative time and the statutory holiday dates, and identity verification and login and logout reporting stay in the publisher's or channel's integration.
Index
Functions
func SpendAllowed(age, amount, monthTotal int) boolSpendAllowed reports whether a player of age may pay amount yuan when the payments of the calendar month so far total monthTotal yuan. An adult may pay any amount, a player under 8 or of negative age none, and other minors at most SpendLimit per payment and per month. A negative amount or monthTotal is refused.
func SpendLimit(age int) (perPayment, perMonth int)SpendLimit returns the per-payment and per-calendar-month caps in yuan for a minor's age: 0 and 0 under 8, 50 and 200 from 8 to 15, 100 and 400 from 16 to 17. It returns 0 and 0 for an adult, who has no cap, and for a negative age; SpendAllowed tells the cases apart.
func Window(age int, now time.Time, holidays map[string]bool) (bool, time.Time)Window reports whether a player of age may play at now: always for an adult, and for a minor only from 20:00 to 21:00 Beijing time (Asia/Shanghai) on Friday, Saturday, Sunday and the statutory holidays the caller supplies as "2006-01-02" dates in holidays. The returned until is the next boundary at which the answer may change: the end of the window while it is open, the start of today's window before it opens on an allowed day, and the next midnight otherwise; it is zero for an adult. A negative age, or a system without the Asia/Shanghai zone, is refused.
Types
type AgeBand intAgeBand is the statutory age group of a verified player, which decides the play window and the spending caps.
const (
Unknown AgeBand = iota
Under8
Age8To15
Age16To17
Adult
)The age bands, from Unknown (a negative, unverified age) to Adult (18 and over).