Exemplo n.º 1
0
    def __init__(self, user_data: UserData, protocol: Protocol):
        self.__data = user_data
        self.__sid = self.__data.svr_player.sid
        self.__uid = self.__data.svr_player.uid
        self.__ksid = self.__data.svr_player.ksid
        self.__request = protocol
        self.get = protocol.request

        self.__block_length = 50
        self.__coord_rate = 10000

        self.__throne_pos = 2500600

        self.__map_block_range = 10
        self.__map_block_site = 1000

        self.__svr_data_json_path = util.get_ini_data(
            conf_path, section="path", section_item="svr_data_json")
        self.__sample_data_dir = util.get_ini_data(conf_path,
                                                   section="path",
                                                   section_item="sample_dir")

        self.__svr_data = self.__init_svr_data()

        self.block_data = dict()

        self.__init_block_data()

        logging.debug("block data's keys length: %s" %
                      len(self.block_data.keys()))
Exemplo n.º 2
0
 def __save_robots(self):
     env_path = util.get_ini_data(ini_path=config.conf_path,
                                  section="path",
                                  section_item="okc_environment")
     last_load = util.read_json_file(env_path)
     if self.robots:
         robot_uid_list = []
         for robot in self.robots:
             robot_uid_list.append(robot.uid)
         last_load["uid"] = robot_uid_list
         # data = {"sid": self.sid, "player_list": robot_uid_list}
         util.write_json_file(file_path=env_path, data=last_load)
Exemplo n.º 3
0
	def mail_send(self, player_name):
		
		mail_type = 0
		
		import util
		import random
		chat_path = util.get_ini_data(conf_path, section="path", section_item="chat_path")
		chat_data = util.read_json_file(file_path=chat_path)
		
		data_key = str(random.randint(0, len(chat_data) - 1))
		content = chat_data[data_key]
		
		return self.__request.mail_send(mail_type=mail_type, target_name=player_name, content=content)
Exemplo n.º 4
0
    def __init__(self, sid: int = 0, start_uid: int = 0, robot_num: int = 0):
        self.sid: int = sid
        self.__start_uid: int = start_uid
        self.__robots_num: int = robot_num
        self.__robots_path = util.get_ini_data(ini_path=conf_path,
                                               section="path",
                                               section_item="okc_robot_uid")

        self.robots: list = []
        self.__init_robots()
        self.__save_robots()

        if len(self.robots) == 0:
            return
        self.robot: Robot = self.robots[0]

        self.__coord_rate = 10000
Exemplo n.º 5
0
    def __init__(self):
        self.app_name = config.okc_app_name

        self.default_wait_time = 1.0
        self.default_save_path = "G:/TestData/okc_test/new_teach/"
        self.ui_pos_path = util.get_ini_data(ini_path=config.conf_path,
                                             section="path",
                                             section_item="ui_pos")
        # util.get_ini_data(config.conf_path, section="path", section_item="okc_test_image_dir")

        self.phone = PhoneManager()
        self.ui_node = UiNodeData()

        self.android_object = None
        self.poco: UnityPoco = None

        self.click_wait_time = 0.3
        self.target_node_pos = tuple()

        self.ui_pos = util.read_json_file(file_path=self.ui_pos_path)
        self.start_game()
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
import util
import os

conf_path = os.path.join(os.getcwd(), "resource/conf.ini")
logo_path = util.get_ini_data(ini_path=conf_path,
                              section="path",
                              section_item="logo_path")

view_title = "弹幕机器人 ----------------- Bill Is Most Handsome Of The World -----------------"
parting_line = "-" * 200
# #### 默认请求间隔时间
request_wait_time = 1
# #### 两次弹幕发送间隔时间
send_text_wait_time = 60


class Platform(object):
    """
	此为平台枚举,不要在任意地方更改
	避免使用Enum,控制包大小
	"""
    ALL = 0
    DOU_YU = 1
    HU_YA = 2


class Params(object):
    # #### 初始平台
    plat_form = Platform.ALL
Exemplo n.º 7
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import config
import util
import logging

from okc_robot.data import number_class as Num
from okc_robot.data.number_class import okc_number_dict

# read game.json
game_json_data_path = util.get_ini_data(ini_path=config.conf_path, section="path", section_item="game_json")
game_json_data = util.read_json_file(file_path=game_json_data_path)

# read error.json
error_json_data_path = util.get_ini_data(ini_path=config.conf_path, section="path", section_item="error_json")
error_json_data = util.read_json_file(file_path=error_json_data_path)

# read wild_res.json
wild_res_json_data_path = util.get_ini_data(config.conf_path, section="path", section_item="wild_res")
wild_res_json_data = util.read_json_file(file_path=wild_res_json_data_path)

# read equip.json
equip_json_data_path = util.get_ini_data(ini_path=config.conf_path, section="path", section_item="equip_json")
equip_json_data = util.read_json_file(file_path=equip_json_data_path)

# 动态创建GameJson类, game_json_data is dict
GameJson = type("GameJson", (object,), game_json_data)


class GameNumerical(GameJson):
	
Exemplo n.º 8
0
    OnlineTest = 2
    Online = 3


okc_app_name = "com.eyougame.sjhg"

conf_path = os.path.join(os.getcwd(), "resource/conf.ini")

request_interval = 0.1

okc_environment = OkcEnvironment.Dev.value

okc_request_mode = OkcRequestMode.Http.value

robots_json_data_path = util.get_ini_data(ini_path=conf_path,
                                          section="path",
                                          section_item="robots_json")

# read game.json
game_json_data_path = util.get_ini_data(ini_path=conf_path,
                                        section="path",
                                        section_item="game_json")
game_json_data = util.read_json_file(file_path=game_json_data_path)

# read error.json
error_json_data_path = util.get_ini_data(ini_path=conf_path,
                                         section="path",
                                         section_item="error_json")
error_json_data = util.read_json_file(file_path=error_json_data_path)

# read wild_res.json
Exemplo n.º 9
0
def okc_robot_start():
    print(
        "welcome to use okc robot.\n\nthe environment : 0-test ,1-dev ,2-online test ,3-online ."
        .title())
    print(
        "no input or input error Use the environment where you last logged in."
        .title())
    print("If this is your first login, use test environment.\n".title())

    input_env = input("choose environment :\n".title())
    sid = input("enter sid:\n".title())
    start_uid = input("start uid:\n".title())
    robot_num = input("robot num:\n".title())

    env_path = util.get_ini_data(ini_path=config.conf_path,
                                 section="path",
                                 section_item="okc_environment")

    def get_help():
        help_info = "-" * 150 + "\n"
        for command_name in robots.__class__.__dict__.keys():
            if not re.match(r"__", command_name):
                help_info += "Command : %s  Params : %s" % (
                    command_name + " " * (30 - len(command_name)) + "·" * 10,
                    robots.__getattribute__(command_name).__doc__)
                help_info += "\n" + "-" * 150 + "\n"
        return help_info

    try:
        input_env = int(input_env)
        if input_env == 0:
            config.okc_environment = config.OkcEnvironment.Test.value
        elif input_env == 1:
            config.okc_environment = config.OkcEnvironment.Dev.value
        elif input_env == 2:
            config.okc_environment = config.OkcEnvironment.OnlineTest.value
        elif input_env == 3:
            config.okc_environment = config.OkcEnvironment.Online.value
        else:
            config.okc_environment = config.OkcEnvironment.Test.value
        logging.info("environment : %s " % config.ENV[config.okc_environment])
        sid = int(sid)
        start_uid = int(start_uid)
        player_num = int(robot_num)
        data = {
            "env": config.okc_environment,
            "sid": sid,
            "uid": list(range(start_uid, start_uid + player_num))
        }
        util.write_json_file(env_path, data=data)
        robots = AnalysisCommand(sid=sid,
                                 start_uid=start_uid,
                                 robot_num=player_num)
    except ValueError:
        last_load = util.read_json_file(env_path)

        env = int(last_load["env"])
        config.okc_environment = env

        logging.info("environment : %s " % config.ENV[config.okc_environment])
        print("-" * 150)

        sid = int(last_load["sid"])
        start_uid = last_load["uid"][0]
        player_num = len(last_load["uid"])

        if start_uid == -1:
            robots = AnalysisCommand()
        else:
            robots = AnalysisCommand(sid=sid,
                                     start_uid=start_uid,
                                     robot_num=player_num)

    if not robots.robots:
        print("Robot Init Failed")
        return
    while True:
        command = input("enter command : \n".title())
        cmd = re.match(r"(\w+)(:?\s+(.*))", command)
        if not cmd:
            print("Input Error.\n")
            print(get_help())
            continue
        try:
            cmd_name, params = cmd.group(1, 2)
        except ValueError:
            print("Input Params Error.\n")
            print(get_help())
            continue
        cmd_list = robots.__dir__()
        if cmd_name in cmd_list:
            cmd_value = getattr(robots, cmd_name)
            try:
                cmd_value(params)
            except:
                logging.error(traceback.print_exc())
        else:
            print("command -> '%s' isn't in cmd list.\n" % cmd_name)
            print(get_help())
            continue