Added the Partisan nationality.

master
Pacman Ghost 2 years ago
parent 38399c355f
commit fe3d30d2e2
  1. 13
      vasl_templates/webapp/data/default-template-pack/national-capabilities.json
  2. 6
      vasl_templates/webapp/data/default-template-pack/nationalities.json
  3. 8
      vasl_templates/webapp/snippets.py
  4. 103
      vasl_templates/webapp/static/main.js
  5. 15
      vasl_templates/webapp/static/nat_caps.js
  6. 8
      vasl_templates/webapp/static/snippets.js
  7. 6
      vasl_templates/webapp/static/utils.js
  8. 14
      vasl_templates/webapp/tests/fixtures/nat-caps/partisan/1940.txt
  9. 14
      vasl_templates/webapp/tests/fixtures/nat-caps/partisan/1941.txt
  10. 14
      vasl_templates/webapp/tests/fixtures/nat-caps/partisan/1942.txt
  11. 14
      vasl_templates/webapp/tests/fixtures/nat-caps/partisan/1943.txt
  12. 14
      vasl_templates/webapp/tests/fixtures/nat-caps/partisan/1944.txt
  13. 14
      vasl_templates/webapp/tests/fixtures/nat-caps/partisan/1945.txt
  14. 5
      vasl_templates/webapp/tests/test_national_capabilities.py
  15. 2
      vasl_templates/webapp/tests/test_vehicles_ordnance.py
  16. 2
      vasl_templates/webapp/tests/test_vo_notes.py
  17. 3
      vasl_templates/webapp/tests/test_vo_reports.py

@ -188,6 +188,19 @@
]
},
"partisan": {
"th_color": [ "Red", "[EXC: ATR/MG]" ],
"notes": [
"Stealthy when Good Order",
"Never Elite/Inexperienced",
"ELR 5",
"Leadership NA for non-Partisan units",
"Massacre OK",
"RtPh Surrender NA",
"Disrupt NA"
]
},
"kfw-rok": {
"th_color": "{! -08/1950 = Red | 09/1950-04/1951 = Red (ROK) ; Black (KMC) | 05/1951- = Black | ??? !}",
"oba": [ "{! 06/1950- = 10B | ??? !}", "3R",

@ -69,12 +69,16 @@
"ob_colors": [ "#d3edfc","#91cdf5", "#e0a22b" ]
},
"partisan": {
"display_name": "Partisan",
"ob_colors": [ "#eabe51","#d68d1a", "#d68d1a" ]
},
"polish": {
"display_name": "Polish",
"ob_colors": [ "#ecd8b0","#e8cfa4", "#84e8c2" ],
"type": "allied-minor"
},
"belgian": {
"display_name": "Belgian",
"ob_colors": [ "#a3ecd1","#82e3bd", "#61d8a6" ],

@ -212,8 +212,12 @@ def get_flag( nat ):
# serve the standard flag
fname = os.path.join( "static/images/flags/", nat+".png" )
with app.open_resource( fname, "rb" ) as fp:
return _get_small_image( fp, key, height )
try:
with app.open_resource( fname, "rb" ) as fp:
return _get_small_image( fp, key, height )
except FileNotFoundError:
abort( 404 )
return None # stop pylint from complaining :-/
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@ -1,6 +1,7 @@
gAppConfig = {} ;
gDefaultTemplatePack = null ;
gTemplatePack = {} ;
gHasPlayerFlag = {} ;
gValidTemplateIds = [] ;
gVehicleOrdnanceListings = {} ;
gVehicleOrdnanceNotes = {} ;
@ -203,39 +204,6 @@ $(document).ready( function () {
edit: function( $sortable2, $entry ) { edit_ob_ordnance( $entry, 2 ) ; },
} ) ;
// initialize the player droplists
function on_player_droplist_open( $sel ) {
// remember the current selection
$sel.data( "prev-val", $sel.val() ) ;
// limit the droplist's height to the available space
restrict_droplist_height( $sel ) ;
}
function format_player_droplist_item( opt ) {
if ( ! opt.id )
return opt.text ;
var url = make_player_flag_url( opt.id, false ) ;
return $( "<div style='display:flex;align-items:center;height:23px;'>" +
"<div style='display:inline-block;width:1em;text-align:center;margin-right:5px;'>" +
"<img src='" + url + "' style='height:0.8em;'>" +
"</div>" +
" " + opt.text +
"</div>" ) ;
}
init_select2( $( "select[name='PLAYER_1']" ),
"auto", false, format_player_droplist_item
).on( "select2:open", function() {
on_player_droplist_open( $(this) ) ;
} ).on( "change", function() {
on_player_change_with_confirm( 1 ) ;
} ) ;
init_select2( $( "select[name='PLAYER_2']" ),
"auto", false, format_player_droplist_item
).on( "select2:open", function() {
on_player_droplist_open( $(this) ) ;
} ).on( "change", function() {
on_player_change_with_confirm( 2 ) ;
} ) ;
// load the ELR's and SAN's
buf = [ "<option value=''>-</option>" ] ; // nb: to help the user to remember to set this
for ( var i=0 ; i <= 5 ; ++i ) // nb: A19.1: ELR is 0-5
@ -343,6 +311,23 @@ $(document).ready( function () {
// is the set of valid template ID's will depend on what's in it :-/
gValidTemplateIds = Object.keys( data.templates ) ;
update_page_load_status( "template-pack" ) ;
// figure out which player flags are available (because some nationalities don't have one)
var nats = Object.keys( gTemplatePack.nationalities ) ;
var nFlagsChecked = 0 ;
function onFlagChecked() {
if ( ++nFlagsChecked === nats.length ) {
// we've checked all the flags - now we can build the player droplists
init_player_droplists() ;
update_page_load_status( "flag-urls" ) ;
}
}
nats.forEach( function( nat ) {
var url = make_player_flag_url( nat, false ) ;
$.ajax( url, {
success: function() { gHasPlayerFlag[nat] = true ; onFlagChecked() ; },
error: function() { onFlagChecked() ; },
} ) ;
} ) ;
} ).fail( function( xhr, status, errorMsg ) {
showErrorMsg( "Can't get the template pack:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
update_page_load_status( "template-pack" ) ;
@ -475,6 +460,42 @@ $(document).ready( function () {
$("input[name='SCENARIO_NAME']").focus().focus() ;
} ) ;
function init_player_droplists()
{
// initialize the player droplists
function on_player_droplist_open( $sel ) {
// remember the current selection
$sel.data( "prev-val", $sel.val() ) ;
// limit the droplist's height to the available space
restrict_droplist_height( $sel ) ;
}
function format_player_droplist_item( opt ) {
if ( ! opt.id )
return opt.text ;
var url = gHasPlayerFlag[opt.id] ? make_player_flag_url( opt.id, false ) : "" ;
return $( "<div style='display:flex;align-items:center;height:23px;'>" +
"<div style='display:inline-block;width:1em;text-align:center;margin-right:5px;'>" +
"<img src='" + url + "' style='height:0.8em;'>" +
"</div>" +
" " + opt.text +
"</div>" ) ;
}
init_select2( $( "select[name='PLAYER_1']" ),
"auto", false, format_player_droplist_item
).on( "select2:open", function() {
on_player_droplist_open( $(this) ) ;
} ).on( "change", function() {
on_player_change_with_confirm( 1 ) ;
} ) ;
init_select2( $( "select[name='PLAYER_2']" ),
"auto", false, format_player_droplist_item
).on( "select2:open", function() {
on_player_droplist_open( $(this) ) ;
} ).on( "change", function() {
on_player_change_with_confirm( 2 ) ;
} ) ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function init_snippet_button( $btn )
@ -553,7 +574,7 @@ gPageLoadStatus = [
"main", "app-config",
"vehicle-listings", "ordnance-listings", "reset-scenario",
"vehicle-notes", "ordnance-notes", "asl-rulebook2-vo-note-targets",
"vasl-piece-info", "online-counter-images", "template-pack", "default-scenario"
"vasl-piece-info", "online-counter-images", "template-pack", "flag-urls", "default-scenario"
] ;
function update_page_load_status( id )
@ -617,9 +638,6 @@ function update_page_load_status( id )
} ).fail( function( xhr, status, errorMsg ) {
showErrorMsg( "Can't get the startup messages:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
} ) ;
// preload the flag images (so that the player droplist renders immediately)
for ( var nat in gTemplatePack.nationalities )
$.get( make_player_flag_url( nat, false ) ) ;
}
}
@ -697,7 +715,7 @@ function install_template_pack( data )
// update the OB tab headers
// NOTE: We don't do this while the page is initially loading, it will be done when the default scenario loaded.
if ( gPageLoadStatus.indexOf( "template-pack" ) === -1 ) {
if ( gPageLoadStatus.indexOf( "flag-urls" ) === -1 ) {
update_ob_tab_header( 1 ) ;
update_ob_tab_header( 2 ) ;
}
@ -805,10 +823,11 @@ function update_ob_tab_header( player_no )
var display_name = get_nationality_display_name( player_nat ) ;
var image_url = make_player_flag_url( player_nat, false ) ;
var $elem = $( "#tabs .ui-tabs-nav a[href='#tabs-ob" + player_no + "']" ) ;
$elem.html(
"<img src='" + image_url + "'>&nbsp;" +
"<span>" + escapeHTML(display_name) + " OB</span>"
) ;
var buf = [] ;
if ( gHasPlayerFlag[ player_nat ] )
buf.push( "<img src='" + image_url + "'>&nbsp;" ) ;
buf.push( "<span>" + escapeHTML(display_name) + " OB</span>" ) ;
$elem.html( buf.join("") ) ;
return player_nat ;
}

@ -25,10 +25,17 @@ function set_nat_caps_params( player_nat, params )
// set the TH# color
if ( nat_caps.th_color ) {
if ( $.isArray( nat_caps.th_color ) ) {
add_nat_cap( "TH_COLOR",
make_time_based_comment( nat_caps.th_color[0], params.SCENARIO_MONTH, params.SCENARIO_YEAR ) + " TH#" +
" <span class='comment'>(" + nat_caps.th_color[1] + ")</span>"
) ;
var buf = [
make_time_based_comment( nat_caps.th_color[0], params.SCENARIO_MONTH, params.SCENARIO_YEAR ) + " TH#",
" <span class='comment'>"
] ;
var comment = nat_caps.th_color[ 1 ] ;
if ( comment.substring( 0, 5 ) === "[EXC:" && comment[comment.length-1] === "]" )
buf.push( comment ) ;
else
buf.push( "(" + comment + ")" ) ;
buf.push( "</span>" ) ;
add_nat_cap( "TH_COLOR", buf.join("") ) ;
} else {
var th_color = make_time_based_comment( nat_caps.th_color, params.SCENARIO_MONTH, params.SCENARIO_YEAR ) ;
var match = th_color.match( /\(.+\)$/ ) ;

@ -157,7 +157,7 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
var colors = get_player_colors( player_no ) ;
params.OB_COLOR = colors[0] ;
params.OB_COLOR_2 = colors[2] ;
if ( gUserSettings["include-flags-in-snippets"] )
if ( gUserSettings["include-flags-in-snippets"] && gHasPlayerFlag[player_nat] )
params.PLAYER_FLAG = make_player_flag_url( player_nat, true ) ;
}
@ -320,8 +320,10 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
params.PLAYER_1_NAME = get_nationality_display_name( params.PLAYER_1 ) ;
params.PLAYER_2_NAME = get_nationality_display_name( params.PLAYER_2 ) ;
if ( gUserSettings["include-flags-in-snippets"] ) {
params.PLAYER_FLAG_1 = make_player_flag_url( get_player_nat(1), true ) ;
params.PLAYER_FLAG_2 = make_player_flag_url( get_player_nat(2), true ) ;
if ( gHasPlayerFlag[ get_player_nat( 1 ) ] )
params.PLAYER_FLAG_1 = make_player_flag_url( get_player_nat(1), true ) ;
if ( gHasPlayerFlag[ get_player_nat( 2 ) ] )
params.PLAYER_FLAG_2 = make_player_flag_url( get_player_nat(2), true ) ;
}
// pass through all the player colors and names

@ -68,8 +68,10 @@ function make_player_flag_url( nat, for_snippet ) {
return null ;
if ( for_snippet && gUserSettings["scenario-images-source"] == SCENARIO_IMAGES_SOURCE_INTERNET )
return gAppConfig.ONLINE_IMAGES_URL_BASE + "/flags/" + nat + ".png" ;
else
return make_app_url( "/flags/" + nat, for_snippet ) ;
else {
var url = "/flags/" + nat ;
return make_app_url( url, for_snippet ) ;
}
}
function get_player_no_for_element( $elem )

@ -0,0 +1,14 @@
=== partisan (ETO 1940) ===
-
HoB: -
Red TH# [EXC: ATR/MG]
OBA: - - -
* Stealthy when Good Order
* Never Elite/Inexperienced
* ELR 5
* Leadership NA for non-Partisan units
* Massacre OK
* RtPh Surrender NA
* Disrupt NA

@ -0,0 +1,14 @@
=== partisan (ETO 1941) ===
-
HoB: -
Red TH# [EXC: ATR/MG]
OBA: - - -
* Stealthy when Good Order
* Never Elite/Inexperienced
* ELR 5
* Leadership NA for non-Partisan units
* Massacre OK
* RtPh Surrender NA
* Disrupt NA

@ -0,0 +1,14 @@
=== partisan (ETO 1942) ===
-
HoB: -
Red TH# [EXC: ATR/MG]
OBA: - - -
* Stealthy when Good Order
* Never Elite/Inexperienced
* ELR 5
* Leadership NA for non-Partisan units
* Massacre OK
* RtPh Surrender NA
* Disrupt NA

@ -0,0 +1,14 @@
=== partisan (ETO 1943) ===
-
HoB: -
Red TH# [EXC: ATR/MG]
OBA: - - -
* Stealthy when Good Order
* Never Elite/Inexperienced
* ELR 5
* Leadership NA for non-Partisan units
* Massacre OK
* RtPh Surrender NA
* Disrupt NA

@ -0,0 +1,14 @@
=== partisan (ETO 1944) ===
-
HoB: -
Red TH# [EXC: ATR/MG]
OBA: - - -
* Stealthy when Good Order
* Never Elite/Inexperienced
* ELR 5
* Leadership NA for non-Partisan units
* Massacre OK
* RtPh Surrender NA
* Disrupt NA

@ -0,0 +1,14 @@
=== partisan (ETO 1945) ===
-
HoB: -
Red TH# [EXC: ATR/MG]
OBA: - - -
* Stealthy when Good Order
* Never Elite/Inexperienced
* ELR 5
* Leadership NA for non-Partisan units
* Massacre OK
* RtPh Surrender NA
* Disrupt NA

@ -117,8 +117,9 @@ def _get_nat_caps( webapp, webdriver, nat, theater, year, month ): #pylint: disa
else:
assert len(elems) == 1
report[ field ] = to_text( elems[0] ).strip()
assert report["hob-drm"].startswith( "Heat of Battle: " )
report["hob-drm"] = report["hob-drm"][16:]
if report["hob-drm"] != "-":
assert report["hob-drm"].startswith( "Heat of Battle: " )
report["hob-drm"] = report["hob-drm"][16:]
# parse the OBA comments
report["oba-comments"] = []

@ -420,6 +420,8 @@ def test_common_vo( webapp, webdriver ): #pylint: disable=too-many-locals
if nat == "kfw-cpva" and vo_type == "vehicles":
assert not elem.is_enabled()
continue
if nat == "partisan":
continue
elem.click()
# get the vehicles/ordnance

@ -548,7 +548,7 @@ def test_vo_notes_reports( webapp, webdriver ): #pylint: disable=too-many-locals
# get the next report
vo_notes, ma_notes, keys = get_vo_notes_report( webapp, webdriver, nat, vo_type )
if nat in ("burmese","filipino") \
if nat in ("burmese","filipino","partisan") \
or (nat,vo_type) in [ ("landing-craft","ordnance"), ("anzac","ordnance"), ("kfw-cpva","vehicles") ]:
assert not vo_notes and not ma_notes and not keys
continue

@ -67,7 +67,8 @@ def test_vo_reports( webapp, webdriver ): #pylint: disable=too-many-locals
if nat == "landing-craft" and vo_type == "ordnance":
continue
results = get_vo_report( webapp, webdriver, vo_type, nat, "ETO", year, 1 )
if nat in ("burmese","filipino") or (nat,vo_type) in [("anzac","ordnance"),("kfw-cpva","vehicles")]:
if nat in ( "burmese", "filipino", "partisan" ) \
or ( nat, vo_type ) in [ ("anzac","ordnance"), ("kfw-cpva","vehicles") ]:
assert not results
continue

Loading…
Cancel
Save