示例#1
0
 def wait_others(self, level=None):
     if level:
         ant.lvl = level
         my_print("LvL up : ", level)
     else:
         my_print("Failed to LvL up !")
     statemachine.closure = lambda: statemachine.pop()
示例#2
0
 def look_end(self, _):
     self.lap_nbr -= 1
     if self.lap_nbr:
         transaction = LookTransaction(self.look_end)
         safe_controller.execute(transaction)
     else:
         my_print("Checking my mails !")
         statemachine.closure = lambda: statemachine.pop()
示例#3
0
 def execute_incantation(self, *args):
     if not self.validIncantation:
         statemachine.closure = lambda: statemachine.pop()
         return
     transactions = PackedTransaction(self.endIncantationState)
     transactions = self.add_usefull_items(
         self.remove_useless_items(transactions))
     self.castIncantation(transactions)
示例#4
0
    def checkEnd(self, *args):
        del args
        check = True

        for k, v in self.items_dict.items():
            if v > 0:
                check = False
        if check and (not self.rollback or self.tracker.stayed()):
            statemachine.closure = lambda: statemachine.pop()
        elif check and self.rollback:
            self.rollback = False
            look, path = self.tracker.returnHome()
            self.pathHandler = PathManipulator(path, self.checkEnd)
            safe_controller.execute(self.pathHandler)
        else:
            safe_controller.execute(LookTransaction(self.updateAntLook))
示例#5
0
 def popped_over(self):
     super().popped_over()
     for m in controller.msgQueue:
         enr = MsgProtocol.is_apply(m.text)
         if enr and enr['recipient'] == ant.uuid:
             mates.add_mate(enr['sender'])
             my_print(enr["sender"], " joined ! {} / {}".format(len(mates), requirement[ant.lvl + 1][0] - 1))
         if len(mates) == requirement[ant.lvl + 1][0] - 1:
             break
     if len(mates) < requirement[ant.lvl + 1][0] - 1:
         my_print("Failed to find a team lvl {}".format(ant.lvl + 1))
         mates.clear()
         ant.is_queen = False
     allow_list = [m.uuid for m in mates]
     msg = MsgProtocol.allowed_ants(ant.uuid, allow_list)
     transaction = BroadcastTransaction(msg, lambda: statemachine.pop())
     safe_controller.execute(transaction, rollback=False)
示例#6
0
 def endCasting(self):
     statemachine.closure = lambda: statemachine.pop()
示例#7
0
 def endIncantationState(self, *args):
     statemachine.closure = lambda: statemachine.pop()
 def popped_over(self):
     super().popped_over()
     statemachine.closure = lambda: statemachine.pop()