Skip to main content

Use this lib to build your plugins to polisan servers

Project description

Polisan by Adlemas

What is Polisan by the way?

Polisan is an online game in the terminal with support for plugins, communication between players, command input. This game is just the beginning of the path of Adlemas games and its transition to 2D or 3D space.


Terminal gaming is boring?

But why should I play the game in the terminal if I can just as well play with friends in any messenger? Game in the terminal differs from correspondence in that you can store the state of the player in the game, change his state, keep track of certain commands that the player has entered. For all this, a python library called Polisan Plugin was created. Thanks to this library, you can easily describe any rules of your server, events on your server, simulation of hunger and thirst, and much more.

How can I create own plugin?

To create your own plugin, you just need to install this library using the pip tool and create a class that will inherit from the main plugin constructor - CommandPlugin.

Installation

Windows

pip install polisan_plugin

Linux, Mac

pip3 install polisan_plugin

Example

from sys import argv
from polisan_plugin import CommandPlugin

class ChatPlugin(CommandPlugin):
    def __init__(self) -> None:
        super().__init__(argv)
        
    def on_command(self, sender: Sender, command: str, args: list) -> None:
        if command == "commit":
            for client in self.clients:
                client.send_message(" ".join(args))
            sender.send_message("Your message was sent.")



if __name__ == "__main__":
    plugin = ChatPlugin()

Build own plugin.

Prepare plugin information.

To build your plugin, you need to create a config.yaml file in the folder with your plugin code and write inside:

name: "PLUGIN_NAME"
version: PLUGIN_VERSION
author: "PLUGIN_AUTHOR"

platforms: # SUPPORTED PLATFORMS
  - linux
  - windows
  - macos

executable: "NAME_OF_PLUGIN_ENTRY"

commands:
  # COMMANDS

  # For example:
  commit: # COMMAND NAME
    description: Send message to whole world! # DESCRIPTION
    usage: /send <message> # USAGE INSTRUCTION

Converting python file into executable.

Then you need to convert your python code into an executable file according to each platform specified in the config file above. For example, if you want your plugin to work on Windows and Linux machines, you need to build the project twice: in an .exe file for Windows and an executable file for Linux.

Using PyInstaller:

pyinstaller -D -F -n <OUT_NAME_OF_EXECUTABLE> -c "path/to/python/file"

That's it. Deploy.

At this point you can publish your plugin or send it to friends so they can use your creation on their server.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polisan_plugin-0.0.7.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file polisan_plugin-0.0.7.tar.gz.

File metadata

  • Download URL: polisan_plugin-0.0.7.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.7

File hashes

Hashes for polisan_plugin-0.0.7.tar.gz
Algorithm Hash digest
SHA256 652307f0dfd05303dc42672f0d42ce11d3f4a3cbb05ddcaa7058918fa13ae1c5
MD5 0fd243e25d5c02bd035972a018a1842d
BLAKE2b-256 9729a6f9437d33061a46473fa1469b07099ec8de45f4e4ed3f8cbb365319a56a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page