diff --git a/chapter-h/chapter-h-placeholders.zip b/chapter-h/chapter-h-placeholders.zip index e802ce7..10e359a 100644 Binary files a/chapter-h/chapter-h-placeholders.zip and b/chapter-h/chapter-h-placeholders.zip differ diff --git a/vasl_templates/tools/make_chapter_h_placeholders.py b/vasl_templates/tools/make_chapter_h_placeholders.py index bc955f8..789cccd 100755 --- a/vasl_templates/tools/make_chapter_h_placeholders.py +++ b/vasl_templates/tools/make_chapter_h_placeholders.py @@ -51,6 +51,10 @@ def make_chapter_h_placeholders( output_fname, log=None \ fname = os.path.join( root, fname ) if os.path.splitext( fname )[1] != ".json": continue + if os.path.splitext( fname )[0].endswith( ".lend-lease" ): + # NOTE: Doing this means we will miss any pieces explicitly defined in a lend-lease file + # (instead of being copied from an existing piece), but we can live with that... :-/ + continue dname2, fname2 = os.path.split( fname ) nat = os.path.splitext( fname2 )[0] if nat == "common": diff --git a/vasl_templates/tools/tests/fixtures/chapter-h-placeholders.txt b/vasl_templates/tools/tests/fixtures/chapter-h-placeholders.txt index 57f4b76..60e7488 100644 --- a/vasl_templates/tools/tests/fixtures/chapter-h-placeholders.txt +++ b/vasl_templates/tools/tests/fixtures/chapter-h-placeholders.txt @@ -1213,17 +1213,8 @@ russian/vehicles/44.png russian/vehicles/45.png russian/vehicles/46.png russian/vehicles/47.png -russian/vehicles/48.png -russian/vehicles/49.png russian/vehicles/5.png -russian/vehicles/50.png -russian/vehicles/51.png -russian/vehicles/52.png -russian/vehicles/53.png -russian/vehicles/54.png -russian/vehicles/59.png russian/vehicles/6.png -russian/vehicles/60.png russian/vehicles/7.png russian/vehicles/8.png russian/vehicles/9.png @@ -1258,13 +1249,10 @@ russian/vehicles/i.html russian/vehicles/j.html russian/vehicles/k.html russian/vehicles/l.html -russian/vehicles/ll.html russian/vehicles/m.html russian/vehicles/n.html -russian/vehicles/o.html russian/vehicles/p.html russian/vehicles/q.html -russian/vehicles/r.html russian/vehicles/s.html russian/vehicles/t.html slovakian/ordnance/28.png diff --git a/vasl_templates/webapp/data/vehicles/russian.json b/vasl_templates/webapp/data/vehicles/russian.json index 2e2836e..5c72626 100644 --- a/vasl_templates/webapp/data/vehicles/russian.json +++ b/vasl_templates/webapp/data/vehicles/russian.json @@ -644,101 +644,6 @@ "notes": [ "S\u20201" ], "id": "ru/v:073", "gpid": 7089 -}, -{ "name": "Stuart III(a)", - "type": "LT", - "CS#": 4, - "capabilities2": { "C": 6 }, - "note_number": "48", - "notes": [ "N", "O", "LL" ], - "id": "ru/v:074", - "gpid": [ 6362, 6364 ] -}, -{ "name": "Lee(a)", - "type": "MT", - "CS#": 7, - "capabilities2": { "C": "4\u2020", "s": "8\u2020" }, - "note_number": "49\u2020", - "notes": [ "B\u20201", "N", "O", "LL" ], - "id": "ru/v:075", - "gpid": [ 704, 706, 7423 ] -}, -{ "name": "Sherman III(a)", - "type": "MT", - "CS#": "5:brewup", - "capabilities2": { "s": 8, "WP": [ [6,"J4+"], "\u2020" ] }, - "note_number": "50\u2020", - "notes": [ "N", "O", "R\u20201", "LL" ], - "id": "ru/v:076", - "gpid": [ 708, 710, 7091 ] -}, -{ "name": "Sherman III(L)(a)", - "type": "MT", - "CS#": "6:brewup", - "capabilities2": { "s": 5, "WP": 7, "sM": 8 }, - "note_number": "50.1", - "notes": [ "N", "O", "R\u2020", "LL" ], - "id": "ru/v:077", - "gpid": [ 712, 714 ] -}, -{ "name": "Matilda II(b)", - "type": "HT", - "CS#": 5, - "capabilities2": { "sD": 6 }, - "note_number": "51\u2020", - "notes": [ "M\u20201", "N", "LL" ], - "id": "ru/v:078", - "gpid": null -}, -{ "name": "Valentine V(b)", - "type": "HT", - "CS#": 4, - "capabilities2": { "sM": 8 }, - "note_number": "52.1", - "notes": [ "N", "LL" ], - "id": "ru/v:079", - "gpid": null -}, -{ "name": "Valentine VIII(b)", - "type": "HT", - "CS#": 4, - "capabilities2": { "HE": 7, "sD": 6 }, - "note_number": "52.2", - "notes": [ "N", "LL" ], - "id": "ru/v:080", - "gpid": null -}, -{ "name": "Churchill III(b)", - "type": "HT", - "CS#": 7, - "capabilities2": { "D": [ [6,"J4"], [7,5], "\u2020" ], "HE": [ [7,"F3"], [8,"4+"], "\u2020" ], "sD": [ [6,"4+"] ], "sM": "8\u2020" }, - "note_number": "53\u2020", - "notes": [ "N", "LL" ], - "id": "ru/v:081", - "gpid": null -}, -{ "name": "M3A1 Scout Car(a)", - "type": "APC", - "CS#": 4, - "note_number": "54\u2020", - "notes": [ "N", "LL" ], - "id": "ru/v:082", - "gpid": null -}, -{ "name": "Jeep GPA(a)", - "type": "atr", - "cs#": 2, - "note_number": "59", - "notes": [ "H\u2020", "L\u20201" ], - "id": "ru/v:083", - "gpid": 7119 -}, -{ "name": "DUKW(a)", - "type": "atr", - "cs#": 7, - "note_number": "60\u2020", - "id": "ru/v:084", - "gpid": 7120 } ] diff --git a/vasl_templates/webapp/data/vehicles/russian.lend-lease.json b/vasl_templates/webapp/data/vehicles/russian.lend-lease.json new file mode 100644 index 0000000..958b36a --- /dev/null +++ b/vasl_templates/webapp/data/vehicles/russian.lend-lease.json @@ -0,0 +1,167 @@ +[ + +{ "name": "Stuart III(a)", + "type": "LT", + "CS#": 4, + "capabilities2": { "C": 6 }, + "note_number": "48", + "notes": [ "N", "O", "LL" ], + "id": "ru/v:074", + "gpid": [ 6364 ], + "_comment_": "VASL also has GPID 6362 (British), but it has extra capabilities." +}, +{ "name": "Lee(a)", + "type": "MT", + "CS#": 7, + "capabilities2": { "C": "4\u2020", "s": "8\u2020" }, + "note_number": "49\u2020", + "notes": [ "B\u20201", "N", "O", "LL" ], + "id": "ru/v:075", + "gpid": [ 704, 7423 ], + "_comment_": "VASL has 2 other GPID's, with different capabilities." +}, +{ "name": "Sherman III(a)", + "type": "MT", + "CS#": "5:brewup", + "capabilities2": { "s": 8, "WP": [ [6,"J4+"], "\u2020" ] }, + "note_number": "50\u2020", + "notes": [ "N", "O", "R\u20201", "LL" ], + "id": "ru/v:076", + "gpid": [ 708, 710, 7091 ], + "_comment_": "VASL also has sD6 (wrong?) and Red TH #'s[< 44] (why?) for all 3 variants." +}, +{ "name": "Sherman III(L)(a)", + "type": "MT", + "CS#": "6:brewup", + "capabilities2": { "s": 5, "WP": 7, "sM": 8 }, + "note_number": "50.1", + "notes": [ "N", "O", "R\u2020", "LL" ], + "id": "ru/v:077", + "gpid": [ 712, 7093 ] +}, +{ "name": "Matilda II(b)", + "type": "HT", + "CS#": 5, + "capabilities2": { "sD": 6 }, + "note_number": "51\u2020", + "notes": [ "M\u20201", "N", "LL" ], + "id": "ru/v:078", + "gpid": null, + "_comment_": "VASL has a Russian variant with CS 4." +}, +{ "id": "ru/v:085", + "copy_from": "br/v:041", + "name": "Valentine II(b)", + "note_number": "52", + "extra_notes": [ "LL" ], + "gpid": [ 724 ] +}, +{ "id": "ru/v:079", + "copy_from": "br/v:042", + "name": "Valentine V(b)", + "note_number": "52\u2020", + "extra_notes": [ "LL" ], + "gpid": [ 726, 728, 7432, 7434 ] +}, +{ "id": "ru/v:080", + "copy_from": "br/v:043", + "name": "Valentine VIII(b)", + "note_number": "52\u2020", + "extra_notes": [ "LL" ], + "gpid": [ 730, 7111 ] +}, +{ "name": "Churchill III(b)", + "type": "HT", + "CS#": 7, + "capabilities2": { "D": [ [6,"J4"], [7,5], "\u2020" ], "HE": [ [7,"F3"], [8,"4+"], "\u2020" ], "sD": [ [6,"4+"] ], "sM": "8\u2020" }, + "note_number": "53\u2020", + "notes": [ "N", "LL" ], + "id": "ru/v:081", + "gpid": [ 732, 7115 ] +}, + +{ "id": "ru/v:082", + "copy_from": "am/v:041", + "name": "M3A1 Scout Car(a)", + "note_number": "54", + "extra_notes": [ "LL" ], + "gpid": [ 7426, 7428 ] +}, +{ "id": "ru/v:086", + "copy_from": "br/v:090", + "note_number": "55", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:087", + "copy_from": "br/v:091", + "note_number": "55", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:088", + "copy_from": "br/v:087", + "note_number": "56", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:089", + "copy_from": "br/v:094", + "note_number": "57", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:090", + "copy_from": "br/v:095", + "note_number": "57", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:091", + "copy_from": "br/v:096", + "note_number": "57", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:092", + "copy_from": "br/v:097", + "note_number": "57", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:093", + "copy_from": "br/v:098", + "note_number": "57", + "extra_notes": [ "LL" ] +}, + +{ "name": "Jeep(a)", + "type": "atr", + "cs#": 2, + "note_number": "58", + "notes": [ "H\u2020", "L\u20201", "LL" ], + "id": "ru/v:083", + "gpid": [ 758, 759, 7119 ] +}, +{ "id": "ru/v:094", + "copy_from": "br/v:123", + "note_number": "Br 85", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:095", + "copy_from": "br/v:124", + "note_number": "Br 85", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:096", + "copy_from": "br/v:125", + "note_number": "Br 85", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:097", + "copy_from": "br/v:126", + "note_number": "Br 85", + "extra_notes": [ "LL" ] +}, +{ "id": "ru/v:084", + "copy_from": "am/v:056", + "note_number": "US 52\u2020", + "extra_notes": [ "LL" ], + "gpid": 7120 +} + +] + diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 0f9d037..178e8a2 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -16,7 +16,8 @@ var _DAY_OF_MONTH_POSTFIXES = { // nb: we assume English :-/ // NOTE: Blood & Jungle has a lot of multi-applicable notes that simply refer to other // multi-applicable notes e.g. "Fr C" = "French Multi-Applicable Note C". -var BFP_MA_NOTE_REDIRECTS = { +// NOTE: These are also used for Lend-Lease vehicles. +var MA_NOTE_REDIRECTS = { "Br": "british", "Ch": "chinese", "Fr": "french", @@ -28,6 +29,12 @@ var BFP_MA_NOTE_REDIRECTS = { "AxM": "axis-minor", } ; +// NOTE: There are BFP references like "Jp 5", but we ignore these since they are referring to +// a vehicle/ordnance *note*, not a multi-applicable note. +MA_NOTE_REDIRECT_REGEX = new RegExp( + "^((Br|Ch|Fr|Ge|Jp|Ru|US|AllM|AxM) [A-Z]{1,2})(\\u2020(\\d)?|T)?$" +) ; + var gDefaultScenario = null ; var gLastSavedScenario = null ; var gLastSavedScenarioFilename = null ; @@ -384,22 +391,38 @@ function get_vo_note_key( vo_entry ) // get the note number for the specified vehicle/ordnance if ( ! vo_entry.note_number ) return null ; - // nb: there are some note numbers of the form "1.2" :-/ - var match = vo_entry.note_number.match( new RegExp( "^([0-9.]+)" ) ) ; + // NOTE: There are some note numbers of the form "1.2" :-/ We also need to handle redirects. + var match = vo_entry.note_number.match( new RegExp( "^((Br|US) )?([0-9]+(.\\d)?)" ) ) ; if ( ! match ) return null ; - var key = match[1] ; + var key = match[0] ; if ( vo_entry.extn_id ) key = vo_entry.extn_id + ":" + key ; return key ; } -function is_known_vo_note_key( vo_type, nat, key ) +function make_vo_note_key_url( vo_type, nat, key ) { + if ( ! key ) + return null ; + + // check for redirects + var match = key.match( /^(Br|US) (.+)$/ ) ; + if ( match ) { + nat = MA_NOTE_REDIRECTS[ match[1] ] ; + key = match[2] ; + } + // check if the vehicle/ordnance note key is known to us - return vo_type in gVehicleOrdnanceNotes && - nat in gVehicleOrdnanceNotes[ vo_type ] && - key in gVehicleOrdnanceNotes[ vo_type ][ nat ] ; + if ( !( vo_type in gVehicleOrdnanceNotes ) ) + return null ; + if ( !( nat in gVehicleOrdnanceNotes[ vo_type ] ) ) + return null ; + if ( !( key in gVehicleOrdnanceNotes[ vo_type ][ nat ] ) ) + return null ; + + // generate the URL + return APP_URL_BASE + "/" + vo_type + "/" + nat + "/note/" + key ; } function get_ma_notes_keys( nat, vo_entries, vo_type ) @@ -419,9 +442,7 @@ function get_ma_notes_keys( nat, vo_entries, vo_type ) new RegExp( "^([A-Z][a-z])$" ), new RegExp( "^([A-Za-z])" ), new RegExp( "^([A-Za-z])$" ), - // NOTE: There are BFP references like "Jp 5", but we ignore these since they are referring to - // a vehicle/ordnance *note*, not a multi-applicable note. - new RegExp( "^((Br|Ch|Fr|Ge|Jp|Ru|US|AllM|AxM) [A-Z]{1,2})(\\u2020(\\d)?)?$" ), + MA_NOTE_REDIRECT_REGEX, ] ; var EXTRA_NOTES_INFO = { "sh/v": [ "landing-craft", "Landing Craft" ], @@ -484,7 +505,7 @@ function get_ma_notes_keys( nat, vo_entries, vo_type ) if ( pos > 0 ) { var val = keys0[i].substr( pos+1 ) ; pos = val.indexOf( " " ) ; - if ( BFP_MA_NOTE_REDIRECTS[ val.substr(0,pos) ] == nat && val.substr(pos+1) in std_keys ) + if ( MA_NOTE_REDIRECTS[ val.substr(0,pos) ] == nat && val.substr(pos+1) in std_keys ) continue ; } keys0a.push( keys0[i] ) ; @@ -545,11 +566,17 @@ function get_ma_note( nat, vo_type, key ) { var ma_notes ; function redirect_ma_note( target, vo_type ) { - pos = target.indexOf( " " ) ; - var nat_redirect = BFP_MA_NOTE_REDIRECTS[ target.substring( 0, pos ) ] ; - if ( nat_redirect ) { - ma_notes = get_ma_notes_for_nat( nat_redirect, vo_type ) ; - return ma_notes[ target.substring( pos+1 ) ] ; + // extract the multi-applicable note ID + var match = target.match( MA_NOTE_REDIRECT_REGEX ) ; + if ( match ) { + // check if it's a valid redirect + pos = match[0].indexOf( " " ) ; + var nat_redirect = MA_NOTE_REDIRECTS[ match[0].substring( 0, pos ) ] ; + if ( nat_redirect ) { + // yup - get the referenced multi-applicable note + ma_notes = get_ma_notes_for_nat( nat_redirect, vo_type ) ; + return ma_notes[ match[0].substring( pos+1 ) ] ; + } } return null ; } @@ -559,6 +586,8 @@ function get_ma_note( nat, vo_type, key ) var pos = key.indexOf( ":" ) ; if ( pos !== -1 ) ma_note = redirect_ma_note( key.substring(pos+1), vo_type ) ; + else + ma_note = redirect_ma_note( key, vo_type ) ; if ( ! ma_note ) { // look for a normal note diff --git a/vasl_templates/webapp/static/vo.js b/vasl_templates/webapp/static/vo.js index 8ee9809..e34e91d 100644 --- a/vasl_templates/webapp/static/vo.js +++ b/vasl_templates/webapp/static/vo.js @@ -165,20 +165,17 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap "" ] ; var vo_note_key = get_vo_note_key( vo_entry ) ; - var vo_nat ; - if ( is_known_vo_note_key( vo_type, nat, vo_note_key ) ) - vo_nat = nat ; - else { + var vo_note_url = make_vo_note_key_url( vo_type, nat, vo_note_key ) ; + if ( ! vo_note_url ) { // NOTE: Note numbers seem to be distinct across all Allied Minor or all Axis Minor vehicles/ordnance, // so if we don't find a note in a given nationality's normal vehicles/ordnance, we can get away with // just checking their corresponding common vehicles/ordnance. var nat_type = gTemplatePack.nationalities[ nat ].type ; if ( ["allied-minor","axis-minor"].indexOf( nat_type ) !== -1 ) { - if ( is_known_vo_note_key( vo_type, nat_type, vo_note_key ) ) - vo_nat = nat_type ; + vo_note_url = make_vo_note_key_url( vo_type, nat_type, vo_note_key ) ; } } - if ( vo_nat ) { + if ( vo_note_url ) { var template_id = (vo_type === "vehicles") ? "ob_vehicle_note" : "ob_ordnance_note" ; if ( is_template_available( template_id ) ) { buf.push( @@ -186,8 +183,7 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap " class='snippet' data-id='" + template_id + "' title='" + GENERATE_SNIPPET_HINT + "'>" ) ; } - var url = APP_URL_BASE + "/" + vo_type + "/" + vo_nat + "/note/" ; - data.vo_note_url = url + vo_note_key ; + data.vo_note_url = vo_note_url ; } buf.push( "" ) ; var $content = $( buf.join("") ) ; diff --git a/vasl_templates/webapp/templates/vo-notes-report.html b/vasl_templates/webapp/templates/vo-notes-report.html index a680e7c..c743fc8 100644 --- a/vasl_templates/webapp/templates/vo-notes-report.html +++ b/vasl_templates/webapp/templates/vo-notes-report.html @@ -2,6 +2,7 @@