Documentation ¶
Index ¶
- Constants
- Variables
- type Game
- func (g *Game) AttachOperation(op *Operation)
- func (g *Game) Extend(timeSecond int)
- func (g *Game) Flee(user *User)
- func (g *Game) ForceStart() error
- func (g *Game) GetPlayer(tgUserID int64) *Player
- func (g *Game) GetPosition(x, y int) *Position
- func (g *Game) GetUser(tgUserID int64) *User
- func (g *Game) HintPlayers()
- func (g *Game) Join(user *User)
- func (g *Game) RunCheck()
- func (g *Game) Start() error
- func (g *Game) String() string
- type GameMode
- type GameStatus
- type Group
- type Operation
- type Player
- func (p *Player) Abort() *Operation
- func (p *Player) ActionClear()
- func (p *Player) Betray() *Operation
- func (p *Player) GetPositionString() string
- func (p *Player) Kill(reason PlayerKilledReason)
- func (p *Player) SetTrap() *Operation
- func (p *Player) Shoot(betray bool, pos *Position) *Operation
- func (p *Player) StatusChange(stage ...int)
- func (p *Player) String() string
- func (p *Player) Union(fromPlayer *Player)
- func (p *Player) UnionCorrection()
- func (p *Player) UnionValidation() bool
- func (p *Player) Ununion()
- type PlayerAction
- type PlayerKilledReason
- type Position
- type QueueElement
- type Role
- type TgGroup
- type UnionReqRecv
- type User
- type UserAchivement
Constants ¶
View Source
const ( GameNotStart GameStatus = 0 GameStart GameStatus = 1 GameOver GameStatus = 2 GameIsDay = true GameIsNight = !GameIsDay GameMinPlayers = 6 )
List of game status
View Source
const ( PlayerLive = true PlayerDead = false PlayerStatusNormal = 0 PlayerStatusXExposed = 1 PlayerStatusYExposed = 2 PlayerStatusBeast = 3 PlayerSetTrap = true PlayerUnsetTrap = false PlayerUnionBetrayed = true PlayerUnionNotBetrayed = !PlayerUnionBetrayed PlayerShootNone = -1 PlayerShootNoneStreakLimit = 3 )
List of some consts
View Source
const ( AchivementGamesJoined = iota // 0 AchivementGamesWon // 1 AchivementShoot // 2 AchivementBetray // 3 AchivementKill // 4 AchivementGuessKill // 5 AchivementSniperKill // 6 AchivementKilledByTrap // 7 AchivementTrap // 8 AchivementUnion // 9 AchivementUnionSuccess // 10 AchivementBeUnioned // 11 )
List of achivement code
Variables ¶
View Source
var ( NewGameHint chan *Game UserJoinHint chan *User GameFleeHint chan *User GameNoFleeHint chan *User NotEnoughPlayersHint chan *Game JoinTimeLeftHint chan *Game TryStartGameHint chan *Game StartGameFailed chan *Game StartGameSuccess chan *Game GameTimeOutOperation chan *Game AbortPlayerHint chan *Player GameChangeToNightHint chan *Game GameChangeToDayHint chan *Game GameLoseHint chan *Game WinGameHint chan *Game PlayersHint chan *Game // Change player list PlayerKillHint chan *Player PlayerBeastHint chan *Player GetPlayersHint chan *Game UserStatsHint chan *User ShootXHint chan *Player ShootYHint chan *Player UnionReqHint chan []*Player //Player[0]: Src, Player[1]: Dst UnionAcceptHint chan []*Player UnionRejectHint chan []*Player UnionHasOneHint chan []*Player UnionInvalidHint chan *Player AchivementRewardedHint chan UserAchivement PlayerSurvivedAtNightHint chan *Player PlayerShootNothingHint chan *Player PlayerShootSomethingHint chan *Player ShootApprovedHint chan *Operation )
List of channels
Functions ¶
This section is empty.
Types ¶
type Game ¶
type Game struct { Round int IsDay bool Founder *User Users []*User Status GameStatus Positions []*Position Players []*Player TgGroup *TgGroup TimeLeft int MsgSent *msgSent Operations []*Operation // Every round will clear GlobalOperations [][]*globalOperation Cron *cron.Cron Winner *Player }
Game is
type Operation ¶
type Operation struct { Player *Player Action PlayerAction Target *Position }
Operation is
func NewOperation ¶
func NewOperation(player *Player, act PlayerAction, target *Position) *Operation
NewOperation is
type Player ¶
type Player struct { User *User Live bool KilledReason PlayerKilledReason Position *Position // two-way bond Unioned *Player Grouped *Group Role *Role //TODO: soon tm Status int TrapSet bool ShootX int // Every round clear ShootY int // Every round clear UnionReqRecv []*UnionReqRecv UnionReq int OperationMsg int Target *Player // Will kill whom HintBeast bool CurrentGamePlayersCount int ShootNoneStreak int }
Player is used in redis
func (*Player) GetPositionString ¶
GetPositionString is a backup method
type PlayerAction ¶
type PlayerAction int
PlayerAction is
const ( Shoot PlayerAction = 0 Abort PlayerAction = 1 // No action or timed out. Trap PlayerAction = 2 Betray PlayerAction = 3 )
List of player actions
type PlayerKilledReason ¶
type PlayerKilledReason int
PlayerKilledReason is
const ( None PlayerKilledReason = -1 Shot PlayerKilledReason = 0 Betrayed PlayerKilledReason = 1 Trapped PlayerKilledReason = 2 Flee PlayerKilledReason = 3 EatenByBeast PlayerKilledReason = 4 BeastKill PlayerKilledReason = 5 // Beasts killed each other )
List of KilledReason
type Position ¶
Position is used in game
func NewPosition ¶
NewPosition is to create new position for play
type QueueElement ¶
QueueElement is
func NewQueueElement ¶
func NewQueueElement(userID int64, messageID int) QueueElement
NewQueueElement is
type TgGroup ¶
type TgGroup struct { ID int TgGroupID int64 `gorm:"unique;not null"` Name string `gorm:"not null"` AdminID int Admin *User Lang string `gorm:"default:\"English\""` Mode GameMode `gorm:"default:0"` Active bool `gorm:"default:1"` }
TgGroup is used in database
type UnionReqRecv ¶
UnionReqRecv is
func NewUnionReqRecv ¶
func NewUnionReqRecv(msg tgApi.Message, from *Player) *UnionReqRecv
NewUnionReqRecv is
type User ¶
type User struct { ID int TgUserID int64 `gorm:"unique;not null;size:50"` TgUserName string `gorm:"key;not null;size:255"` Name string `gorm:"not null"` Language string `gorm:"default:\"English\""` //User stats GamesJoined int `gorm:"default:0;not null"` GamesJoinedAchive int `gorm:"default:0;not null"` GamesWon int `gorm:"default:0;not null"` GamesWonAchive int `gorm:"default:0;not null"` ShootCount int `gorm:"default:0;not null"` ShootAchive int `gorm:"default:0;not null"` BetrayCount int `gorm:"default:0;not null"` BetrayAchive int `gorm:"default:0;not null"` KillCount int `gorm:"default:0;not null"` KillAchive int `gorm:"default:0;not null"` GuessKillCount int `gorm:"default:0;not null"` GuessKillCountAchive int `gorm:"default:0;not null"` SniperKillCount int `gorm:"default:0;not null"` SniperKillCountAchive int `gorm:"default:0;not null"` KilledByTrapCount int `gorm:"default:0;not null"` KilledByTrapAchive int `gorm:"default:0;not null"` TrapCount int `gorm:"default:0;not null"` TrapAchive int `gorm:"default:0;not null"` UnionCount int `gorm:"default:0;not null"` UnionAchive int `gorm:"default:0;not null"` UnionSuccessCount int `gorm:"default:0;not null"` UnionSuccessAchive int `gorm:"default:0;not null"` BeUnionedCount int `gorm:"default:0;not null"` BeUnionedAchive int `gorm:"default:0;not null"` AchiveRewardedCount int `gorm:"default:0;not null"` //Wont record into database below QueryMsg *tgApi.Message `gorm:"-"` TgGroupJoinGame *TgGroup `gorm:"-"` }
User is used in database
func (*User) CheckAchivement ¶
func (u *User) CheckAchivement()
CheckAchivement is every achivement has only 5 levels(0-4)
Click to show internal directories.
Click to hide internal directories.