Documentation
¶
Index ¶
- type BasePhase
- func (b *BasePhase) AddActionToList(action PhaseAction)
- func (b *BasePhase) GetActions() []PhaseAction
- func (b *BasePhase) GetAlivePlayersByRole(role werewolf.RoleType, players []PhasePlayer) []PhasePlayer
- func (b *BasePhase) GetAlivePlayersCount(players []PhasePlayer) int
- func (b *BasePhase) GetName() werewolf.PhaseType
- func (b *BasePhase) GetPlayerByID(playerID string, players []PhasePlayer) *PhasePlayer
- func (b *BasePhase) GetRound() int
- func (b *BasePhase) HasPlayerActed(playerID string) bool
- func (b *BasePhase) Reset()
- func (b *BasePhase) ValidatePlayer(playerID string, players []PhasePlayer) error
- func (b *BasePhase) ValidateTarget(targetID string, players []PhasePlayer, requireAlive bool) error
- type DayPhase
- func (d *DayPhase) AddAction(action PhaseAction, players []PhasePlayer) error
- func (d *DayPhase) IsComplete(players []PhasePlayer) bool
- func (d *DayPhase) Process(players []PhasePlayer) (PhaseResult, error)
- func (d *DayPhase) Reset()
- func (d *DayPhase) Start(players []PhasePlayer, round int) (bool, error)
- type NightPhase
- func (n *NightPhase) AddAction(action PhaseAction, players []PhasePlayer) error
- func (n *NightPhase) IsComplete(players []PhasePlayer) bool
- func (n *NightPhase) Process(players []PhasePlayer) (PhaseResult, error)
- func (n *NightPhase) Reset()
- func (n *NightPhase) Start(players []PhasePlayer, round int) (bool, error)
- type Phase
- type PhaseAction
- type PhasePlayer
- type PhaseResult
- type VotePhase
- func (v *VotePhase) AddAction(action PhaseAction, players []PhasePlayer) error
- func (v *VotePhase) IsComplete(players []PhasePlayer) bool
- func (v *VotePhase) Process(players []PhasePlayer) (PhaseResult, error)
- func (v *VotePhase) Reset()
- func (v *VotePhase) Start(players []PhasePlayer, round int) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasePhase ¶
type BasePhase struct {
// contains filtered or unexported fields
}
BasePhase 基础阶段实现 提供通用的阶段功能
func (*BasePhase) AddActionToList ¶
func (b *BasePhase) AddActionToList(action PhaseAction)
AddActionToList 添加行动到列表(供子类使用)
func (*BasePhase) GetAlivePlayersByRole ¶
func (b *BasePhase) GetAlivePlayersByRole(role werewolf.RoleType, players []PhasePlayer) []PhasePlayer
GetAlivePlayersByRole 获取指定角色的存活玩家
func (*BasePhase) GetAlivePlayersCount ¶
func (b *BasePhase) GetAlivePlayersCount(players []PhasePlayer) int
GetAlivePlayersCount 获取存活玩家数量
func (*BasePhase) GetPlayerByID ¶
func (b *BasePhase) GetPlayerByID(playerID string, players []PhasePlayer) *PhasePlayer
GetPlayerByID 根据ID获取玩家
func (*BasePhase) HasPlayerActed ¶
HasPlayerActed 检查玩家是否已行动
func (*BasePhase) ValidatePlayer ¶
func (b *BasePhase) ValidatePlayer(playerID string, players []PhasePlayer) error
ValidatePlayer 验证玩家是否可以行动
func (*BasePhase) ValidateTarget ¶
func (b *BasePhase) ValidateTarget(targetID string, players []PhasePlayer, requireAlive bool) error
ValidateTarget 验证目标玩家是否有效
type DayPhase ¶
type DayPhase struct {
*BasePhase
// contains filtered or unexported fields
}
DayPhase 白天阶段 主要用于玩家发言讨论,不强制要求行动
func (*DayPhase) AddAction ¶
func (d *DayPhase) AddAction(action PhaseAction, players []PhasePlayer) error
AddAction 添加玩家行动
func (*DayPhase) IsComplete ¶
func (d *DayPhase) IsComplete(players []PhasePlayer) bool
IsComplete 检查白天阶段是否完成
func (*DayPhase) Process ¶
func (d *DayPhase) Process(players []PhasePlayer) (PhaseResult, error)
Process 处理白天阶段
type NightPhase ¶
type NightPhase struct {
*BasePhase
// contains filtered or unexported fields
}
NightPhase 夜晚阶段 处理狼人杀人、预言家查验、女巫用药、守卫守护等行动
func (*NightPhase) AddAction ¶
func (n *NightPhase) AddAction(action PhaseAction, players []PhasePlayer) error
AddAction 添加玩家行动
func (*NightPhase) IsComplete ¶
func (n *NightPhase) IsComplete(players []PhasePlayer) bool
IsComplete 检查夜晚阶段是否完成
func (*NightPhase) Process ¶
func (n *NightPhase) Process(players []PhasePlayer) (PhaseResult, error)
Process 处理夜晚阶段
func (*NightPhase) Start ¶
func (n *NightPhase) Start(players []PhasePlayer, round int) (bool, error)
Start 开始夜晚阶段
type Phase ¶
type Phase interface {
// GetName 获取阶段名称
GetName() werewolf.PhaseType
// Start 开始阶段
// 返回是否需要玩家行动
Start(players []PhasePlayer, round int) (requiresAction bool, error error)
// AddAction 添加玩家行动
// 返回行动是否有效
AddAction(action PhaseAction, players []PhasePlayer) error
// IsComplete 检查阶段是否完成
// 判断是否所有必要的行动都已收集
IsComplete(players []PhasePlayer) bool
// Process 处理阶段
// 执行阶段逻辑,计算结果
Process(players []PhasePlayer) (PhaseResult, error)
// Reset 重置阶段状态
// 准备下一次使用
Reset()
}
Phase 阶段接口 定义每个游戏阶段必须实现的方法
type PhaseAction ¶
type PhaseAction struct {
PlayerID string // 行动玩家ID
ActionType werewolf.ActionType // 行动类型
TargetID string // 目标玩家ID(可选)
Data map[string]interface{} // 额外数据
}
PhaseAction 表示玩家在阶段中的一个行动
type PhasePlayer ¶
PhasePlayer 阶段中的玩家信息(简化版)
type PhaseResult ¶
type PhaseResult struct {
DeadPlayers []string // 本阶段死亡的玩家ID列表
VoteResult map[string]int // 投票结果(投票阶段使用)
Data map[string]interface{} // 其他结果数据
}
PhaseResult 阶段处理结果
type VotePhase ¶
type VotePhase struct {
*BasePhase
// contains filtered or unexported fields
}
VotePhase 投票阶段 所有存活玩家投票驱逐一名玩家
func (*VotePhase) AddAction ¶
func (v *VotePhase) AddAction(action PhaseAction, players []PhasePlayer) error
AddAction 添加玩家行动
func (*VotePhase) IsComplete ¶
func (v *VotePhase) IsComplete(players []PhasePlayer) bool
IsComplete 检查投票阶段是否完成
func (*VotePhase) Process ¶
func (v *VotePhase) Process(players []PhasePlayer) (PhaseResult, error)
Process 处理投票阶段
Click to show internal directories.
Click to hide internal directories.