def use_with_arg(cls, state, card_index, *args): if len(args) == 0: hand_card = state.my_hand_cards[card_index] warn_print(f"Receive 0 args in using SpellPointMine card {hand_card.name}") return mine_index = args[0] click.choose_card(card_index, state.my_hand_card_num) click.choose_my_minion(mine_index, state.my_minion_num) click.cancel_click() time.sleep(cls.wait_time)
def use_with_arg(cls, state, card_index, *args): gap_index = args[0] oppo_index = args[1] click.choose_card(card_index, state.my_hand_card_num) click.put_minion(gap_index, state.my_minion_num) if oppo_index >= 0: click.choose_opponent_minion(oppo_index, state.oppo_minion_num) else: click.choose_oppo_hero() click.cancel_click() time.sleep(BASIC_MINION_PUT_INTERVAL)
def use_with_arg(cls, state, card_index, *args): gap_index = args[0] my_index = args[1] click.choose_card(card_index, state.my_hand_card_num) click.put_minion(gap_index, state.my_minion_num) if my_index >= 0: # 这时这个随从已经在场上了, 其他随从已经移位了 click.choose_my_minion(my_index, state.my_minion_num + 1) else: click.choose_my_hero() click.cancel_click() time.sleep(BASIC_MINION_PUT_INTERVAL)
def use_with_arg(cls, state, card_index, *args): if len(args) == 0: hand_card = state.my_hand_cards[card_index] warn_print(f"Receive 0 args in using SpellPointOppo card {hand_card.name}") return oppo_index = args[0] click.choose_card(card_index, state.my_hand_card_num) if oppo_index >= 0: click.choose_opponent_minion(oppo_index, state.oppo_minion_num) else: click.choose_oppo_hero() click.cancel_click() time.sleep(cls.wait_time)
def QuittingBattle(): print_out() time.sleep(5) loop_count = 0 while True: if quitting_flag: sys.exit(0) state = get_screen.get_state() if state in [FSM_CHOOSING_HERO, FSM_LEAVE_HS]: return state click.cancel_click() click.test_click() click.commit_error_report() loop_count += 1 if loop_count >= 15: return FSM_ERROR time.sleep(STATE_CHECK_INTERVAL)
def Battling(): global win_count global log_state print_out() not_mine_count = 0 mine_count = 0 last_controller_is_me = False while True: if quitting_flag: sys.exit(0) ok = update_log_state() if not ok: return FSM_ERROR if log_state.is_end: if log_state.my_entity.query_tag("PLAYSTATE") == "WON": win_count += 1 info_print("你赢得了这场对战") else: info_print("你输了") return FSM_QUITTING_BATTLE # 在对方回合等就行了 if not log_state.is_my_turn: last_controller_is_me = False mine_count = 0 not_mine_count += 1 if not_mine_count >= 400: warn_print("Time out in Opponent's turn") return FSM_ERROR continue # 接下来考虑在我的回合的出牌逻辑 # 如果是这个我的回合的第一次操作 if not last_controller_is_me: time.sleep(4) # 在游戏的第一个我的回合, 发一个你好 # game_num_turns_in_play在每一个回合开始时都会加一, 即 # 后手放第一个回合这个数是2 if log_state.game_num_turns_in_play <= 2: click.emoj(0) else: # 在之后每个回合开始时有概率发表情 if random.random() < EMOJ_RATIO: click.emoj() last_controller_is_me = True not_mine_count = 0 mine_count += 1 if mine_count >= 20: if mine_count >= 40: return FSM_ERROR click.end_turn() click.commit_error_report() click.cancel_click() time.sleep(STATE_CHECK_INTERVAL) debug_print("-" * 60) strategy_state = StrategyState(log_state) strategy_state.debug_print_out() # 考虑要不要出牌 index, args = strategy_state.best_h_index_arg() # index == -1 代表使用技能, -2 代表不出牌 if index != -2: strategy_state.use_best_entity(index, args) continue # 如果不出牌, 考虑随从怎么打架 my_index, oppo_index = strategy_state.get_best_attack_target() # my_index == -1代表英雄攻击, -2 代表不攻击 if my_index != -2: strategy_state.my_entity_attack_oppo(my_index, oppo_index) else: click.end_turn() time.sleep(STATE_CHECK_INTERVAL)
def use_with_arg(cls, state, card_index, *args): click.choose_and_use_spell(card_index, state.my_hand_card_num) click.cancel_click() time.sleep(cls.wait_time)
def use_with_arg(cls, state, card_index, *args): click.choose_and_use_spell(card_index, state.my_hand_card_num) click.cancel_click() time.sleep(BASIC_WEAPON_WAIT_TIME)
def use_with_arg(cls, state, card_index, *args): gap_index = args[0] click.choose_card(card_index, state.my_hand_card_num) click.put_minion(gap_index, state.my_minion_num) click.cancel_click() time.sleep(BASIC_MINION_PUT_INTERVAL)