Ejemplo n.º 1
0
def solver(msg):
    global status, data_queue, start, start_time_stamp, terminate
    Logger(msg, tag="Solver")
    data = msg.split(" ", 1)
    if data[0] == "start":
        if memFix: fix_crafter(player)
        status = Status(player, target, BallManager.defaultBall)
        format_status(status)
        data_queue = [[None, type(BallManager.defaultBall).__name__]]
        start = time.perf_counter()
        start_time_stamp = int(time.time())
        return deal_status(status)
    elif data[0] == "use":
        if len(data) == 2 and status is not None:
            data = data[1].rsplit(" ", 1)
            skill = data[0] if len(
                data) == 1 or data[1] == "成功" else data[0] + ":fail"
            if skill in SkillManager:
                print("use:", skill)
                data_queue[-1][0] = skill
                status = status.use_skill(SkillManager[skill])
                if not status.is_finish():
                    sleep(0.5)
                    status.ball = get_ball()
                    if memFix: fix_status(status)
                    data_queue.append([None, type(status.ball).__name__])
                    format_status(status)
                    return deal_status(status)
            else:
                raise Exception("unknown skill %s" % skill)
    elif data[0] == "end":
        if data_queue and status is not None:
            with open(os.path.join(config.BasePath, log_name), "a+") as f:
                f.write(str(start_time_stamp) + "|")
                f.write("|".join("{};{}".format(i[0], i[1])
                                 for i in data_queue))
                f.write("|{}|{}|{}\n".format(status.currentProgress,
                                             status.currentQuality,
                                             time.perf_counter() - start))
        print("#" * 10 + "end" + "#" * 10)
        TTS("finsih")
        status = None
        terminate = False
        return ("end")
    else:
        print("unknown")
    return ""
Ejemplo n.º 2
0
from core.Simulator.Status import Status
from core.Simulator.Role import Crafter, Target
from core.Simulator.Manager import SkillManager, BuffManager, BallManager
from solver.Solver import format_status,solver

for manager in [SkillManager, BuffManager, BallManager]: manager.load()
player = Crafter(80, 2758, 2917, 657)
target = Target(511, 50, 11126, 82400)
status = Status(player, target, BallManager.defaultBall)
status.ball=BallManager.RedBall
q=[["\u95f2\u9759", "WhiteBall"], ["\u5d07\u656c", "WhiteBall"], ["\u9ad8\u901f\u5236\u4f5c", "BlueBall"], ["\u638c\u63e1", "GreenBall"], ["\u9ad8\u901f\u5236\u4f5c:fail", "GreenBall"], ["\u9ad8\u901f\u5236\u4f5c:fail", "GreenBall"], ["\u5d07\u656c", "WhiteBall"], ["\u9ad8\u901f\u5236\u4f5c:fail", "GreenBall"], ["\u9ad8\u901f\u5236\u4f5c", "WhiteBall"], ["\u9ad8\u901f\u5236\u4f5c", "WhiteBall"], ["\u7cbe\u4fee", "BlueBall"], ["\u4e13\u5fc3\u52a0\u5de5", "WhiteBall"], ["\u4fed\u7ea6\u52a0\u5de5", "WhiteBall"], ["\u638c\u63e1", "GreenBall"], ["\u4fed\u7ea6\u52a0\u5de5", "GreenBall"], ["\u4fed\u7ea6\u52a0\u5de5", "GreenBall"], ["\u4fed\u7ea6", "GreenBall"], ["\u6539\u9769", "YellowBall"], ["\u576f\u6599\u52a0\u5de5", "YellowBall"], ["\u576f\u6599\u52a0\u5de5", "BlueBall"], ["\u89c2\u5bdf", "BlueBall"], ["\u576f\u6599\u52a0\u5de5", "BlueBall"], ["\u6539\u9769", "WhiteBall"], ["\u89c2\u5bdf", "WhiteBall"], ["\u6ce8\u89c6\u52a0\u5de5", "WhiteBall"], ["\u79d8\u8bc0", "RedBall"], ["\u4fed\u7ea6\u52a0\u5de5", "YellowBall"], ["\u79d8\u8bc0", "RedBall"], ["\u9614\u6b65", "YellowBall"], ["\u6539\u9769", "RedBall"], ["\u89c2\u5bdf", "GreenBall"], ["\u6ce8\u89c6\u52a0\u5de5", "WhiteBall"], ["\u9614\u6b65", "WhiteBall"], ["\u6bd4\u5c14\u683c\u7684\u795d\u798f", "RedBall"], ["\u5236\u4f5c", "GreenBall"]]
solver("start")
while q:
    action=q.pop(0)
    status.ball=getattr(BallManager,action[1])
    format_status(status)
    use = action[0]
    if use in SkillManager:
        print("use:", use)
        status = status.use_skill(SkillManager[use])
    else:
        print("invalid input")
format_status(status)
Ejemplo n.º 3
0
                                    status.target.maxProgress))
    print("quality:\t{}/{}".format(status.currentQuality,
                                   status.target.maxQuality))
    if status.buffs:
        print("buffs:",
              " ".join([str(buff) for buff in status.buffs.values()]))
    print("CP:\t{}/{}".format(status.currentCp, status.player.maxCp))


#创建角色,对象实体
player = Crafter(80, 2758, 2917, 657)
target = Target(511, 50, 11126, 82400)

#创建status开局
status = Status(player, target, BallManager.defaultBall)

#一些直接修改局面属性的api
#注意:为了避免循环加载,或缺漏注入等情况,请不要直接import skills.py ball.py 等文件
#请使用manager相关
status.ball = BallManager.PurpleBall
status.get_buff(BuffManager.InnerQuiet)
status.execute_buff_change()
if status.has_buff('內静'):
    status.get_buff('內静').data['lv'] = 11

#使用use skill 创建下一回合的局面
next_status = status.use_skill(SkillManager['俭约'])

#格式化输出
print_status(next_status)