本文整理汇总了Golang中github.com/zond/godip/common.Validator.Phase方法的典型用法代码示例。如果您正苦于以下问题:Golang Validator.Phase方法的具体用法?Golang Validator.Phase怎么用?Golang Validator.Phase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zond/godip/common.Validator
的用法示例。
在下文中一共展示了Validator.Phase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Options
func (self *disband) Options(v dip.Validator, nation dip.Nation, src dip.Province) (result dip.Options) {
if v.Phase().Type() == cla.Adjustment {
if v.Graph().Has(src) {
if unit, actualSrc, ok := v.Unit(src); ok {
if unit.Nation == nation {
if _, _, balance := cla.AdjustmentStatus(v, unit.Nation); balance < 0 {
result = dip.Options{
dip.SrcProvince(actualSrc): nil,
}
}
}
}
}
} else if v.Phase().Type() == cla.Retreat {
if v.Graph().Has(src) {
if unit, actualSrc, ok := v.Dislodged(src); ok {
if unit.Nation == nation {
result = dip.Options{
dip.SrcProvince(actualSrc): nil,
}
}
}
}
}
return
}
示例2: Validate
func (self *move) Validate(v dip.Validator) error {
if v.Phase().Type() == cla.Movement {
return self.validateMovementPhase(v)
} else if v.Phase().Type() == cla.Retreat {
return self.validateRetreatPhase(v)
}
return cla.ErrInvalidPhase
}
示例3: Validate
func (self *disband) Validate(v dip.Validator) error {
if v.Phase().Type() == cla.Adjustment {
return self.validateBuildPhase(v)
} else if v.Phase().Type() == cla.Retreat {
return self.validateRetreatPhase(v)
}
return cla.ErrInvalidPhase
}
示例4: Options
func (self *move) Options(v dip.Validator, nation dip.Nation, src dip.Province) (result dip.Options) {
if v.Phase().Type() == cla.Retreat {
if !self.flags[cla.ViaConvoy] {
if v.Graph().Has(src) {
if unit, actualSrc, ok := v.Dislodged(src); ok {
if unit.Nation == nation {
for _, dst := range cla.PossibleMoves(v, src, false, true) {
if _, _, foundUnit := v.Unit(dst); !foundUnit {
if !v.Bounce(src, dst) {
if result == nil {
result = dip.Options{}
}
if result[dip.SrcProvince(actualSrc)] == nil {
result[dip.SrcProvince(actualSrc)] = dip.Options{}
}
result[dip.SrcProvince(actualSrc)][dst] = nil
}
}
}
}
}
}
}
} else if v.Phase().Type() == cla.Movement {
if v.Graph().Has(src) {
if unit, actualSrc, ok := v.Unit(src); ok {
if unit.Nation == nation {
if !self.flags[cla.ViaConvoy] || unit.Type == cla.Army {
for _, dst := range cla.PossibleMoves(v, src, true, false) {
if !self.flags[cla.ViaConvoy] {
if result == nil {
result = dip.Options{}
}
if result[dip.SrcProvince(actualSrc)] == nil {
result[dip.SrcProvince(actualSrc)] = dip.Options{}
}
result[dip.SrcProvince(actualSrc)][dst] = nil
} else {
if cp := cla.AnyConvoyPath(v, src, dst, false, nil); len(cp) > 1 {
if result == nil {
result = dip.Options{}
}
if result[dip.SrcProvince(actualSrc)] == nil {
result[dip.SrcProvince(actualSrc)] = dip.Options{}
}
result[dip.SrcProvince(actualSrc)][dst] = nil
}
}
}
}
}
}
}
}
return
}
示例5: Validate
func (self *hold) Validate(v dip.Validator) error {
if v.Phase().Type() != cla.Movement {
return cla.ErrInvalidPhase
}
if !v.Graph().Has(self.targets[0]) {
return cla.ErrInvalidTarget
}
var ok bool
if _, self.targets[0], ok = v.Unit(self.targets[0]); !ok {
return cla.ErrMissingUnit
}
return nil
}
示例6: Options
func (self *hold) Options(v dip.Validator, nation dip.Nation, src dip.Province) (result dip.Options) {
if v.Phase().Type() == cla.Movement {
if v.Graph().Has(src) {
if unit, actualSrc, ok := v.Unit(src); ok {
if unit.Nation == nation {
result = dip.Options{
dip.SrcProvince(actualSrc): nil,
}
}
}
}
}
return
}