let fs = require("fs") let data = {} // Factions const DS = 0 const BK = 1 const VE = 2 const MI = 3 // Pieces const DISC = 0 const ELITE = 1 const TROOPS = 2 // Creating cards const IMAP = { D: DS, B: BK, V: VE } let order = [] data.card_title = [ null ] data.card_order = [ null ] data.card_flavor = [] data.card_flavor_shaded = [] function def_order(s) { order = [ IMAP[s[0]], IMAP[s[1]], IMAP[s[2]] ] } function def_card(number, name) { data.card_title[number] = name data.card_order[number] = order } function flavor(id, unshaded, shaded) { id = parseInt(id) if (unshaded) data.card_flavor[id] = unshaded if (shaded) data.card_flavor_shaded[id] = shaded } def_order("BDV") def_card(3, "Diamond Mines of Golconda") def_card(10, "Capital Relocated") def_card(15, "Uprising in Daulatabad") def_card(19, "Bengali Resistance") def_card(29, "Ashvapati, Lord of Horses") def_card(30, "Bara Gazi Toph") def_order("BVD") def_card(16, "Gulbarga Fort") def_card(17, "Sufi Shaikh Relocates") def_card(18, "Center of High Culture") def_card(28, "The Turquoise Throne") def_card(31, "The Raichur Doab") def_card(35, "Hindu-Muslim Marriages") def_order("DBV") def_card(1, "Malik Kafur") def_card(2, "Mongol Army Repelled") def_card(8, "Yadava Kingdom Annexed") def_card(11, "Hindu Kush Mountains") def_card(20, "Eastern Ganga Dynasty") def_card(21, "Vindhya Range") def_order("DVB") def_card(4, "Ears of the Sultan") def_card(6, "Siege of Warangal") def_card(7, "The Conquest of Madurai") def_card(9, "Kakatiya Empire Extinguished") def_card(22, "A New Calculus") def_card(27, "Taghi the Elusive") def_order("VBD") def_card(13, "Sage of Vidyaranya") def_card(14, "Last Great King of the Hoysalas") def_card(25, "Empire Building") def_card(26, "Of Gods and Kings") def_card(32, "The Hare and the Hounds") def_card(33, "Commercial Port of Goa") def_order("VDB") def_card(5, "Siege of Chittor") def_card(12, "Musunuri Nayakas") def_card(23, "Virupaksha Temple") def_card(24, "Stone Temple Chariots") def_card(34, "Bahmani Sultan Assassinated") def_card(36, "Northern Alliances") order = null def_card(37, "Mongol Invasion") def_card(38, "Mongol Invasion") def_card(39, "Mongol Invasion") def_card(40, "Mongol Invasion") def_card(41, "Mongol Invasion") def_card(42, "Mongol Invasion") def_card(43, "Mongol Invasion") def_card(44, "Mongol Invasion") def_card(45, "Zenith of the Delhi Sultanate") def_card(46, "Rise of the Rebel Sultans") def_card(47, "Lords of the Deccan") def_card(48, "Timurid Empire") def_card(49, "Timurid Empire") flavor("1. Malik Kafur", "General assassinated, power struggle ensues", "Favored slave-general brilliant in battle") flavor("2. Mongol Army Repelled", "Pyrrhic victory", "Sultan’s mercenary army victorious") flavor("3. Diamond Mines of Golconda", "Untold riches lie just beneath the surface", "Sultan’s oppressive taxation") flavor("4. Ears of the Sultan", "Sultan’s plans intercepted", "Network of spies covers the Deccan") flavor("5. Siege of Chittor", "Hammir Singh reclaims a Rajput Kingdom", "Massacre at Chittor") flavor("6. Siege of Warangal", "Continual looting encourages resistance", "Koh-i-Noor diamond among war spoils") flavor("7. The Conquest of Madurai", "Tale of Madurai Sultan’s defeat chronicled in epic Sanskrit poem", "Sultan’s generals plunder Pandyan kingdom") flavor("8. Yadava Kingdom Annexed", "Multi-ethnic polity seeds development", "Sultanate reclaims natural stronghold") flavor("9. Kakatiya Empire Extinguished", "Telugu kingdom leaves a mythic legacy", "Sultanate tires of awaiting tribute") flavor("10. Capital Relocated", "Political damage and chaos ensues as the Delhi elite is forced to migrate", "Sultan shortens his reach into the Deccan") flavor("11. Hindu Kush Mountains", "Sultanate army perishes in the snow on a scheme of foreign conquest", "Grandiose schemes pay dividends") flavor("12. Musunuri Nayakas", "“Warrior kings” rise in the shadow of the Kakatiya Empire", "Telugu warriors no match for siege technology from Central Asia") flavor("13. Sage of Vidyaranya", "Meeting with revered jagadguru in Sringeri sparks a foundational myth", "Inferior military suffers early defeats") flavor("14. Last Great King of the Hoysalas", "Vijayanagara emerges from the crumbling kingdom of Veera Ballala III", "Delhi’s armies plunder the Hoysala Capital") flavor("15. Uprising in Daulatabad", "Delhi resentment reaches breaking point", "Commanders sentenced to death") flavor("16. Gulbarga Fort", "Defenses expanded in the first Bahmani capital", "Bahmani Kingdom threatens control") flavor("17. Sufi Shaikh Relocates", "Siraj-al-Din Junaidi takes up residence", "Relationships sour between Bahmani rulers and Sufi shaikhs") flavor("18. Center of High Culture", "Bahmani Kingdom attracts great minds from afar; culture flourishes in the Deccan", "Divisions among Deccanis and newcomers") flavor("19. Bengali Resistance", "Governors repeatedly assert independence", "Criminals conscripted to reclaim Bengal") flavor("20. Eastern Ganga Dynasty", "Prosperous kingdom falls into decline", "Sultanate invades Orissa") flavor("21. Vindhya Range", "Mountainous region provides a natural buffer from Delhi", "Long campaigns go unchallenged") flavor("22. A New Calculus", "Madhava of Sangamagrama founds the Kerala School of Astronomy and Mathematics", "Narayana Pandita’s mathematical treatises offer new insights of immediate use") flavor("23. Virupaksha Temple", "Temple to Shiva merges regional goddess cults", "Symbols of sovereignty destroyed") flavor("24. Stone Temple Chariots", "Chariots carry representations of Puranic Hindu gods", "Cultural development draws interest") flavor("25. Empire Building", "Lords of the Eastern and Western Oceans", "Sultan’s new roads thrust into the Deccan") flavor("26. Of Gods and Kings", "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", "") flavor("27. Taghi the Elusive", "Fugitive rebel an expensive distraction", "The Sultan marches west in pursuit") flavor("28. The Turquoise Throne", "Bahmanis cross the Krishna river into Telangana", "Telangana Nayakas implore allies to attack") flavor("29. Ashvapati, Lord of Horses", "Bahmani rulers likened to Hindu god", "War horses and siege technology imported from overseas") flavor("30. Bara Gazi Toph", "Gigantic cannons defend Bahmani forts", "Gunpowder and cannons appear suddenly in the subcontinent") flavor("31. The Raichur Doab", "Repeated raids over fertile lands", "Massive casualties in both kingdoms") flavor("32. The Hare and the Hounds", "Identical empire origin stories lean on regional cult mythologies", "Persian values inherited from Delhi") flavor("33. Commercial Port of Goa", "Struggle for critical maritime routes", "Competition over ports boils over") flavor("34. Bahmani Sultan Assassinated", "Vijayanagara captures Goa while the Bahmanis are destabilized", "Bahmani successor ushers in a period of social reform and cultural revival") flavor("35. Hindu-Muslim Marriages", "Bahmani Sultan weds a Hindu bride", "Diffusion and dilution of culture") flavor("36. Northern Alliances", "Vijayanagara probes an alliance with Delhi", "Alliance rejected") // Defining spaces data.spaces = [ ] data.space_name = [ ] function def_space(type, pop, name) { data.spaces.push({ type, id: to_ascii(name), pop, adjacent: [] }) data.space_name.push(name) } function adjacent(an, bn) { ax = data.space_name.indexOf(an) bx = data.space_name.indexOf(bn) set_add(data.spaces[ax].adjacent, bx) set_add(data.spaces[bx].adjacent, ax) } def_space("province", 1, "Andhra") def_space("province", 2, "Bengal") def_space("province", 1, "Gondwana") def_space("province", 2, "Gujarat") def_space("province", 1, "Jaunpur") def_space("province", 2, "Karnataka") def_space("province", 1, "Madhyadesh") def_space("province", 2, "Maharashtra") def_space("province", 2, "Malwa") def_space("province", 1, "Orissa") def_space("province", 1, "Rajput Kingdoms") def_space("province", 1, "Sindh") def_space("province", 1, "Tamilakam") def_space("capital", 0, "Delhi") def_space("mongol", 0, "Mountain Passes") def_space("mongol", 0, "Punjab") def_space("holdbox", null, "MI_available") def_space("holdbox", null, "DS_available") def_space("holdbox", null, "BK_available") def_space("holdbox", null, "VE_available") def_space("holdbox", null, "BK_DI_2") def_space("holdbox", null, "BK_DI_4") def_space("holdbox", null, "VE_DI_1") def_space("holdbox", null, "VE_DI_2") def_space("holdbox", null, "VE_DI_3") def_space("holdbox", null, "VE_DI_4") adjacent("Andhra", "Gondwana") adjacent("Andhra", "Karnataka") adjacent("Andhra", "Madhyadesh") adjacent("Andhra", "Maharashtra") adjacent("Andhra", "Orissa") adjacent("Andhra", "Tamilakam") adjacent("Bengal", "Gondwana") adjacent("Bengal", "Jaunpur") adjacent("Bengal", "Orissa") adjacent("Gondwana", "Jaunpur") adjacent("Gondwana", "Madhyadesh") adjacent("Gondwana", "Orissa") adjacent("Gujarat", "Madhyadesh") adjacent("Gujarat", "Maharashtra") adjacent("Gujarat", "Malwa") adjacent("Gujarat", "Rajput Kingdoms") adjacent("Gujarat", "Sindh") adjacent("Jaunpur", "Delhi") adjacent("Jaunpur", "Malwa") adjacent("Karnataka", "Maharashtra") adjacent("Karnataka", "Tamilakam") adjacent("Madhyadesh", "Malwa") adjacent("Madhyadesh", "Maharashtra") adjacent("Madhyadesh", "Orissa") adjacent("Maharashtra", "Malwa") adjacent("Malwa", "Delhi") adjacent("Malwa", "Rajput Kingdoms") adjacent("Rajput Kingdoms", "Delhi") adjacent("Rajput Kingdoms", "Punjab") adjacent("Rajput Kingdoms", "Sindh") adjacent("Sindh", "Mountain Passes") 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) set_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", "Maharashtra") adjacent_city("Gulbarga", "Andhra") adjacent_city("Gulbarga", "Madhyadesh") adjacent_city("Gulbarga", "Maharashtra") adjacent_city("Vijayanagara", "Andhra") adjacent_city("Vijayanagara", "Karnataka") adjacent_city("Vijayanagara", "Maharashtra") 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) { data.first_piece[faction][type] = null data.last_piece[faction][type] = null } else { data.first_piece[faction][type] = pc_index data.last_piece[faction][type] = pc_index + count - 1 pc_index += count } } pc_index = 0 data.first_piece = [ [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0] ] data.last_piece = [ [-1, -1, -1], [-1, -1, -1], [-1, -1, -1], [-1, -1, -1] ] def_piece(DS, DISC, 5) def_piece(DS, ELITE, 5) def_piece(DS, TROOPS, 32) def_piece(BK, DISC, 5) def_piece(BK, ELITE, 18) def_piece(BK, TROOPS, 0) def_piece(VE, DISC, 5) def_piece(VE, ELITE, 22) def_piece(VE, TROOPS, 0) def_piece(MI, DISC, 0) def_piece(MI, ELITE, 0) def_piece(MI, TROOPS, 12) // Tools function array_insert(array, index, item) { for (let i = array.length; i > index; --i) array[i] = array[i - 1] array[index] = item } function set_add(set, item) { let a = 0 let b = set.length - 1 while (a <= b) { let m = (a + b) >> 1 let x = set[m] if (item < x) b = m - 1 else if (item > x) a = m + 1 else return } array_insert(set, a, item) } function to_ascii(s) { return s.normalize("NFD").replace(/[\u0300-\u036f]/g, "") } // Output data file fs.writeFileSync("data.js", "const data = " + JSON.stringify(data, 0, 0) + "\nif (typeof module !== 'undefined') module.exports = data\n")