Documentation
¶
Index ¶
- Constants
- Variables
- type GameId
- type GameImpl
- func (g *GameImpl) GetNewRatingForPlayer(playerId PlayerId) (rating float64, err error)
- func (g *GameImpl) GetTeam(team Team) (players []*PlayerImpl, err error)
- func (g *GameImpl) GetTeamRating(team Team) (rating float64, err error)
- func (g *GameImpl) GetWinPercentage(team Team) (winRate float64, err error)
- func (g *GameImpl) SetWinner(team Team)
- func (g *GameImpl) UpdatePlayersAfterGame() (updatedPlayers []*PlayerImpl, err error)
- type PlayerId
- type PlayerImpl
- type Role
- type Team
Constants ¶
View Source
const ( LoyalServant Role = "servant" Merlin = "merlin" Percival = "percival" Morgana = "morgana" Assassin = "assassin" MinionOfMordred = "minion" Mordred = "mordred" Oberon = "oberon" )
Variables ¶
View Source
var TeamByRole map[Role]Team = map[Role]Team{ LoyalServant: Blue, Merlin: Blue, Percival: Blue, Morgana: Red, Assassin: Red, MinionOfMordred: Red, Mordred: Red, Oberon: Red, }
View Source
var TimeNow = time.Now
Export for faking
Functions ¶
This section is empty.
Types ¶
type GameImpl ¶
type GameImpl struct { Id GameId Winner Team RoleByPlayerId map[PlayerId]Role CreatedAt time.Time // Keep a static snapshot of players so the game calculation is repeatable PlayersById map[PlayerId]*PlayerImpl // contains filtered or unexported fields }
func NewGame ¶
func NewGame( playersById map[PlayerId]*PlayerImpl, roleByPlayerId map[PlayerId]Role, ) *GameImpl
Creates a new game
func (*GameImpl) GetNewRatingForPlayer ¶
Given a game, return what the update should be for that player
func (*GameImpl) GetTeam ¶
func (g *GameImpl) GetTeam( team Team, ) (players []*PlayerImpl, err error)
Returns a list of players on a team
func (*GameImpl) GetTeamRating ¶
Returns the arthmetic average team rating for a team in the game
func (*GameImpl) GetWinPercentage ¶
Returns the expectation of the team winning, which is:
1/(1 + 10 ** ((r_other - r_team)/400))
cached via teamWinPercentages in game
func (*GameImpl) UpdatePlayersAfterGame ¶
func (g *GameImpl) UpdatePlayersAfterGame() (updatedPlayers []*PlayerImpl, err error)
Returns a list of updated players for when the game is finished
The list of players is deep copied to preserve the game's state
type PlayerImpl ¶
func NewPlayer ¶
func NewPlayer(name string) *PlayerImpl
func (*PlayerImpl) GetUpdateConstant ¶
func (p *PlayerImpl) GetUpdateConstant() float64
Click to show internal directories.
Click to hide internal directories.