Esempio n. 1
0
def main(cliwin, pid, app_config_path: str, char_configs_path: str,
         enable_mana: bool, enable_hp: bool, enable_magic_shield: bool,
         enable_speed: bool, only_monitor: bool):
    if pid is None or pid == "":
        raise Exception("PID is required, you may use psgrep -a -l bin/Tibia "
                        "to find the process id")
    app_configs_schema = AppConfigsSchema()
    app_configs = app_configs_schema.loadf(app_config_path)
    app_config = app_configs[str(pid)]
    tibia_wid = get_tibia_wid(pid)
    stats_logger = StatsLogger()

    def print_async(msg):
        stats_logger.log_action(2, msg)

    view_renderer = ViewRenderer(cliwin)
    cmd_processor = CommandProcessor(tibia_wid, stats_logger, only_monitor)
    hotkeys_config = HotkeysConfigSchema().loadf(
        os.path.join(char_configs_path, 'hotkeys_config.json'))
    char_configs = list(load_configs(char_configs_path))
    if len(char_configs) == 0:
        print(f"No .charconfig files found in {char_configs_path}",
              file=sys.stderr)
        sys.exit(1)
    client = ClientInterface(hotkeys_config,
                             logger=stats_logger,
                             cmd_processor=cmd_processor)
    char_keeper = CharKeeper(client, char_configs[0],
                             char_configs[0].battle_configs[0], hotkeys_config)
    char_reader = CharReader(MemoryReader(pid, print_async))
    eq_reader = EquipmentReader()
    loot_macro = LootMacro(client, hotkeys_config)
    tibia_terminator = TibiaTerminator(tibia_wid,
                                       char_keeper,
                                       char_reader,
                                       eq_reader,
                                       app_config,
                                       char_configs,
                                       cliwin,
                                       loot_macro,
                                       stats_logger,
                                       view_renderer,
                                       cmd_processor,
                                       enable_mana=enable_mana,
                                       enable_hp=enable_hp,
                                       enable_magic_shield=enable_magic_shield,
                                       enable_speed=enable_speed,
                                       only_monitor=only_monitor)
    tibia_terminator.monitor_char()
Esempio n. 2
0
def main(args: Namespace):
    set_debug_level(args.debug_level)
    if args.debug_level > 1:
        print(args)

    if not args.pid:
        raise Exception("PID is required, you may use psgrep -a -l bin/Tibia "
                        "to find the process id")
    app_configs_schema = AppConfigsSchema()
    app_configs = app_configs_schema.loadf(args.app_config_path)
    app_config = app_configs[str(args.pid)]
    if not app_configs[str(args.pid)]:
        raise Exception(
            f"App config for PID: {args.pid} not configured. Available"
            f" PIDs: {[c.pid for c in app_configs.configs]}")
    hotkeys_config = HotkeysConfigSchema().loadf(
        os.path.join(args.char_configs_path, "hotkeys_config.json"))
    char_configs = list(load_configs(args.char_configs_path))
    if len(char_configs) == 0:
        raise Exception(
            f"No .charconfig files found in {args.char_configs_path}")
    tibia_window_spec_schema = TibiaWindowSpecSchema()
    tibia_window_spec = tibia_window_spec_schema.loadf(
        args.tibia_window_config_path)

    curses.wrapper(
        curses_main,
        args.pid,
        app_config,
        char_configs,
        tibia_window_spec,
        hotkeys_config,
        enable_mana=not args.no_mana,
        enable_hp=not args.no_hp,
        enable_magic_shield=not args.no_magic_shield,
        enable_speed=not args.no_speed,
        only_monitor=args.only_monitor,
        x_offset=args.x_offset,
    )
Esempio n. 3
0
        reader.init_magic_shield_address()
    if soul_points_address is not None:
        reader.init_soul_points_address(int(soul_points_address, 16))
    if magic_shield_address is not None:
        reader.init_magic_shield_address(int(magic_shield_address, 16))
    if max_hp_address is not None:
        reader.init_max_hp_address(int(max_hp_address, 16))
    if max_mana_address is not None:
        reader.init_max_mana_address(int(max_mana_address, 16))

    stats = reader.get_stats().get()
    print(f"HP={stats['hp']};MANA={stats['mana']};SPEED={stats['speed']};"
          f"SOUL_POINTS={stats['soul_points']};"
          f"MAGIC_SHIELD={stats['magic_shield']};"
          f"MAX_MANA={reader.get_max_mana()};MAX_HP={reader.get_max_hp()}")


if __name__ == "__main__":
    args = parser.parse_args()
    pid = args.pid or MEM_CONFIG['default_pid']
    app_config_schema = AppConfigsSchema()
    configs = app_config_schema.loadf(args.app_config_path)
    config = configs[pid]
    main(pid, args.mana_address or config.mana_memory_address, args.hp_address
         or config.hp_memory_address, args.magic_shield_address
         or config.magic_shield_memory_address, args.speed_address
         or config.speed_memory_address, args.soul_points_address
         or config.soul_points_memory_address, args.max_hp_address
         or config.max_hp_address, args.max_mana_address
         or config.max_mana_address, args.verbose)