diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2025-01-15 13:40:22 -0500 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2025-01-15 13:40:22 -0500 |
commit | 18416aa5490342334c53ab806d06669f5d17a5de (patch) | |
tree | 8f7532b2803ef5b0056a364e8aa17444d5c818fb | |
parent | 33d213ce1547fa295854ade306e71b91c46460e9 (diff) | |
download | vijayanagara-18416aa5490342334c53ab806d06669f5d17a5de.tar.gz |
Basic event structure.
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | data.js | 2 | ||||
-rw-r--r-- | events.txt | 214 | ||||
-rw-r--r-- | play.css | 8 | ||||
-rw-r--r-- | play.html | 5 | ||||
-rw-r--r-- | rules.js | 553 | ||||
-rw-r--r-- | tools/gencode.js | 136 | ||||
-rw-r--r-- | tools/gendata.js | 47 |
8 files changed, 958 insertions, 14 deletions
@@ -1,3 +1,6 @@ default: rules.js -rules.js: - sed -i -ne '/\/\/ === CONST ===/ {p; r const.js' -e ':a; n; /\/\/ === CONST ===/ {p; b}; ba}; p' rules.js
\ No newline at end of file +rules.js: events.txt + sed -i -ne '/\/\/ === CONST ===/ {p; r const.js' -e ':a; n; /\/\/ === CONST ===/ {p; b}; ba}; p' rules.js + sed '/const CODE /,$$d' < rules.js > /tmp/rules.js + node tools/gencode.js >> /tmp/rules.js + cp /tmp/rules.js rules.js
\ No newline at end of file @@ -1,2 +1,2 @@ -const data = {"card_title":[null,"Malik Kafur","Mongol Army Repelled","Diamond Mines of Golconda","Ears of the Sultan","Siege of Chittor","Siege of Warangal","The Conquest of Madurai","Yadava Kingdom Annexed","Kakatiya Empire Extinguished","Capital Relocated","Hindu Kush Mountains","Musunuri Nayakas","Sage of Vidyaranya","Last Great King of the Hoysalas","Uprising in Daulatabad","Gulbarga Fort","Sufi Shaikh Relocates","Center of High Culture","Bengali Resistance","Eastern Ganga Dynasty","Vindhya Range","A New Calculus","Virupaksha Temple","Stone Temple Chariots","Empire Building","Of Gods and Kings","Taghi the Elusive","The Turquoise Throne","Ashvapati, Lord of Horses","Bara Gazi Toph","The Raichur Doab","The Hare and the Hounds","Commercial Port of Goa","Bahmani Sultan Assassinated","Hindu-Muslim Marriages","Northern Alliances","Mongol Invasion","Mongol Invasion","Mongol Invasion","Mongol Invasion","Mongol Invasion","Mongol Invasion","Timurid Empire","Timurid Empire","Zenith of the Delhi Sultanate","Rise of the Rebel Sultans","Lords of the Deccan"],"card_order":[null,[0,1,2],[0,1,2],[1,0,2],[0,2,1],[2,0,1],[0,2,1],[0,2,1],[0,1,2],[0,2,1],[1,0,2],[0,1,2],[2,0,1],[2,1,0],[2,1,0],[1,0,2],[1,2,0],[1,2,0],[1,2,0],[1,0,2],[0,1,2],[0,1,2],[0,2,1],[2,0,1],[2,0,1],[2,1,0],[2,1,0],[0,2,1],[1,2,0],[1,0,2],[1,0,2],[1,2,0],[2,1,0],[2,1,0],[2,0,1],[1,2,0],[2,0,1],null,null,null,null,null,null,null,null,null,null,null],"card_flavor":[null,"General assassinated, power struggle ensues","Pyrrhic victory","Untold riches lie just beneath the surface","Sultan’s plans intercepted","Hammir Singh reclaims a Rajput Kingdom","Continual looting encourages resistance","Tale of Madurai Sultan’s defeat chronicled in epic Sanskrit poem","Multi-ethnic polity seeds development","Telugu kingdom leaves a mythic legacy","Political damage and chaos ensues as the Delhi elite is forced to migrate","Sultanate army perishes in the snow on a scheme of foreign conquest","“Warrior kings” rise in the shadow of the Kakatiya Empire","Meeting with revered jagadguru in Sringeri sparks a foundational myth","Vijayanagara emerges from the crumbling kingdom of Veera Ballala III","Delhi resentment reaches breaking point","Defenses expanded in the first Bahmani capital","Siraj-al-Din Junaidi takes up residence","Bahmani Kingdom attracts great minds from afar; culture flourishes in the Deccan","Governors repeatedly assert independence","Prosperous kingdom falls into decline","Mountainous region provides a natural buffer from Delhi","Madhava of Sangamagrama founds the Kerala School of Astronomy and Mathematics","Temple to Shiva merges regional goddess cults","Chariots carry representations of Puranic Hindu gods","Lords of the Eastern and Western Oceans","Telugu poet Srinatha revolutionizes the craft and weaves the tapestry of an Empire, while Sufi devotional songs of Amir Khusrau praise the Sultans in Delhi","Fugitive rebel an expensive distraction","Bahmanis cross the Krishna river into Telangana","Bahmani rulers likened to Hindu god","Gigantic cannons defend Bahmani forts","Repeated raids over fertile lands","Identical empire origin stories lean on regional cult mythologies","Struggle for critical maritime routes","Vijayanagara captures Goa while the Bahmanis are destabilized","Bahmani Sultan weds a Hindu bride","Vijayanagara probes an alliance with Delhi"],"card_flavor_shaded":[null,"Favored slave-general brilliant in battle","Sultan’s mercenary army victorious","Sultan’s oppressive taxation","Network of spies covers the Deccan","Massacre at Chittor","Koh-i-Noor diamond among war spoils","Sultan’s generals plunder Pandyan kingdom","Sultanate reclaims natural stronghold","Sultanate tires of awaiting tribute","Sultan shortens his reach into the Deccan","Grandiose schemes pay dividends","Telugu warriors no match for siege technology from Central Asia","Inferior military suffers early defeats","Delhi’s armies plunder the Hoysala Capital","Commanders sentenced to death","Bahmani Kingdom threatens control","Relationships sour between Bahmani rulers and Sufi shaikhs","Divisions among Deccanis and newcomers","Criminals conscripted to reclaim Bengal","Sultanate invades Orissa","Long campaigns go unchallenged","Narayana Pandita’s mathematical treatises offer new insights of immediate use","Symbols of sovereignty destroyed","Cultural development draws interest","Sultan’s new roads thrust into the Deccan",null,"The Sultan marches west in pursuit","Telangana Nayakas implore allies to attack","War horses and siege technology imported from overseas","Gunpowder and cannons appear suddenly in the subcontinent","Massive casualties in both kingdoms","Persian values inherited from Delhi","Competition over ports boils over","Bahmani successor ushers in a period of social reform and cultural revival","Diffusion and dilution of culture","Alliance rejected"],"spaces":[{"type":"province","id":"Andhra","pop":1,"adjacent":[2,5,6,7,9,12]},{"type":"province","id":"Bengal","pop":2,"adjacent":[2,4,9]},{"type":"province","id":"Gondwana","pop":1,"adjacent":[0,1,4,6,9]},{"type":"province","id":"Gujarat","pop":2,"adjacent":[6,7,8,10,11]},{"type":"province","id":"Jaunpur","pop":1,"adjacent":[1,2,13,8]},{"type":"province","id":"Karnataka","pop":2,"adjacent":[0,7,12]},{"type":"province","id":"Madhyadesh","pop":1,"adjacent":[0,2,3,8,7,9]},{"type":"province","id":"Maharashtra","pop":2,"adjacent":[0,3,5,6,8]},{"type":"province","id":"Malwa","pop":2,"adjacent":[3,4,6,7,13,10]},{"type":"province","id":"Orissa","pop":1,"adjacent":[0,1,2,6]},{"type":"province","id":"Rajput Kingdoms","pop":1,"adjacent":[3,8,13,15,11]},{"type":"province","id":"Sindh","pop":1,"adjacent":[3,10,14,15]},{"type":"province","id":"Tamilakam","pop":1,"adjacent":[0,5]},{"type":"capital","id":"Delhi","pop":0,"adjacent":[4,8,10,15]},{"type":"mongol","id":"Mountain Passes","pop":0,"adjacent":[11,15]},{"type":"mongol","id":"Punjab","pop":0,"adjacent":[10,11,13,14]},{"type":"holdbox","id":"MI_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"DS_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"BK_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"BK_DI_2","pop":null,"adjacent":[]},{"type":"holdbox","id":"BK_DI_4","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_1","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_2","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_3","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_4","pop":null,"adjacent":[]}],"space_name":["Andhra","Bengal","Gondwana","Gujarat","Jaunpur","Karnataka","Madhyadesh","Maharashtra","Malwa","Orissa","Rajput Kingdoms","Sindh","Tamilakam","Delhi","Mountain Passes","Punjab","MI_available","DS_available","BK_available","VE_available","BK_DI_2","BK_DI_4","VE_DI_1","VE_DI_2","VE_DI_3","VE_DI_4"],"first_piece":[[0,5,10],[42,47,null],[65,70,null],[null,null,92]],"last_piece":[[4,9,41],[46,64,null],[69,91,null],[null,null,103]]} +const data = {"card_title":[null,"Malik Kafur","Mongol Army Repelled","Diamond Mines of Golconda","Ears of the Sultan","Siege of Chittor","Siege of Warangal","The Conquest of Madurai","Yadava Kingdom Annexed","Kakatiya Empire Extinguished","Capital Relocated","Hindu Kush Mountains","Musunuri Nayakas","Sage of Vidyaranya","Last Great King of the Hoysalas","Uprising in Daulatabad","Gulbarga Fort","Sufi Shaikh Relocates","Center of High Culture","Bengali Resistance","Eastern Ganga Dynasty","Vindhya Range","A New Calculus","Virupaksha Temple","Stone Temple Chariots","Empire Building","Of Gods and Kings","Taghi the Elusive","The Turquoise Throne","Ashvapati, Lord of Horses","Bara Gazi Toph","The Raichur Doab","The Hare and the Hounds","Commercial Port of Goa","Bahmani Sultan Assassinated","Hindu-Muslim Marriages","Northern Alliances","Mongol Invasion","Mongol Invasion","Mongol Invasion","Mongol Invasion","Mongol Invasion","Mongol Invasion","Timurid Empire","Timurid Empire","Zenith of the Delhi Sultanate","Rise of the Rebel Sultans","Lords of the Deccan"],"card_order":[null,[0,1,2],[0,1,2],[1,0,2],[0,2,1],[2,0,1],[0,2,1],[0,2,1],[0,1,2],[0,2,1],[1,0,2],[0,1,2],[2,0,1],[2,1,0],[2,1,0],[1,0,2],[1,2,0],[1,2,0],[1,2,0],[1,0,2],[0,1,2],[0,1,2],[0,2,1],[2,0,1],[2,0,1],[2,1,0],[2,1,0],[0,2,1],[1,2,0],[1,0,2],[1,0,2],[1,2,0],[2,1,0],[2,1,0],[2,0,1],[1,2,0],[2,0,1],null,null,null,null,null,null,null,null,null,null,null],"card_flavor":[null,"General assassinated, power struggle ensues","Pyrrhic victory","Untold riches lie just beneath the surface","Sultan’s plans intercepted","Hammir Singh reclaims a Rajput Kingdom","Continual looting encourages resistance","Tale of Madurai Sultan’s defeat chronicled in epic Sanskrit poem","Multi-ethnic polity seeds development","Telugu kingdom leaves a mythic legacy","Political damage and chaos ensues as the Delhi elite is forced to migrate","Sultanate army perishes in the snow on a scheme of foreign conquest","“Warrior kings” rise in the shadow of the Kakatiya Empire","Meeting with revered jagadguru in Sringeri sparks a foundational myth","Vijayanagara emerges from the crumbling kingdom of Veera Ballala III","Delhi resentment reaches breaking point","Defenses expanded in the first Bahmani capital","Siraj-al-Din Junaidi takes up residence","Bahmani Kingdom attracts great minds from afar; culture flourishes in the Deccan","Governors repeatedly assert independence","Prosperous kingdom falls into decline","Mountainous region provides a natural buffer from Delhi","Madhava of Sangamagrama founds the Kerala School of Astronomy and Mathematics","Temple to Shiva merges regional goddess cults","Chariots carry representations of Puranic Hindu gods","Lords of the Eastern and Western Oceans","Telugu poet Srinatha revolutionizes the craft and weaves the tapestry of an Empire, while Sufi devotional songs of Amir Khusrau praise the Sultans in Delhi","Fugitive rebel an expensive distraction","Bahmanis cross the Krishna river into Telangana","Bahmani rulers likened to Hindu god","Gigantic cannons defend Bahmani forts","Repeated raids over fertile lands","Identical empire origin stories lean on regional cult mythologies","Struggle for critical maritime routes","Vijayanagara captures Goa while the Bahmanis are destabilized","Bahmani Sultan weds a Hindu bride","Vijayanagara probes an alliance with Delhi"],"card_flavor_shaded":[null,"Favored slave-general brilliant in battle","Sultan’s mercenary army victorious","Sultan’s oppressive taxation","Network of spies covers the Deccan","Massacre at Chittor","Koh-i-Noor diamond among war spoils","Sultan’s generals plunder Pandyan kingdom","Sultanate reclaims natural stronghold","Sultanate tires of awaiting tribute","Sultan shortens his reach into the Deccan","Grandiose schemes pay dividends","Telugu warriors no match for siege technology from Central Asia","Inferior military suffers early defeats","Delhi’s armies plunder the Hoysala Capital","Commanders sentenced to death","Bahmani Kingdom threatens control","Relationships sour between Bahmani rulers and Sufi shaikhs","Divisions among Deccanis and newcomers","Criminals conscripted to reclaim Bengal","Sultanate invades Orissa","Long campaigns go unchallenged","Narayana Pandita’s mathematical treatises offer new insights of immediate use","Symbols of sovereignty destroyed","Cultural development draws interest","Sultan’s new roads thrust into the Deccan",null,"The Sultan marches west in pursuit","Telangana Nayakas implore allies to attack","War horses and siege technology imported from overseas","Gunpowder and cannons appear suddenly in the subcontinent","Massive casualties in both kingdoms","Persian values inherited from Delhi","Competition over ports boils over","Bahmani successor ushers in a period of social reform and cultural revival","Diffusion and dilution of culture","Alliance rejected"],"spaces":[{"type":"province","id":"Andhra","pop":1,"adjacent":[2,5,6,7,9,12]},{"type":"province","id":"Bengal","pop":2,"adjacent":[2,4,9]},{"type":"province","id":"Gondwana","pop":1,"adjacent":[0,1,4,6,9]},{"type":"province","id":"Gujarat","pop":2,"adjacent":[6,7,8,10,11]},{"type":"province","id":"Jaunpur","pop":1,"adjacent":[1,2,13,8]},{"type":"province","id":"Karnataka","pop":2,"adjacent":[0,7,12]},{"type":"province","id":"Madhyadesh","pop":1,"adjacent":[0,2,3,8,7,9]},{"type":"province","id":"Maharashtra","pop":2,"adjacent":[0,3,5,6,8]},{"type":"province","id":"Malwa","pop":2,"adjacent":[3,4,6,7,13,10]},{"type":"province","id":"Orissa","pop":1,"adjacent":[0,1,2,6]},{"type":"province","id":"Rajput Kingdoms","pop":1,"adjacent":[3,8,13,15,11]},{"type":"province","id":"Sindh","pop":1,"adjacent":[3,10,14,15]},{"type":"province","id":"Tamilakam","pop":1,"adjacent":[0,5]},{"type":"capital","id":"Delhi","pop":0,"adjacent":[4,8,10,15]},{"type":"mongol","id":"Mountain Passes","pop":0,"adjacent":[11,15]},{"type":"mongol","id":"Punjab","pop":0,"adjacent":[10,11,13,14]},{"type":"holdbox","id":"MI_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"DS_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"BK_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_available","pop":null,"adjacent":[]},{"type":"holdbox","id":"BK_DI_2","pop":null,"adjacent":[]},{"type":"holdbox","id":"BK_DI_4","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_1","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_2","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_3","pop":null,"adjacent":[]},{"type":"holdbox","id":"VE_DI_4","pop":null,"adjacent":[]}],"space_name":["Andhra","Bengal","Gondwana","Gujarat","Jaunpur","Karnataka","Madhyadesh","Maharashtra","Malwa","Orissa","Rajput Kingdoms","Sindh","Tamilakam","Delhi","Mountain Passes","Punjab","MI_available","DS_available","BK_available","VE_available","BK_DI_2","BK_DI_4","VE_DI_1","VE_DI_2","VE_DI_3","VE_DI_4"],"city":[{"id":"Chittor","adjacent":[3,8,10]},{"id":"Devagiri","adjacent":[3,6,7,8]},{"id":"Goa","adjacent":[5,6]},{"id":"Gulbarga","adjacent":[0,6,7]},{"id":"Vijayanagara","adjacent":[0,5,6]},{"id":"Warangal","adjacent":[0,2,6,9]}],"city_name":["Chittor","Devagiri","Goa","Gulbarga","Vijayanagara","Warangal"],"first_piece":[[0,5,10],[42,47,null],[65,70,null],[null,null,92]],"last_piece":[[4,9,41],[46,64,null],[69,91,null],[null,null,103]]} if (typeof module !== 'undefined') module.exports = data diff --git a/events.txt b/events.txt new file mode 100644 index 0000000..3268551 --- /dev/null +++ b/events.txt @@ -0,0 +1,214 @@ +# Events for Vijayanagara + +EVENT 1 + log "NOT IMPLEMENTED" + +SHADED 1 + log "NOT IMPLEMENTED" + +EVENT 2 + log "NOT IMPLEMENTED" + +SHADED 2 + log "NOT IMPLEMENTED" + +EVENT 3 + log "NOT IMPLEMENTED" + +SHADED 3 + log "NOT IMPLEMENTED" + +EVENT 4 + log "NOT IMPLEMENTED" + +SHADED 4 + log "NOT IMPLEMENTED" + +EVENT 5 + log "NOT IMPLEMENTED" + +SHADED 5 + log "NOT IMPLEMENTED" + +EVENT 6 + log "NOT IMPLEMENTED" + +SHADED 6 + log "NOT IMPLEMENTED" + +EVENT 7 + log "NOT IMPLEMENTED" + +SHADED 7 + log "NOT IMPLEMENTED" + +EVENT 8 + log "NOT IMPLEMENTED" + +SHADED 8 + log "NOT IMPLEMENTED" + +EVENT 9 + log "NOT IMPLEMENTED" + +SHADED 9 + log "NOT IMPLEMENTED" + +EVENT 10 + log "NOT IMPLEMENTED" + +SHADED 10 + log "NOT IMPLEMENTED" + +EVENT 11 + log "NOT IMPLEMENTED" + +SHADED 11 + log "NOT IMPLEMENTED" + +EVENT 12 + log "NOT IMPLEMENTED" + +SHADED 12 + log "NOT IMPLEMENTED" + +EVENT 13 + log "NOT IMPLEMENTED" + +SHADED 13 + log "NOT IMPLEMENTED" + +EVENT 14 + log "NOT IMPLEMENTED" + +SHADED 14 + log "NOT IMPLEMENTED" + +EVENT 15 + log "NOT IMPLEMENTED" + +SHADED 15 + log "NOT IMPLEMENTED" + +EVENT 16 + log "NOT IMPLEMENTED" + +SHADED 16 + log "NOT IMPLEMENTED" + +EVENT 17 + log "NOT IMPLEMENTED" + +SHADED 17 + log "NOT IMPLEMENTED" + +EVENT 18 + log "NOT IMPLEMENTED" + +SHADED 18 + log "NOT IMPLEMENTED" + +EVENT 19 + log "NOT IMPLEMENTED" + +SHADED 19 + log "NOT IMPLEMENTED" + +EVENT 20 + log "NOT IMPLEMENTED" + +SHADED 20 + log "NOT IMPLEMENTED" + +EVENT 21 + log "NOT IMPLEMENTED" + +SHADED 21 + log "NOT IMPLEMENTED" + +EVENT 22 + log "NOT IMPLEMENTED" + +SHADED 22 + log "NOT IMPLEMENTED" + +EVENT 23 + log "NOT IMPLEMENTED" + +SHADED 23 + log "NOT IMPLEMENTED" + +EVENT 24 + log "NOT IMPLEMENTED" + +SHADED 24 + log "NOT IMPLEMENTED" + +EVENT 25 + log "NOT IMPLEMENTED" + +SHADED 25 + log "NOT IMPLEMENTED" + +EVENT 26 + log "NOT IMPLEMENTED" + +EVENT 27 + log "NOT IMPLEMENTED" + +SHADED 27 + log "NOT IMPLEMENTED" + +EVENT 28 + log "NOT IMPLEMENTED" + +SHADED 28 + log "NOT IMPLEMENTED" + +EVENT 29 + log "NOT IMPLEMENTED" + +SHADED 29 + log "NOT IMPLEMENTED" + +EVENT 30 + log "NOT IMPLEMENTED" + +SHADED 30 + log "NOT IMPLEMENTED" + +EVENT 31 + log "NOT IMPLEMENTED" + +SHADED 31 + log "NOT IMPLEMENTED" + +EVENT 32 + log "NOT IMPLEMENTED" + +SHADED 32 + log "NOT IMPLEMENTED" + +EVENT 33 + log "NOT IMPLEMENTED" + +SHADED 33 + log "NOT IMPLEMENTED" + +EVENT 34 + log "NOT IMPLEMENTED" + +SHADED 34 + log "NOT IMPLEMENTED" + +EVENT 35 + log "NOT IMPLEMENTED" + +SHADED 35 + log "NOT IMPLEMENTED" + +EVENT 36 + log "NOT IMPLEMENTED" + +SHADED 36 + log "NOT IMPLEMENTED"
\ No newline at end of file @@ -40,25 +40,25 @@ main { background-color: #777; } #mapwrap { grid-column: 2; - grid-row: 1; + grid-row: 2; } #card_panel { grid-column: 2; - grid-row: 2; + grid-row: 1; } #mapwrap[data-fit="both"] + #card_panel { max-width: 250px; grid-column: 3; - grid-row: 1; + grid-row: 2; } @media (min-width: 2000px) { #card_panel { max-width: 250px; grid-column: 3; - grid-row: 1; + grid-row: 2; } } @@ -57,7 +57,7 @@ <div id="table"> -<div id="combat_table"> +<details id="combat_table" class="hide"> <div id="attacker" class="player_pool"> <div id="name_attack" class="player_name">Attacker</div> @@ -68,7 +68,7 @@ <div id="name_defender" class="player_name">Defender</div> </div> -</div> +</details> <div id="mapwrap"> <div id="map"> @@ -351,7 +351,6 @@ c-32 0 -38 0 -46 2 -11 2 -20 5 -23 6 -2 0 -5 2 -8 3 -4 1 -10 4 -14 6 -6 4 <div id="this_card" class="card card_1"><div id="unshaded_event"></div><div id="shaded_event"></div></div> <div id="deck_outer" class="card card_back"><div id="deck_size">35</div></div> <div id="dynasty_card" class="card card_dynasty_khalji"></div> - <div id="of_gods_and_kings" class="card card_26"><div id="of_gods_and_kings_label">~ Of Gods and Kings ~</div></div> </div> </div> @@ -8,6 +8,7 @@ let view = null const data = require("./data.js") const SPACES = data.spaces const SPACE_NAME = data.space_name +const CITIES = data.city function get_space_id(name) { return SPACE_NAME.indexOf(name); @@ -40,6 +41,15 @@ const S_VE_INF_2 = 23 const S_VE_INF_3 = 24 const S_VE_INF_4 = 25 +const C_CHITTOR = 0 +const C_DEVAGIRI = 1 +const C_GOA = 2 +const C_GULBARGA = 3 +const C_VIJAYANAGARA = 4 +const C_WARANGAL = 5 + +const SINGLE_EVENTS = [26] + const first_piece = data.first_piece const last_piece = data.last_piece const first_space = S_ANDHRA @@ -521,7 +531,6 @@ states.eligible = { states.main_phase = { inactive: "Eligible Faction", prompt() { - if (game.cmd && game.cmd.limited === 1) { view.prompt = "Select a limited Command." gen_any_command() @@ -532,7 +541,7 @@ states.main_phase = { } else if (game.cmd && game.cmd.event === 1) { view.prompt = "Select a Command or the Event." gen_any_command() - // gen_event() + gen_any_event() } else if (game.cmd) { view.prompt = "Select a Command." gen_any_command() @@ -559,6 +568,9 @@ states.main_phase = { rebel: goto_rebel, tax: goto_tax, trade: goto_trade, + event() { goto_event(0) }, + unshaded() { goto_event(0) }, + shaded() { goto_event(1) }, end_of_turn: resume_event_card, } @@ -2368,6 +2380,10 @@ function move_all_faction_piece_from(faction, type, from, to) { }) } +function is_adjacent_to_city(city, s) { + return set_has(CITIES[city].adjacent, s) +} + function is_selected_cmd_space(s) { return game.cmd.spaces && set_has(game.cmd.spaces, s) } @@ -3114,6 +3130,108 @@ function for_each_movable(faction, f) { } } +// === EVENTS === + +function gen_any_event() { + if (set_has(SINGLE_EVENTS, this_card())) { + view.actions.event = 1 + } else { + console.log("GEN ANY EVENT!") + view.actions.unshaded = 1 + view.actions.shaded = 1 + console.log(view.actions) + } +} + +function goto_event(shaded) { + push_undo() + let c = this_card() + + game.cmd = 0 + + if (shaded) { + log_h2(faction_name[game.current] + " - Shaded Event") + log("C" + c) + log(".i " + data.card_flavor_shaded[c] + ".") + log_br() + goto_vm(c * 2 + 1) + } else { + log_h2(faction_name[game.current] + " - Event") + log("C" + c) + if (data.card_flavor[c]) + log(".i " + data.card_flavor[c] + ".") + log_br() + goto_vm(c * 2 + 0) + } +} + +function end_event() { + game.vm = null + resume_event_card() +} + +function event_prompt(str) { + if (typeof str === "undefined") + str = CODE[game.vm.fp][game.vm.prompt][1] + if (typeof str === "function") + str = str() + view.prompt = data.card_title[this_card()] + ": " + str +} + +// === VM === + +function goto_vm(proc) { + game.state = "vm" + game.vm = { + prompt: 0, + fp: proc, + ip: 0, + ss: [], + s: -1, + pp: [], + p: -1, + m: 0, + } + vm_exec() +} + +function vm_exec() { + vm_inst(0)() +} + +function vm_inst(a) { + return CODE[game.vm.fp][game.vm.ip][a] +} + +function vm_log() { + log(vm_operand(1)) + vm_next() +} + +function vm_next() { + game.vm.ip ++ + vm_exec() +} + +function vm_operand(a) { + let x = CODE[game.vm.fp][game.vm.ip][a] + if (a > 0 && typeof x === "function") + return x() + return x +} + +function vm_return() { + game.state = "vm_return" +} + +states.vm_return = { + prompt() { + event_prompt("Done.") + view.actions.end_event = 1 + }, + end_event, +} + // === CONST === // Factions @@ -3151,5 +3269,432 @@ const SOP_LIMITED_COMMAND = 1 const SOP_COMMAND_DECREE = 2 const SOP_EVENT_OR_COMMAND = 3 const SOP_PASS = 4 -const INELIGIBLE = 5 -// === CONST ===
\ No newline at end of file +const INELIGIBLE = 5// === CONST === + +const CODE = [] + +// EVENT 1 +CODE[1 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 1 +CODE[1 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 2 +CODE[2 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 2 +CODE[2 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 3 +CODE[3 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 3 +CODE[3 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 4 +CODE[4 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 4 +CODE[4 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 5 +CODE[5 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 5 +CODE[5 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 6 +CODE[6 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 6 +CODE[6 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 7 +CODE[7 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 7 +CODE[7 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 8 +CODE[8 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 8 +CODE[8 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 9 +CODE[9 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 9 +CODE[9 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 10 +CODE[10 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 10 +CODE[10 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 11 +CODE[11 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 11 +CODE[11 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 12 +CODE[12 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 12 +CODE[12 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 13 +CODE[13 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 13 +CODE[13 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 14 +CODE[14 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 14 +CODE[14 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 15 +CODE[15 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 15 +CODE[15 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 16 +CODE[16 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 16 +CODE[16 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 17 +CODE[17 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 17 +CODE[17 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 18 +CODE[18 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 18 +CODE[18 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 19 +CODE[19 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 19 +CODE[19 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 20 +CODE[20 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 20 +CODE[20 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 21 +CODE[21 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 21 +CODE[21 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 22 +CODE[22 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 22 +CODE[22 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 23 +CODE[23 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 23 +CODE[23 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 24 +CODE[24 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 24 +CODE[24 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 25 +CODE[25 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 25 +CODE[25 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 26 +CODE[26 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 27 +CODE[27 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 27 +CODE[27 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 28 +CODE[28 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 28 +CODE[28 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 29 +CODE[29 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 29 +CODE[29 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 30 +CODE[30 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 30 +CODE[30 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 31 +CODE[31 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 31 +CODE[31 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 32 +CODE[32 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 32 +CODE[32 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 33 +CODE[33 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 33 +CODE[33 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 34 +CODE[34 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 34 +CODE[34 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 35 +CODE[35 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 35 +CODE[35 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// EVENT 36 +CODE[36 * 2 + 0] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] + +// SHADED 36 +CODE[36 * 2 + 1] = [ + [ vm_log, "NOT IMPLEMENTED" ], + [ vm_return ], +] diff --git a/tools/gencode.js b/tools/gencode.js new file mode 100644 index 0000000..d4d8d23 --- /dev/null +++ b/tools/gencode.js @@ -0,0 +1,136 @@ +"use strict" + +let fs = require("fs") + +let pc = 0 +let UCODE = Array(72).fill(0) +let SCODE = Array(72).fill(0) + +function emit(line) { + ++pc + line[0] = "vm_" + line[0] + for (let i = 1; i < line.length; ++i) { + if (typeof line[i] === "string") { + if (line[i] === "all") + line[i] = 999 + if (line[i][0] === "(" && !line[i].match(/\)=>/)) + line[i] = "()=>" + line[i] + if (line[i][0] === "`") + line[i] = "()=>" + line[i] + } + } + console.log("\t[ " + line.join(", ") + " ],") +} + +console.log("const CODE = []") +let first = false + +for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { + line = line.trim() + if (line.length === 0 || line[0] === "#") + continue + if (line === "EOF") + break + line = line.split(" ") + switch (line[0]) { + case "EVENT": + if (first++) { + emit(["return"]) + console.log("]") + } + UCODE[line[1]] = pc + console.log("") + console.log("// EVENT " + line[1]) + console.log("CODE[" + line[1] + " * 2 + 0] = [") + break + case "SHADED": + if (first++) { + emit(["return"]) + console.log("]") + } + SCODE[line[1]] = pc + console.log("") + console.log("// SHADED " + line[1]) + console.log("CODE[" + line[1] + " * 2 + 1] = [") + break + + case "if_space": + emit([ "if", "()=>can_vm_space(1,(s)=>" + line.slice(1).join(" ") + ")" ]) + emit([ "space", true, 1, 1, "(s)=>" + line.slice(1).join(" ") ]) + emit([ "else" ]) + break + + case "or_space": + emit([ "space", true, 1, 1, "(s)=>" + line.slice(1).join(" ") ]) + emit([ "endif" ]) + break + + case "space_no_undo": + emit([ "space", false, line[1], line[1], "(s)=>" + line.slice(2).join(" ") ]) + break + case "space": + emit([ "space", true, line[1], line[1], "(s)=>" + line.slice(2).join(" ") ]) + break + case "space_opt": + emit([ "space", true, 0, line[1], "(s)=>" + line.slice(2).join(" ") ]) + break + + case "piece": + emit([ "piece", false, line[1], line[1], "(p,s)=>" + line.slice(2).join(" ") ]) + break + case "piece_undo": + emit([ "piece", true, line[1], line[1], "(p,s)=>" + line.slice(2).join(" ") ]) + break + case "piece_range": + emit([ "piece", false, line[1], line[2], "(p,s)=>" + line.slice(3).join(" ") ]) + break + case "piece_opt": + emit([ "piece", false, 0, line[1], "(p,s)=>" + line.slice(2).join(" ") ]) + break + case "piece_undo_opt": + emit([ "piece", true, 0, line[1], "(p,s)=>" + line.slice(2).join(" ") ]) + break + + case "shipment": + emit([ "shipment", false, line[1], line[1], "(p,s)=>" + line.slice(2).join(" ") ]) + break + case "shipment_opt": + emit([ "shipment", false, 0, line[1], "(p,s)=>" + line.slice(2).join(" ") ]) + break + + case "place": + emit([ "place", false, 0, line[1], line[2] ]) + break + case "place_opt": + emit([ "place", false, 1, line[1], line[2] ]) + break + case "auto_place": + emit([ "auto_place", false, 0, line[1], line[2] ]) + break + + case "log": + case "prompt": + emit([ line[0], line.slice(1).join(" ") ]) + break + + case "count_spaces": + emit([ line[0], "(s)=>" + line.slice(1).join(" ") ]) + break + case "count_pieces": + emit([ line[0], "(p,s)=>" + line.slice(1).join(" ") ]) + break + + case "asm": + case "if": + case "while": + emit([ line[0], "()=>" + line.slice(1).join(" ") ]) + break + + default: + emit(line) + break + } +} + +emit(["return"]) +console.log("]") diff --git a/tools/gendata.js b/tools/gendata.js index 21418e1..dfc26f3 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -222,6 +222,53 @@ adjacent("Sindh", "Punjab") adjacent("Punjab", "Delhi") adjacent("Punjab", "Mountain Passes") +// Def cities +data.city = [ ] +data.city_name = [ ] + +function def_city(name) { + data.city.push({ id: to_ascii(name), adjacent: [] }) + data.city_name.push(name) +} + +function adjacent_city(city, province) { + c = data.city_name.indexOf(city) + p = data.space_name.indexOf(province) + add(data.city[c].adjacent, p) +} + +def_city("Chittor") +def_city("Devagiri") +def_city("Goa") +def_city("Gulbarga") +def_city("Vijayanagara") +def_city("Warangal") + +adjacent_city("Chittor", "Gujarat") +adjacent_city("Chittor", "Malwa") +adjacent_city("Chittor", "Rajput Kingdoms") + +adjacent_city("Devagiri", "Gujarat") +adjacent_city("Devagiri", "Madhyadesh") +adjacent_city("Devagiri", "Maharashtra") +adjacent_city("Devagiri", "Malwa") + +adjacent_city("Goa", "Karnataka") +adjacent_city("Goa", "Madhyadesh") + +adjacent_city("Gulbarga", "Andhra") +adjacent_city("Gulbarga", "Madhyadesh") +adjacent_city("Gulbarga", "Maharashtra") + +adjacent_city("Vijayanagara", "Andhra") +adjacent_city("Vijayanagara", "Karnataka") +adjacent_city("Vijayanagara", "Madhyadesh") + +adjacent_city("Warangal", "Andhra") +adjacent_city("Warangal", "Gondwana") +adjacent_city("Warangal", "Madhyadesh") +adjacent_city("Warangal", "Orissa") + // Pieces numbers function def_piece(faction, type, count) { if (count == 0) { |