feat: fight.Round 新增获取当前操作超时时间的函数
This commit is contained in:
parent
e3224d010b
commit
060fb05fb8
|
@ -47,6 +47,7 @@ type Round[Data RoundData] struct {
|
||||||
campOrder []int // 阵营顺序
|
campOrder []int // 阵营顺序
|
||||||
actionTimeout time.Duration // 行动超时时间
|
actionTimeout time.Duration // 行动超时时间
|
||||||
actionTimeoutTickerName string // 行动超时计时器名称
|
actionTimeoutTickerName string // 行动超时计时器名称
|
||||||
|
actionTimeoutTime int64 // 行动超时时间
|
||||||
round int // 回合数
|
round int // 回合数
|
||||||
roundCount int // 回合计数
|
roundCount int // 回合计数
|
||||||
currentCamp int // 当前行动阵营
|
currentCamp int // 当前行动阵营
|
||||||
|
@ -137,6 +138,7 @@ func (slf *Round[Data]) SkipCamp() {
|
||||||
// ActionRefresh 刷新行动超时时间
|
// ActionRefresh 刷新行动超时时间
|
||||||
func (slf *Round[Data]) ActionRefresh() {
|
func (slf *Round[Data]) ActionRefresh() {
|
||||||
slf.currentEndTime = time.Now().Unix()
|
slf.currentEndTime = time.Now().Unix()
|
||||||
|
slf.actionTimeoutTime = time.Now().Add(slf.actionTimeout).Unix()
|
||||||
slf.ticker.After(slf.actionTimeoutTickerName, slf.actionTimeout, slf.loop, true)
|
slf.ticker.After(slf.actionTimeoutTickerName, slf.actionTimeout, slf.loop, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +156,11 @@ func (slf *Round[Data]) GetRound() int {
|
||||||
return slf.round
|
return slf.round
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetActionTimeoutTime 获取行动超时时间
|
||||||
|
func (slf *Round[Data]) GetActionTimeoutTime() int64 {
|
||||||
|
return slf.actionTimeoutTime
|
||||||
|
}
|
||||||
|
|
||||||
// AllowAction 是否允许行动
|
// AllowAction 是否允许行动
|
||||||
func (slf *Round[Data]) AllowAction(camp, entity int) bool {
|
func (slf *Round[Data]) AllowAction(camp, entity int) bool {
|
||||||
return (slf.currentCamp == camp && slf.currentEntity == entity) || slf.shareAction && camp == slf.currentCamp
|
return (slf.currentCamp == camp && slf.currentEntity == entity) || slf.shareAction && camp == slf.currentCamp
|
||||||
|
|
Loading…
Reference in New Issue