Added support for American Ordnance Note C.

master
Pacman Ghost 5 years ago
parent ebbfa3305c
commit 635c6d5093
  1. 6
      vasl_templates/webapp/static/main.js
  2. 79
      vasl_templates/webapp/static/snippets.js
  3. 6
      vasl_templates/webapp/static/vo.js
  4. 4
      vasl_templates/webapp/static/vo2.js
  5. 4
      vasl_templates/webapp/templates/vo-report.html
  6. 28
      vasl_templates/webapp/tests/test_capabilities.py

@ -116,7 +116,11 @@ $(document).ready( function () {
.click( disconnect_roar ) ;
// initialize the scenario theater
init_select2( $("select[name='SCENARIO_THEATER']"), "5em", false, null ) ;
init_select2(
$("select[name='SCENARIO_THEATER']"), "5em", false, null
).on( "change", function() {
on_scenario_theater_change() ;
} ) ;
// initialize the scenario date picker
$("input[name='SCENARIO_DATE']").datepicker( {

@ -782,7 +782,7 @@ function unload_snippet_params( unpack_scenario_date, template_id )
// we will show the warnings when we make the raw capabilities.
capabilities = make_capabilities(
false,
vo_entry, nat, elite,
vo_entry, vo_type, nat, elite,
params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH,
false
) ;
@ -793,7 +793,7 @@ function unload_snippet_params( unpack_scenario_date, template_id )
}
capabilities = make_capabilities(
true,
vo_entry, nat, elite,
vo_entry, vo_type, nat, elite,
params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH,
show_warnings
) ;
@ -824,7 +824,7 @@ function unload_snippet_params( unpack_scenario_date, template_id )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function make_capabilities( raw, vo_entry, nat, elite, scenario_theater, scenario_year, scenario_month, show_warnings )
function make_capabilities( raw, vo_entry, vo_type, nat, elite, scenario_theater, scenario_year, scenario_month, show_warnings )
{
var capabilities = [] ;
@ -933,18 +933,20 @@ function make_capabilities( raw, vo_entry, nat, elite, scenario_theater, scenari
if ( crew_survival )
capabilities.push( crew_survival ) ;
// do any special adjustments
if ( nat === "american" && vo_type === "ordnance" && scenario_theater === "PTO" )
adjust_capabilities_for_us_ordnance_note_c( capabilities, vo_entry ) ;
if ( elite )
adjust_capabilities_for_elite( capabilities, +1 ) ;
// remove uninteresting capabilities
var capabilities2 = [] ;
var adjusted_capabilities = [] ;
for ( i=0 ; i < capabilities.length ; ++i ) {
if ( ["T","NT","ST"].indexOf( capabilities[i] ) === -1 )
capabilities2.push( capabilities[i] ) ;
adjusted_capabilities.push( capabilities[i] ) ;
}
// check for elite vehicles/ordnance
if ( elite )
adjust_capabilities_for_elite( capabilities2, +1 ) ;
return capabilities2 ;
return adjusted_capabilities ;
}
function make_raw_capability( name, capability )
@ -1126,6 +1128,41 @@ function make_crew_survival( vo_entry )
return crew_survival ;
}
function adjust_capabilities_for_us_ordnance_note_c( capabilities, vo_entry )
{
// NOTE: American Ordnance Note C: Canister depletion number is increased by 3 in the PTO,
// unless it has a "P" superscript. This seems to affect the following ordnance:
// - M3A1 37mm AT Gun
// - T32 37mm Manpack Gun
// - M1A1 75mm Pack Howitzer
// - M2A1 105mm Howitzer (*)
// - M3 105mm Howitzer (*)
// (*) = has "P" superscript.
// check if the ordnance has Note C
if ( ! vo_entry.notes )
return ;
var hasNoteC=false, i ;
for ( i=0 ; i < vo_entry.notes.length ; ++i ) {
if ( vo_entry.notes[i].match( /^C\u2020?/ ) )
hasNoteC = true ;
}
if ( ! hasNoteC )
return ;
// FUDGE! Figuring out if a capability has a "P" subscript would be incredibly messy, since it gets removed
// in _check_capability_timestamp() :-/ We just hard-code the relevant counters instead :-/
if ( ["am/o:013","am/o:014"].indexOf( vo_entry.id ) !== -1 )
return ;
// update the Canister depletion number
for ( i=0 ; i < capabilities.length ; ++i ) {
var match = capabilities[i].match( /^C(\d+)/ ) ;
if ( match )
capabilities[i] = "C" + (parseInt(match[1]) + 3) + capabilities[i].substr(match[0].length) ;
}
}
function adjust_capabilities_for_elite( capabilities, delta )
{
// adjust the list of capabilities for elite status
@ -1915,15 +1952,23 @@ function on_scenario_date_change()
update_ui( "baz", is_baz_available() ) ;
update_ui( "atmm", is_atmm_available() ) ;
// update the vehicle/ordnance entries
_update_vo_sortable2_entries() ;
}
function _update_vo_sortable2_entries()
{
// update all the vehicle/ordnance entries
var snippet_params = unload_snippet_params( true, null ) ;
function update_vo( $sortable2 ) {
function update_vo( vo_type, player_no ) {
var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ;
$sortable2.children( "li" ).each( function() {
update_vo_sortable2_entry( $(this), snippet_params ) ;
update_vo_sortable2_entry( $(this), vo_type, snippet_params ) ;
} ) ;
}
for ( var player_no=1 ; player_no <= 2 ; ++player_no ) {
update_vo( $( "#ob_vehicles-sortable_" + player_no ) ) ;
update_vo( $( "#ob_ordnance-sortable_" + player_no ) ) ;
update_vo( "vehicles", player_no ) ;
update_vo( "ordnance", player_no ) ;
}
}
@ -1949,3 +1994,9 @@ function on_scenario_details_change()
if ( gWebChannelHandler )
gWebChannelHandler.on_scenario_details_change( caption ) ;
}
function on_scenario_theater_change()
{
// update the vehicle/ordnance entries
_update_vo_sortable2_entries() ;
}

@ -215,7 +215,7 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap
content: $content,
data: data,
} ) ;
update_vo_sortable2_entry( $entry ) ;
update_vo_sortable2_entry( $entry, vo_type ) ;
// add a handler for the snippet button
$content.children("img.snippet").click( function( evt ) {
@ -224,7 +224,7 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap
} ) ;
}
function update_vo_sortable2_entry( $entry, snippet_params )
function update_vo_sortable2_entry( $entry, vo_type, snippet_params )
{
// initialize
if ( ! snippet_params )
@ -239,7 +239,7 @@ function update_vo_sortable2_entry( $entry, snippet_params )
var player_no = get_player_no_for_element( $entry ) ;
capabilities = make_capabilities(
false,
vo_entry,
vo_entry, vo_type,
snippet_params[ "PLAYER_"+player_no ],
data.elite,
snippet_params.SCENARIO_THEATER, snippet_params.SCENARIO_YEAR, snippet_params.SCENARIO_MONTH,

@ -9,7 +9,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
function get_default_capabilities( vo_entry, params, show_warnings ) {
return make_capabilities(
false,
vo_entry,
vo_entry, vo_type,
params[ "PLAYER_"+player_no ],
false,
params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH,
@ -198,7 +198,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
delete $entry.data( "sortable2-data" ).custom_comments ;
}
// update the original V/O entry to reflect the changes
update_vo_sortable2_entry( $entry ) ;
update_vo_sortable2_entry( $entry, vo_type ) ;
$(this).dialog( "close" ) ;
},
Cancel: function() { $(this).dialog( "close" ) ; },

@ -67,9 +67,9 @@ function load_vo_listings( objs )
continue ;
buf.push( "<tr>" ) ;
buf.push( "<td>", fmtval(obj.name) ) ;
var capabilities = make_capabilities( true, obj, nat, false, theater, year, month, true ) ;
var capabilities = make_capabilities( true, obj, "{{VO_TYPE}}", nat, false, theater, year, month, true ) ;
buf.push( "<td>", listval(capabilities) ) ;
var capabilities = make_capabilities( false, obj, nat, false, theater, year, month, true ) ;
var capabilities = make_capabilities( false, obj, "{{VO_TYPE}}", nat, false, theater, year, month, true ) ;
buf.push( "<td>", listval(capabilities) ) ;
var note_number = obj.note_number ? "<span class='val'>" + fmtval(obj.note_number) + "</span>" : fmtval("") ;
buf.push( "<td>", note_number ) ;

@ -428,6 +428,34 @@ def test_theater_capabilities_bfp( webapp, webdriver ):
# ---------------------------------------------------------------------
@pytest.mark.skipif(
pytest.config.option.short_tests, #pylint: disable=no-member
reason = "--short-tests specified"
)
def test_american_ordnance_note_c( webapp, webdriver ):
"""Test handling of American Ordnance Note C."""
# M3A1 37mm AT Gun: QSU C7[A2+]†[1]
ordnance = [ "american", "ordnance", "M3A1 37mm AT Gun" ]
_check_capabilities( webdriver, webapp, *ordnance , "ETO", "07/1942", "QSU" )
_check_capabilities( webdriver, webapp, *ordnance , "PTO", "07/1942", "QSU" )
_check_capabilities( webdriver, webapp, *ordnance , "ETO", "08/1942", "QSU C7[!1]" )
_check_capabilities( webdriver, webapp, *ordnance , "PTO", "08/1942", "QSU C10[!1]" ) # nb: C# += 3
# M2A1 105mm Howitzer: C7[4+P]†[1] H6 WP8 s7
ordnance = [ "american", "ordnance", "M2A1 105mm Howitzer" ]
_check_capabilities( webdriver, webapp, *ordnance , "ETO", "12/1943", "H6 WP8 s7" )
_check_capabilities( webdriver, webapp, *ordnance , "PTO", "12/1943", "H6 WP8 s7" )
_check_capabilities( webdriver, webapp, *ordnance , "ETO", "01/1944", "H6 WP8 s7" )
_check_capabilities( webdriver, webapp, *ordnance , "PTO", "01/1944", "C7[!1] H6 WP8 s7" ) # nb: no += 3
# M3 105mm Howitzer: C7[P]†[1] H7 WP8 s7
ordnance = [ "american", "ordnance", "M3 105mm Howitzer" ]
_check_capabilities( webdriver, webapp, *ordnance , "ETO", "01/1940", "H7 WP8 s7" )
_check_capabilities( webdriver, webapp, *ordnance , "PTO", "01/1940", "C7[!1] H7 WP8 s7" ) # nb: no += 3
# ---------------------------------------------------------------------
@pytest.mark.skipif(
pytest.config.option.short_tests, #pylint: disable=no-member
reason = "--short-tests specified"

Loading…
Cancel
Save