Skip to main content

Python tools for manipulating VASSAL modules

Project description

VASSAL Python

Tools for manipulating VASSAL module files using python

Implemented using jpype

The successor to VASSAL::Perl

Components

The package implements the following modules for working with VASSAL game modules

Manager

The class that wraps a headless version of the VASSAL so that it is possible to call all the module loading, parsing, and saving features without a Swing GUI.

from python.vassal.manager import Manager

manager = Manager()
gameModule = manager.open_module("./test.vmod")

Walker

The class that enables recursive descent into the Buildables hierarchy of a game module and enables printing or actions on pieces and components.

from python.vassal.manager import Manager
from python.vassal.walker import Walker

manager = Manager()
gameModule = manager.open_module("./test.vmod")
walker = Walker(gameModule)
walker.print_game_module_pieces()

Loading the JVM

Jpype needs the JVM started before it can begin loading the Java classes. This is handled inside manager.py during the module loading. The JVM needs to find both Vengine.jar and Helper.class in the classpath. One easy way to do that is to set the classpath using jpype before loading manager.py

import jpype
import jpype.imports

jpype.addClassPath("./lib/Vengine.jar")
jpype.addClassPath("classlib/")  # Helper.class
from python.vassal.manager import Manager

Example Applications

  • module-print.py: recursively prints the names of all the piece windows and the pieces in each window
  • add-starting-strengths.py: compares the name of each piece in the module to a predefined list of piece names, and if found, creates a new "StartingStrength" trait on the piece and sets the value to that listed in the file

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

vassal-python-0.2.0.tar.gz (5.1 MB view hashes)

Uploaded Source

Built Distribution

vassal_python-0.2.0-py3-none-any.whl (5.2 MB view hashes)

Uploaded Python 3

Supported by

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