Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DashboardRequestHandler ¶
func DashboardRequestHandler(w http.ResponseWriter, r *http.Request)
DashboardRequestHandler coordinates the response to a dashboard load
func TurnRequestHandler ¶
func TurnRequestHandler(w http.ResponseWriter, r *http.Request)
TurnRequestHandler coordinates the execution of a turn
Types ¶
type DashboardRequest ¶
type DashboardRequest struct {
UserID string `json:"user_id"`
}
DashboardRequest models a request to load a dashboard
type Dice ¶
type Dice struct {
NormFloat64 func() float64
}
Dice permits us to inject random
func (*Dice) NormalRandomAdjustment ¶
type Storefront ¶
type Storefront struct { // status UserID string `json:"user_id" db:"user_id"` Turn int64 `json:"turn" db:"turn"` Backstock int64 `json:"backstock" db:"backstock"` Cash int64 `json:"cash" db:"cash"` // weather CurrentTemperature int64 `json:"cur_temp" db:"cur_temp"` ForecastTemperature int64 `json:"for_temp" db:"for_temp"` CurrentPrecipitation int64 `json:"cur_prec" db:"cur_prec"` ForecastPrecipitation int64 `json:"for_prec" db:"for_prec"` // turn summary Purchased int64 `json:"purchased" db:"purchased"` Prepared int64 `json:"prepared" db:"prepared"` Sales int64 `json:"sales" db:"sales"` Demand int64 `json:"demand" db:"demand"` Waste int64 `json:"waste" db:"waste"` // submitted values Preparing int64 `json:"preparing" db:"preparing"` Purchasing int64 `json:"purchasing" db:"purchasing"` Price int64 `json:"price" db:"price"` }
Storefront is the core game object that records status from turn to turn
func LoadStorefront ¶
func LoadStorefront(ctx context.Context, userID string) (*Storefront, error)
LoadStorefront loads up a storefront from the database
func NewStorefront ¶
func NewStorefront(userID string) *Storefront
NewStorefront creates a storefront for the supplied userID and populates it with defaults
func (*Storefront) ProcessTurn ¶
func (s *Storefront) ProcessTurn(purchasing, preparing, price int64) *Storefront
ProcessTurn is the meat of the game. It advances one turn.
Click to show internal directories.
Click to hide internal directories.