Beispiel #1
0
def doCommond(mudRole, flows):
    if flows is None:
        return None
    for commond in flows:
        logger.info(mudRole.name + ": do [" + commond + "]")
        mudRole.doCommond(commond)
        time.sleep(1)
 def doTask(self, msg):
     if self.status is TaskStatus.END:
         return None
     if self.status is TaskStatus.STARTING:
         self.status = TaskStatus.LOCK
         return self.__initTask()
     self.__load(msg)
     self.__matchineDo(msg)
     if self.taskIsOver and self.status is not TaskStatus.END:
         self.__selfRest()
         return self.__initTask()
     if self.status is TaskStatus.LOCK or self.status is TaskStatus.END:
         return None
     if self.npcId.get("id") is not None and  self.npcId['isGet'] is True \
             and self.taskGood.get('name') is None:
         flows = ["task sm " + self.npcId.get('id')]
         self.status = TaskStatus.LOCK
         return flows
     if  self.taskGood.get('name') is not None \
         and self.currentLoop != -1 \
         and self.taskGood.get('isBuy') is False \
         and self.giveUp.get('begin') is False:
         if self.taskGood.get(
                 'id') is not None and self.taskGood.get('isBuy') is False:
             self.status = TaskStatus.LOCK
             self.taskGood['buyying'] = True
             logger.info("Buyying ="+str(self.currentLoop)+ \
             "||"+str(self.goodsLoopList[self.currentLoop]))
             return ["buy 1 "+self.taskGood.get('id')+" from " \
                     +self.goodsLoopList[self.currentLoop].get('id')]
         currentSearch = self.goodsLoopList[self.currentLoop]
         if currentSearch.get('done') is False:
             self.status = TaskStatus.LOCK
             return utils.getFlows(currentSearch.get('name'))
         elif currentSearch.get('id') != "" and currentSearch.get(
                 'isList') is False:
             self.status = TaskStatus.LOCK
             self.goodsLoopList[self.currentLoop]['isList'] = True
             return ['list ' + currentSearch.get('id')]
     if self.taskGood.get('isBuy') is True and self.pushNpc.get('id') is None \
         and self.pushNpc.get('getting') is True:
         self.status = TaskStatus.LOCK
         return utils.getFlows(self.flows)
     if self.pushNpc.get('id') is not None and self.pushNpc.get('isGet') is True \
         and self.giveUp.get('begin') is False:
         self.status = TaskStatus.LOCK
         self.taskIsPush = True
         return [
             'task sm ' + self.pushNpc.get('id') + ' give ' +
             self.taskGood.get('id')
         ]
     if self.giveUp.get('begin') is True and self.giveUp.get('move') is False \
         and self.giveUp.get('do') is False:
         self.status = TaskStatus.LOCK
         return utils.getFlows(self.flows)
     if self.giveUp.get('do') is True and self.pushNpc.get(
             "id") is not None:
         self.status = TaskStatus.LOCK
         return ['task sm ' + self.pushNpc.get('id') + ' giveup']
Beispiel #3
0
def main():

    name = "闻人晓"
    auth, socket_url = utils.getRoleConfig(name)
    mud = MudClient(auth, socket_url)
    mud.login()
    mineTask = MineTaskMatchine(name, TaskStatus.STARTING)
    dailyTask = DailyTaskMachine(name, TaskStatus.STARTING)
    goodUseMatchine = GoodUseMatchine("养精丹", None)
    dupMatchine = DuplicateTask(name, TaskStatus.STARTING, "dupBY")
    signinTaskIsOver = False
    goodUse = False

    isDoingDailyTask = True
    isDoingDuplicateTask = True
    while isDoingDailyTask:
        value = mud.flush()
        msg, flag = logger.info(value)
        flows = dailyTask.doTask(msg)
        doCommond(mud, flows)
        if dailyTask.status is TaskStatus.END:
            isDoingDailyTask = False
            print(isDoingDailyTask)

    flows = goodUseMatchine.open()
    doCommond(mud, flows)
    for i in range(8):
        value = mud.flush()
        msg, flag = logger.info(value)
        if goodUseMatchine.isOpen is True:
            flows = goodUseMatchine.mathineDo(msg)
        doCommond(mud, flows)

    while isDoingDuplicateTask:
        value = mud.flush()
        msg, flag = logger.info(value)
        flows = dupMatchine.doTask(msg, 0)
        if dupMatchine.status is TaskStatus.OVER:
            isDoingDuplicateTask = False
            print(isDoingDailyTask)
        doCommond(mud, flows)

    doCommond(mud, ['taskover signin'])

    for i in range(30):
        value = mud.flush()
        msg, flag = logger.info(value)
        flows = mineTask.doTask(msg)
        doCommond(mud, flows)

    mud.close()
    logger.close()
Beispiel #4
0
def main():
    name = "闻人晓"
    auth, socket_url = utils.getRoleConfig(name)
    mud = MudClient(auth, socket_url)
    mud.login()
    taskMatchine = LearnTaskMatchine(name, TaskStatus.STARTING)
    mineTask = MineTaskMatchine(name, TaskStatus.STARTING)
    tag = True
    while tag:
        value = mud.flush()
        msg, flag = logger.info(value)
        flows = taskMatchine.doTask(msg)
        if taskMatchine.status is TaskStatus.OVER:
            flows = mineTask.doTask(msg)
            tag = False
        doCommond(mud, flows)

    for i in range(20):
        value = mud.flush()
        logger.info(value)

    mud.close()
    logger.close()
def test():
    name = "韦晓宝"
    auth, socket_url = utils.getRoleConfig(name)
    mud = MudClient(auth, socket_url)
    mud.login()
    #taskMatchine = LearnTaskMatchine(name,TaskStatus.STARTING)
    mineTask = MineTaskMatchine(name, TaskStatus.STARTING)
    dailyTask = DailyTaskMachine(name, TaskStatus.STARTING)
    for i in range(2000):
        value = mud.flush()
        msg, flag = logger.info(value)
        flows = dailyTask.doTask(msg)
        if dailyTask.status is TaskStatus.END:
            flows = mineTask.doTask(msg)
        doCommond(mud, flows)
    mud.close()
    logger.close()
def test():
    name = "闻人晓"
    auth, socket_url = utils.getRoleConfig(name)
    mud = MudClient(auth, socket_url)
    mud.login()
    mineTask = MineTaskMatchine(name, TaskStatus.STARTING)
    goodUseMatchine = GoodUseMatchine("养精丹", None)
    flows = goodUseMatchine.open()
    doCommond(mud, flows)
    for i in range(100):
        value = mud.flush()
        msg, flag = logger.info(value)
        if goodUseMatchine.isOpen is True:
            flows = goodUseMatchine.mathineDo(msg)
        else:
            flows = mineTask.doTask(msg)
        doCommond(mud, flows)
    mud.close()
    logger.close()
Beispiel #7
0
def test():
    name = "韦晓宝"
    auth,socket_url = utils.getRoleConfig(name)
    mud = MudClient(auth,socket_url)
    mud.login()
    signinTaskIsOver = False
    #dupOne  dupBY
    dupMatchine = DuplicateTask(name,TaskStatus.STARTING,"dupBY")
    mineTask = MineTaskMatchine(name,TaskStatus.STARTING)
    for i in range (11000):
        value = mud.flush()
        msg,flag = logger.info(value)
        flows = dupMatchine.doTask(msg,i)
        if dupMatchine.status is TaskStatus.OVER:
            flows = mineTask.doTask(msg)
            if signinTaskIsOver is False :
                flows.append('taskover signin')
                signinTaskIsOver = True
        doCommond(mud,flows)
    mud.close()
    logger.close()
 def __matchineDo(self, msg):
     if self.taskIsOver:
         print("task is over")
         return
     if self.currentLoop > 3 and self.giveUp['begin'] is False:
         logger.info("...give up this Task...")
         self.status = TaskStatus.DOING
         self.giveUp['begin'] = True
         return
     if self.pushNpc.get(
             'id') is not None and self.pushNpc.get('isGet') is False:
         self.status = TaskStatus.DOING
         self.pushNpc['isGet'] = True
         logger.info("pushNpc:" + str(self.pushNpc))
         return
     if self.taskGood.get('isBuy') is True and self.pushNpc.get('id') is None \
         and self.pushNpc.get('getting') is False:
         logger.info("taskGood:[" + str(self.taskGood) + "] is Buy")
         self.pushNpc['getting'] = True
         self.status = TaskStatus.DOING
         return
     if self.giveUp.get('begin') is False \
         and self.goodsLoopList[self.currentLoop].get('id') != '' \
         and self.taskGood.get('name') is not None \
         and self.taskGood.get('buyying') is False:
         self.status = TaskStatus.DOING
         logger.info("searchLoop:"+str(self.goodsLoopList[self.currentLoop]) \
                     +" \n loopNum:"+str(self.currentLoop))
         return
     if self.taskGood.get('name') is not None and self.currentLoop == -1:
         self.status = TaskStatus.DOING
         self.currentLoop = 0
         logger.info("Task Good:" + str(self.taskGood))
         return
     if self.npcId.get(
             "id") is not None and self.npcId.get("isGet") is False:
         self.status = TaskStatus.DOING
         self.npcId['isGet'] = True
         logger.info("NPC:" + self.npcName + "|" + str(self.npcId) +
                     " has been get.")
     if self.giveUp.get('begin') is True and self.giveUp.get(
             'move') is False:
         self.status = TaskStatus.DOING
         self.giveUp['move'] = True
     if self.giveUp.get('do') is False and self.pushNpc.get(
             "id") is not None:
         self.status = TaskStatus.DOING
         self.giveUp['do'] = True