Documentation
¶
Index ¶
- Constants
- Variables
- func RolesFromConfig(config Config) (map[Role]int, error)
- type Agent
- type BroadcastPacket
- type Config
- type Connection
- type CustomProfileConfig
- type DynamicProfileConfig
- type GameConfig
- type GameLoggerConfig
- type GameStatus
- type Guard
- type Info
- type JSONLoggerConfig
- type Judge
- type LogicConfig
- type MatchWeight
- type MatchingConfig
- type Packet
- type Phase
- type Profile
- type RealtimeBroadcasterConfig
- type Request
- type Role
- type ServerConfig
- type Setting
- type Species
- type Status
- type TTSBroadcasterConfig
- type Talk
- type TalkConfig
- type TalkSetting
- type Team
- type Vote
Constants ¶
View Source
const ( T_OVER = "Over" T_SKIP = "Skip" T_FORCE_SKIP = "ForceSkip" )
Variables ¶
View Source
var ( R_NAME = Request{ Type: "NAME", RequireResponse: true, } R_TALK = Request{ Type: "TALK", RequireResponse: true} R_WHISPER = Request{ Type: "WHISPER", RequireResponse: true} R_VOTE = Request{ Type: "VOTE", RequireResponse: true} R_DIVINE = Request{ Type: "DIVINE", RequireResponse: true} R_GUARD = Request{ Type: "GUARD", RequireResponse: true} R_ATTACK = Request{ Type: "ATTACK", RequireResponse: true} R_INITIALIZE = Request{ Type: "INITIALIZE", RequireResponse: false} R_DAILY_INITIALIZE = Request{ Type: "DAILY_INITIALIZE", RequireResponse: false} R_DAILY_FINISH = Request{ Type: "DAILY_FINISH", RequireResponse: false} R_FINISH = Request{ Type: "FINISH", RequireResponse: false} )
View Source
var ( R_WEREWOLF = Role{Name: "WEREWOLF", Team: T_WEREWOLF, Species: S_WEREWOLF} R_POSSESSED = Role{Name: "POSSESSED", Team: T_WEREWOLF, Species: S_HUMAN} R_SEER = Role{Name: "SEER", Team: T_VILLAGER, Species: S_HUMAN} R_BODYGUARD = Role{Name: "BODYGUARD", Team: T_VILLAGER, Species: S_HUMAN} R_VILLAGER = Role{Name: "VILLAGER", Team: T_VILLAGER, Species: S_HUMAN} R_MEDIUM = Role{Name: "MEDIUM", Team: T_VILLAGER, Species: S_HUMAN} R_NONE = Role{Name: "NONE", Team: T_NONE, Species: S_NONE} )
Functions ¶
Types ¶
type Agent ¶
type Agent struct { Idx int TeamName string OriginalName string GameName string Profile *Profile ProfileDescription *string Role Role Connection *websocket.Conn HasError bool }
func NewAgentWithProfile ¶ added in v0.3.1
func (Agent) MarshalJSON ¶
func (*Agent) SendPacket ¶
type BroadcastPacket ¶
type BroadcastPacket struct { Id string `json:"id"` Idx int `json:"idx"` Day int `json:"day"` IsDay bool `json:"is_day"` Agents []struct { Idx int `json:"idx"` Team string `json:"team"` Name string `json:"name"` Profile *string `json:"profile,omitempty"` Avatar *string `json:"avatar,omitempty"` Role string `json:"role"` IsAlive bool `json:"is_alive"` } `json:"agents"` Event string `json:"event"` Message *string `json:"message,omitempty"` FromIdx *int `json:"from_idx,omitempty"` ToIdx *int `json:"to_idx,omitempty"` BubbleIdx *int `json:"bubble_idx,omitempty"` }
type Config ¶
type Config struct { Server ServerConfig `yaml:"server"` Game GameConfig `yaml:"game"` Logic LogicConfig `yaml:"logic"` Matching MatchingConfig `yaml:"matching"` CustomProfile CustomProfileConfig `yaml:"custom_profile"` JSONLogger JSONLoggerConfig `yaml:"json_logger"` GameLogger GameLoggerConfig `yaml:"game_logger"` RealtimeBroadcaster RealtimeBroadcasterConfig `yaml:"realtime_broadcaster"` TTSBroadcaster TTSBroadcasterConfig `yaml:"tts_broadcaster"` }
func LoadFromPath ¶
type Connection ¶
type Connection struct { TeamName string OriginalName string Conn *websocket.Conn Header *http.Header }
func NewConnection ¶
type CustomProfileConfig ¶ added in v0.4.5
type CustomProfileConfig struct { Enable bool `yaml:"enable"` ProfileEncoding map[string]string `yaml:"profile_encoding"` Profiles []Profile `yaml:"profiles"` DynamicProfile DynamicProfileConfig `yaml:"dynamic_profile"` }
type DynamicProfileConfig ¶ added in v0.4.8
type GameConfig ¶ added in v0.4.5
type GameConfig struct { AgentCount int `yaml:"agent_count"` MaxDay int `yaml:"max_day"` VoteVisibility bool `yaml:"vote_visibility"` Talk TalkConfig `yaml:"talk"` Whisper TalkConfig `yaml:"whisper"` Vote struct { MaxCount int `yaml:"max_count"` AllowSelfVote bool `yaml:"allow_self_vote"` } `yaml:"vote"` AttackVote struct { MaxCount int `yaml:"max_count"` AllowSelfVote bool `yaml:"allow_self_vote"` AllowNoTarget bool `yaml:"allow_no_target"` } `yaml:"attack_vote"` }
type GameLoggerConfig ¶ added in v0.4.3
type GameStatus ¶
type GameStatus struct { Day int MediumResult *Judge DivineResult *Judge ExecutedAgent *Agent AttackedAgent *Agent Guard *Guard Votes []Vote AttackVotes []Vote Talks []Talk Whispers []Talk StatusMap map[Agent]Status RemainCountMap *map[Agent]int RemainLengthMap *map[Agent]int RemainSkipMap *map[Agent]int }
func NewInitializeGameStatus ¶
func NewInitializeGameStatus(agents []*Agent) GameStatus
func (GameStatus) NextDay ¶
func (g GameStatus) NextDay() GameStatus
type Info ¶
type Info struct { GameID string `json:"game_id"` Day int `json:"day"` Agent *Agent `json:"agent"` Profile *string `json:"profile,omitempty"` MediumResult *Judge `json:"medium_result,omitempty"` DivineResult *Judge `json:"divine_result,omitempty"` ExecutedAgent *Agent `json:"executed_agent,omitempty"` AttackedAgent *Agent `json:"attacked_agent,omitempty"` VoteList []Vote `json:"vote_list,omitempty"` AttackVoteList []Vote `json:"attack_vote_list,omitempty"` TalkList []Talk `json:"-"` WhisperList []Talk `json:"-"` StatusMap map[Agent]Status `json:"status_map"` RoleMap map[Agent]Role `json:"role_map"` RemainCount *int `json:"remain_count,omitempty"` RemainLength *int `json:"remain_length,omitempty"` RemainSkip *int `json:"remain_skip,omitempty"` }
func (Info) MarshalJSON ¶
type JSONLoggerConfig ¶ added in v0.4.3
type LogicConfig ¶ added in v0.4.3
type MatchWeight ¶
type MatchWeight struct { RoleIdxs map[Role][]int `json:"role_idxs"` Weight float64 `json:"weight"` }
func (MatchWeight) Equal ¶
func (mw MatchWeight) Equal(other MatchWeight) bool
func (MatchWeight) MarshalJSON ¶
func (mw MatchWeight) MarshalJSON() ([]byte, error)
type MatchingConfig ¶ added in v0.4.5
type RealtimeBroadcasterConfig ¶ added in v0.4.3
type ServerConfig ¶ added in v0.4.5
type ServerConfig struct { WebSocket struct { Host string `yaml:"host"` Port int `yaml:"port"` } `yaml:"web_socket"` Authentication struct { Enable bool `yaml:"enable"` } `yaml:"authentication"` Timeout struct { Action time.Duration `yaml:"action"` Response time.Duration `yaml:"response"` Acceptable time.Duration `yaml:"acceptable"` } `yaml:"timeout"` MaxContinueErrorRatio float64 `yaml:"max_continue_error_ratio"` }
type Setting ¶
type Setting struct { AgentCount int `json:"agent_count"` MaxDay *int `json:"max_day,omitempty"` RoleNumMap map[Role]int `json:"role_num_map"` VoteVisibility bool `json:"vote_visibility"` Talk struct { TalkSetting `json:",inline"` } `json:"talk"` Whisper struct { TalkSetting `json:",inline"` } `json:"whisper"` Vote struct { MaxCount int `json:"max_count"` AllowSelfVote bool `json:"allow_self_vote"` } `json:"vote"` AttackVote struct { MaxCount int `json:"max_count"` AllowSelfVote bool `json:"allow_self_vote"` AllowNoTarget bool `json:"allow_no_target"` } `json:"attack_vote"` Timeout struct { Action int `json:"action"` Response int `json:"response"` } `json:"timeout"` }
func NewSetting ¶
func (Setting) MarshalJSON ¶
type TTSBroadcasterConfig ¶ added in v0.4.3
type TTSBroadcasterConfig struct { Enable bool `yaml:"enable"` Async bool `yaml:"async"` TargetDuration time.Duration `yaml:"target_duration"` SegmentDir string `yaml:"segment_dir"` TempDir string `yaml:"temp_dir"` Host string `yaml:"host"` Timeout time.Duration `yaml:"timeout"` FfmpegPath string `yaml:"ffmpeg_path"` FfprobePath string `yaml:"ffprobe_path"` ConvertArgs []string `yaml:"convert_args"` DurationArgs []string `yaml:"duration_args"` PreConvertArgs []string `yaml:"pre_convert_args"` SplitArgs []string `yaml:"split_args"` }
type Talk ¶
type Talk struct { Idx int `json:"idx"` Day int `json:"day"` Turn int `json:"turn"` Agent Agent `json:"agent"` Text string `json:"text"` }
func (Talk) MarshalJSON ¶
type TalkConfig ¶ added in v0.3.1
type TalkConfig struct { MaxCount struct { PerAgent int `yaml:"per_agent"` PerDay int `yaml:"per_day"` } `yaml:"max_count"` MaxLength struct { CountInWord bool `yaml:"count_in_word"` CountSpaces bool `yaml:"count_spaces"` PerTalk int `yaml:"per_talk"` MentionLength int `yaml:"mention_length"` PerAgent int `yaml:"per_agent"` BaseLength int `yaml:"base_length"` } `yaml:"max_length"` MaxSkip int `yaml:"max_skip"` }
type TalkSetting ¶ added in v0.3.1
type TalkSetting struct { MaxCount struct { PerAgent int `json:"per_agent"` PerDay int `json:"per_day"` } `json:"max_count"` MaxLength struct { CountInWord *bool `json:"count_in_word,omitempty"` CountSpaces *bool `json:"count_spaces,omitempty"` PerTalk *int `json:"per_talk,omitempty"` MentionLength *int `json:"mention_length,omitempty"` PerAgent *int `json:"per_agent,omitempty"` BaseLength *int `json:"base_length,omitempty"` } `json:"max_length"` MaxSkip int `json:"max_skip"` }
Click to show internal directories.
Click to hide internal directories.