Ejemplo n.º 1
0
 def take_order(self,
                o,
                forget_previous=True,
                imperative=False,
                order_id=None):
     # an imperative "go" order on a unit is an "attack" order
     # note: this could be done by the user interface
     if imperative and o[0] == "go":
         target = self.player.get_object_by_id(o[1])
         if getattr(target, "player", None) is not None:
             o[0] = "attack"
     if self.is_inside:
         self.place.notify("order_impossible")
         return
     cls = ORDERS_DICT.get(o[0])
     if cls is None:
         warning("unknown order: %s", o)
         return
     if not cls.is_allowed(self, *o[1:]):
         self.notify("order_impossible")
         debug("wrong order to %s: %s", self.type_name, o)
         return
     if forget_previous and not cls.never_forget_previous:
         self.cancel_all_orders()
     order = cls(self, o[1:])
     order.id = order_id
     if imperative:
         order.is_imperative = imperative
     order.immediate_action()
Ejemplo n.º 2
0
 def take_order(self, o, forget_previous=True, imperative=False, order_id=None):
     if self.is_inside:
         self.place.notify("order_impossible")
         return
     cls = ORDERS_DICT.get(o[0])
     if cls is None:
         warning("unknown order: %s", o)
         return
     if not cls.is_allowed(self, *o[1:]):
         self.notify("order_impossible")
         debug("wrong order to %s: %s", self.type_name, o)
         return
     if forget_previous and not cls.never_forget_previous:
         self.cancel_all_orders()
     order = cls(self, o[1:])
     order.id = order_id
     if imperative:
         order.is_imperative = imperative
     order.immediate_action()
Ejemplo n.º 3
0
 def take_order(self, o, forget_previous=True, imperative=False, order_id=None):
     if self.is_inside:
         self.place.notify("order_impossible")
         return
     cls = ORDERS_DICT.get(o[0])
     if cls is None:
         warning("unknown order: %s", o)
         return
     if not cls.is_allowed(self, *o[1:]):
         self.notify("order_impossible")
         debug("wrong order to %s: %s", self.type_name, o)
         return
     if forget_previous and not cls.never_forget_previous:
         self.cancel_all_orders()
     order = cls(self, o[1:])
     order.id = order_id
     if imperative:
         order.is_imperative = imperative
     order.immediate_action()