示例#1
0
文件: orders.py 项目: eswald/parlance
 def matches(self, order_set):
     ''' Whether the order is matched by the convoying unit(s). '''
     def matching(fleet):
         counterpart = order_set.get_order(fleet)
         if counterpart:
             return (counterpart.is_convoying()
                     and counterpart.supported == self.unit
                     and counterpart.destination.matches(self.destination.key))
         return False
     if self.path: return all(matching(unit) for unit in self.path)
     else: return True
示例#2
0
文件: orders.py 项目: eswald/parlance
 def get_routes(self, convoyers, ignore_foreign):
     if self.unit.can_be_convoyed():
         if self.path:
             path_list = [[fleet.location.province for fleet in self.path]]
         else: path_list = self.routes
         if path_list:
             key = self.unit.key
             def available(prov):
                 return convoyers.get(prov.key, (None, None))[0] == key
             all_routes = [path for path in path_list
                     if all(available(place) for place in path)]
             
             if ignore_foreign:
                 # DPTG craziness: ignore foreign convoyers if we can go alone.
                 nation = self.unit.nation
                 def countryman(prov):
                     return convoyers.get(prov.key, (None, None))[1] == nation
                 solo_routes = [path for path in all_routes
                         if all(countryman(place) for place in path)]
             else: solo_routes = None
             return (solo_routes or all_routes)
     return []
示例#3
0
文件: orders.py 项目: eswald/parlance
 def check(f): return not all(f(unit) for unit in self.path)
 if   check(real_prov):                 note = NSP
示例#4
0
 def is_valid(self):
     if self.homes and not self.key.is_supply(): return False
     if not self.locations: return False
     return all(location.is_valid() for location in self.locations)