diff --git a/vasl_templates/webapp/lfa.py b/vasl_templates/webapp/lfa.py index 7934b01..516d4ed 100644 --- a/vasl_templates/webapp/lfa.py +++ b/vasl_templates/webapp/lfa.py @@ -131,6 +131,12 @@ def parse_analysis_report( fname, logger=None ): "turnNo": elem.attrib[ "turnNo" ], "phase": elem.attrib[ "phase" ] } ) + elif elem.tag == "customLabelEvent": + # found a CUSTOM label + events.append( { + "eventType": "customLabel", + "caption": elem.text + } ) else: if logger: logger.warn( "Found an unknown analysis event: %s", elem.tag ) diff --git a/vasl_templates/webapp/static/lfa.js b/vasl_templates/webapp/static/lfa.js index 9b28a63..0d0f9e8 100644 --- a/vasl_templates/webapp/static/lfa.js +++ b/vasl_templates/webapp/static/lfa.js @@ -684,6 +684,10 @@ function updateTimePlotChart( currWindowSize ) // we have a Turn Track event - use the phase description as the next label nextLabel = evt.side + " " + evt.turnNo + " " + evt.phase ; }, + onCustomLabelEvent: function( evt ) { + // we have a custom label event - use the caption as the next label + nextLabel = evt.caption ; + }, onRollEvent: function( evt ) { // we have a DR/dr roll - check if we want to include it if ( rollType === "" ) { @@ -1672,6 +1676,10 @@ function onDownloadData() // save the phase (it will be included in the next row of data) nextLabel = evt.side + " " + evt.turnNo + " " + evt.phase ; }, + onCustomLabelEvent: function( evt ) { + // save the custom label (it will be included in the next row of data) + nextLabel = evt.caption ; + }, onRollEvent: function( evt ) { // generate the next row of data if ( nextLogFilename ) { diff --git a/vasl_templates/webapp/tests/fixtures/analyze-vlog/custom-labels.vlog b/vasl_templates/webapp/tests/fixtures/analyze-vlog/custom-labels.vlog new file mode 100644 index 0000000..34c05db Binary files /dev/null and b/vasl_templates/webapp/tests/fixtures/analyze-vlog/custom-labels.vlog differ diff --git a/vasl_templates/webapp/tests/test_lfa.py b/vasl_templates/webapp/tests/test_lfa.py index b6e8e57..2352220 100644 --- a/vasl_templates/webapp/tests/test_lfa.py +++ b/vasl_templates/webapp/tests/test_lfa.py @@ -509,6 +509,45 @@ def test_download_data( webapp, webdriver ): # --------------------------------------------------------------------- +@pytest.mark.skipif( not pytest.config.option.vasl_mods, reason="--vasl-mods not specified" ) #pylint: disable=no-member +@pytest.mark.skipif( not pytest.config.option.vassal, reason="--vassal not specified" ) #pylint: disable=no-member +def test_custom_labels( webapp, webdriver ): + """Test custom labels in the log file.""" + + # initialize + control_tests = init_webapp( webapp, webdriver, vlog_persistence=1, lfa_persistence=1 ) + + def do_test(): #pylint: disable=missing-docstring + + # analyze the log file + _analyze_vlogs( "custom-labels.vlog" ) + + # download the data + marker = set_stored_msg_marker( "_lfa-download_" ) + find_child( "#lfa button.download" ).click() + wait_for( 2, lambda: get_stored_msg("_lfa-download_") != marker ) + data = get_stored_msg( "_lfa-download_" ) + + # check the results + data = data.split( "\n" ) + rows = list( csv.reader( data, quoting=csv.QUOTE_NONNUMERIC ) ) + assert rows == [ + [ "Log file", "Phase", "Player", "Type", "Die 1", "Die 2" ], + [ "custom-labels.vlog", "", "test", "Other", 5, 3 ], + [ "", "", "test", "Other", 3, "" ], + [ "", "Custom Label 1", "test", "Other", 6, 6 ], + [ "", "", "test", "RS", 6, "" ], + [ "", "Axis 1 PFPh", "test", "Other", 4, 4 ], + [ "", "", "test", "RS", 6, "" ], + [ "", "Custom label 2", "test", "Other", 2, 1 ], + [ "", "", "test", "RS", 1, "" ] + ] + + # run the test + _run_tests( control_tests, do_test, False ) + +# --------------------------------------------------------------------- + def _analyze_vlogs( fnames ): """Analyze log file(s).""" diff --git a/vassal-shim/release/vassal-shim.jar b/vassal-shim/release/vassal-shim.jar index 6ca0b54..c2fd713 100644 Binary files a/vassal-shim/release/vassal-shim.jar and b/vassal-shim/release/vassal-shim.jar differ diff --git a/vassal-shim/src/vassal_shim/VassalShim.java b/vassal-shim/src/vassal_shim/VassalShim.java index 790e7ee..1351969 100644 --- a/vassal-shim/src/vassal_shim/VassalShim.java +++ b/vassal-shim/src/vassal_shim/VassalShim.java @@ -223,9 +223,12 @@ public class VassalShim Pattern diceRoll3EventPattern = Pattern.compile( config.getProperty( "LFA_PATTERN_DICE3_ROLL", "^\\*\\*\\* 3d6 = (?\\d),(?\\d),(?\\d) \\*\\*\\*\\s+\\<(?.+?)\\>" ) ) ; - Pattern turnTrackEventPatter = Pattern.compile( + Pattern turnTrackEventPattern = Pattern.compile( config.getProperty( "LFA_PATTERN_TURN_TRACK", "^\\* New: (?.+?) Turn (?\\d+) - (?.+?) \\*" ) ) ; + Pattern customLabelEventPattern = Pattern.compile( + config.getProperty( "LFA_PATTERN_CUSTOM_LABEL", "!!vt-label (?