Giter Club home page Giter Club logo

pylanthia's Introduction

Pylanthia

A terminal-based dragonrealms client in Python. Lich is used as a scripting backend.

Setup

This needs improved to run multiple instances with different configs from the same install.

  • Clone this repo
  • Fill in at least 1 character in characters.json
  • Go into vendor and run ./setup.sh
  • run pylanthia: ./play <charname>
    • Make sure docker is running before doing this
    • if you pull changes you may need to rebuild the image
  • follow these steps from here
    • copy dependency.lic over from dr-scripts
      • this is the equivalent of ;repository download dependency.lic
    • `;dependency install
    • ;e toggle_developer_mode
    • ;e use_lich_fork
    • sometimes you need to restart DR a few times at this step
      • It will say "invalid game client, choose one of the following..."
      • Just restart and debug a bit, all config seems right.
    • ;repository download-mapdb (works great)
    • ;autostart add --global roomnumbers
  • Delete backups made by repository: rm lich/scripts/*.bak
  • Go into vendor/lich-scripts and run ./update.sh
    • must happen after ;e toggle_developer_mode

Autostart

Add these scripts to your autostart and dependency.lic lich fork autostart.

  • ;autostart add drinfomon roomnumbers percmoons
  • ;e autostart('rpa_sniper', false)

Play Instructions

Use ./run <charname> to start the game.

charname does accept lowercased abbreviations, try it out.

Lich setup

See [[docs/lich.md]]

  • There was some lich first time setup that might require automation each time the docker image is created. Hopefully idempotent.

Current Dev Direction

  1. pylanthia.py needs broken into modules to be more digestible
  2. Logging and Event Handling need improved, see [[docs/xml-handling.md]]

Cached data

It would be nice to cache a lot of player data in regular format, so that connection can be brokered a bit differently in game, and state navigation can be somewhat done offline or without querying the game. I guess the uses of cached state are to view it, or to queue up commands, or track events over time like training rate or bundle value, hunting times, etc... also possible to diff inventory etc.

The connection could be connected/disconnected from the game console or something. Not sure what value this adds, maybe character switching. Maybe multiple characters in an instance, i don't see the point of developing that yet.

Buffer Bugs

  • sometimes the buffer skips ahead, i assume it's 1 line ahead of my position
  • this is best solved by changing the buffer manual mode detection method
    • when you move the buffer a flag should be flipped until you go back to the end, then it should follow the end again
  • up/down is still unhandled, it needs handled by the urwid widget
  • is it possible to tap into widget height to fill the height? this would be really nice for filling the screen without overflowing up (if that still happens)

Buffering windows

The idea is to tab through windows and only see what you care about.

  • basic modes:
    • filter out of a window
    • filter into a window
    • substitute part of a line
    • highlight a line

Updating pip

  • pyenv install needs apt install zlib1g libsqlite3-dev libbz2-dev libffi-dev libreadline-dev libssl-dev on ubuntu 18 ami
  • PIP_REQUIRE_VIRTUALENV=false pyenv install
  • PIP_REQUIRE_VIRTUALENV=false pyenv exec pip install pipenv
  • now you can mess with your Pipfile and Pipfile.lock

Electron Client

Develop a draft of this after moving view buffers out of urwid_ui.

How does electron install work with a python backend and a docker compose run launching lich?

  • I don't really think docker is necessary since I can just set the host to localhost and change the port in lich.
  • How would I test this? Feed my pylanthia client a totally different port, then run lich subprocess with the incoming port as a cli option... but wait
    • The problem with lich is also the ruby setup, which the docker container handles. So port management is not the only issue.

How can I handle python dependencies and ruby dependencies inside electron? I would want to rpc between dockerized processes within electron

Looks like it would be an electron + react + redux-electron + python subprocess + zerorpc.

Article: https://www.fyears.org/2017/02/electron-as-gui-of-python-apps-updated.html

Some notes - move these

The client is implemented with socket and urwid.

Global variables may not yet be locked properly for threading, especially when appending sent text to the stream.

There is some confusion about how much information newlines from the server actually hold. The server does not seem to provide newlines between consecutive xml tags so some data needs to be extracted from the stream

The stream can also be logged directly and replayed in order to test certain behavior. This is probably the best place to start.

Processing steps before player sees lines:

1. convert xml lines to events or 'window streams'
    - some streams:
        - room
        - backpack
        - inventory
        - health snapshot
        - roundtime
        - prompt/time
        - logins, logouts
        - deaths, raises, etc?
3. 'ignore filter' the lines
    - a line is ignored if a substring is found in it
4. 'color filter' the lines: 
    - substring search, potential for regex search
    - a line can be colored or just the substring/regex section of the string
    - need conversion of hex colors downscaled for terminal? mapping?
    - customize background and foreground color, per-character basis
5. need persistent data structure to store 'ignore filters' and 'color filters'
    - SQLite or flat config file
    - maybe a flat config file at first so it can be configured outside the game
    - ability to hot reload the flat config
    - how will a player use filters to create new streams?
        - this is a killer feature

TCP Lines: - tcp lines are logged by appending to a file

Display lines: - player display lines should be displayed and logged after all processing - processing could all occur in the same thread? - Where are display lines consumed? - urwid loop thread - logging method?

TODO: - log per character name - make a 'last played' log that is easier to tail for debugging and building xml - separate xml parsing into its own data structure, consider sqlite if huge

pylanthia's People

Contributors

robbintt avatar

Stargazers

Shawn O'Hare avatar  avatar Jonas Andersson avatar Richard Hertzog avatar

Watchers

James Cloos avatar  avatar Richard Hertzog avatar  avatar

pylanthia's Issues

Feature requests: squelch management and persistence

  1. persist squelches in database
  2. manage squelches via some cli interface or script, automated squelch adding (approved?, also deduplication/degeneration)
  3. conditional squelching: squelch when flags dr-scripts flags are flipped (e.g. while some script is in some phase)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.