summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.js3
-rw-r--r--play.js2
-rw-r--r--rules.js147
-rw-r--r--tools/gendata.js5
4 files changed, 87 insertions, 70 deletions
diff --git a/data.js b/data.js
index 7a87ae6..ffff2e5 100644
--- a/data.js
+++ b/data.js
@@ -1,3 +1,4 @@
+const all_hexes = [7,8,9,10,30,31,32,33,34,35,36,37,38,39,40,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215]
const hex_exists = [0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0]
const hex_road = [0,0,0,0,0,0,0,4,4,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,1,1,4,2,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,4,1,1,1,1,2,1,1,2,2,1,1,4,1,4,2,4,4,2,4,4,0,0,0,2,1,2,2,2,1,0,1,1,1,1,1,0,1,0,2,0,0,0,2,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,1,1,0,2,0,0,0,2,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,1,1,1,1,2,0,0,0,0,0,0,0,0,0,4,1,1,0,0,0,1,0,0,0,0,1,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
const side_road = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,4,4,0,0,4,0,4,0,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,4,4,0,4,4,0,0,0,0,0,0,0,1,4,1,2,4,4,0,4,2,0,4,0,4,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,4,1,0,1,1,0,0,1,0,0,2,1,2,2,0,2,2,1,0,4,2,1,2,2,0,2,0,0,4,2,1,4,0,1,4,0,0,4,0,1,4,0,0,4,0,2,4,0,0,4,0,0,4,2,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,0,2,0,0,2,0,2,2,0,0,0,0,0,0,0,1,0,0,0,1,0,1,2,0,0,2,1,0,2,1,0,0,1,2,0,0,0,0,0,1,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,0,0,1,2,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
@@ -5,4 +6,4 @@ const side_limit = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,1,
const hex_name = {"7":"El Garib","8":"Cyrene","9":"El Gubba","10":"Derna","30":"Tocra","31":"Barce","32":"Marawa","33":"Wadi Cuff","34":"Wadi Cuff E","35":"Gazala","36":"Acroma","37":"Tobruk","38":"Belhamed","39":"Gambut","40":"Bardia","54":"Benghazi","55":"Er Regima","56":"Charruba","57":"Charruba E","58":"Mechili","59":"Rotonda Segnali","60":"Sidi Mufta","61":"Bir Harmat","62":"El Adem","63":"Sidi Rezegh","64":"Ft. Capuzzo","65":"Sollum","66":"Buq Buq","67":"Sidi Barrani","68":"Sidi Barrani E","69":"Mersa Matruh","70":"Fuka","71":"El Daba","72":"El Alamein","73":"El Hamam","74":"Alexandria","78":"Ghemines","79":"Skeleidima","80":"Msus","81":"Msus E","82":"Tengeder W","83":"Tengeder","84":"Tengeder E","85":"Bir Hacheim","86":"Retma","87":"Bir Gubi","88":"Gabr Saleh","89":"Sidi Omar","90":"Bir Habata","91":"Sofafi","92":"Sofafi E","93":"Bir el Kenayis","94":"Bir Khalda","95":"Bir Khalda E","96":"Alam Halfa W","97":"Alam Halfa","98":"Alam Halfa E","103":"Beda Fomm","104":"Antelat","105":"Antelat E","106":"Ben Gania","107":"Ben Gania E","108":"Tengeder SE","109":"Bir Hacheim SW","110":"Bir Hacheim SE","111":"Retma SE","112":"Ft. Maddalena W","113":"Ft. Maddalena","114":"Ft. Maddalena E","115":"Bir Khamsa","116":"Bir el Qatrani","117":"Bir el Qatrani E","118":"Bir el Kenayis SE","119":"Bir Khalda SE","120":"El Himeimat W","121":"El Himeimat","122":"El Himeimat E","128":"Agedabia","129":"Jebel el Matar","130":"Haraga","131":"Haraga E","137":"Ft. Maddalena SW","138":"Ft. Maddalena SE","139":"Bir Khamsa SW","140":"Bir Fuad W","141":"Bir Fuad","142":"Bir Fuad E","151":"El Agheila","152":"Mersa Brega","153":"El Haseiat","154":"El Haseiat E","155":"Haraga SE","162":"Jarabub Oasis NW","163":"Jarabub Oasis NE","165":"Bir Fuad SW","166":"Bir Fuad SE","176":"Maaten Giofer","177":"Maaten Giofer E","178":"Sahaba","179":"Sahaba E","180":"Jalo Oasis NE","186":"Jarabub Oasis W","187":"Jarabub Oasis","188":"Jarabub Oasis E","189":"Siwa Oasis NE","200":"Maaten Giofer SW","201":"Maaten Giofer SE","202":"Sahaba SW","203":"Jalo Oasis W","204":"Jalo Oasis","205":"Jalo Oasis E","211":"Jarabub Oasis SW","212":"Siwa Oasis W","213":"Siwa Oasis","214":"Siwa Oasis E"}
const regions = {"Libya":[7,8,9,10,30,31,32,33,34,35,36,37,38,39,40,54,55,56,57,58,59,60,61,62,63,64,78,79,80,81,82,83,84,85,86,87,88,103,104,105,106,107,108,109,110,111,112,113,128,129,130,131,132,133,134,135,136,137,138,151,152,153,154,155,156,157,158,159,160,161,162,176,177,178,179,180,181,182,183,184,185,186,187,200,201,202,203,204,205,206,207,208,209,210,211],"Egypt":[65,66,67,68,69,70,71,72,73,74,89,90,91,92,93,94,95,96,97,98,114,115,116,117,118,119,120,121,122,123,139,140,141,142,143,144,163,164,165,166,167,188,189,190,191,212,213,214,215],"Sidi Omar":[89],"Tobruk":[37],"Sollum":[65],"El Agheila":[151],"Mersa Brega":[152],"East Line":[36,37,38,39,40,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,85,86,87,88,89,90,91,92,93,94,95,96,97,98,112,113,114,115,116,117,118,119,120,121,122,123,137,138,139,140,141,142,143,144,162,163,164,165,166,167,187,188,189,190,191],"West Line":[7,8,9,10,30,31,32,33,34,35,54,55,56,57,58,59,78,79,80,81,82,83,103,104,105,106,107,128,129,130],"Jebel el Akhdar":[7,8,9,32,33,34,56,57],"Sebkha el Segira":[152,176],"Sebket el Jeneinen":[179,203],"Qattara Depression":[144,145,146,168,169,192,193,216,217]}
const units = [{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":"S","steps":4,"elite":0,"label":12,"name":"Tre"},{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":"S","steps":4,"elite":0,"label":13,"name":"Pav"},{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":"S","steps":4,"elite":0,"label":14,"name":"Bre"},{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":"S","steps":3,"elite":0,"label":15,"name":"Bol"},{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":"S","steps":3,"elite":0,"label":16,"name":"Sav"},{"nationality":"italian","type":"mech. inf.","class":1,"speed":3,"appearance":7,"steps":4,"elite":0,"label":21,"name":"Tri"},{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":7,"steps":2,"elite":0,"label":22,"name":"Sab"},{"nationality":"italian","type":"armor","class":0,"speed":3,"appearance":11,"steps":3,"elite":0,"label":23,"name":"Lit"},{"nationality":"italian","type":"mot. inf.","class":1,"speed":2,"appearance":17,"steps":3,"elite":0,"label":24,"name":"Fas"},{"nationality":"italian","type":"mot. inf.","class":1,"speed":2,"appearance":19,"steps":3,"elite":0,"label":25,"name":"Cen"},{"nationality":"italian","type":"infantry","class":1,"speed":1,"appearance":19,"steps":2,"elite":0,"label":26,"name":"Pis"},{"nationality":"italian","type":"para","class":1,"speed":1,"appearance":"M","steps":4,"elite":0,"label":27,"name":"Fol"},{"nationality":"italian","type":"artillery","class":3,"speed":1,"appearance":"S","steps":2,"elite":0,"label":28,"name":"Ita"},{"nationality":"italian","type":"armor","class":0,"speed":3,"appearance":"S","steps":4,"elite":0,"label":29,"name":"Ari"},{"nationality":"german","type":"armor","class":0,"speed":3,"appearance":"S","steps":3,"elite":1,"label":14,"name":"21/5"},{"nationality":"german","type":"recon","class":0,"speed":4,"appearance":"S","steps":1,"elite":1,"label":15,"name":"21/3"},{"nationality":"german","type":"mech. inf.","class":1,"speed":3,"appearance":"S","steps":3,"elite":1,"label":16,"name":"21/104"},{"nationality":"german","type":"recon","class":0,"speed":4,"appearance":3,"steps":1,"elite":1,"label":17,"name":"15/33"},{"nationality":"german","type":"mob. a/t","class":2,"speed":3,"appearance":3,"steps":2,"elite":1,"label":18,"name":"88mm/A"},{"nationality":"german","type":"mech. inf.","class":1,"speed":3,"appearance":3,"steps":3,"elite":1,"label":19,"name":"15/115"},{"nationality":"german","type":"armor","class":0,"speed":3,"appearance":5,"steps":3,"elite":1,"label":21,"name":"15/8"},{"nationality":"german","type":"recon","class":0,"speed":4,"appearance":5,"steps":1,"elite":1,"label":22,"name":"90/580"},{"nationality":"german","type":"mot. inf.","class":1,"speed":2,"appearance":5,"steps":2,"elite":1,"label":23,"name":"90/361"},{"nationality":"german","type":"mot. a/t","class":2,"speed":2,"appearance":5,"steps":2,"elite":1,"label":24,"name":"50mm"},{"nationality":"german","type":"artillery","class":3,"speed":1,"appearance":7,"steps":2,"elite":1,"label":25,"name":"/104"},{"nationality":"german","type":"mot. inf.","class":1,"speed":2,"appearance":7,"steps":2,"elite":1,"label":26,"name":"90/200"},{"nationality":"german","type":"mob. a/t","class":2,"speed":3,"appearance":11,"steps":2,"elite":1,"label":27,"name":"88mm/B"},{"nationality":"german","type":"mech. inf.","class":1,"speed":3,"appearance":11,"steps":2,"elite":1,"label":28,"name":"90/sv288"},{"nationality":"german","type":"mech. inf.","class":1,"speed":3,"appearance":11,"steps":2,"elite":1,"label":29,"name":"90/346"},{"nationality":"german","type":"para","class":1,"speed":1,"appearance":"M","steps":3,"elite":1,"label":31,"name":"Ram"},{"nationality":"german","type":"infantry","class":1,"speed":1,"appearance":"M","steps":3,"elite":1,"label":32,"name":"164/382+433"},{"nationality":"german","type":"infantry","class":1,"speed":1,"appearance":"M","steps":2,"elite":1,"label":33,"name":"164/125"},{"nationality":"german","type":"mech. inf.","class":1,"speed":3,"appearance":3,"steps":3,"elite":1,"label":34,"name":"90/155"},{"nationality":"german","type":"mot. a/t","class":2,"speed":2,"appearance":17,"steps":2,"elite":1,"label":35,"name":"76mm"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":"S","steps":2,"elite":0,"label":14,"name":"2/3"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":"S","steps":2,"elite":0,"label":15,"name":"2/SG"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":"S","steps":2,"elite":0,"label":16,"name":"4IN/3m"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":"S","steps":4,"elite":0,"label":17,"name":"9AU/20"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":"S","steps":4,"elite":0,"label":18,"name":"70/14+16"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":"S","steps":3,"elite":0,"label":19,"name":"70/23"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":"T","steps":1,"elite":1,"label":21,"name":"Matilda/A"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":"T","steps":3,"elite":0,"label":22,"name":"7/SG"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":"T","steps":3,"elite":0,"label":23,"name":"7/22G"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":"T","steps":3,"elite":0,"label":24,"name":"/Pol"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":"T","steps":3,"elite":0,"label":25,"name":"7AU/18"},{"nationality":"allied","type":"artillery","class":3,"speed":1,"appearance":"T","steps":2,"elite":0,"label":26,"name":"/Tob"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":18,"steps":4,"elite":0,"label":27,"name":"51H/152"},{"nationality":"allied","type":"self prop. arty","class":3,"speed":3,"appearance":18,"steps":2,"elite":0,"label":28,"name":"Priest"},{"nationality":"allied","type":"artillery","class":3,"speed":1,"appearance":18,"steps":4,"elite":0,"label":29,"name":"/C"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":2,"steps":4,"elite":0,"label":31,"name":"7/7"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":2,"steps":3,"elite":0,"label":32,"name":"4IN/7m"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":2,"steps":3,"elite":0,"label":33,"name":"4IN/5"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":2,"steps":3,"elite":0,"label":34,"name":"4IN/11"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":4,"steps":1,"elite":1,"label":35,"name":"Matilda/B"},{"nationality":"allied","type":"i-tank","class":0,"speed":3,"appearance":4,"steps":4,"elite":0,"label":36,"name":"/1AT"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":4,"steps":3,"elite":0,"label":37,"name":"7/4"},{"nationality":"allied","type":"recon","class":0,"speed":4,"appearance":4,"steps":2,"elite":0,"label":38,"name":"7"},{"nationality":"allied","type":"artillery","class":3,"speed":1,"appearance":20,"steps":3,"elite":0,"label":39,"name":"/D"},{"nationality":"allied","type":"mot. a/t","class":2,"speed":2,"appearance":6,"steps":3,"elite":0,"label":41,"name":"2#"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":6,"steps":4,"elite":0,"label":42,"name":"2NZ/4"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":6,"steps":4,"elite":0,"label":43,"name":"2NZ/5"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":6,"steps":4,"elite":0,"label":44,"name":"2NZ/6"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":6,"steps":4,"elite":0,"label":45,"name":"1SA/2+5"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":6,"steps":3,"elite":0,"label":46,"name":"1SA/1"},{"nationality":"allied","type":"recon","class":0,"speed":4,"appearance":8,"steps":2,"elite":0,"label":47,"name":"1SA"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":8,"steps":3,"elite":0,"label":48,"name":"1SA/3"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":8,"steps":3,"elite":0,"label":49,"name":"2SA/4+6"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":8,"steps":4,"elite":0,"label":51,"name":"1/22"},{"nationality":"allied","type":"i-tank","class":0,"speed":3,"appearance":8,"steps":3,"elite":0,"label":52,"name":"/32AT"},{"nationality":"allied","type":"artillery","class":3,"speed":1,"appearance":8,"steps":2,"elite":0,"label":53,"name":"/A"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":10,"steps":4,"elite":0,"label":54,"name":"1/2"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":10,"steps":3,"elite":0,"label":55,"name":"1/201G"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":10,"steps":2,"elite":0,"label":56,"name":"1/SG"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":10,"steps":3,"elite":0,"label":57,"name":"5IN/29"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":12,"steps":2,"elite":1,"label":58,"name":"Grant"},{"nationality":"allied","type":"mot. a/t","class":2,"speed":2,"appearance":12,"steps":3,"elite":0,"label":59,"name":"6#/A"},{"nationality":"allied","type":"mech. inf.","class":1,"speed":3,"appearance":14,"steps":2,"elite":0,"label":61,"name":"10IN/161m"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":14,"steps":4,"elite":0,"label":62,"name":"5IN/9+10"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":14,"steps":4,"elite":0,"label":63,"name":"10IN/21+25"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":14,"steps":2,"elite":0,"label":64,"name":"8IN/18"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":14,"steps":4,"elite":0,"label":65,"name":"FF/2"},{"nationality":"allied","type":"artillery","class":3,"speed":1,"appearance":14,"steps":4,"elite":0,"label":66,"name":"/B"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":20,"steps":3,"elite":1,"label":67,"name":"Sher/B"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":20,"steps":3,"elite":0,"label":68,"name":"8/9"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":20,"steps":3,"elite":0,"label":69,"name":"8/24"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":16,"steps":4,"elite":0,"label":71,"name":"10/8"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":16,"steps":3,"elite":0,"label":72,"name":"10/23"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":16,"steps":4,"elite":0,"label":73,"name":"9AU/26"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":16,"steps":4,"elite":0,"label":74,"name":"9AU/24"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":16,"steps":4,"elite":0,"label":75,"name":"44/131+133"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":16,"steps":2,"elite":0,"label":76,"name":"44/132"},{"nationality":"allied","type":"armor","class":0,"speed":3,"appearance":18,"steps":3,"elite":1,"label":77,"name":"Sher/A"},{"nationality":"allied","type":"mot. a/t","class":2,"speed":2,"appearance":18,"steps":4,"elite":0,"label":78,"name":"6#/B"},{"nationality":"allied","type":"mot. inf.","class":1,"speed":2,"appearance":18,"steps":4,"elite":0,"label":79,"name":"51H/154"}]
-if (typeof module !== 'undefined') module.exports = { hex_exists, hex_name, hex_road, side_road, side_limit, regions, units }
+if (typeof module !== 'undefined') module.exports = { all_hexes, hex_exists, hex_name, hex_road, side_road, side_limit, regions, units }
diff --git a/play.js b/play.js
index 63c0a91..a39588c 100644
--- a/play.js
+++ b/play.js
@@ -551,6 +551,7 @@ function on_update() {
action_button("stop", "Stop")
action_button("end_move", "End move")
+ action_button("end_retreat", "End retreat")
action_button("end_combat", "End combat")
action_button("group", "Group")
@@ -567,4 +568,5 @@ function on_update() {
}
drag_element_with_mouse("#battle", "#battle_header")
+drag_element_with_mouse("#pursuit", "#pursuit_header")
scroll_with_middle_mouse("main")
diff --git a/rules.js b/rules.js
index 6df7316..54647b8 100644
--- a/rules.js
+++ b/rules.js
@@ -12,7 +12,7 @@ var states = {}
var game = null
var view = null
-let { hex_exists, hex_road, side_road, side_limit, hex_name, units, regions } = require("./data")
+let { all_hexes, hex_exists, hex_road, side_road, side_limit, hex_name, units, regions } = require("./data")
function debug_hexes3(n, list) {
console.log("--", n, "--")
@@ -105,10 +105,6 @@ const region_libya_and_sidi_omar_and_sollum = regions["Libya"].concat(regions["S
const region_egypt_and_tobruk = regions["Egypt"].concat(regions["Tobruk"])
const region_libya_except_tobruk = regions["Libya"].filter(r => r !== TOBRUK)
-const region_all = []
-for (let x = first_hex; x <= last_hex; ++x)
- region_all.push(x)
-
function calc_distance(a, b) {
let ax = a % hexw, ay = (a / hexw)|0, az = -ax - ay
let bx = b % hexw, by = (b / hexw)|0, bz = -bx - by
@@ -159,7 +155,7 @@ function find_unit(name) {
}
function is_map_hex(x) {
- return next >= first_hex && next <= last_hex && hex_exists[next] === 1
+ return x >= first_hex && x <= last_hex && hex_exists[x] === 1
}
function is_hex_or_adjacent_to(x, where) {
@@ -442,16 +438,13 @@ function release_hex_control(a) {
// no longer a battle hex: release hexsides if possible
set_delete(game.axis_hexes, a)
set_delete(game.allied_hexes, a)
- for (let s = 0; s < 6; ++s) {
- let b = a + hexnext[s]
- if (b >= first_hex && b <= last_hex && hex_exists[b]) {
- if (!is_battle_hex(b)) {
- let side = to_side_id(a, b)
- set_delete(game.axis_sides, side)
- set_delete(game.allied_sides, side)
- }
+ for_each_adjacent_hex(a, b => {
+ if (!is_battle_hex(b)) {
+ let side = to_side_id(a, b)
+ set_delete(game.axis_sides, side)
+ set_delete(game.allied_sides, side)
}
- }
+ })
}
function is_new_battle_hex(a) {
@@ -468,28 +461,24 @@ function claim_hex_control_for_defender(a) {
else
set_add(game.axis_hexes, a)
- for (let s = 0; s < 6; ++s) {
- let b = a + hexnext[s]
- if (b >= first_hex && b <= last_hex && hex_exists[b]) {
- let side = to_side_id(a, b)
- if (side_limit[side] > 0) {
- if (game.active === AXIS) {
- if (!set_has(game.axis_sides, side))
- set_add(game.allied_sides, side)
- } else {
- if (!set_has(game.allied_sides, side))
- set_add(game.axis_sides, side)
- }
+ for_each_adjacent_hex(a, b => {
+ let side = to_side_id(a, b)
+ if (side_limit[side] > 0) {
+ if (game.active === AXIS) {
+ if (!set_has(game.axis_sides, side))
+ set_add(game.allied_sides, side)
+ } else {
+ if (!set_has(game.allied_sides, side))
+ set_add(game.axis_sides, side)
}
}
- }
+ })
}
function claim_stuff() {
- for (let x = first_hex; x <= last_hex; ++x)
- if (hex_exists[x])
- if (is_new_battle_hex(x))
- claim_hex_control_for_defender(x)
+ for (let x of all_hexes)
+ if (is_new_battle_hex(x))
+ claim_hex_control_for_defender(x)
}
// === SUPPLY NETWORK ===
@@ -554,7 +543,7 @@ function trace_supply_highway(here, d) {
let has_supply = false
- supply_visited[here] = true
+ supply_visited[here] = 1
for (let s = 0; s < 6; ++s) {
let next = here + hexnext[s]
@@ -586,7 +575,7 @@ function trace_supply_highway(here, d) {
}
}
- supply_visited[here] = false
+ supply_visited[here] = 0
if (has_supply) {
supply_net[here] = 1
@@ -607,7 +596,7 @@ function trace_supply_chain(here, d, n, range) {
let has_supply = false
- supply_visited[here] = true
+ supply_visited[here] = 1
for (let s = 0; s < 6; ++s) {
let next = here + hexnext[s]
@@ -659,7 +648,7 @@ function trace_supply_chain(here, d, n, range) {
}
}
- supply_visited[here] = false
+ supply_visited[here] = 0
if (has_supply) {
supply_net[here] = 1
@@ -670,11 +659,17 @@ function trace_supply_chain(here, d, n, range) {
return has_supply
}
+var supply_visited = new Array(hexcount)
+var supply_src = new Array(hexcount)
+
function trace_supply_network(start) {
- supply_visited = new Array(hexcount).fill(false)
- supply_net = new Array(hexcount).fill(0)
- supply_line = new Array(sidecount).fill(0)
- supply_src = new Array(hexcount).fill(0)
+ supply_net = new Array(hexcount)
+ supply_line = new Array(sidecount)
+
+ supply_visited.fill(0)
+ supply_src.fill(0)
+ supply_net.fill(0)
+ supply_line.fill(0)
supply_src[start] = 1
supply_net[start] = 1
@@ -885,24 +880,29 @@ function pick_path(to, road, speed) {
return next_road
}
-function pay_movement_cost(to, this_road, speed) {
-}
-
-function neighbor_has_friendly_unit(here) {
+function adjacent_hex_has_friendly_unit(here) {
for (let s = 0; s < 6; ++s) {
let next = here + hexnext[s]
- if (next >= first_hex && next <= last_hex)
+ if (is_map_hex(next))
if (has_friendly_unit(next))
return true
}
return false
}
+function for_each_adjacent_hex(here, fn) {
+ for (let s = 0; s < 6; ++s) {
+ let next = here + hexnext[s]
+ if (is_map_hex(next))
+ fn(next)
+ }
+}
+
function for_each_hex_and_adjacent_hex(here, fn) {
fn(here)
for (let s = 0; s < 6; ++s) {
let next = here + hexnext[s]
- if (next >= first_hex && next <= last_hex && hex_exists[next])
+ if (is_map_hex(next))
fn(next)
}
}
@@ -980,8 +980,14 @@ function goto_supply_check() {
goto_turn_option()
}
+function clear_all_unit_moved() {
+ for (let u = 0; u < units.length; ++u)
+ clear_unit_moved(u)
+}
+
function goto_turn_option() {
game.state = 'turn_option'
+ clear_all_unit_moved()
}
states.turn_option = {
@@ -1100,7 +1106,7 @@ states.regroup_move_command_point = {
gen_rommel_move()
for (let x = first_hex; x <= last_hex; ++x) {
if (!is_enemy_hex(x)) {
- if (has_friendly_unit(x) || neighbor_has_friendly_unit(x))
+ if (has_friendly_unit(x) || adjacent_hex_has_friendly_unit(x))
gen_action_hex(x)
}
}
@@ -1273,8 +1279,6 @@ function apply_move(move, who, from, to) {
set_unit_moved(who)
set_unit_hex(who, to)
- pay_movement_cost(to, game.move_road, speed)
-
if (is_battle_hex(to)) {
let side = to_side_id(to, path_from[road][to])
@@ -1345,13 +1349,13 @@ states.move_to = {
search_move(from, 0, 4)
if (from === game.from1 && !game.to1)
- for (let to = first_hex; to <= last_hex; ++to)
- if (to != from && hex_exists[to] && can_move_group_1(who, from, to))
+ for (let to of all_hexes)
+ if (to != from && can_move_group_1(who, from, to))
gen_action_hex(to)
if (from === game.from2 && !game.to2)
- for (let to = first_hex; to <= last_hex; ++to)
- if (to != from && hex_exists[to] && can_move_group_2(who, from, to))
+ for (let to of all_hexes)
+ if (to != from && can_move_group_2(who, from, to))
gen_action_hex(to)
if (can_move_regroup_1(who, from, game.to1))
@@ -1422,13 +1426,13 @@ states.group_move_to = {
search_move(from, game.move_used, game.move_road)
if (game.move_from === game.from1 && !game.to1)
- for (let to = first_hex; to <= last_hex; ++to)
- if (to != from && hex_exists[to] && can_move_group_1(who, game.move_from, to))
+ for (let to of all_hexes)
+ if (to != from && can_move_group_1(who, game.move_from, to))
gen_action_hex(to)
if (game.move_from === game.from2 && !game.to2)
- for (let to = first_hex; to <= last_hex; ++to)
- if (to != from && hex_exists[to] && can_move_group_2(who, game.move_from, to))
+ for (let to of all_hexes)
+ if (to != from && can_move_group_2(who, game.move_from, to))
gen_action_hex(to)
gen_action_unit(who)
@@ -1474,8 +1478,8 @@ function stop_move(who) {
// === REFUSE BATTLE ===
function gen_withdraw_group_move(who, from) {
- for (let to = first_hex; to <= last_hex; ++to)
- if (to != from && hex_exists[to] && can_move_to(to, 4, unit_speed(who)))
+ for (let to of all_hexes)
+ if (to != from && can_move_to(to, 4, unit_speed(who)))
gen_action_hex(to)
}
@@ -1512,17 +1516,22 @@ states.refuse_battle_who = {
inactive: "refuse battle (withdraw group move: who)",
prompt() {
view.prompt = `Withdraw: Select unit to move.`
+ let done = true
for_each_friendly_unit_in_hex(game.from1, u => {
gen_action_unit(u)
+ done = false
})
+ if (done)
+ gen_action('end_retreat')
},
unit(u) {
push_undo()
game.selected = [ u ]
game.state = 'refuse_battle_to'
},
- next() {
+ end_retreat() {
clear_undo()
+ release_hex_control(game.from1)
game.state = 'refuse_battle'
}
}
@@ -1545,10 +1554,6 @@ states.refuse_battle_to = {
game.selected = []
game.state = 'refuse_battle_who'
},
- next() {
- clear_undo()
- game.state = 'refuse_battle'
- }
}
// ==== COMBAT PHASE ===
@@ -1563,10 +1568,9 @@ states.select_active_battles = {
inactive: "combat phase (select active battles)",
prompt() {
view.prompt = `Select active battles.`
- for (let x = first_hex; x <= last_hex; ++x)
- if (hex_exists[x])
- if (!set_has(game.active_battles, x) && is_battle_hex(x))
- gen_action_hex(x)
+ for (let x of all_hexes)
+ if (!set_has(game.active_battles, x) && is_battle_hex(x))
+ gen_action_hex(x)
gen_action('next')
},
hex(x) {
@@ -1999,6 +2003,13 @@ states.pursuit_hits = {
},
}
+function end_pursuit_fire() {
+ game.from1 = game.pursuit
+ game.pursuit = 0
+ set_passive_player()
+ game.state = 'refuse_battle_who'
+}
+
// === DEPLOYMENT ===
states.free_deployment = {
diff --git a/tools/gendata.js b/tools/gendata.js
index a4fb97c..a963248 100644
--- a/tools/gendata.js
+++ b/tools/gendata.js
@@ -571,6 +571,9 @@ def_block("allied", "armor", 18, 3, 1, 77, "Sher/A");
def_block("allied", "mot. a/t", 18, 4, 0, 78, "6#/B");
def_block("allied", "mot. inf.", 18, 4, 0, 79, "51H/154");
+let all_hexes = hex_exists.map((x,i) => x ? i : 0).filter(x => x > 0)
+
+console.log("const all_hexes = " + JSON.stringify(all_hexes));
console.log("const hex_exists = " + JSON.stringify(hex_exists));
console.log("const hex_road = " + JSON.stringify(hex_road));
console.log("const side_road = " + JSON.stringify(side_road));
@@ -578,4 +581,4 @@ console.log("const side_limit = " + JSON.stringify(side_limit));
console.log("const hex_name = " + JSON.stringify(hex_name));
console.log("const regions = " + JSON.stringify(regions));
console.log("const units = " + JSON.stringify(units));
-console.log("if (typeof module !== 'undefined') module.exports = { hex_exists, hex_name, hex_road, side_road, side_limit, regions, units }");
+console.log("if (typeof module !== 'undefined') module.exports = { all_hexes, hex_exists, hex_name, hex_road, side_road, side_limit, regions, units }");