Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrGameAlreadyPlaying = errors.New("game is already playing") ErrGameAlreadyFinished = errors.New("game is already finished") ErrGameNotPlaying = errors.New("game is not playing") )
View Source
var (
ErrInsufficientCoins = errors.New("insufficient coins")
)
View Source
var (
ErrUserDeactivated = errors.New("user is deactivated")
)
Functions ¶
This section is empty.
Types ¶
type GameResult ¶
type GameResult int
const ( GameResultUnknown GameResult = iota GameResultWin GameResultLose GameResultDraw )
type GameSession ¶
type GameSession struct { ID uuid.UUID UserID uuid.UUID GameID GameID Status GameStatus Result GameResult Wager Coins Payout Coins StartedAt time.Time FinishedAt time.Time }
GameSession は、PvE ゲームのセッションを表します。
func NewGameSession ¶
func NewGameSession(id uuid.UUID, userID uuid.UUID, gameID GameID, status GameStatus, result GameResult, wager Coins, payout Coins, startedAt time.Time, finishedAt time.Time) (GameSession, error)
func (*GameSession) FinishPlaying ¶
func (g *GameSession) FinishPlaying(result GameResult, now time.Time) (Coins, error)
func (GameSession) IsPlaying ¶
func (g GameSession) IsPlaying() bool
type GameSessionStartService ¶
type GameSessionStartService struct {
// contains filtered or unexported fields
}
func NewGameSessionService ¶
func NewGameSessionService(ctx context.Context, userID uuid.UUID, playingSessions []GameSession) (GameSessionStartService, error)
func (*GameSessionStartService) StartPlaying ¶
func (s *GameSessionStartService) StartPlaying(id uuid.UUID, gameID GameID, wager Coins, now time.Time) (GameSession, error)
type GameStatus ¶
type GameStatus int
const ( GameStatusPlaying GameStatus = iota + 1 GameStatusFinished )
type JankenHand ¶
type JankenHand int
const ( JankenHandRock JankenHand = iota + 1 JankenHandScissors JankenHandPaper )
func (JankenHand) Battle ¶
func (mine JankenHand) Battle(opponent JankenHand) GameResult
type JankenHistory ¶
type JankenHistory struct { Turn int MyHand JankenHand OpponentHand JankenHand }
func NewJankenHistory ¶
func NewJankenHistory(turn int, myHand JankenHand, opponentHand JankenHand) JankenHistory
type JankenSession ¶
type JankenSession struct { GameSessionID uuid.UUID Seed int Histories []JankenHistory }
func NewJankenSession ¶
func NewJankenSession(gameSessionID uuid.UUID, seed int, histories []JankenHistory) JankenSession
func (*JankenSession) Choose ¶
func (j *JankenSession) Choose(session GameSession, hand JankenHand, now time.Time) (GameSession, Coins, JankenHistory, error)
type JankenSessionStartService ¶
type JankenSessionStartService struct {
GameSessionStartService
}
func NewJankenSessionStartService ¶
func NewJankenSessionStartService(ctx context.Context, userID uuid.UUID, playingSessions []GameSession) (JankenSessionStartService, error)
func (JankenSessionStartService) StartPlaying ¶
func (s JankenSessionStartService) StartPlaying(id uuid.UUID, wager Coins, now time.Time) (GameSession, JankenSession, error)
type User ¶
type User struct { ID uuid.UUID Status UserStatus }
type UserStatus ¶ added in v0.2.0
type UserStatus int
const ( // 設定が未完了で、他ユーザには公開されていない状態。 // サインイン後、設定を完了するまでこの状態が続く。 UserStatusPending UserStatus = 1 + iota // アカウントが利用可能で、他ユーザにも公開されている状態。 UserStatusActive // アカウントが削除され、利用不可な状態。 // この状態になると、二度と利用できなくなる。 UserStatusDeactivated )
Click to show internal directories.
Click to hide internal directories.