本文整理汇总了Golang中github.com/zond/godip/common.Province类的典型用法代码示例。如果您正苦于以下问题:Golang Province类的具体用法?Golang Province怎么用?Golang Province使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Province类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Coasts
func (self *Graph) Coasts(prov common.Province) (result []common.Province) {
if node, ok := self.nodes[prov.Super()]; ok {
for _, sub := range node.subs {
result = append(result, sub.getName())
}
}
return
}
示例2: edges
func (self *Graph) edges(n common.Province) (result map[common.Province]*edge) {
p, c := n.Split()
if node, ok := self.nodes[p]; ok {
if sub, ok := node.subs[c]; ok {
result = sub.edges
}
}
return
}
示例3: Flags
func (self *Graph) Flags(n common.Province) (result map[common.Flag]bool) {
p, c := n.Split()
if node, ok := self.nodes[p]; ok {
if sub, ok := node.subs[c]; ok {
result = sub.flags
}
}
return
}
示例4: Has
func (self *Graph) Has(n common.Province) (result bool) {
p, c := n.Split()
if node, ok := self.nodes[p]; ok {
if _, ok := node.subs[c]; ok {
result = true
}
}
return
}
示例5: Prov
func (self *Graph) Prov(n common.Province) *subNode {
p, c := n.Split()
if self.nodes[p] == nil {
self.nodes[p] = &node{
name: p,
subs: make(map[common.Province]*subNode),
graph: self,
}
}
return self.nodes[p].sub(c)
}
示例6: AllFlags
func (self *Graph) AllFlags(n common.Province) (result map[common.Flag]bool) {
result = map[common.Flag]bool{}
p, _ := n.Split()
if node, ok := self.nodes[p]; ok {
for _, sub := range node.subs {
for flag, _ := range sub.flags {
result[flag] = true
}
}
}
return
}
示例7: AddBounce
func (self *State) AddBounce(src, dst common.Province) {
if existing, ok := self.bounces[dst.Super()]; ok {
existing[src.Super()] = true
} else {
self.bounces[dst.Super()] = map[common.Province]bool{
src.Super(): true,
}
}
}
示例8: Order
func (self *State) Order(prov common.Province) (o common.Order, p common.Province, ok bool) {
if o, ok = self.orders[prov]; ok {
p = prov
return
}
sup, _ := prov.Split()
if o, ok = self.orders[sup]; ok {
p = sup
return
}
for _, name := range self.graph.Coasts(prov) {
if o, ok = self.orders[name]; ok {
p = name
return
}
}
return
}
示例9: SupplyCenter
func (self *State) SupplyCenter(prov common.Province) (n common.Nation, p common.Province, ok bool) {
if n, ok = self.supplyCenters[prov]; ok {
p = prov
return
}
sup, _ := prov.Split()
if n, ok = self.supplyCenters[sup]; ok {
p = sup
return
}
for _, name := range self.graph.Coasts(prov) {
if n, ok = self.supplyCenters[name]; ok {
p = name
return
}
}
return
}
示例10: Unit
func (self *State) Unit(prov common.Province) (u common.Unit, p common.Province, ok bool) {
if u, ok = self.units[prov]; ok {
p = prov
return
}
sup, _ := prov.Split()
if u, ok = self.units[sup]; ok {
p = sup
return
}
for _, name := range self.graph.Coasts(prov) {
if u, ok = self.units[name]; ok {
p = name
return
}
}
return
}
示例11: Bounce
func (self *State) Bounce(src, dst common.Province) bool {
if sources, ok := self.bounces[dst.Super()]; ok {
if dislodger, ok := self.dislodgers[dst.Super()]; ok {
if len(sources) == 1 && sources[dislodger.Super()] {
return false
}
}
return true
}
if self.dislodgers[dst.Super()] == src.Super() {
return true
}
return false
}
示例12: SC
func (self *Graph) SC(n common.Province) (result *common.Nation) {
if node, ok := self.nodes[n.Super()]; ok {
result = node.sc
}
return
}
示例13: SetDislodger
func (self *State) SetDislodger(attacker, victim common.Province) {
self.dislodgers[attacker.Super()] = victim.Super()
}