diff --git a/.pylintrc b/.pylintrc
index 1ce6b75..65626e0 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -140,6 +140,7 @@ disable=print-statement,
wrong-import-position,
global-statement,
too-few-public-methods,
+ too-many-lines,
duplicate-code, # can't get it to shut up about @pytest.mark.skipif's :-/
no-else-return
diff --git a/vasl_templates/webapp/data/default-template-pack/ob_ordnance.j2 b/vasl_templates/webapp/data/default-template-pack/ob_ordnance.j2
index 4fc8f84..45fb9c0 100644
--- a/vasl_templates/webapp/data/default-template-pack/ob_ordnance.j2
+++ b/vasl_templates/webapp/data/default-template-pack/ob_ordnance.j2
@@ -26,7 +26,7 @@ sup { font-size: 75% ; }
{%for ord in OB_ORDNANCE%}
- {{ord.name}}
+ {{ord.name}} {%if ord.elite%}Ⓔ{%endif%}
{%if ord.image%} {%endif%}
{%if ord.extn_id%} ❖ {%endif%}
diff --git a/vasl_templates/webapp/data/default-template-pack/ob_vehicles.j2 b/vasl_templates/webapp/data/default-template-pack/ob_vehicles.j2
index fc856d7..74af6df 100644
--- a/vasl_templates/webapp/data/default-template-pack/ob_vehicles.j2
+++ b/vasl_templates/webapp/data/default-template-pack/ob_vehicles.j2
@@ -26,7 +26,7 @@ sup { font-size: 75% ; }
{%for veh in OB_VEHICLES%}
- {{veh.name}}
+ {{veh.name}} {%if veh.elite%}Ⓔ{%endif%}
{%if veh.image%} {%endif%}
{%if veh.extn_id%} ❖ {%endif%}
diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js
index 3364ef6..f39c6f1 100644
--- a/vasl_templates/webapp/static/snippets.js
+++ b/vasl_templates/webapp/static/snippets.js
@@ -648,11 +648,13 @@ function unload_snippet_params( unpack_scenario_date, template_id )
var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ;
var objs = [] ;
$sortable2.children( "li" ).each( function() {
- var vo_entry = $(this).data( "sortable2-data" ).vo_entry ;
- var vo_image_id = $(this).data( "sortable2-data" ).vo_image_id ;
+ var data = $(this).data( "sortable2-data" ) ;
+ var vo_entry = data.vo_entry ;
+ var vo_image_id = data.vo_image_id ;
+ var elite = data.elite ;
var obj = {
id: vo_entry.id,
- seq_id: $(this).data( "sortable2-data" ).id,
+ seq_id: data.id,
image_id: (vo_image_id !== null) ? vo_image_id[0]+"/"+vo_image_id[1] : null,
name: vo_entry.name,
note_number: vo_entry.note_number,
@@ -682,7 +684,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,
+ vo_entry, nat, elite,
params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH,
false
) ;
@@ -691,12 +693,15 @@ function unload_snippet_params( unpack_scenario_date, template_id )
}
capabilities = make_capabilities(
true,
- vo_entry, nat,
+ vo_entry, nat, elite,
params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH,
show_warnings
) ;
- if ( capabilities )
+ if ( capabilities ) {
obj.raw_capabilities = capabilities ;
+ if ( elite )
+ obj.elite = true ;
+ }
var comments = $(this).data( "sortable2-data" ).custom_comments ;
if ( comments ) {
obj.comments = comments ;
@@ -719,7 +724,7 @@ function unload_snippet_params( unpack_scenario_date, template_id )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-function make_capabilities( raw, vo_entry, nat, scenario_theater, scenario_year, scenario_month, show_warnings )
+function make_capabilities( raw, vo_entry, nat, elite, scenario_theater, scenario_year, scenario_month, show_warnings )
{
var capabilities = [] ;
@@ -835,6 +840,10 @@ function make_capabilities( raw, vo_entry, nat, scenario_theater, scenario_year,
capabilities2.push( capabilities[i] ) ;
}
+ // check for elite vehicles/ordnance
+ if ( elite )
+ adjust_capabilities_for_elite( capabilities2, +1 ) ;
+
return capabilities2 ;
}
@@ -1017,6 +1026,21 @@ function make_crew_survival( vo_entry )
return crew_survival ;
}
+function adjust_capabilities_for_elite( capabilities, delta )
+{
+ // adjust the list of capabilities for elite status
+ // Pondicherry, India (FEB/19)
+ if ( ! capabilities )
+ return ;
+ for ( var i=0 ; i < capabilities.length ; ++i ) {
+ if ( capabilities[i].indexOf( " " ) !== -1 )
+ continue ; // nb: ignore raw capabilities (e.g. if the scenario date hasn't been set)
+ var match = capabilities[i].match( /^(A|M|H|C|D|HE|AP|WP|s|S|sD|sM|sN)([1-9][0-9]?)/ ) ;
+ if ( match )
+ capabilities[i] = match[1] + (parseInt(match[2]) + delta) + capabilities[i].substr(match[1].length+match[2].length) ;
+ }
+}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function get_template( template_id, fixup )
@@ -1256,7 +1280,7 @@ function do_load_scenario_data( params )
warnings.push( "Invalid V/O image ID for '" + params[key][i].name + "': " + params[key][i].image_id ) ;
}
if ( vo_entry )
- do_add_vo( vo_type, player_no, vo_entry, vo_image_id, params[key][i].custom_capabilities, params[key][i].custom_comments, params[key][i].seq_id ) ;
+ do_add_vo( vo_type, player_no, vo_entry, vo_image_id, params[key][i].elite, params[key][i].custom_capabilities, params[key][i].custom_comments, params[key][i].seq_id ) ;
else
unknown_vo.push( vo_id || "(not set)" ) ;
}
@@ -1415,6 +1439,8 @@ function unload_params_for_save( user_requested )
entry.image_id = params[key][i].image_id ;
if ( params[key][i].custom_capabilities )
entry.custom_capabilities = params[key][i].custom_capabilities ;
+ if ( params[key][i].elite )
+ entry.elite = true ;
if ( params[key][i].custom_comments )
entry.custom_comments = params[key][i].custom_comments ;
entries.push( entry ) ;
diff --git a/vasl_templates/webapp/static/vo.js b/vasl_templates/webapp/static/vo.js
index 6f09c2f..8ee9809 100644
--- a/vasl_templates/webapp/static/vo.js
+++ b/vasl_templates/webapp/static/vo.js
@@ -111,7 +111,7 @@ function add_vo( vo_type, player_no )
var $img = $elem.find( "img[class='vasl-image']" ) ;
var vo_image_id = $img.data( "vo-image-id" ) ;
var seq_id = auto_assign_id( usedSeqIds, "seq_id" ) ;
- do_add_vo( vo_type, player_no, sel_entry, vo_image_id, null, null, seq_id ) ;
+ do_add_vo( vo_type, player_no, sel_entry, vo_image_id, false, null, null, seq_id ) ;
$dlg.dialog( "close" ) ;
}
if ( usedVoIds.indexOf( sel_entry.id ) !== -1 ) {
@@ -131,7 +131,7 @@ function add_vo( vo_type, player_no )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, custom_capabilities, custom_comments, seq_id )
+function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_capabilities, custom_comments, seq_id )
{
// add the specified vehicle/ordnance
// NOTE: We set a fixed height for the sortable2 entries (based on the CSS settings in tabs-ob.css),
@@ -149,6 +149,7 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, custom_capabiliti
caption: vo_entry.name,
vo_entry: vo_entry,
vo_image_id: vo_image_id,
+ elite: elite,
fixed_height: fixed_height
} ;
if ( custom_capabilities )
@@ -208,9 +209,10 @@ function update_vo_sortable2_entry( $entry, snippet_params )
// initialize
if ( ! snippet_params )
snippet_params = unload_snippet_params( true, null ) ;
- var vo_entry = $entry.data( "sortable2-data" ).vo_entry ;
- var vo_image_id = $entry.data( "sortable2-data" ).vo_image_id ;
- var capabilities = $entry.data( "sortable2-data" ).custom_capabilities ;
+ var data = $entry.data( "sortable2-data" ) ;
+ var vo_entry = data.vo_entry ;
+ var vo_image_id = data.vo_image_id ;
+ var capabilities = data.custom_capabilities ;
if ( capabilities )
capabilities = capabilities.slice() ;
else {
@@ -219,6 +221,7 @@ function update_vo_sortable2_entry( $entry, snippet_params )
false,
vo_entry,
snippet_params[ "PLAYER_"+player_no ],
+ data.elite,
snippet_params.SCENARIO_THEATER, snippet_params.SCENARIO_YEAR, snippet_params.SCENARIO_MONTH,
false
) ;
@@ -228,7 +231,10 @@ function update_vo_sortable2_entry( $entry, snippet_params )
var url = get_vo_image_url( vo_entry, vo_image_id, true ) ;
var $content = $entry.children( ".vo-entry" ) ;
$content.find( "img.vasl-image" ).attr( "src", url ) ;
- $content.find( "div.vo-name" ).html( vo_entry.name ) ;
+ var name = vo_entry.name ;
+ if ( data.elite )
+ name += " \u24ba" ;
+ $content.find( "div.vo-name" ).html( name ) ;
for ( var i=0 ; i < capabilities.length ; ++i )
capabilities[i] = "" + capabilities[i] + "" ;
$content.find( "div.vo-capabilities" ).html( capabilities.join("") ) ;
diff --git a/vasl_templates/webapp/static/vo2.js b/vasl_templates/webapp/static/vo2.js
index 7aae2f9..64986e7 100644
--- a/vasl_templates/webapp/static/vo2.js
+++ b/vasl_templates/webapp/static/vo2.js
@@ -11,6 +11,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
false,
vo_entry,
params[ "PLAYER_"+player_no ],
+ false,
params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH,
show_warnings
) ;
@@ -34,12 +35,23 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
return entries ;
}
+ function make_vo_name( name, elite ) {
+ if ( elite )
+ name += " \u24ba" ;
+ else {
+ if ( name.substr( name.length-2 ) === " \u24ba" )
+ name = name.substr( 0, name.length-2 ) ;
+ }
+ return name ;
+ }
+
// get the vehicle/ordnance's capabilities/comments
var params = unload_snippet_params( true, null ) ;
var vo_entry = $entry.data( "sortable2-data" ).vo_entry ;
var capabilities = $entry.data( "sortable2-data" ).custom_capabilities ;
if ( ! capabilities )
capabilities = get_default_capabilities( vo_entry, params, true ).slice() ;
+ var elite = $entry.data( "sortable2-data" ).elite ;
var comments = $entry.data( "sortable2-data" ).custom_comments ;
if ( ! comments )
comments = get_default_comments( vo_entry ) ;
@@ -50,7 +62,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
var buf = [ "" +
@@ -96,9 +109,11 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
var $reset_capabilities = $( "#vo_capabilities-reset" ) ;
$reset_capabilities.data( { vo_entry: vo_entry, params: params } ) ;
function on_reset_capabilities() {
+ $dlg.find( ".header .vo-name" ).html( make_vo_name( vo_entry.name, elite ) ) ;
load_entries( $capabilities,
get_default_capabilities( $reset_capabilities.data("vo_entry"), $reset_capabilities.data("params"), false )
) ;
+ $elite.prop( "checked", false ) ;
}
var $reset_comments = $( "#vo_comments-reset" ) ;
$reset_comments.data( { vo_entry: vo_entry, params: params } ) ;
@@ -108,6 +123,16 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
) ;
}
+ function update_for_elite( delta ) {
+ // update the capabilities
+ var capabilities = unload_entries( $capabilities ) ;
+ adjust_capabilities_for_elite( capabilities, delta ) ;
+ load_entries( $capabilities, capabilities ) ;
+ // update the vehicle/ordnance name
+ var $name = $( "#edit-vo .header .vo-name" ) ;
+ $name.html( make_vo_name( $name.html(), delta > 0 ) ) ;
+ }
+
// show the dialog
var $dlg = $( "#edit-vo" ).dialog( {
dialogClass: "edit-vo",
@@ -128,6 +153,9 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
reset: on_reset_comments,
no_confirm_delete: true,
} ) ;
+ $elite.click( function() {
+ update_for_elite( $(this).prop( "checked" ) ? +1 : -1 ) ;
+ } ) ;
},
open: function() {
// initialize
@@ -141,6 +169,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
} ) ;
// load the dialog
load_entries( $capabilities, capabilities ) ;
+ $elite.prop( "checked", elite ? true : false ) ;
load_entries( $comments, comments ) ;
},
buttons: {
@@ -158,6 +187,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type )
// the capabilities are the same as the default - no need to retain these custom settings
delete $entry.data( "sortable2-data" ).custom_capabilities ;
}
+ $entry.data( "sortable2-data" ).elite = $elite.prop( "checked" ) ;
// unload the comments
var comments = unload_entries( $comments ) ;
if ( comments.join() !== get_default_comments( vo_entry ).join() ) {
diff --git a/vasl_templates/webapp/templates/edit-vo-dialog.html b/vasl_templates/webapp/templates/edit-vo-dialog.html
index c1443c1..229e679 100644
--- a/vasl_templates/webapp/templates/edit-vo-dialog.html
+++ b/vasl_templates/webapp/templates/edit-vo-dialog.html
@@ -3,7 +3,11 @@
- Capabilities:
+
+ Capabilities:
+ Elite
+
+
| |