Documentation
¶
Overview ¶
Package game implements treasure hunting game.
Package game is a generated GoMock package.
Index ¶
- Variables
- type Area
- type Config
- type Coord
- type Ctx
- type Factory
- type Game
- type License
- type MockGame
- func (m *MockGame) Balance() (int, []int)
- func (m *MockGame) Cash(pos Coord) ([]int, error)
- func (m *MockGame) CountTreasures(area Area, depth uint8) (int, error)
- func (m *MockGame) Dig(licenseID int, pos Coord) (bool, error)
- func (m *MockGame) EXPECT() *MockGameMockRecorder
- func (m *MockGame) IssueLicense(wallet []int) (License, error)
- func (m *MockGame) Licenses() []License
- func (m *MockGame) WriteTo(w io.Writer) (int64, error)
- type MockGameMockRecorder
- func (mr *MockGameMockRecorder) Balance() *gomock.Call
- func (mr *MockGameMockRecorder) Cash(pos interface{}) *gomock.Call
- func (mr *MockGameMockRecorder) CountTreasures(area, depth interface{}) *gomock.Call
- func (mr *MockGameMockRecorder) Dig(licenseID, pos interface{}) *gomock.Call
- func (mr *MockGameMockRecorder) IssueLicense(wallet interface{}) *gomock.Call
- func (mr *MockGameMockRecorder) Licenses() *gomock.Call
- func (mr *MockGameMockRecorder) WriteTo(w interface{}) *gomock.Call
- type TreasureValueAlg
Constants ¶
This section is empty.
Variables ¶
var ( ErrActiveLicenseLimit = errors.New("no more active licenses allowed") ErrNoThreasure = errors.New("no treasure") ErrBogusCoin = errors.New("bogus coin") ErrNoSuchLicense = errors.New("no such license") ErrNotDigged = errors.New("treasure is not digged") ErrWrongCoord = errors.New("wrong coordinates") ErrWrongDepth = errors.New("wrong depth") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Seed int64 MaxActiveLicenses int Density int // About one treasure per Density cells. SizeX int SizeY int Depth uint8 TreasureValue *[]int // Pointer to keep this struct comparable. TreasureValueAlg TreasureValueAlg }
Config contains game configuration.
type Factory ¶ added in v0.3.0
type Factory struct{}
Factory implements app.GameFactory interface.
type Game ¶
type Game interface { // WriteTo saves current game state. WriteTo(w io.Writer) (n int64, err error) // Balance returns current balance and up to 1000 issued coins. Balance() (balance int, wallet []int) // Licenses returns all active licenses. Licenses() []License // IssueLicense creates and returns a new license with given digAllowed. // Errors: ErrActiveLicenseLimit, ErrBogusCoin. IssueLicense(wallet []int) (License, error) // CountTreasures returns amount of not-digged-yet treasures in the area // at depth. // Errors: ErrWrongCoord, ErrWrongDepth. CountTreasures(area Area, depth uint8) (int, error) // Dig tries to dig at pos and returns if any treasure was found. // The pos depth must be next to current (already digged) one. // Also it increment amount of used dig calls in given active license. // If amount of used dig calls became equal to amount of allowed dig calls // then license will became inactive after the call. // Errors: ErrNoSuchLicense, ErrWrongCoord, ErrWrongDepth. Dig(licenseID int, pos Coord) (found bool, _ error) // Cash returns coins earned for treasure as given pos. // Errors: ErrWrongCoord, ErrNotDigged, ErrAlreadyCached. Cash(pos Coord) (wallet []int, err error) }
Game implements treasure hunting game.
type MockGame ¶
type MockGame struct {
// contains filtered or unexported fields
}
MockGame is a mock of Game interface
func NewMockGame ¶
func NewMockGame(ctrl *gomock.Controller) *MockGame
NewMockGame creates a new mock instance
func (*MockGame) CountTreasures ¶
CountTreasures mocks base method
func (*MockGame) EXPECT ¶
func (m *MockGame) EXPECT() *MockGameMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockGame) IssueLicense ¶
IssueLicense mocks base method
type MockGameMockRecorder ¶
type MockGameMockRecorder struct {
// contains filtered or unexported fields
}
MockGameMockRecorder is the mock recorder for MockGame
func (*MockGameMockRecorder) Balance ¶
func (mr *MockGameMockRecorder) Balance() *gomock.Call
Balance indicates an expected call of Balance
func (*MockGameMockRecorder) Cash ¶
func (mr *MockGameMockRecorder) Cash(pos interface{}) *gomock.Call
Cash indicates an expected call of Cash
func (*MockGameMockRecorder) CountTreasures ¶
func (mr *MockGameMockRecorder) CountTreasures(area, depth interface{}) *gomock.Call
CountTreasures indicates an expected call of CountTreasures
func (*MockGameMockRecorder) Dig ¶
func (mr *MockGameMockRecorder) Dig(licenseID, pos interface{}) *gomock.Call
Dig indicates an expected call of Dig
func (*MockGameMockRecorder) IssueLicense ¶
func (mr *MockGameMockRecorder) IssueLicense(wallet interface{}) *gomock.Call
IssueLicense indicates an expected call of IssueLicense
func (*MockGameMockRecorder) Licenses ¶
func (mr *MockGameMockRecorder) Licenses() *gomock.Call
Licenses indicates an expected call of Licenses
func (*MockGameMockRecorder) WriteTo ¶ added in v0.3.0
func (mr *MockGameMockRecorder) WriteTo(w interface{}) *gomock.Call
WriteTo indicates an expected call of WriteTo
type TreasureValueAlg ¶ added in v1.0.0
type TreasureValueAlg int
TreasureValueAlg define which algorithm to use for calculating min/max treasure value range at given depth.
const ( // AlgDoubleMax generates treasure values in range x…x*2 // where x is Config.TreasureValue[depth]. AlgDoubleMax TreasureValueAlg = iota + 1 // AlgQuarterAround generates treasure values in range x*0.75…x*1.25 // where x is Config.TreasureValue[depth]. AlgQuarterAround )