GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizgame/scenarios

Unified GrandEngine factory and runner powering all 8 playable real-Earth simulation genres (the age of sail, a 4X of nations, the Three Kingdoms, a steppe empire, crowns and trade, modern geopolitics, flight, and an airline) over a single Earth + StrategyWorld + VoyageWorld + FlightSim core with zero duplication.

gizlang
import * as Scenarios from "gizgame/scenarios";

Types

GrandEngine

gizlang
class GrandEngine { mode: string = MODE_AGE_OF_SAIL; title: string = ""; year: i64 = 1522; strategy: StrategyWorld = new StrategyWorld(false); voyage: VoyageWorld | undefined = undefined; flight: FlightSim | undefined = undefined; flightDestCode: string = "HND"; flightDestName: string = "Tokyo Haneda"; flightDestLat: f64 = 35.5523; flightDestLon: f64 = 139.7798; flightDestElevM: f64 = 11.0; constructor(mode: string, isKo: bool = false, gaz?: EarthGazetteer, relief?: Relief) { this.mode = mode; this.strategy = new StrategyWorld(isKo); if (mode === MODE_AGE_OF_SAIL) { this.initAgeOfSail(isKo, gaz); } else if (mode === MODE_FOUR_X) { this.initFourX(isKo, relief); } else if (mode === MODE_THREE_KINGDOMS) { this.initThreeKingdoms(isKo); } else if (mode === MODE_STEPPE_EMPIRE) { this.initSteppeEmpire(isKo); } else if (mode === MODE_GRAND_STRATEGY) { this.initGrandStrategy(isKo); } else if (mode === MODE_GEOPOLITICS) { this.initGeopolitics(isKo, gaz); } else if (mode === MODE_FLIGHT_SIM) { this.initFlightSim(gaz, relief); } else if (mode === MODE_AIRLINE) { this.initAirline(isKo, gaz); } else { this.initAgeOfSail(isKo, gaz); } } stepTurn(): VictoryStatus { if (this.mode === MODE_AGE_OF_SAIL && this.voyage !== undefined) { this.voyage!.strategy.stepMonth(); this.strategy = this.voyage!.strategy; this.year = this.voyage!.year; return this.strategy.checkVictory(); } this.strategy.stepMonth(); if (this.mode === MODE_FOUR_X) { this.year + = 25; } else if (this.mode === MODE_STEPPE_EMPIRE) { this.year + = 1; } else if (this.strategy.turn % 12 === 0) { this.year + = 1; } return this.strategy.checkVictory(); } stepFlight(dt: f64, ctrl: FlightControl, relief?: Relief): IlsGuidance | undefined { if (this.flight === undefined) { return undefined; } const fl = this.flight!; const groundM = relief !== undefined ? Math.max(0.0, relief!.sample(fl.state.lat, fl.state.lon)): 10.0; fl.step(dt, ctrl, groundM, this.strategy.monthOfTurn()); return fl.guidanceTo(this.flightDestLat, this.flightDestLon, this.flightDestElevM, this.flightDestCode, this.flightDestName); } private initAgeOfSail(isKo: bool, gaz?: EarthGazetteer): void { this.title = "Age of Sail (1522)"; this.year = 1522; const vw = new VoyageWorld(isKo); if (gaz !== undefined) { vw.attachGazetteer(gaz!, 32); } this.voyage = vw; this.strategy = vw.strategy; } private initFourX(isKo: bool, relief?: Relief): void { this.title = "Dawn of Nations (4000 BCE)"; this.year = -4000; let sw = this.strategy; sw.factions = [{ id: 0, nameEn: "Rome", nameKo: "로마", color: [0.68, 0.22, 0.82, 1.0], gold: 200, food: 100, prestige: 50, capitalId: 0, personality: "aggressive", isPlayer: true }, { id: 1, nameEn: "Egypt", nameKo: "이집트", color: [0.95, 0.82, 0.24, 1.0], gold: 200, food: 120, prestige: 55, capitalId: 1, personality: "diplomatic", isPlayer: false }, { id: 2, nameEn: "China", nameKo: "중국", color: [0.22, 0.78, 0.46, 1.0], gold: 220, food: 130, prestige: 60, capitalId: 2, personality: "defensive", isPlayer: false }, { id: 3, nameEn: "Korea", nameKo: "한국", color: [0.24, 0.64, 0.96, 1.0], gold: 200, food: 110, prestige: 55, capitalId: 3, personality: "diplomatic", isPlayer: false }, { id: 4, nameEn: "Babylon", nameKo: "바빌론", color: [0.32, 0.86, 0.92, 1.0], gold: 210, food: 115, prestige: 55, capitalId: 4, personality: "mercantile", isPlayer: false }, { id: 5, nameEn: "America", nameKo: "미국", color: [0.25, 0.44, 0.92, 1.0], gold: 200, food: 110, prestige: 50, capitalId: 5, personality: "mercantile", isPlayer: false }]; const capitals: Vec<{ name: string; lat: f64; lon: f64; river: bool; }> = [{ name: "Rome", lat: 41.90, lon: 12.50, river: true }, { name: "Cairo", lat: 30.04, lon: 31.24, river: true }, { name: "Xi'an", lat: 34.26, lon: 108.94, river: true }, { name: "Seoul", lat: 37.57, lon: 126.98, river: true }, { name: "Baghdad", lat: 33.31, lon: 44.37, river: true }, { name: "Washington", lat: 38.91, lon: -77.04, river: true }]; for (const [i, cap] of capitals.entries()) { const elev = relief !== undefined ? Math.max(0.0, relief!.sample(cap.lat, cap.lon)): 45.0; sw.regions.push({ id: i, nameEn: cap.name, nameKo: cap.name, factionId: i, lat: cap.lat, lon: cap.lon, economy: 3, industry: 3, defense: 30, troops: 100, morale: 85, connections: [(i + 1) % 6, (i + 5) % 6] }); sw.foundCity(i, elev, cap.river); sw.monarchs.push({ factionId: i, adm: 50, dip: 50, mil: 50, stability: 1, alarm: 0, era: 0, science: 0, culture: 0, faith: 0 }); } sw.techs = [{ id: "writing", branch: "civil", nameEn: "Writing", nameKo: "문자", descEn: "Unlocks the Academy", descKo: "캠퍼스 해금", level: 0, maxLevel: 1, baseCost: 80, bonusPerLv: 0.12 }, { id: "iron_working", branch: "military", nameEn: "Iron Working", nameKo: "철기", descEn: "+15% Infantry Combat", descKo: "보병 전투력 +15%", level: 0, maxLevel: 3, baseCost: 120, bonusPerLv: 0.15 }, { id: "navigation", branch: "special", nameEn: "Ocean Navigation", nameKo: "원양 항해", descEn: "Cross Deep Ocean", descKo: "원양 항해 해금", level: 0, maxLevel: 2, baseCost: 180, bonusPerLv: 0.15 }, { id: "rocketry", branch: "special", nameEn: "Rocketry", nameKo: "로켓 공학", descEn: "Space Race Victory", descKo: "우주 경쟁 승리", level: 0, maxLevel: 3, baseCost: 400, bonusPerLv: 0.25 }]; } private initThreeKingdoms(isKo: bool): void { this.title = "Romance of the Three Kingdoms (208 CE)"; this.year = 208; let sw = this.strategy; sw.factions = [{ id: 0, nameEn: "Shu Han", nameKo: "촉한", color: [0.22, 0.82, 0.44, 1.0], gold: 3200, food: 4500, prestige: 180, capitalId: 0, personality: "diplomatic", isPlayer: true }, { id: 1, nameEn: "Cao Wei", nameKo: "조위", color: [0.28, 0.52, 0.96, 1.0], gold: 5600, food: 7200, prestige: 240, capitalId: 2, personality: "aggressive", isPlayer: false }, { id: 2, nameEn: "Eastern Wu", nameKo: "동오", color: [0.94, 0.34, 0.34, 1.0], gold: 4400, food: 5600, prestige: 200, capitalId: 4, personality: "defensive", isPlayer: false }]; sw.regions = [{ id: 0, nameEn: "Chengdu", nameKo: "성도", factionId: 0, lat: 30.57, lon: 104.07, economy: 7, industry: 6, defense: 75, troops: 12000, morale: 88, connections: [1, 2] }, { id: 1, nameEn: "Jingzhou", nameKo: "형주", factionId: 0, lat: 30.35, lon: 112.19, economy: 8, industry: 7, defense: 68, troops: 15000, morale: 85, connections: [0, 3, 4] }, { id: 2, nameEn: "Luoyang", nameKo: "낙양", factionId: 1, lat: 34.62, lon: 112.45, economy: 9, industry: 8, defense: 85, troops: 22000, morale: 86, connections: [0, 3] }, { id: 3, nameEn: "Xuchang", nameKo: "허창", factionId: 1, lat: 34.03, lon: 113.85, economy: 9, industry: 9, defense: 82, troops: 24000, morale: 87, connections: [1, 2, 4, 5] }, { id: 4, nameEn: "Jianye", nameKo: "건업", factionId: 2, lat: 32.06, lon: 118.79, economy: 9, industry: 8, defense: 80, troops: 18000, morale: 88, connections: [1, 3, 5] }, { id: 5, nameEn: "Chaisang", nameKo: "시상", factionId: 2, lat: 29.71, lon: 115.99, economy: 7, industry: 7, defense: 76, troops: 16000, morale: 90, connections: [3, 4] }]; sw.officers = [{ id: 0, nameEn: "Liu Bei", nameKo: "유비", factionId: 0, lea: 82, war: 74, intl: 78, pol: 84, cha: 99, loyalty: 100, office: "administrator" }, { id: 1, nameEn: "Zhuge Liang", nameKo: "제갈량", factionId: 0, lea: 93, war: 38, intl: 100, pol: 98, cha: 95, loyalty: 100, office: "strategist" }, { id: 2, nameEn: "Guan Yu", nameKo: "관우", factionId: 0, lea: 96, war: 97, intl: 76, pol: 64, cha: 94, loyalty: 100, office: "" }, { id: 3, nameEn: "Cao Cao", nameKo: "조조", factionId: 1, lea: 98, war: 72, intl: 92, pol: 95, cha: 96, loyalty: 100, office: "administrator" }, { id: 4, nameEn: "Sima Yi", nameKo: "사마의", factionId: 1, lea: 97, war: 63, intl: 98, pol: 94, cha: 87, loyalty: 88, office: "strategist" }, { id: 5, nameEn: "Xiahou Dun", nameKo: "하후돈", factionId: 1, lea: 89, war: 90, intl: 58, pol: 70, cha: 82, loyalty: 99, office: "" }, { id: 6, nameEn: "Sun Quan", nameKo: "손권", factionId: 2, lea: 84, war: 67, intl: 80, pol: 89, cha: 95, loyalty: 100, office: "administrator" }, { id: 7, nameEn: "Zhou Yu", nameKo: "주유", factionId: 2, lea: 97, war: 71, intl: 96, pol: 86, cha: 93, loyalty: 99, office: "strategist" }, { id: 8, nameEn: "Lu Xun", nameKo: "육손", factionId: 2, lea: 95, war: 69, intl: 95, pol: 88, cha: 90, loyalty: 97, office: "" }]; for (const r of sw.regions) { sw.domestics.push({ regionId: r.id, agriculture: 60, commerce: 58, order: 80, fortification: r.defense, foodStock: 4000, training: 75, governorId: r.factionId*3 }); } sw.setTreaty(0, 2, "ally", 24); sw.setTreaty(0, 1, "war", 0); sw.setTreaty(2, 1, "war", 0); } private initSteppeEmpire(isKo: bool): void { this.title = "Steppe Empire (1206 CE Eurasia)"; this.year = 1206; let sw = this.strategy; sw.factions = [{ id: 0, nameEn: "Mongol Empire", nameKo: "몽골 제국", color: [0.95, 0.68, 0.18, 1.0], gold: 3800, food: 3600, prestige: 260, capitalId: 0, personality: "aggressive", isPlayer: true }, { id: 1, nameEn: "Song Dynasty", nameKo: "남송", color: [0.22, 0.82, 0.58, 1.0], gold: 6800, food: 6000, prestige: 240, capitalId: 1, personality: "defensive", isPlayer: false }, { id: 2, nameEn: "Khwarazm", nameKo: "호라즘", color: [0.34, 0.72, 0.92, 1.0], gold: 4500, food: 4200, prestige: 210, capitalId: 2, personality: "mercantile", isPlayer: false }, { id: 3, nameEn: "Kievan Rus", nameKo: "키예프 루스", color: [0.84, 0.34, 0.34, 1.0], gold: 3400, food: 3800, prestige: 185, capitalId: 3, personality: "defensive", isPlayer: false }, { id: 4, nameEn: "Holy Roman Empire", nameKo: "신성로마제국", color: [0.92, 0.86, 0.32, 1.0], gold: 5200, food: 4800, prestige: 230, capitalId: 4, personality: "diplomatic", isPlayer: false }]; sw.regions = [{ id: 0, nameEn: "Karakorum", nameKo: "카라코룸", factionId: 0, lat: 47.20, lon: 102.85, economy: 5, industry: 6, defense: 55, troops: 18000, morale: 96, connections: [1, 2] }, { id: 1, nameEn: "Hangzhou", nameKo: "항저우", factionId: 1, lat: 30.27, lon: 120.15, economy: 10, industry: 9, defense: 85, troops: 20000, morale: 80, connections: [0, 2] }, { id: 2, nameEn: "Samarkand", nameKo: "사마르칸트", factionId: 2, lat: 39.65, lon: 66.96, economy: 9, industry: 7, defense: 72, troops: 15000, morale: 82, connections: [0, 1, 3] }, { id: 3, nameEn: "Kyiv", nameKo: "키이우", factionId: 3, lat: 50.45, lon: 30.52, economy: 7, industry: 6, defense: 68, troops: 12000, morale: 84, connections: [2, 4] }, { id: 4, nameEn: "Vienna", nameKo: "빈", factionId: 4, lat: 48.21, lon: 16.37, economy: 9, industry: 8, defense: 82, troops: 16000, morale: 85, connections: [3] }]; sw.dynasties = [{ factionId: 0, rulerName: "Temujin", heirName: "Ogedei", legitimacy: 98, nomadMode: true, vassalOf: -1, royalMarriages: [] }, { factionId: 1, rulerName: "Ningzong", heirName: "Lizong", legitimacy: 88, nomadMode: false, vassalOf: -1, royalMarriages: [] }, { factionId: 2, rulerName: "Muhammad II", heirName: "Jalal al-Din", legitimacy: 85, nomadMode: false, vassalOf: -1, royalMarriages: [] }, { factionId: 3, rulerName: "Mstislav", heirName: "Daniil", legitimacy: 80, nomadMode: false, vassalOf: -1, royalMarriages: [] }, { factionId: 4, rulerName: "Otto IV", heirName: "Frederick II", legitimacy: 86, nomadMode: false, vassalOf: -1, royalMarriages: [] }]; sw.tradeNodes = [{ id: 0, name: "Silk Road East", regionId: 1, lat: 30.27, lon: 120.15, localValue: 28.0, downstream: [1], controllerId: 1 }, { id: 1, name: "Samarkand Hub", regionId: 2, lat: 39.65, lon: 66.96, localValue: 22.0, downstream: [2], controllerId: 2 }, { id: 2, name: "Vienna Danubian", regionId: 4, lat: 48.21, lon: 16.37, localValue: 24.0, downstream: [], controllerId: 4 }]; } private initGrandStrategy(isKo: bool): void { this.title = "Crowns and Trade (1444 CE)"; this.year = 1444; let sw = this.strategy; sw.factions = [{ id: 0, nameEn: "Ottoman Empire", nameKo: "오스만 제국", color: [0.24, 0.74, 0.42, 1.0], gold: 4800, food: 1200, prestige: 220, capitalId: 0, personality: "aggressive", isPlayer: true }, { id: 1, nameEn: "France", nameKo: "프랑스", color: [0.24, 0.52, 0.96, 1.0], gold: 5200, food: 1400, prestige: 230, capitalId: 1, personality: "aggressive", isPlayer: false }, { id: 2, nameEn: "Castile", nameKo: "카스티야", color: [0.96, 0.78, 0.22, 1.0], gold: 4600, food: 1100, prestige: 210, capitalId: 2, personality: "mercantile", isPlayer: false }, { id: 3, nameEn: "England", nameKo: "잉글랜드", color: [0.92, 0.28, 0.28, 1.0], gold: 4900, food: 1100, prestige: 205, capitalId: 3, personality: "mercantile", isPlayer: false }, { id: 4, nameEn: "Ming", nameKo: "명나라", color: [0.94, 0.56, 0.22, 1.0], gold: 7500, food: 2200, prestige: 260, capitalId: 4, personality: "defensive", isPlayer: false }, { id: 5, nameEn: "Joseon", nameKo: "조선", color: [0.32, 0.82, 0.92, 1.0], gold: 4100, food: 1300, prestige: 195, capitalId: 5, personality: "diplomatic", isPlayer: false }]; sw.regions = [{ id: 0, nameEn: "Constantinople", nameKo: "콘스탄티노플", factionId: 0, lat: 41.01, lon: 28.98, economy: 10, industry: 9, defense: 85, troops: 24000, morale: 90, connections: [1, 4] }, { id: 1, nameEn: "Paris", nameKo: "파리", factionId: 1, lat: 48.86, lon: 2.35, economy: 10, industry: 9, defense: 82, troops: 22000, morale: 88, connections: [0, 2, 3] }, { id: 2, nameEn: "Seville", nameKo: "세비야", factionId: 2, lat: 37.39, lon: -5.98, economy: 9, industry: 8, defense: 76, troops: 18000, morale: 86, connections: [1, 3] }, { id: 3, nameEn: "London", nameKo: "런던", factionId: 3, lat: 51.51, lon: -0.13, economy: 10, industry: 9, defense: 80, troops: 19000, morale: 87, connections: [1, 2] }, { id: 4, nameEn: "Beijing", nameKo: "베이징", factionId: 4, lat: 39.90, lon: 116.41, economy: 10, industry: 10, defense: 88, troops: 32000, morale: 85, connections: [0, 5] }, { id: 5, nameEn: "Hanyang", nameKo: "한양", factionId: 5, lat: 37.57, lon: 126.98, economy: 8, industry: 8, defense: 78, troops: 14000, morale: 88, connections: [4] }]; for (const f of sw.factions) { sw.monarchs.push({ factionId: f.id, adm: 120, dip: 120, mil: 120, stability: 1, alarm: 0, era: 3, science: 0, culture: 0, faith: 0 }); } sw.tradeNodes = [{ id: 0, name: "Beijing", regionId: 4, lat: 39.90, lon: 116.41, localValue: 35.0, downstream: [1], controllerId: 4 }, { id: 1, name: "Constantinople", regionId: 0, lat: 41.01, lon: 28.98, localValue: 30.0, downstream: [2], controllerId: 0 }, { id: 2, name: "Seville", regionId: 2, lat: 37.39, lon: -5.98, localValue: 28.0, downstream: [3], controllerId: 2 }, { id: 3, name: "English Channel", regionId: 3, lat: 51.51, lon: -0.13, localValue: 34.0, downstream: [], controllerId: 3 }]; } private initGeopolitics(isKo: bool, gaz?: EarthGazetteer): void { this.title = "Modern Geopolitics"; this.year = 2026; let sw = this.strategy; const seeds: Vec<{ iso: string; name: string; lat: f64; lon: f64; gdp: f64; popK: i64; nukes: i64; gov: string; }> = [{ iso: "KOR", name: "South Korea", lat: 37.57, lon: 126.98, gdp: 1800.0, popK: 51700, nukes: 0, gov: "democracy" }, { iso: "USA", name: "United States", lat: 38.91, lon: -77.04, gdp: 27000.0, popK: 335000, nukes: 5200, gov: "republic" }, { iso: "CHN", name: "China", lat: 39.90, lon: 116.41, gdp: 18500.0, popK: 1410000, nukes: 500, gov: "autocracy" }, { iso: "JPN", name: "Japan", lat: 35.68, lon: 139.69, gdp: 4200.0, popK: 124000, nukes: 0, gov: "democracy" }, { iso: "DEU", name: "Germany", lat: 52.52, lon: 13.40, gdp: 4500.0, popK: 84000, nukes: 0, gov: "democracy" }, { iso: "GBR", name: "United Kingdom", lat: 51.51, lon: -0.13, gdp: 3400.0, popK: 68000, nukes: 225, gov: "democracy" }]; for (const [i, s] of seeds.entries()) { let gdp = s.gdp; let popK = s.popK; let lat = s.lat; let lon = s.lon; if (gaz !== undefined) { const found = gaz!.byCode(s.iso, PLACE_COUNTRY); if (found !== undefined) { if (found!.gdpBillions> 0) { gdp = f64(found!.gdpBillions); } if (found!.population> 0) { popK = found!.population; } } } sw.factions.push({ id: i, nameEn: s.name, nameKo: s.name, color: [0.25 + f64(i%3)*0.3, 0.45 + f64((i+1)%3)*0.22, 0.85 - f64(i%2)*0.35, 1.0], gold: i64(Math.round(gdp*10.0)), food: 5000, prestige: 300, capitalId: i, personality: i === 0 ? "diplomatic": "mercantile", isPlayer: i === 0 }); sw.regions.push({ id: i, nameEn: s.name, nameKo: s.name, factionId: i, lat, lon, economy: 10, industry: 10, defense: 90, troops: 40000, morale: 90, connections: [(i + 1) % 6, (i + 5) % 6] }); sw.macros.push({ factionId: i, isoCode: s.iso, gdpBillions: gdp, populationK: popK, inflation: 0.025, interestRate: 0.035, taxPersonal: 0.28, taxCorporate: 0.22, debtBillions: gdp*0.65, approval: 62.0, stability: 78.0, government: s.gov, budgetDefense: 0.028, budgetInfra: 0.04, budgetEdu: 0.05, budgetResearch: 0.03, nuclearWarheads: s.nukes, missileDefense: 0.65, airPower: 450, navalPower: 120, armorPower: 1200 }); } sw.setTreaty(0, 1, "ally", 48); sw.setTreaty(0, 3, "trade", 36); } private initFlightSim(gaz?: EarthGazetteer, relief?: Relief): void { this.title = "Real-Earth Flight Simulator (ICN -> HND)"; this.year = 2026; let depLat = 37.4602; let depLon = 126.4407; let depElev = 7.0; if (gaz !== undefined) { const icn = gaz!.byCode("ICN", PLACE_AIRPORT); if (icn !== undefined) { depLat = icn!.lat; depLon = icn!.lon; depElev = f64(icn!.elevationM); } const hnd = gaz!.byCode("HND", PLACE_AIRPORT); if (hnd !== undefined) { this.flightDestCode = "HND"; this.flightDestName = hnd!.name; this.flightDestLat = hnd!.lat; this.flightDestLon = hnd!.lon; this.flightDestElevM = f64(hnd!.elevationM); } } if (relief !== undefined) { depElev = Math.max(depElev, relief!.sample(depLat, depLon)); } const brng = initialBearingDeg({ lat: depLat, lon: depLon }, { lat: this.flightDestLat, lon: this.flightDestLon }); this.flight = new FlightSim("a320", depLat, depLon, depElev, brng, false); } private initAirline(isKo: bool, gaz?: EarthGazetteer): void { this.title = "Global Airline"; this.year = 1992; let sw = this.strategy; sw.factions = [{ id: 0, nameEn: "Pacific Sky Airways", nameKo: "퍼시픽 스카이 항공", color: [0.22, 0.72, 0.98, 1.0], gold: 80000, food: 0, prestige: 120, capitalId: 0, personality: "mercantile", isPlayer: true }, { id: 1, nameEn: "Atlantic Wings", nameKo: "애틀랜틱 윙스", color: [0.94, 0.36, 0.36, 1.0], gold: 80000, food: 0, prestige: 120, capitalId: 2, personality: "aggressive", isPlayer: false }, { id: 2, nameEn: "EuroJet", nameKo: "유로젯", color: [0.32, 0.84, 0.48, 1.0], gold: 80000, food: 0, prestige: 120, capitalId: 3, personality: "diplomatic", isPlayer: false }]; const hubs: Vec<{ code: string; name: string; lat: f64; lon: f64; econ: i64; ind: i64; }> = [{ code: "ICN", name: "Seoul", lat: 37.4602, lon: 126.4407, econ: 9, ind: 9 }, { code: "HND", name: "Tokyo", lat: 35.5523, lon: 139.7798, econ: 10, ind: 10 }, { code: "JFK", name: "New York", lat: 40.6413, lon: -73.7781, econ: 10, ind: 9 }, { code: "LHR", name: "London", lat: 51.4700, lon: -0.4543, econ: 10, ind: 9 }, { code: "SIN", name: "Singapore", lat: 1.3644, lon: 103.9915, econ: 9, ind: 9 }, { code: "DXB", name: "Dubai", lat: 25.2532, lon: 55.3657, econ: 9, ind: 8 }]; for (const [i, h] of hubs.entries()) { let lat = h.lat; let lon = h.lon; if (gaz !== undefined) { const ap = gaz!.byCode(h.code, PLACE_AIRPORT); if (ap !== undefined) { lat = ap!.lat; lon = ap!.lon; } } sw.regions.push({ id: i, nameEn: h.name, nameKo: h.name, factionId: i <2 ? 0: i <4 ? 1: 2, lat, lon, economy: h.econ, industry: h.ind, defense: 50, troops: 0, morale: 100, connections: [] }); } const u0 = sw.buyAircraft(0, "a320", 0); if (u0> = 0) { sw.openAirRoute(0, 0, 1, u0, 260); } } }

Unified playable engine container for any of the 8 real-Earth game modes.

  • mode: string
  • title: string
  • year: i64
  • strategy: Ref<M261.StrategyWorld>
  • voyage: _gizlang_sdk_core.Option<Ref<M266.VoyageWorld>>
  • flight: _gizlang_sdk_core.Option<Ref<M224.FlightSim>>
  • flightDestCode: string
  • flightDestName: string
  • flightDestLat: f64
  • flightDestLon: f64
  • flightDestElevM: f64

Functions

supportedModes

gizlang
function supportedModes(): Vec<string>

Lists all 8 supported playable scenario modes.

Effects: fail, alloc.

constructor

gizlang
constructor(mode: string, isKo: bool = false, gaz?: EarthGazetteer, relief?: Relief)

The engine of MODE, in Korean with ISKO, on the places of GAZ and the heights of RELIEF.

Effects: fail, read, write, alloc.

Methods

GrandEngine.stepTurn

gizlang
stepTurn(): VictoryStatus

Advances one strategic turn (or monthly tick) across the active mode and returns current victory status.

Effects: fail, read, write, alloc.

GrandEngine.stepFlight

gizlang
stepFlight(dt: f64, ctrl: FlightControl, relief?: Relief): IlsGuidance | undefined

Advances 6-DoF flight simulation by DT seconds (active in flight_sim mode).

Effects: fail, read, write, alloc.

Constants

MODE_AGE_OF_SAIL

gizlang
const MODE_AGE_OF_SAIL: string = "age_of_sail"

Canonical scenario mode identifiers supported by GrandEngine.

MODE_FOUR_X

gizlang
const MODE_FOUR_X: string = "four_x"

A 4X of nations from 4000 BCE.

MODE_THREE_KINGDOMS

gizlang
const MODE_THREE_KINGDOMS: string = "three_kingdoms"

The Three Kingdoms of China.

MODE_STEPPE_EMPIRE

gizlang
const MODE_STEPPE_EMPIRE: string = "steppe_empire"

A steppe empire of 1206.

MODE_GRAND_STRATEGY

gizlang
const MODE_GRAND_STRATEGY: string = "grand_strategy"

Crowns and trade from 1444.

MODE_GEOPOLITICS

gizlang
const MODE_GEOPOLITICS: string = "geopolitics"

Modern geopolitics.

MODE_FLIGHT_SIM

gizlang
const MODE_FLIGHT_SIM: string = "flight_sim"

A flight between two airports.

MODE_AIRLINE

gizlang
const MODE_AIRLINE: string = "airline"

A global airline.