Ejemplo n.º 1
0
	def reset_skill(self) -> Response:
		item_id = 350
		if str(item_id) in self.__data.svr_bag.item_list.keys():
			cost_type = 0
		else:
			cost_type = 1
		price = game_table.get_item(item_id=item_id).item_price
		return self.__request.lord_skill_reset(cost_type=cost_type, gem_num=price, item_id=item_id)
Ejemplo n.º 2
0
    def march_speed(self, is_finish_action=False):

        action_data: dict = self.__data.get_all_actions()

        if not action_data:
            return False

        for action_id, action_detail in action_data.items():

            action_type = action_detail["basic"][10]

            if action_type not in Enum.MarchActionType.__dict__.values():
                continue

            action_info = ActionInfo(action_detail)

            action_status = action_info.basic.action_status

            if action_status != Enum.ActionStatus.Marching and action_status != Enum.ActionStatus.Returning:
                continue

            if action_type == Enum.ActionType.RallyWar:
                item_id = 308
            else:
                item_id = 130

            item_info = game_table.get_item(str(item_id))
            price = item_info.item_price

            action_time = action_info.basic.cost_time

            if not is_finish_action:
                result = self.__request.item_buy_and_use(
                    item=item_id,
                    target_id=action_id,
                    price=price,
                    rally_id=0,
                    is_attack=0,
                    action_type=Enum.ActionType.RallyWar)

                if result.is_right_ret_code:
                    continue
                else:
                    break
            else:
                while True:
                    result = self.__request.item_buy_and_use(
                        item=item_id,
                        target_id=action_id,
                        price=price,
                        rally_id=0,
                        is_attack=0,
                        action_type=Enum.ActionType.RallyWar)

                    action_time /= 2

                    if result.is_right_ret_code != 0 or action_time <= 2:
                        break
Ejemplo n.º 3
0
	def add_energy(self):
		item_id = 300
		target_id = self.__data.svr_player.uid
		item_price = game_table.get_item(item_id).item_price
		if self.__data.svr_player.dragon["energy"] < 5000:
			self.__request.item_buy_and_use(item=item_id, price=item_price, target_id=target_id, action_type=-1,
											rally_id=0, is_attack=1)
		else:
			logging.info("龙能量大于5000,不加")
Ejemplo n.º 4
0
    def __get_speed_item():
        time_gem_dict = {}

        for item in game_table.game_item.keys():
            item_object = game_table.get_item(item_id=item)
            if item_object.category == 1 and item_object.is_show:
                time_gem_dict[item_object.reward_num] = item_object.item_price
        speed_items = list(time_gem_dict.keys())
        speed_items.sort(reverse=True)

        return speed_items, time_gem_dict
Ejemplo n.º 5
0
	def player_avatar_change(self) -> Response:
		item_id = 216
		if str(item_id) in self.__data.svr_bag.item_list.keys():
			cost_type = 0
			gem_num = 0
		else:
			cost_type = 1
			item_id = -1
			gem_num = game_table.get_item(item_id=item_id).item_price
		avatar_id = random.randint(0, 5)
		return self.__request.player_avatar_change(avatar_id, cost_type, gem_num, item_id)
Ejemplo n.º 6
0
	def add_lord_point(self, item_id=1671) -> Response:
		items = [1670, 1671]
		has_item = False
		for item in items:
			if str(item) in self.__data.svr_bag.item_list.keys():
				item_id = item
				has_item = True
				break
		price = game_table.get_item(item_id=item_id).item_price
		if has_item:
			return self.__request.item_use(item_id, self.__uid, action_type=-1, rally_war_id=0, is_attack=0)
		else:
			return self.__request.item_buy_and_use(item_id, self.__uid, price, action_type=-1, rally_id=0, is_attack=0)
Ejemplo n.º 7
0
 def kingdom_move(self, pos: int):
     item_id = 1
     if self.__data.svr_bag.get_own_item_num(item_id) > 0:
         item_price = 0
     else:
         item_price = game_table.get_item(item_id=item_id).item_price
     own_gem = self.__data.svr_login.gem
     if own_gem < item_price:
         return Response()
     old_position = self.__data.svr_player.city_pos
     result = self.__request.move_city_new(item_id, item_price,
                                           old_position,
                                           Enum.MoveCityType.KingdomMove,
                                           pos)
     return result
Ejemplo n.º 8
0
	def player_name_change(self, name="") -> Response:
		if name == "":
			name = str(self.__uid)
		else:
			name = "%s%s" % (self.__uid, name)
		
		item_id = 6
		if str(item_id) in self.__data.svr_bag.item_list.keys():
			gem = 0
		else:
			gem = game_table.get_item(item_id=item_id).item_price
		have_gem = self.__data.svr_login.gem
		if have_gem < gem:
			logging.error("gem is too little. gem num : %s " % have_gem)
			return Response()
		else:
			return self.__request.player_name_change(item_id=item_id, name=name, gem=gem)
Ejemplo n.º 9
0
    def march_dragon_attack(self, pos: int):
        if self.__data.svr_player.has_dragon != 1 and self.__data.svr_player.dragon[
                "status"] != 0:
            return False
        cost_time = self.get_march_time(march_type=Enum.MarchType.DragonAttack,
                                        target=pos)

        item_id = 300
        target_id = self.__data.svr_player.uid
        item_price = game_table.get_item(item_id).item_price
        if self.__data.svr_player.dragon["energy"] < 5000:
            self.__request.item_buy_and_use(item=item_id,
                                            price=item_price,
                                            target_id=target_id,
                                            action_type=-1,
                                            rally_id=0,
                                            is_attack=1)

        return self.__request.march_dragon_attack(cost_time=cost_time, pos=pos)
Ejemplo n.º 10
0
    def remove_all_build(self, position=0):
        item_id = 9
        gem = game_table.get_item(item_id).item_price

        remove_type = 2

        for pos, build_info in self.__data.svr_building.building.items():
            build_id = int(build_info[0])
            build_level = build_info[1]
            if game_table.get_building(build_id=build_id,
                                       level=build_level).can_remove:
                if position == 0:
                    self.__request.building_remove(remove_type=remove_type,
                                                   position=pos,
                                                   cost_time=0,
                                                   gem=gem)
                else:
                    self.__request.building_remove(remove_type=remove_type,
                                                   position=position,
                                                   cost_time=0,
                                                   gem=gem)
Ejemplo n.º 11
0
    def task_start(self):
        self.__init_ui_test()
        if self.okc is None:
            return
        uid = self.player.uid
        logging.info("uid:%s" % uid)
        self.okc.now_scene = Scene.city
        if not self.player.data.svr_task.is_open:
            logging.error("task is not open".title())
            return
        self.__update_recommended_task()
        if self.recommended_task == "null":
            logging.error("no recommended task".title())
            return
        self.player.protocol.op_self_set_gem(gem=self.default_gem)
        for resource_id in range(0, 5):
            self.player.protocol.op_self_set_resource(
                rss_id=resource_id, rss_num=self.default_resource)
        self.player.protocol.op_self_set_troop(troop_id=0, troop_num=500000)
        has_alliance = False

        while self.recommended_task != "null":
            if self.is_in_guide():
                self.__guide_task()
            if not has_alliance:
                if not self.player.cmd_alliance.alliance_create(
                        name="Bill%s" % self.player.uid):
                    has_alliance = True

            if self.okc.find_ui_node(ui_node_name="ViewLordLevelUpPop"):
                self.okc.click(now_view="ViewLordLevelUpPop",
                               node_name="ok_btn",
                               result_view="ViewMain")

            if self.okc.find_ui_node(ui_node_name="ViewCivicCenterUpgradePop"):
                self.okc.click("ViewCivicCenterUpgradePop", "collect_btn",
                               "ViewMain")

            if self.okc.find_ui_node(ui_node_name="ViewVipDailyPop"):
                self.okc.click("ViewVipDailyPop", "ok_btn", "ViewMain")

            if self.recommended_task.status:
                logging.info("task had finish".title())
                self.__collect_task_reward()
                continue

            if KillBandit.max_id >= self.recommended_task.task_id >= KillBandit.min_id:
                svr_action_list_old_length = len(
                    self.player.data.svr_action_list.keys())
                logging.info("开始杀土匪拉")
                self.__execute_task("bandit_kill")
                while True:
                    self.player.protocol.operate_login_get()
                    if len(self.player.data.svr_action_list.keys()
                           ) <= svr_action_list_old_length:
                        logging.info(
                            "new action length: %s  old action length : %s" %
                            (len(self.player.data.svr_action_list.keys()),
                             svr_action_list_old_length))
                        break
                    else:
                        self.player.cmd_map.march_speed()
                self.__update_recommended_task()

                if self.recommended_task.status:
                    logging.info("完成任务")
                    continue
                else:
                    logging.info("没完成任务")
                    continue
            if BuildingTask.max_id >= self.recommended_task.task_id >= BuildingTask.min_id:
                logging.info("开始建房子了")
                if self.recommended_task.goal_value <= 1:
                    self.__execute_task("building_create")
                else:
                    self.__execute_task("building_upgrade")
                self.__update_recommended_task()
                if self.recommended_task.status:
                    logging.info("完成任务")
                    continue
                else:
                    logging.info("没完成任务")
                    continue
            if TrainTroop.max_id >= self.recommended_task.task_id >= TrainTroop.min_id:
                logging.info("开始杀练兵拉")
                self.__execute_task("training")
                self.__update_recommended_task()
                if self.recommended_task.status:
                    logging.info("完成任务")
                    continue
                else:
                    logging.info("没完成任务")
                    break
            if KillMonster.max_id >= self.recommended_task.task_id >= KillMonster.min_id:
                svr_action_list_old_length = len(
                    self.player.data.svr_action_list.keys())
                logging.info("开始杀怪拉")
                self.__execute_task("monster_kill")
                while True:
                    self.player.protocol.operate_login_get()
                    if len(self.player.data.svr_action_list.keys()
                           ) <= svr_action_list_old_length:
                        logging.info(
                            "new action length: %s  old action length : %s" %
                            (len(self.player.data.svr_action_list.keys()),
                             svr_action_list_old_length))
                        break
                    else:
                        self.player.cmd_map.march_speed()
                self.__update_recommended_task()

                if self.recommended_task.status:
                    logging.info("完成任务")
                    continue
                else:
                    logging.info("没完成任务,继续打")
                    item_id = 300
                    target_id = self.player.data.svr_player.uid
                    item_price = game_table.get_item(item_id).item_price
                    if self.player.data.svr_player.dragon["energy"] < 5000:
                        self.player.protocol.item_buy_and_use(
                            item=item_id,
                            price=item_price,
                            target_id=target_id,
                            action_type=-1,
                            rally_id=0,
                            is_attack=1)
                    continue
            else:
                logging.warning("Not support".title())
                break