### Deck Property Expression Counting Examples Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/Deck.adoc These examples demonstrate how to define expressions for counting properties within a deck. The format is ' : '. These expressions are used to expose map-level properties based on the number of pieces that satisfy the condition. ```plaintext battleships:BB=1 cruisers:{CA==1} ``` -------------------------------- ### Configure Dependent Projects with Vassal Maven Repository Source: https://github.com/vassalengine/vassal/blob/master/developers-guide/developers-guide.adoc Example XML configuration for Maven projects depending on Vassal. Ensure you use the correct Vassal version. ```xml org.vassalengine vassal-app 3.4.1 vassal-releases https://vassalengine.org/maven/ ``` -------------------------------- ### Example Property Match Expressions Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionSumCount.adoc Demonstrates the syntax for property match expressions within Sum and Count functions. These expressions must be enclosed in curly braces and double quotes, with internal double quotes escaped using \". ```beanshell CountStack("{Strength>3}") + CountStack("{StepCount < 2 && Army == \"Russian\"}") ``` -------------------------------- ### Substring from Start Index Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionString.adoc Extracts a portion of a string starting from a specified character index to the end. ```Vassal Test.substring(1) ``` -------------------------------- ### Simulate HiDPI Display During Development Source: https://context7.com/vassalengine/vassal/llms.txt Run VASSAL with a system property to simulate a HiDPI display for development purposes. ```bash # Simulate a HiDPI display during development java -Dsun.java2d.uiScale=2 -jar vassal-app/target/Vengine.jar ``` -------------------------------- ### Old-Style Property Match Expression Example Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/PropertyMatchExpression.adoc An example of an old-style property match expression. These expressions are not enclosed in curly braces and have a restricted syntax for compatibility with older VASSAL modules. ```plaintext nation = "German" ``` -------------------------------- ### Clean Project Build Source: https://github.com/vassalengine/vassal/blob/master/developers-guide/developers-guide.adoc Use this make command to clean the project before building. ```bash $ make clean ``` -------------------------------- ### Running VASSAL Source: https://context7.com/vassalengine/vassal/llms.txt Commands to build VASSAL, run the Player with a module, and run the Editor to design modules. Includes an option to simulate HiDPI displays. ```APIDOC ## Building and Running VASSAL **Maven build with all checks skipped (fast local build)** ```bash # Full build, skip tests and static analysis tools ./mvnw clean package \ -DskipTests=true \ -Dcheckstyle.skip=true \ -Dspotbugs.skip=true \ -Dmaven.javadoc.skip=true \ -Dasciidoctor.skip=true \ -Dclirr.skip=true # Run the Player with a module java -jar vassal-app/target/Vengine.jar /path/to/MyGame.vmod # Run the Editor to design/edit a module java -jar vassal-app/target/Vengine.jar --edit /path/to/MyGame.vmod # Simulate a HiDPI display during development java -Dsun.java2d.uiScale=2 -jar vassal-app/target/Vengine.jar ``` ``` -------------------------------- ### Get String Length Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionString.adoc Returns the number of characters in a string. Use this to determine the size of a string property. ```vassal LastZone.length() ``` ```vassal "Beach".length() = 5 ``` ```vassal "".length = 0 ``` -------------------------------- ### Compile only, skip tests and other plugins Source: https://github.com/vassalengine/vassal/blob/master/developers-guide/developers-guide.adoc Use this command to perform a clean build, package the application, and skip various plugins like tests, checkstyle, spotbugs, javadoc, asciidoctor, and clirr. ```bash $ mvn clean package -DskipTests=true -Dcheckstyle.skip=true -Dspotbugs.skip=true -Dmaven.javadoc.skip=true -Dasciidoctor.skip=true -Dclirr.skip=true ``` -------------------------------- ### Initialize and Access BasicPiece Properties Source: https://context7.com/vassalengine/vassal/llms.txt Demonstrates how to create a BasicPiece instance and access its built-in properties, such as location and name. Use this for the fundamental representation of a game piece. ```java import VASSAL.counters.BasicPiece; import VASSAL.build.module.BasicCommandEncoder; // Standard type string format: "piece;IMAGE_NAME;PIECE_NAME" String typeString = BasicPiece.ID + "infantry.png;Infantry Unit"; BasicPiece bp = new BasicPiece(typeString, null); // Key built-in property names exposed by BasicPiece System.out.println(BasicPiece.LOCATION_NAME); // "LocationName" System.out.println(BasicPiece.CURRENT_MAP); // "CurrentMap" System.out.println(BasicPiece.CURRENT_BOARD); // "CurrentBoard" System.out.println(BasicPiece.CURRENT_ZONE); // "CurrentZone" System.out.println(BasicPiece.CURRENT_X); // "CurrentX" System.out.println(BasicPiece.CURRENT_Y); // "CurrentY" System.out.println(BasicPiece.OLD_LOCATION_NAME);// "OldLocationName" System.out.println(BasicPiece.BASIC_NAME); // "BasicName" System.out.println(BasicPiece.PIECE_NAME); // "PieceName" System.out.println(BasicPiece.DECK_NAME); // "DeckName" System.out.println(BasicPiece.STACK_POS); // "StackPos" System.out.println(BasicPiece.STACK_SIZE); // "StackSize" System.out.println(BasicPiece.UNIQUE_ID); // "UniqueID" System.out.println(BasicPiece.CLICKED_X); // "ClickedX" — position of last right-click System.out.println(BasicPiece.CLICKED_Y); // "ClickedY" // Read location-related properties Object locationName = bp.getProperty(BasicPiece.LOCATION_NAME); Object oldLocation = bp.getProperty(BasicPiece.OLD_LOCATION_NAME); ``` -------------------------------- ### Substring with Start and End Indices Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionString.adoc Extracts a portion of a string between two specified character indices. The end index is exclusive. ```Vassal Test.substring(1, 3) ``` -------------------------------- ### Check if String Starts With Substring Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionString.adoc Returns true if the target string begins with the specified search string. Useful for prefix matching. ```vassal GetProperty("Test-1").startsWith("ZZ") ``` ```vassal "ZZ-23".startsWith("ZZ") = true ``` ```vassal "ZY-23".startsWith("ZZ") = false ``` -------------------------------- ### Build and Use DynamicProperty Trait in Java Source: https://context7.com/vassalengine/vassal/llms.txt Demonstrates how to programmatically create a piece with a DynamicProperty trait, set its value, and send a network command. Use this for dynamic game state management. ```java import VASSAL.counters.DynamicProperty; import VASSAL.counters.BasicPiece; import VASSAL.counters.Decorator; import VASSAL.command.Command; import VASSAL.command.ChangeTracker; // --- Build a piece with a Dynamic Property trait in code --- // Type string format: "PROP;;;;;;;;<...commands>" BasicPiece base = new BasicPiece("piece;tank.png;Tank", null); // Wrap a DynamicProperty trait around it (named "Strength", numeric 0-10, no wrap) DynamicProperty dpTrait = new DynamicProperty( "PROP;Strength;true;0;10;false;;Armor strength;", base); // dpTrait is now the outermost piece // Read the value System.out.println(dpTrait.getProperty("Strength")); // " (initial empty value) // Programmatically set the value and generate a network Command ChangeTracker tracker = new ChangeTracker(dpTrait); dpTrait.setProperty("Strength", "7"); Command cmd = tracker.getChangeCommand(); GameModule.getGameModule().sendAndLog(cmd); ``` ```java import VASSAL.configure.Parameter; import java.util.List; List params = List.of( new Parameter("Strength", "7"), new Parameter("Morale", "4") ); Command bulkCmd = Decorator.setDynamicProperties(params, dpTrait, propertySource, ownerAuditable); GameModule.getGameModule().sendAndLog(bulkCmd); ``` -------------------------------- ### Build VASSAL with Maven (Skip Checks) Source: https://context7.com/vassalengine/vassal/llms.txt Use this command for a fast local build of VASSAL, skipping tests and static analysis tools. ```bash # Full build, skip tests and static analysis tools ./mvnw clean package \ -DskipTests=true \ -Dcheckstyle.skip=true \ -Dspotbugs.skip=true \ -Dmaven.javadoc.skip=true \ -Dasciidoctor.skip=true \ -Dclirr.skip=true ``` -------------------------------- ### Get and Set Global Property Values Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/GlobalProperties.adoc Use these methods to retrieve the current value of a global property or to assign a new value to it. ```Java property.getPropertyValue() ``` ```Java property.setPropertyValue() ``` -------------------------------- ### BeanShell Property Match Expression Examples Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/PropertyMatchExpression.adoc BeanShell Property Match Expressions leverage the full BeanShell language for complex conditions. They are enclosed in curly braces. ```beanshell {MaxHeight < (CurrentHeight + Growth) && Age > $myAge$} ``` ```beanshell {Nation == (unitType=="Infantry" ? unitNation : formationNation)} ``` -------------------------------- ### Run VASSAL Editor to Design/Edit a Module Source: https://context7.com/vassalengine/vassal/llms.txt Launch the VASSAL Editor to create or modify a game module. ```bash # Run the Editor to design/edit a module java -jar vassal-app/target/Vengine.jar --edit /path/to/MyGame.vmod ``` -------------------------------- ### BeanShell Expression - Logical Operations Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/Expression.adoc Provides examples of logical operators (AND, OR, NOT) and grouping in BeanShell expressions. These are commonly used in property match expressions and conditional logic. ```beanshell {Nation=="Germany" && Type == "Unit"} ``` ```beanshell {Nation == "Germany" || Type == "Unit"} ``` ```beanshell {!isInUse} ``` ```beanshell {A==B && (C == 1 || D == 2)} ``` -------------------------------- ### Run VASSAL Player with a Module Source: https://context7.com/vassalengine/vassal/llms.txt Execute the VASSAL Player application with a specified game module. ```bash # Run the Player with a module java -jar vassal-app/target/Vengine.jar /path/to/MyGame.vmod ``` -------------------------------- ### Configure OpenGL for Graphics Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/userguide/userguide.adoc Add these VM flags to the vassal.vmoptions file to potentially resolve map tearing or graphics corruption issues on non-Windows platforms. Try them one at a time. ```properties -Dsun.java2d.opengl=true ``` ```properties -Dsun.java2d.opengl=false ``` -------------------------------- ### Create New Branch for FlatPak Release Source: https://github.com/vassalengine/vassal/blob/master/developers-guide/developers-guide.adoc Create and checkout a new branch for the FlatPak release. ```bash cd org.vassalengine.vassal git checkout -b release-x.y.z ``` -------------------------------- ### Ternary Operator Example Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/Expression.adoc The ternary operator provides a concise way to express conditional logic, returning one of two values based on a boolean expression. ```Vassal Expression {A == B ? C : D} ``` -------------------------------- ### Find Last Occurrence of Substring Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionString.adoc Searches for the last occurrence of a substring and returns its starting index (0-based). Returns -1 if the substring is not found. Useful for finding the final instance of a pattern. ```vassal Test.lastIndexOf("-") ``` ```vassal "23-ZZ-23".lastIndexOf("23") = 6 ``` ```vassal "ZZ-23".lastIndexOf("ZZ") = 0 ``` ```vassal "abcdefa".lastIndexOf("A") = -1 ``` -------------------------------- ### VASSAL.tools.logging.LogEntry Fields and Constructors Source: https://github.com/vassalengine/vassal/blob/master/vassal-app/src/test/resources/depreport/deprecated.txt Represents a single log entry with severity, message, and other details. ```APIDOC ## VASSAL.tools.logging.LogEntry ### Description Represents a structured log message, containing information about its type, timestamp, process ID, and the message content. ### Constructors - `LogEntry(int type, int pid, java.lang.Throwable throwable, java.lang.String message, boolean flush)`: Constructs a log entry with detailed information. - `LogEntry(long timestamp, int type, int pid, java.lang.Throwable throwable, java.lang.String message, boolean flush)`: Constructs a log entry with a specified timestamp. ### Fields - `BUG`: Constant for bug log type. - `DEBUG`: Constant for debug log type. - `ERROR`: Constant for error log type. - `MESSAGE`: Constant for general message log type. - `SYSTEM`: Constant for system log type. - `WARNING`: Constant for warning log type. - `message`: The log message string. - `pid`: The process ID associated with the log entry. - `serialVersionUID`: Serial version UID for serialization. - `timestamp`: The time the log entry was created. - `trace`: The throwable associated with the log entry. - `type`: The type or severity of the log entry. ### Methods - `toString()`: Returns a string representation of the log entry. - `wait`: (Note: This field seems out of place for a LogEntry, likely a typo or internal detail not meant for public API documentation). ``` -------------------------------- ### Find First Occurrence of Substring Source: https://github.com/vassalengine/vassal/blob/master/vassal-doc/src/main/readme-referencemanual/ReferenceManual/ExpressionString.adoc Searches for the first occurrence of a substring and returns its starting index (0-based). Returns -1 if the substring is not found. Useful for locating specific parts of a string. ```vassal { Test.indexOf("zone") < 0 ? "Not Found" : "Found" } ``` ```vassal "ZZ-23".indexOf("ZZ") = 0 ``` ```vassal "ZY-23".indexOf("ZZ") = -1 ``` ```vassal "ZY-23-Y2".indexOf("Y") = 1 ```