gizgame/voyage
Universal composable Earth-scale maritime exploration, dynamic trade economy, multi-ship fleet, port facilities (Market/Shipyard/Tavern/Guild/Palace/Bank), provisions, weather/wind, cartography, and tactical naval combat + boarding captain duel (일기토) module. Reusable by ANY game or AI-generated world.
import * as Voyage from "gizgame/voyage";Types
TradeGood
type TradeGood = { id: i64; nameEn: string; nameKo: string; basePrice: i64; homeRegion: i64; demandRegion: i64; }One regional trade commodity with base price and producing region index (0..5).
id:i64nameEn:stringnameKo:stringbasePrice:i64homeRegion:i64demandRegion:i64
ShipClass
type ShipClass = { id: i64; nameEn: string; nameKo: string; price: i64; maxHull: i64; maxCargo: i64; maxCrew: i64; guns: i64; speedMul: f64; minInd: i64; }One playable ship hull class with authentic Uncharted Waters 2 stats.
id:i64nameEn:stringnameKo:stringprice:i64maxHull:i64maxCargo:i64maxCrew:i64guns:i64speedMul:f64minInd:i64
FleetShip
type FleetShip = { classId: i64; name: string; hull: i64; maxHull: i64; guns: i64; cargoCap: i64; sailLv: i64; }One ship inside the player's multi-ship fleet (up to 5 ships sailing in formation).
classId:i64name:stringhull:i64maxHull:i64guns:i64cargoCap:i64sailLv:i64
Officer
type Officer = { id: i64; nameEn: string; nameKo: string; roleEn: string; roleKo: string; cost: i64; hired: bool; bonus: string; }One recruitable named officer (Navigator, Gunner, Merchant, Admiral, Surgeon, Cartographer).
id:i64nameEn:stringnameKo:stringroleEn:stringroleKo:stringcost:i64hired:boolbonus:string
Port
type Port = { id: i64; nameEn: string; nameKo: string; region: i64; nation: string; x: f64; z: f64; economy: i64; industry: i64; specialty: i64; demand: i64; discovered: bool; boomGood: i64; }One historic/regional port on the Earth-scale 16,000m x 8,000m world map.
id:i64nameEn:stringnameKo:stringregion:i64nation:stringx:f64z:f64economy:i64industry:i64specialty:i64demand:i64discovered:boolboomGood:i64
Discovery
type Discovery = { id: i64; nameEn: string; nameKo: string; x: f64; z: f64; reward: i64; fame: i64; found: bool; reported: bool; }One discoverable World Wonder / Landmark on the Earth-scale map.
id:i64nameEn:stringnameKo:stringx:f64z:f64reward:i64fame:i64found:boolreported:bool
Contract
type Contract = { kind: string; titleEn: string; titleKo: string; targetPort: i64; goodId: i64; need: i64; progress: i64; reward: i64; fame: i64; }Active Guild contract (delivery, pirate bounty, or discovery expedition).
kind:stringtitleEn:stringtitleKo:stringtargetPort:i64goodId:i64need:i64progress:i64reward:i64fame:i64
DuelState
type DuelState = { active: bool; pirateIdx: i64; enemyName: string; pHp: i64; pMax: i64; eHp: i64; eMax: i64; round: i64; lastLog: string; }Active Captain Sword Duel (일기토) state during boarding combat.
active:boolpirateIdx:i64enemyName:stringpHp:i64pMax:i64eHp:i64eMax:i64round:i64lastLog:string
VoyageWorld
class VoyageWorld { isKo: bool = false; year: i64 = 1522; month: i64 = 4; day: i64 = 1; dayAccum: f64 = 0.0; weather: string = "clear"; weatherTimer: f64 = 38.0; weatherCycleIdx: i64 = 0; gold: i64 = 3200; bankGold: i64 = 0; food: i64 = 80; water: i64 = 80; crew: i64 = 36; morale: i64 = 88; tradeFame: i64 = 100; adventureFame: i64 = 100; battleFame: i64 = 100; rankIdx: i64 = 0; swordPower: i64 = 24; armorDef: i64 = 8; hasAstrolabe: bool = false; hasSpyglass: bool = false; fleet: Vec<FleetShip> = []; cargo: Vec<i64> = []; cargoCost: Vec<i64> = []; officers: Vec<Officer> = []; ports: Vec<Port> = []; goods: Vec<TradeGood> = []; ships: Vec<ShipClass> = []; discoveries: Vec<Discovery> = []; contract: Contract = { kind: "", titleEn: "", titleKo: "", targetPort: -1, goodId: -1, need: 0, progress: 0, reward: 0, fame: 0 }; explored: Vec<bool> = []; dockedPort: i64 = -1; portTab: i64 = 0; chartOpen: bool = false; autopilotPort: i64 = -1; nearestPort: i64 = 0; nearestPortDist: f64 = 999.0; duel: DuelState = { active: false, pirateIdx: -1, enemyName: "", pHp: 100, pMax: 100, eHp: 100, eMax: 100, round: 1, lastLog: "" }; notice: string = ""; noticeTimer: f64 = 0.0; pendingTeleport: Point3 | undefined = undefined; constructor(isKo: bool) { this.isKo = isKo; this.goods = [{ id: 0, nameEn: "Wine", nameKo: "포도주", basePrice: 45, homeRegion: 0, demandRegion: 1 }, { id: 1, nameEn: "Wool", nameKo: "모직물", basePrice: 60, homeRegion: 1, demandRegion: 0 }, { id: 2, nameEn: "Velvet", nameKo: "벨벳", basePrice: 120, homeRegion: 0, demandRegion: 4 }, { id: 3, nameEn: "Firearms", nameKo: "화승총", basePrice: 165, homeRegion: 0, demandRegion: 5 }, { id: 4, nameEn: "Ivory", nameKo: "상아", basePrice: 190, homeRegion: 2, demandRegion: 0 }, { id: 5, nameEn: "Gold Ore", nameKo: "금괴", basePrice: 340, homeRegion: 2, demandRegion: 1 }, { id: 6, nameEn: "Coffee", nameKo: "커피", basePrice: 110, homeRegion: 3, demandRegion: 0 }, { id: 7, nameEn: "Spices", nameKo: "향신료", basePrice: 145, homeRegion: 3, demandRegion: 0 }, { id: 8, nameEn: "Gems", nameKo: "보석", basePrice: 310, homeRegion: 3, demandRegion: 1 }, { id: 9, nameEn: "Silk", nameKo: "비단", basePrice: 210, homeRegion: 4, demandRegion: 0 }, { id: 10, nameEn: "Porcelain", nameKo: "도자기", basePrice: 230, homeRegion: 4, demandRegion: 1 }, { id: 11, nameEn: "Tea", nameKo: "차", basePrice: 125, homeRegion: 4, demandRegion: 1 }, { id: 12, nameEn: "Sugar", nameKo: "설탕", basePrice: 78, homeRegion: 5, demandRegion: 0 }, { id: 13, nameEn: "Silver", nameKo: "은괴", basePrice: 255, homeRegion: 5, demandRegion: 4 }, { id: 14, nameEn: "Timber", nameKo: "목재", basePrice: 42, homeRegion: 1, demandRegion: 3 }, { id: 15, nameEn: "Salt", nameKo: "소금", basePrice: 34, homeRegion: 0, demandRegion: 2 }]; this.ships = [{ id: 0, nameEn: "Caravel", nameKo: "카라벨", price: 1400, maxHull: 100, maxCargo: 80, maxCrew: 45, guns: 14, speedMul: 1.00, minInd: 1 }, { id: 1, nameEn: "Brigantine", nameKo: "브리건틴", price: 2800, maxHull: 145, maxCargo: 120, maxCrew: 65, guns: 24, speedMul: 1.12, minInd: 2 }, { id: 2, nameEn: "Carrack", nameKo: "캐랙", price: 5200, maxHull: 210, maxCargo: 220, maxCrew: 95, guns: 36, speedMul: 1.06, minInd: 3 }, { id: 3, nameEn: "Galleon", nameKo: "갤리온", price: 9500, maxHull: 310, maxCargo: 320, maxCrew: 140, guns: 54, speedMul: 1.15, minInd: 4 }, { id: 4, nameEn: "Frigate", nameKo: "프리깃", price: 13500, maxHull: 340, maxCargo: 240, maxCrew: 150, guns: 68, speedMul: 1.32, minInd: 5 }, { id: 5, nameEn: "Oriental Junk", nameKo: "정크선", price: 11200, maxHull: 290, maxCargo: 360, maxCrew: 125, guns: 48, speedMul: 1.24, minInd: 4 }, { id: 6, nameEn: "Geobukseon", nameKo: "거북선", price: 22000, maxHull: 520, maxCargo: 260, maxCrew: 180, guns: 92, speedMul: 1.22, minInd: 6 }, { id: 7, nameEn: "Man-of-War", nameKo: "전열함", price: 32000, maxHull: 640, maxCargo: 420, maxCrew: 240, guns: 110, speedMul: 1.28, minInd: 7 }]; this.ports = [{ id: 0, nameEn: "Lisbon", nameKo: "리스본", region: 0, nation: "Portugal", x: 0.0, z: -68.0, economy: 5, industry: 4, specialty: 0, demand: 7, discovered: true, boomGood: 7 }, { id: 1, nameEn: "Seville", nameKo: "세비야", region: 0, nation: "Spain", x: 240.0, z: -130.0, economy: 5, industry: 4, specialty: 3, demand: 9, discovered: true, boomGood: 9 }, { id: 2, nameEn: "Venice", nameKo: "베네치아", region: 0, nation: "Venice", x: 1080.0, z: -460.0, economy: 6, industry: 5, specialty: 2, demand: 7, discovered: false, boomGood: 7 }, { id: 3, nameEn: "Alexandria", nameKo: "알렉산드리아", region: 0, nation: "Ottoman", x: 1620.0, z: 220.0, economy: 5, industry: 4, specialty: 7, demand: 3, discovered: false, boomGood: 1 }, { id: 4, nameEn: "London", nameKo: "런던", region: 1, nation: "England", x: 310.0, z: -1020.0, economy: 6, industry: 6, specialty: 1, demand: 11, discovered: false, boomGood: 11 }, { id: 5, nameEn: "Amsterdam", nameKo: "암스테르담", region: 1, nation: "Netherlands", x: 640.0, z: -1080.0, economy: 6, industry: 5, specialty: 14, demand: 10, discovered: false, boomGood: 10 }, { id: 6, nameEn: "Dakar", nameKo: "다카르", region: 2, nation: "Portugal", x: -420.0, z: 1060.0, economy: 3, industry: 2, specialty: 4, demand: 15, discovered: false, boomGood: 3 }, { id: 7, nameEn: "Cape Town", nameKo: "케이프타운", region: 2, nation: "Netherlands", x: 960.0, z: 2580.0, economy: 4, industry: 3, specialty: 5, demand: 0, discovered: false, boomGood: 0 }, { id: 8, nameEn: "Aden", nameKo: "아덴", region: 3, nation: "Ottoman", x: 2420.0, z: 1140.0, economy: 4, industry: 3, specialty: 6, demand: 2, discovered: false, boomGood: 2 }, { id: 9, nameEn: "Calicut", nameKo: "캘리컷", region: 3, nation: "India", x: 3840.0, z: 1240.0, economy: 6, industry: 4, specialty: 7, demand: 5, discovered: false, boomGood: 5 }, { id: 10, nameEn: "Malacca", nameKo: "말라카", region: 4, nation: "Malacca", x: 5080.0, z: 1720.0, economy: 5, industry: 4, specialty: 8, demand: 3, discovered: false, boomGood: 3 }, { id: 11, nameEn: "Macao", nameKo: "마카오", region: 4, nation: "Ming", x: 5880.0, z: 800.0, economy: 7, industry: 6, specialty: 9, demand: 13, discovered: false, boomGood: 13 }, { id: 12, nameEn: "Nagasaki", nameKo: "나가사키", region: 4, nation: "Japan", x: 6580.0, z: 120.0, economy: 6, industry: 6, specialty: 10, demand: 9, discovered: false, boomGood: 3 }, { id: 13, nameEn: "Busan", nameKo: "부산", region: 4, nation: "Joseon", x: 6460.0, z: -240.0, economy: 7, industry: 7, specialty: 11, demand: 7, discovered: false, boomGood: 7 }, { id: 14, nameEn: "Havana", nameKo: "아바나", region: 5, nation: "Spain", x: -3460.0, z: 720.0, economy: 5, industry: 4, specialty: 12, demand: 2, discovered: false, boomGood: 2 }, { id: 15, nameEn: "Veracruz", nameKo: "베라크루스", region: 5, nation: "Spain", x: -4140.0, z: 860.0, economy: 5, industry: 3, specialty: 13, demand: 3, discovered: false, boomGood: 3 }, { id: 16, nameEn: "Santo Domingo", nameKo: "산토도밍고", region: 5, nation: "Spain", x: -2820.0, z: 840.0, economy: 4, industry: 3, specialty: 12, demand: 0, discovered: false, boomGood: 0 }, { id: 17, nameEn: "Rio", nameKo: "리우데자네이루", region: 5, nation: "Portugal", x: -1760.0, z: 2260.0, economy: 5, industry: 4, specialty: 5, demand: 1, discovered: false, boomGood: 1 }]; this.discoveries = [{ id: 0, nameEn: "Pillars of Hercules", nameKo: "헤라클레스의 기둥", x: 140.0, z: 45.0, reward: 650, fame: 120, found: false, reported: false }, { id: 1, nameEn: "Pyramids of Giza", nameKo: "기자의 피라미드", x: 1760.0, z: 380.0, reward: 1400, fame: 260, found: false, reported: false }, { id: 2, nameEn: "Cape of Good Hope", nameKo: "희망봉", x: 860.0, z: 2740.0, reward: 1800, fame: 320, found: false, reported: false }, { id: 3, nameEn: "Angkor Sanctuary", nameKo: "앙코르 유적", x: 5260.0, z: 1420.0, reward: 2200, fame: 380, found: false, reported: false }, { id: 4, nameEn: "Mount Fuji", nameKo: "후지산", x: 6820.0, z: -60.0, reward: 2400, fame: 420, found: false, reported: false }, { id: 5, nameEn: "Krakatoa Volcano", nameKo: "크라카토아 화산", x: 5340.0, z: 2120.0, reward: 2000, fame: 360, found: false, reported: false }, { id: 6, nameEn: "El Dorado Cove", nameKo: "엘도라도 만", x: -2940.0, z: 1320.0, reward: 2800, fame: 480, found: false, reported: false }, { id: 7, nameEn: "Machu Picchu", nameKo: "마추픽추", x: -3420.0, z: 1980.0, reward: 2600, fame: 450, found: false, reported: false }, { id: 8, nameEn: "Giant Kraken Reef", nameKo: "거대 크라켄 암초", x: -1120.0, z: 380.0, reward: 1650, fame: 300, found: false, reported: false }, { id: 9, nameEn: "Northern Aurora", nameKo: "북극 오로라", x: 480.0, z: -1580.0, reward: 1900, fame: 340, found: false, reported: false }, { id: 10, nameEn: "Atlantis Shoals", nameKo: "아틀란티스 해저유적", x: -1620.0, z: -320.0, reward: 2500, fame: 440, found: false, reported: false }, { id: 11, nameEn: "Spice Islands", nameKo: "향신료 제도", x: 5720.0, z: 1860.0, reward: 2100, fame: 390, found: false, reported: false }]; this.officers = [{ id: 0, nameEn: "Vasco", nameKo: "바스코", roleEn: "Navigator (+20% Speed)", roleKo: "항해사 (속도 +20%)", cost: 900, hired: false, bonus: "speed" }, { id: 1, nameEn: "Catalina", nameKo: "카탈리나", roleEn: "Master Gunner (+35% Cannon)", roleKo: "포술장 (포격 +35%)", cost: 1200, hired: false, bonus: "cannon" }, { id: 2, nameEn: "Marco", nameKo: "마르코", roleEn: "Chief Merchant (+20% Profit)", roleKo: "회계사 (교역 +20%)", cost: 1100, hired: false, bonus: "trade" }, { id: 3, nameEn: "Admiral Yi", nameKo: "이순신 제독", roleEn: "Tactician (+35% Duel & Fleet)", roleKo: "전술가 (일기토/함대 +35%)", cost: 2400, hired: false, bonus: "duel" }, { id: 4, nameEn: "Elena", nameKo: "엘레나", roleEn: "Surgeon (Morale & Food Save)", roleKo: "군의관 (사기/식량 절감)", cost: 1000, hired: false, bonus: "crew" }, { id: 5, nameEn: "Pietro", nameKo: "피에트로", roleEn: "Cartographer (+50% Discovery)", roleKo: "지도학자 (발견 보상 +50%)", cost: 1300, hired: false, bonus: "explore" }]; for (const _ of range(0, this.goods.length)) { this.cargo.push(0); this.cargoCost.push(0); } for (const _ of range(0, 32*16)) { this.explored.push(false); } this.fleet.push({ classId: 0, name: isKo ? "산타마리아호": "Santa Maria", hull: 100, maxHull: 100, guns: 14, cargoCap: 80, sailLv: 1 }); this.revealAround(0.0, 0.0, 2); this.rollContract(0); } hasOfficer(bonus: string): bool { return this.officers.some(o => o.hired && o.bonus === bonus); } totalCargoUsed(): i64 { let s = 0; for (const q of this.cargo) { s+ = q; } return s; } totalCargoCap(): i64 { let s = 0; for (const sh of this.fleet) { s+ = sh.cargoCap; } return Math.maxI64(40, s); } totalGuns(): i64 { let s = 0; for (const sh of this.fleet) { s+ = sh.guns; } return s; } flagship(): FleetShip { return this.fleet[0]; } speedMultiplier(): f64 { const sc = this.ships[Math.minI64(this.ships.length-1, this.fleet[0].classId)]; const sailBonus = 1.0+f64(this.fleet[0].sailLv-1)*0.12; const navBonus = this.hasOfficer("speed") ? 1.20: 1.0; const astBonus = this.hasAstrolabe ? 1.12: 1.0; const provPenalty = (this.food <= 0 || this.water <= 0) ? 0.65: 1.0; return sc.speedMul*sailBonus*navBonus*astBonus*provPenalty; } cannonDamage(): i64 { const base = 25 + this.totalGuns()*2; return this.hasOfficer("cannon") ? i64(f64(base)*1.35): base; } rankTitle(): string { const en = ["Squire", "Knight", "Baron", "Viscount", "Earl", "Marquess", "Grand Duke"]; const ko = ["견습 항해사", "기사", "남작", "자작", "백작", "후작", "대공"]; const i = Math.maxI64(0, Math.minI64(6, this.rankIdx)); return this.isKo ? ko[i]: en[i]; } updateRank(): void { const total = this.tradeFame+this.adventureFame+this.battleFame; const next = total> = 6000 ? 6: total> = 3800 ? 5: total> = 2400 ? 4: total> = 1500 ? 3: total> = 900 ? 2: total> = 500 ? 1: 0; if (next> this.rankIdx) { this.rankIdx = next; this.pushNotice(this.isKo ? `왕실 작위 승급!! [${this.rankTitle() }] 서훈!`: `ROYAL PROMOTION!! Granted title of [${this.rankTitle() }]!`); } } pushNotice(msg: string, dur: f64 = 3.4): void { this.notice = msg; this.noticeTimer = dur; } priceAt(pid: i64, gid: i64, selling: bool): i64 { const p = this.ports[pid]; const g = this.goods[gid]; let mul = 1.0; if (p.specialty === gid) { mul = 0.58; } else if (g.homeRegion === p.region) { mul = 0.76; } else if (p.demand === gid) { mul = 2.35; } else if (g.demandRegion === p.region) { mul = 1.85; } else { mul = 1.18 + f64((pid*7 + gid*13)%9)*0.07; } if (p.boomGood === gid) { mul* = 1.32; } const econMul = 1.0 + f64(p.economy)*0.025; let price = f64(g.basePrice)*mul*(selling ? econMul: 1.0); if (selling && this.hasOfficer("trade")) { price* = 1.20; } if (!selling) { price* = 1.04; } return Math.maxI64(15, i64(Math.round(price))); } revealAround(x: f64, z: f64, rad: i64): void { const gx = i64(Math.floor(((x+5000.0)/12500.0)*32.0)); const gz = i64(Math.floor(((z+2200.0)/5600.0)*16.0)); const r = this.hasSpyglass ? rad+1: rad; for (const dz of range(-r, r+1)) { for (const dx of range(-r, r+1)) { const cx = gx+dx; const cz = gz+dz; if (cx> = 0 && cx <32 && cz> = 0 && cz <16) { this.explored[cz*32+cx] = true; } } } } rollContract(pid: i64): void { const p = this.ports[pid]; const dest = (pid + 1 + (this.day + pid)%4) % this.ports.length; const dp = this.ports[dest]; const gid = p.specialty; const g = this.goods[gid]; const qty = 12 + (this.rankIdx+1)*6; const reward = qty*this.priceAt(dest, gid, true)/2 + 450; this.contract = { kind: "delivery", titleEn: `Deliver ${qty } ${ g.nameEn } to ${ dp.nameEn }`, titleKo: `${dp.nameKo }에 ${ g.nameKo } ${ qty }개 운송`, targetPort: dest, goodId: gid, need: qty, progress: 0, reward, fame: 180 }; } step(px: f64, pz: f64, speed: f64, dt: f64): void { if (this.noticeTimer> 0.0) { this.noticeTimer = Math.max(0.0, this.noticeTimer-dt); } if (this.dockedPort> = 0 || this.duel.active) { return; } this.weatherTimer - = dt; if (this.weatherTimer <= 0.0) { const seq = ["clear", "breeze", "cloudy", "rain", "gale", "storm", "breeze", "clear", "typhoon", "clear"]; this.weatherCycleIdx = (this.weatherCycleIdx+1)%seq.length; this.weather = seq[this.weatherCycleIdx]; this.weatherTimer = this.weather === "storm" || this.weather === "typhoon" ? 26.0: 42.0; const wLabelKo = this.weather === "typhoon" ? "태풍 경보! 거대한 파도와 폭풍우!": this.weather === "storm" ? "폭풍우 접근! 돛을 줄이고 파도를 헤쳐 나가세요!": this.weather === "gale" ? "강풍이 불어옵니다! 순풍을 타면 고속 항해 가능!": this.weather === "rain" ? "바다에 비가 내리기 시작합니다.": this.weather === "clear" ? "맑고 화창한 순풍 항해 날씨입니다!": "잔잔한 해풍이 붑니다."; const wLabelEn = this.weather === "typhoon" ? "TYPHOON WARNING! Towering swells & fierce gales!": this.weather === "storm" ? "STORM APPROACHING! Heavy swells & lightning!": this.weather === "gale" ? "GALE WINDS! Ride the tailwind for high knots!": this.weather === "rain" ? "Rain squalls sweeping across the sea.": this.weather === "clear" ? "Clear skies & sparkling trade winds!": "Steady maritime breeze."; this.pushNotice(this.isKo ? wLabelKo: wLabelEn, 3.8); } this.dayAccum + = dt * (speed> 2.0 ? 0.22: 0.08); if (this.dayAccum> = 1.0) { this.dayAccum - = 1.0; this.day + = 1; if (this.day> 30) { this.day = 1; this.month + = 1; if (this.bankGold> 0) { this.bankGold + = Math.maxI64(10, this.bankGold/25); } if (this.month> 12) { this.month = 1; this.year + = 1; } } const drain = this.hasOfficer("crew") ? 1: 2; this.food = Math.maxI64(0, this.food-drain); this.water = Math.maxI64(0, this.water-drain); if (this.food === 0 || this.water === 0) { this.morale = Math.maxI64(15, this.morale-5); this.pushNotice(this.isKo ? "경고! 식량/식수 부족 — 가까운 항구에서 보급하세요!": "WARNING! Low Food/Water — Resupply at nearest Port!", 3.2); } if ((this.weather === "storm" || this.weather === "typhoon") && this.fleet.length> 0) { let fl = this.fleet[0]; fl.hull = Math.maxI64(15, fl.hull - (this.weather === "typhoon" ? 4: 2)); this.fleet[0] = fl; } } this.revealAround(px, pz, 1); let bestP = 0; let bestD = 1.0e9; for (const i of range(0, this.ports.length)) { let pt = this.ports[i]; const d = Math.sqrt((px-pt.x)*(px-pt.x)+(pz-pt.z)*(pz-pt.z)); if (d <bestD) { bestD = d; bestP = i; } if (!pt.discovered && d <(this.hasSpyglass ? 130.0: 88.0)) { pt.discovered = true; this.ports[i] = pt; this.adventureFame + = 80; this.gold + = 300; this.updateRank(); this.pushNotice(this.isKo ? `신항로 개척! [${pt.nameKo }] 항구 발견! (+300G · 모험명성 +80)`: `PORT DISCOVERED! [${pt.nameEn }] charted! (+300G · +80 Adventure Fame)`, 4.2); } } this.nearestPort = bestP; this.nearestPortDist = bestD; const discRange = this.hasSpyglass ? 95.0: 62.0; for (const i of range(0, this.discoveries.length)) { let dc = this.discoveries[i]; if (dc.found) { continue; } const d = Math.sqrt((px-dc.x)*(px-dc.x)+(pz-dc.z)*(pz-dc.z)); if (d <discRange) { dc.found = true; this.discoveries[i] = dc; const bonus = this.hasOfficer("explore") ? i64(f64(dc.fame)*1.5): dc.fame; this.adventureFame + = bonus; this.updateRank(); this.pushNotice(this.isKo ? `대발견!! [${dc.nameKo }] 발견! 조합에 보고하여 보상을 받으세요!`: `GREAT DISCOVERY!! [${dc.nameEn }] found! Report at any Guild for Gold!`, 4.8); } } } startDuel(pirateIdx: i64, enemyName: string): void { const bonus = this.hasOfficer("duel") ? 35: 0; this.duel = { active: true, pirateIdx, enemyName, pHp: 100 + bonus, pMax: 100 + bonus, eHp: 90 + this.rankIdx*15, eMax: 90 + this.rankIdx*15, round: 1, lastLog: this.isKo ? "접현 백병전 돌입! [강공 / 찌르기 / 반격] 중 선택하세요!": "BOARDING DUEL! Choose [Slash / Thrust / Parry]!" }; } duelMove(choice: i64): i64 { if (!this.duel.active) { return 0; } const enemy = (this.duel.round*3 + this.day + choice)%3; const namesEn = ["Slash", "Thrust", "Parry"]; const namesKo = ["강공", "찌르기", "반격"]; const pDmg = this.swordPower + (this.hasOfficer("duel") ? 10: 0); const eDmg = Math.maxI64(8, 22 - this.armorDef); const win = (choice === 0 && enemy === 1) || (choice === 1 && enemy === 2) || (choice === 2 && enemy === 0); const draw = choice === enemy; if (win) { const hit = i64(f64(pDmg)*1.45); this.duel.eHp = Math.maxI64(0, this.duel.eHp - hit); this.duel.lastLog = this.isKo ? `필살 적중! ${namesKo[choice] } > 적 ${ namesKo[enemy] } (-${ hit } HP)`: `CRITICAL HIT! ${namesEn[choice] } beats ${ namesEn[enemy] } (-${ hit } HP)`; } else if (draw) { this.duel.eHp = Math.maxI64(0, this.duel.eHp - pDmg/2); this.duel.pHp = Math.maxI64(0, this.duel.pHp - eDmg/2); this.duel.lastLog = this.isKo ? `검이 부딪혔습니다! 서로 피해 (${namesKo[choice] })`: `Blades clash! Both take glancing blows (${namesEn[choice] })`; } else { this.duel.pHp = Math.maxI64(0, this.duel.pHp - eDmg); this.duel.lastLog = this.isKo ? `적의 반격! ${namesKo[enemy] } > ${ namesKo[choice] } (-${ eDmg } HP)`: `Enemy counters! ${namesEn[enemy] } beats ${ namesEn[choice] } (-${ eDmg } HP)`; } this.duel.round + = 1; if (this.duel.eHp <= 0) { this.duel.active = false; const loot = 750 + this.rankIdx*220; this.gold + = loot; this.battleFame + = 220; this.morale = Math.minI64(100, this.morale+12); if (this.totalCargoUsed()+8 <= this.totalCargoCap()) { this.cargo[7] + = 8; } this.updateRank(); this.pushNotice(this.isKo ? `일기토 승리!! 적함 나포 +${loot }G & 향신료 약탈!`: `DUEL VICTORY!! Captured prize ship: +${loot }G & Spice Plunder!`, 4.8); return 1; } if (this.duel.pHp <= 0) { this.duel.active = false; this.gold = Math.maxI64(0, this.gold - 250); this.morale = Math.maxI64(25, this.morale - 15); this.pushNotice(this.isKo ? "일기토 패배 — 함대로 철수합니다 (-250G)": "Duel Lost — Retreated back to your flagship (-250G)", 3.8); return -1; } return 0; } handleAction(code: string): void { if (code === "V_CLOSE") { this.dockedPort = -1; this.chartOpen = false; return; } if (code === "V_CHART") { this.chartOpen = !this.chartOpen; if (this.chartOpen) { this.dockedPort = -1; } return; } if (code === "V_WEATHER") { const seq = ["clear", "breeze", "rain", "gale", "storm", "typhoon"]; const idx = (seq.indexOf(this.weather)+1)%seq.length; this.weather = seq[idx]; this.weatherTimer = 45.0; this.pushNotice(this.isKo ? `해상 날씨 변경: ${this.weather.toUpperCase() }`: `Sea Weather: ${this.weather.toUpperCase() }`, 2.4); return; } if (code === "V_DOCK") { if (this.nearestPortDist <95.0) { this.dockedPort = this.nearestPort; this.portTab = 0; this.chartOpen = false; let pt = this.ports[this.dockedPort]; pt.discovered = true; this.ports[this.dockedPort] = pt; if (this.contract.kind === "delivery" && this.contract.targetPort === this.dockedPort && this.cargo[this.contract.goodId]> = this.contract.need) { this.cargo[this.contract.goodId] - = this.contract.need; this.gold + = this.contract.reward; this.tradeFame + = this.contract.fame; this.pushNotice(this.isKo ? `조합 의뢰 완료!! +${this.contract.reward }G · 교역명성 +${ this.contract.fame }`: `CONTRACT COMPLETE!! +${this.contract.reward }G · +${ this.contract.fame } Trade Fame`, 4.5); this.rollContract(this.dockedPort); this.updateRank(); } } return; } if (code.startsWith("V_TAB_")) { const n = code.slice(6).parseInt() ?? 0; this.portTab = Math.maxI64(0, Math.minI64(5, n)); return; } if (code.startsWith("V_SAIL_")) { const pid = code.slice(7).parseInt() ?? -1; if (pid> = 0 && pid <this.ports.length) { const p = this.ports[pid]; const dist = Math.sqrt(p.x*p.x+p.z*p.z); const days = Math.maxI64(2, Math.minI64(24, i64(dist/320.0))); this.day + = days; while (this.day> 30) { this.day - = 30; this.month + = 1; if (this.month> 12) { this.month = 1; this.year + = 1; } } this.food = Math.maxI64(5, this.food - days); this.water = Math.maxI64(5, this.water - days); this.pendingTeleport = point3(p.x, 0.5, p.z + 36.0); this.chartOpen = false; this.autopilotPort = pid; this.revealAround(p.x, p.z, 2); this.pushNotice(this.isKo ? `${days }일 항해 끝에 [${ p.nameKo }] 앞바다 도착! 입항 버튼을 눌러 들어가세요.`: `Arrived off [${p.nameEn }] after ${ days } days at sea! Tap Dock to enter.`, 4.2); } return; } if (this.duel.active) { if (code === "V_DUEL_0") { void(this.duelMove(0)); return; } if (code === "V_DUEL_1") { void(this.duelMove(1)); return; } if (code === "V_DUEL_2") { void(this.duelMove(2)); return; } } if (this.dockedPort <0) { return; } const pid = this.dockedPort; if (code.startsWith("V_BUY_")) { const gid = code.slice(6).parseInt() ?? -1; if (gid> = 0 && gid <this.goods.length) { const pr = this.priceAt(pid, gid, false); const qty = Math.minI64(10, Math.minI64(this.totalCargoCap()-this.totalCargoUsed(), this.gold/Math.maxI64(1, pr))); if (qty> 0) { this.gold - = qty*pr; this.cargo[gid] + = qty; this.cargoCost[gid] = pr; this.pushNotice(this.isKo ? `${this.goods[gid].nameKo } ${ qty }개 매입 (-${ qty*pr }G)`: `Bought ${qty } ${ this.goods[gid].nameEn } (-${ qty*pr }G)`, 2.2); } else { this.pushNotice(this.isKo ? "금화 또는 적재 공간이 부족합니다!": "Not enough Gold or Cargo space!", 2.0); } } return; } if (code.startsWith("V_SELL_")) { const gid = code.slice(7).parseInt() ?? -1; if (gid> = 0 && gid <this.goods.length && this.cargo[gid]> 0) { const qty = this.cargo[gid]; const pr = this.priceAt(pid, gid, true); const rev = qty*pr; const profit = Math.maxI64(0, rev - qty*this.cargoCost[gid]); this.cargo[gid] = 0; this.gold + = rev; this.tradeFame + = Math.maxI64(15, profit/12); this.updateRank(); this.pushNotice(this.isKo ? `${this.goods[gid].nameKo } ${ qty }개 매각 (+${ rev }G · 순이익 +${ profit }G)`: `Sold ${qty } ${ this.goods[gid].nameEn } (+${ rev }G · Profit +${ profit }G)`, 3.0); } return; } if (code === "V_REPAIR") { let cost = 0; for (const i of range(0, this.fleet.length)) { let sh = this.fleet[i]; const dmg = sh.maxHull - sh.hull; if (dmg> 0) { cost + = dmg*4; sh.hull = sh.maxHull; this.fleet[i] = sh; } } const paid = Math.minI64(this.gold, cost); this.gold - = paid; this.pushNotice(this.isKo ? `함대 선체 완전 수리 완료! (-${paid }G)`: `Entire Fleet Repaired to 100%! (-${paid }G)`, 2.6); return; } if (code === "V_UP_GUNS") { const cost = 650 + this.fleet[0].guns*18; if (this.gold> = cost) { this.gold - = cost; let fl = this.fleet[0]; fl.guns + = 12; this.fleet[0] = fl; this.pushNotice(this.isKo ? `기함 함포 증설 완료! (${fl.guns }문)`: `Flagship Cannons Upgraded! (${fl.guns } guns)`, 2.6); } return; } if (code === "V_UP_SAIL") { const cost = 550 + this.fleet[0].sailLv*350; if (this.gold> = cost && this.fleet[0].sailLv <6) { this.gold - = cost; let fl = this.fleet[0]; fl.sailLv + = 1; this.fleet[0] = fl; this.pushNotice(this.isKo ? `기함 돛 개조 Lv.${fl.sailLv }! 항해 속도 증가!`: `Flagship Sails Lv.${fl.sailLv }! Speed boosted!`, 2.6); } return; } if (code.startsWith("V_SHIP_")) { const sid = code.slice(7).parseInt() ?? -1; if (sid> = 0 && sid <this.ships.length) { const sc = this.ships[sid]; if (this.gold <sc.price) { this.pushNotice(this.isKo ? `금화가 부족합니다 (${sc.price }G 필요)`: `Need ${sc.price }G to commission ${ sc.nameEn }`, 2.4); return; } this.gold - = sc.price; const built: FleetShip = { classId: sid, name: this.isKo ? sc.nameKo: sc.nameEn, hull: sc.maxHull, maxHull: sc.maxHull, guns: sc.guns, cargoCap: sc.maxCargo, sailLv: 1 }; if (this.fleet.length <5) { if (sc.maxHull> this.fleet[0].maxHull) { this.fleet = [built, ...this.fleet]; } else { this.fleet.push(built); } this.pushNotice(this.isKo ? `[${sc.nameKo }] 건조 완료! 함대 ${ this.fleet.length }척 편성!`: `Commissioned [${sc.nameEn }]! Fleet now ${ this.fleet.length } ships!`, 3.4); } else { this.fleet[0] = built; this.pushNotice(this.isKo ? `기함을 [${sc.nameKo }]으로 교체 완료!`: `Flagship upgraded to [${sc.nameEn }]!`, 3.4); } } return; } if (code === "V_CREW") { if (this.gold> = 180) { this.gold - = 180; this.crew + = 15; this.morale = Math.minI64(100, this.morale+6); this.pushNotice(this.isKo ? "선원 15명 고용 완료!": "Recruited 15 Sailors!", 2.2); } return; } if (code === "V_TREAT") { if (this.gold> = 120) { this.gold - = 120; this.morale = 100; this.pushNotice(this.isKo ? "주점 회식! 선원 사기 100% 회복!": "Rounds on the Captain! Crew Morale 100%!", 2.4); } return; } if (code.startsWith("V_OFF_")) { const oid = code.slice(6).parseInt() ?? -1; if (oid> = 0 && oid <this.officers.length && !this.officers[oid].hired && this.gold> = this.officers[oid].cost) { let of = this.officers[oid]; this.gold - = of.cost; of.hired = true; this.officers[oid] = of; this.pushNotice(this.isKo ? `항해사 [${of.nameKo }] 합류! (${ of.roleKo })`: `Officer [${of.nameEn }] joined your crew!`, 3.4); } return; } if (code === "V_REPORT") { let earned = 0; let fEarned = 0; let count = 0; for (const i of range(0, this.discoveries.length)) { let dc = this.discoveries[i]; if (dc.found && !dc.reported) { dc.reported = true; this.discoveries[i] = dc; const mult = this.hasOfficer("explore") ? 1.5: 1.0; earned + = i64(f64(dc.reward)*mult); fEarned + = i64(f64(dc.fame)*mult); count + = 1; } } if (count> 0) { this.gold + = earned; this.adventureFame + = fEarned; this.updateRank(); this.pushNotice(this.isKo ? `발견물 ${count }건 보고 완료!! +${ earned }G · 모험명성 +${ fEarned }`: `Reported ${count } Discoveries!! +${ earned }G · +${ fEarned } Adventure Fame`, 4.0); } else { this.pushNotice(this.isKo ? "보고할 신규 발견물이 없습니다. 세계 해역의 유적을 탐험하세요!": "No new discoveries to report — explore the world seas!", 2.8); } return; } if (code === "V_NEW_CONTRACT") { this.rollContract(pid); this.pushNotice(this.isKo ? `새 의뢰 수락: ${this.contract.titleKo }`: `Contract accepted: ${this.contract.titleEn }`, 3.0); return; } if (code === "V_GEAR_ASTRO" && !this.hasAstrolabe && this.gold> = 850) { this.gold - = 850; this.hasAstrolabe = true; this.pushNotice(this.isKo ? "아스트롤라베 구입! 항해 속도 +12%": "Astrolabe equipped! +12% Speed", 2.6); return; } if (code === "V_GEAR_SPY" && !this.hasSpyglass && this.gold> = 700) { this.gold - = 700; this.hasSpyglass = true; this.pushNotice(this.isKo ? "망원경 구입! 항구/발견물 탐색 거리 대폭 증가!": "Spyglass equipped! Vastly wider Discovery range!", 2.6); return; } if (code === "V_GEAR_SWORD" && this.gold> = 950) { this.gold - = 950; this.swordPower + = 14; this.pushNotice(this.isKo ? `다마스쿠스 검 장착! 일기토 공격력 ${this.swordPower }`: `Damascus Cutlass equipped! Duel Power ${this.swordPower }`, 2.6); return; } if (code === "V_INV_ECON" || code === "V_INV_IND") { const cost = 1000; if (this.gold> = cost) { this.gold - = cost; let pt = this.ports[pid]; if (code === "V_INV_ECON") { pt.economy = Math.minI64(10, pt.economy+1); } else { pt.industry = Math.minI64(10, pt.industry+1); } this.ports[pid] = pt; this.tradeFame + = 140; this.updateRank(); this.pushNotice(this.isKo ? `[${pt.nameKo }] 투자 완료! 상업 Lv.${ pt.economy } · 공업 Lv.${ pt.industry }`: `Invested in [${pt.nameEn }]! Economy Lv.${ pt.economy } · Industry Lv.${ pt.industry }`, 3.2); } return; } if (code === "V_SUPPLY") { const cost = 160; if (this.gold> = cost) { this.gold - = cost; this.food = 100; this.water = 100; this.pushNotice(this.isKo ? "식량 100 · 식수 100 완충 완료!": "Food & Water provisioned to 100!", 2.4); } return; } if (code === "V_BANK_DEP") { const amt = Math.minI64(1000, this.gold); if (amt> 0) { this.gold - = amt; this.bankGold + = amt; this.pushNotice(this.isKo ? `은행 ${amt }G 예금 (월 4% 복리 이자)`: `Deposited ${amt }G in Bank (4% monthly interest)`, 2.4); } return; } if (code === "V_BANK_WD") { const amt = Math.minI64(1000, this.bankGold); if (amt> 0) { this.bankGold - = amt; this.gold + = amt; this.pushNotice(this.isKo ? `은행 ${amt }G 출금 완료`: `Withdrew ${amt }G from Bank`, 2.4); } return; } } drawHud(h: Hud, px: f64, pz: f64, speed: f64, heading: f64, time: f64, canBoard: bool): string throws string { let clicked = ""; const btn = (key: string, label: string, x: f64, y: f64, w: f64, hh: f64, bg: Vec<f64>, fg: Vec<f64>): void throws string => { h.panel(x, y, w, hh, bg, 10.0, [0.68, 0.86, 1.0, 0.32]); const sz = h.fit(label, 13.0, w-14.0, true); h.text(label, x+w*0.5, y+(hh-sz*1.15)*0.5, sz, fg, 0.5, true); h.press(key, x, y, w, hh); if (h.game.typed().includes(key)) { clicked = key; } }; const safeW = Math.max(240.0, h.rightEdge-h.leftEdge); const topBase = h.touch ? h.topEdge+h.css(46): Math.max(h.topEdge, 14.0); const wf = windOf(this.weather, time); const wDirs = ["E", "SE", "S", "SW", "W", "NW", "N", "NE"]; const wDir = wDirs[i64(Math.round((((wf.angle*180.0/Math.PI)%360.0)+360.0)%360.0/45.0))%8]; const dateStr = `${this.year }-${ this.month <10 ? "0": "" }${ this.month }-${ this.day <10 ? "0": "" }${ this.day }`; const wName = this.weather.toUpperCase(); const stripLine = this.isKo ? `${dateStr } · ${ this.gold }G · 함대 ${ this.fleet.length }척 · 식량 ${ this.food } / 물 ${ this.water } · ${ wName } ${ i64(wf.knots) }KT ${ wDir }`: `${dateStr } · ${ this.gold }G · Fleet ${ this.fleet.length } · Food ${ this.food } / Water ${ this.water } · ${ wName } ${ i64(wf.knots) }KT ${ wDir }`; const sSz = h.fit(stripLine, 13.0, safeW-24.0, true); const sW = Math.min(safeW, h.measure(stripLine, sSz, true)+26.0); const stripX = h.touch ? h.width*0.5-sW*0.5: h.leftEdge; const stripY = topBase+40.0; h.panel(stripX, stripY, sW, 28.0, [0.04, 0.08, 0.15, 0.84], 12.0, [0.55, 0.82, 1.0, 0.22]); h.text(stripLine, stripX+sW*0.5, stripY+(28.0-sSz*1.15)*0.5, sSz, [0.88, 0.96, 1.0, 1.0], 0.5, true); const barY = stripY+34.0; const bw = h.upright() ? 86.0: 108.0; const gap = 8.0; let bx = h.leftEdge; btn("V_CHART", h.touch ? (this.isKo ? "세계 해도": "World Map"): (this.isKo ? "세계 해도 [M]": "World Map [M]"), bx, barY, bw, 30.0, [0.07, 0.20, 0.38, 0.90], [0.95, 0.99, 1.0, 1.0]); bx + = bw+gap; btn("V_WEATHER", this.isKo ? `날씨: ${wName }`: `Sky: ${wName }`, bx, barY, bw, 30.0, [0.08, 0.13, 0.23, 0.88], [0.80, 0.92, 1.0, 1.0]); bx + = bw+gap; if (this.nearestPortDist <95.0 && this.dockedPort <0) { const np = this.ports[this.nearestPort]; btn("V_DOCK", h.touch ? (this.isKo ? `${np.nameKo } 입항`: `Dock ${np.nameEn }`): (this.isKo ? `${np.nameKo } 입항 [E]`: `Dock ${np.nameEn } [E]`), bx, barY, bw+28.0, 30.0, [0.76, 0.50, 0.10, 0.95], [1.0, 0.98, 0.90, 1.0]); bx + = bw+28.0+gap; } if (canBoard && !this.duel.active && this.dockedPort <0) { btn("V_BOARD", h.touch ? (this.isKo ? "접현 일기토": "Board Duel"): (this.isKo ? "접현 일기토 [X]": "Board Duel [X]"), bx, barY, bw+22.0, 30.0, [0.74, 0.16, 0.14, 0.95], [1.0, 0.96, 0.90, 1.0]); } if (this.noticeTimer> 0.0 && this.notice !== "" && this.dockedPort <0 && !this.chartOpen) { const nSz = h.fit(this.notice, 14.5, safeW-32.0, true); const nW = Math.min(safeW, h.measure(this.notice, nSz, true)+32.0); const ny = barY+38.0; h.panel(h.width*0.5-nW*0.5, ny, nW, 32.0, [0.05, 0.12, 0.24, 0.88], 16.0, [1.0, 0.86, 0.42, 0.34]); h.text(this.notice, h.width*0.5, ny+(32.0-nSz*1.15)*0.5, nSz, [1.0, 0.92, 0.58, 1.0], 0.5, true); } if (this.duel.active) { const mw = Math.min(safeW, 440.0); const mh = 250.0; const mx = h.width*0.5-mw*0.5; const my = h.height*0.5-mh*0.5; h.panel(mx, my, mw, mh, [0.04, 0.07, 0.13, 0.95], 18.0, [1.0, 0.82, 0.36, 0.38]); h.text(this.isKo ? `⚔ 접현 일기토 — ${this.duel.enemyName }`: `CAPTAIN DUEL — ${this.duel.enemyName }`, mx+mw*0.5, my+16.0, 18.0, [1.0, 0.85, 0.35, 1.0], 0.5, true); h.text(this.isKo ? `나 ${this.duel.pHp }/${ this.duel.pMax }`: `YOU ${this.duel.pHp }/${ this.duel.pMax }`, mx+20.0, my+52.0, 14.0, [0.45, 0.92, 1.0, 1.0]); h.bar(mx+mw*0.28, my+78.0, mw*0.42, 12.0, f64(this.duel.pHp)/f64(Math.maxI64(1, this.duel.pMax)), [0.2, 0.78, 1.0, 1.0], [0.16, 0.2, 0.28, 1.0]); h.text(`${this.duel.eHp }/${ this.duel.eMax }`, mx+mw-20.0, my+52.0, 14.0, [1.0, 0.45, 0.42, 1.0], 1.0); h.bar(mx+mw*0.72, my+78.0, mw*0.42, 12.0, f64(this.duel.eHp)/f64(Math.maxI64(1, this.duel.eMax)), [0.95, 0.28, 0.25, 1.0], [0.16, 0.2, 0.28, 1.0]); const logSz = h.fit(this.duel.lastLog, 14.0, mw-32.0, false); h.text(this.duel.lastLog, mx+mw*0.5, my+108.0, logSz, [0.92, 0.95, 1.0, 0.95], 0.5); const dbw = (mw-56.0)/3.0; btn("V_DUEL_0", this.isKo ? "강공 (Slash)": "Slash", mx+16.0, my+168.0, dbw, 48.0, [0.78, 0.24, 0.18, 0.95], [1.0, 0.98, 0.94, 1.0]); btn("V_DUEL_1", this.isKo ? "찌르기 (Thrust)": "Thrust", mx+28.0+dbw, my+168.0, dbw, 48.0, [0.18, 0.46, 0.82, 0.95], [1.0, 0.98, 0.94, 1.0]); btn("V_DUEL_2", this.isKo ? "반격 (Parry)": "Parry", mx+40.0+dbw*2.0, my+168.0, dbw, 48.0, [0.18, 0.62, 0.42, 0.95], [1.0, 0.98, 0.94, 1.0]); if (clicked !== "") { this.handleAction(clicked); } return clicked; } if (this.chartOpen) { const mw = Math.min(safeW, 740.0); const mh = Math.min(h.height-96.0, 470.0); const mx = h.width*0.5-mw*0.5; const my = h.height*0.5-mh*0.5; h.panel(mx, my, mw, mh, [0.03, 0.07, 0.13, 0.96], 18.0, [0.42, 0.72, 0.96, 0.38]); h.text(this.isKo ? "세계 항해 해도 · 항구를 클릭하면 즉시 출항합니다": "EARTH-SCALE SEA CHART · Click any Port to Sail", mx+18.0, my+14.0, h.fit(this.isKo ? "세계 항해 해도 · 항구를 클릭하면 즉시 출항합니다": "EARTH-SCALE SEA CHART · Click any Port to Sail", 15.5, mw-106.0, true), [1.0, 0.88, 0.44, 1.0], 0.0, true); btn("V_CLOSE", this.isKo ? "닫기 [M]": "Close [M]", mx+mw-86.0, my+10.0, 74.0, 28.0, [0.18, 0.24, 0.34, 0.95], [1.0, 1.0, 1.0, 1.0]); const cx0 = mx+16.0; const cy0 = my+46.0; const cw = mw-32.0; const ch = mh-94.0; h.panel(cx0, cy0, cw, ch, [0.04, 0.14, 0.27, 0.96], 12.0, [0.35, 0.65, 0.92, 0.30]); const cellW = cw/32.0; const cellH = ch/16.0; for (const cz of range(0, 16)) { for (const cx of range(0, 32)) { if (this.explored[cz*32+cx]) { h.box(cx0+f64(cx)*cellW, cy0+f64(cz)*cellH, cellW+0.5, cellH+0.5, [0.07, 0.24, 0.42, 0.42]); } } } const mapX = (wx: f64): f64 => cx0 + Math.max(0.02, Math.min(0.98, (wx+4600.0)/11800.0))*cw; const mapY = (wz: f64): f64 => cy0 + Math.max(0.04, Math.min(0.96, (wz+1800.0)/4800.0))*ch; for (const gl of [-3000.0, -1000.0, 1000.0, 3000.0, 5000.0]) { h.box(mapX(gl), cy0+2.0, 1.0, ch-4.0, [0.55, 0.78, 0.96, 0.11]); } for (const gz of [-900.0, 120.0, 1320.0, 2280.0]) { const isEq = Math.abs(gz-1320.0) <10.0; h.box(cx0+2.0, mapY(gz), cw-4.0, 1.0, isEq ? [1.0, 0.82, 0.36, 0.24]: [0.55, 0.78, 0.96, 0.11]); } const GREEN: Vec<f64> = [0.22, 0.38, 0.27, 0.94]; const land = (x0: f64, z0: f64, x1: f64, z1: f64, rad: f64, tintCol: Vec<f64>): void => { const lx = mapX(x0); const ly = mapY(z0); const lw = Math.max(4.0, mapX(x1)-lx); const lh = Math.max(4.0, mapY(z1)-ly); h.card(lx-3.0, ly-3.0, lw+6.0, lh+6.0, [0.10, 0.36, 0.52, 0.36], rad+3.0); h.card(lx, ly, lw, lh, tintCol, rad); if (lw> 14.0 && lh> 12.0) { h.card(lx+3.0, ly+3.0, lw-6.0, lh-6.0, [tintCol[0]+0.08, tintCol[1]+0.07, tintCol[2]+0.02, 0.52], Math.max(2.0, rad-3.0)); } }; land(-4520.0, -1620.0, -2500.0, 320.0, 16.0, GREEN); land(-4460.0, 220.0, -3720.0, 1080.0, 10.0, GREEN); land(-3780.0, 920.0, -3100.0, 1340.0, 8.0, GREEN); land(-2050.0, -1700.0, -1020.0, -1080.0, 10.0, [0.34, 0.44, 0.42, 0.88]); land(-3560.0, 620.0, -3260.0, 770.0, 5.0, GREEN); land(-2960.0, 760.0, -2680.0, 900.0, 5.0, GREEN); land(-3480.0, 1220.0, -1740.0, 2120.0, 16.0, GREEN); land(-3050.0, 1980.0, -2180.0, 2860.0, 12.0, GREEN); land(110.0, -1380.0, 410.0, -960.0, 7.0, GREEN); land(-20.0, -420.0, 380.0, 30.0, 8.0, GREEN); land(360.0, -1120.0, 2150.0, -400.0, 14.0, GREEN); land(680.0, -1680.0, 1580.0, -1160.0, 10.0, GREEN); land(940.0, -520.0, 1240.0, -60.0, 6.0, GREEN); land(1420.0, -460.0, 2280.0, 40.0, 8.0, GREEN); land(-400.0, 180.0, 1820.0, 1340.0, 18.0, [0.38, 0.39, 0.24, 0.92]); land(480.0, 1180.0, 1780.0, 2560.0, 16.0, [0.24, 0.38, 0.25, 0.94]); land(1940.0, 1920.0, 2140.0, 2360.0, 6.0, GREEN); land(1960.0, 220.0, 2880.0, 1120.0, 12.0, [0.42, 0.40, 0.25, 0.92]); land(2250.0, -1250.0, 4580.0, 440.0, 16.0, [0.27, 0.37, 0.26, 0.94]); land(3640.0, 400.0, 4420.0, 1360.0, 12.0, [0.25, 0.40, 0.26, 0.94]); land(4540.0, -1480.0, 6220.0, 860.0, 18.0, [0.24, 0.39, 0.27, 0.94]); land(6240.0, -560.0, 6480.0, -180.0, 5.0, [0.28, 0.44, 0.30, 0.96]); land(6620.0, -340.0, 6920.0, 180.0, 6.0, [0.28, 0.44, 0.30, 0.96]); land(4840.0, 820.0, 5360.0, 1700.0, 8.0, GREEN); land(5200.0, 1880.0, 6180.0, 2140.0, 6.0, GREEN); land(5680.0, 2280.0, 6920.0, 2860.0, 14.0, [0.40, 0.35, 0.24, 0.92]); h.text("ATLANTIC", mapX(-1150.0), mapY(560.0), 10.5, [0.55, 0.80, 0.98, 0.38], 0.5, true); h.text("INDIAN OCEAN", mapX(3250.0), mapY(2050.0), 10.0, [0.55, 0.80, 0.98, 0.38], 0.5, true); h.text("PACIFIC", mapX(6840.0), mapY(1120.0), 10.0, [0.55, 0.80, 0.98, 0.38], 0.5, true); const crX = cx0+36.0; const crY = cy0+ch-36.0; h.panel(crX-20.0, crY-20.0, 40.0, 40.0, [0.05, 0.12, 0.22, 0.84], 20.0, [1.0, 0.84, 0.38, 0.42]); h.box(crX-12.0, crY-0.5, 24.0, 1.0, [1.0, 0.84, 0.38, 0.55]); h.box(crX-0.5, crY-12.0, 1.0, 24.0, [1.0, 0.84, 0.38, 0.55]); h.text("N", crX, crY-19.0, 9.5, [1.0, 0.88, 0.42, 0.95], 0.5, true); const routes: Vec<Vec<i64>> = [[0, 6], [6, 7], [7, 9], [9, 10], [10, 11], [11, 13], [13, 12], [0, 4], [4, 5], [0, 16], [16, 14], [14, 15], [6, 17]]; for (const rtPair of routes) { const pa = this.ports[rtPair[0]]; const pb = this.ports[rtPair[1]]; const ax = mapX(pa.x); const ay = mapY(pa.z); const bxR = mapX(pb.x); const byR = mapY(pb.z); for (const s of range(1, 6)) { const f = f64(s)/6.0; h.box(ax+(bxR-ax)*f-1.0, ay+(byR-ay)*f-1.0, 2.5, 2.5, [0.95, 0.84, 0.45, 0.36]); } } for (const dc of this.discoveries) { const dx = mapX(dc.x); const dy = mapY(dc.z); h.card(dx-3.0, dy-3.0, 6.0, 6.0, dc.found ? [1.0, 0.86, 0.24, 1.0]: [0.75, 0.84, 0.92, 0.45], 3.0); } const lblOff: Vec<Vec<f64>> = [[-16.0, 7.0], [18.0, -17.0], [0.0, -18.0], [6.0, 8.0], [-20.0, -17.0], [24.0, -17.0], [-14.0, 8.0], [0.0, 8.0], [0.0, 8.0], [0.0, 8.0], [0.0, 8.0], [-6.0, 8.0], [10.0, 8.0], [-12.0, -18.0], [0.0, -18.0], [-8.0, 8.0], [14.0, 8.0], [0.0, 8.0]]; for (const pt of this.ports) { const pxM = mapX(pt.x); const pyM = mapY(pt.z); const col = pt.discovered ? [0.22, 0.92, 0.58, 1.0]: [1.0, 0.72, 0.24, 0.96]; h.card(pxM-6.0, pyM-6.0, 12.0, 12.0, [0.02, 0.06, 0.12, 0.85], 6.0); h.card(pxM-4.5, pyM-4.5, 9.0, 9.0, col, 4.5); const off = pt.id <lblOff.length ? lblOff[pt.id]: [0.0, 8.0]; const nm = this.isKo ? pt.nameKo: pt.nameEn; const tw = h.measure(nm, 10.0, true)+8.0; const lx = Math.max(cx0+tw*0.5+2.0, Math.min(cx0+cw-tw*0.5-2.0, pxM+off[0])); const ly = Math.max(cy0+4.0, Math.min(cy0+ch-16.0, pyM+off[1])); h.card(lx-tw*0.5, ly-1.0, tw, 13.5, [0.03, 0.07, 0.14, 0.78], 4.0); h.text(nm, lx, ly+0.5, 10.0, [0.96, 0.99, 1.0, 0.98], 0.5, true); const key = `V_SAIL_${pt.id }`; h.press(key, pxM-24.0, pyM-16.0, 48.0, 34.0); if (h.game.typed().includes(key)) { clicked = key; } } const fx = mapX(px); const fy = mapY(pz); const pGlow = 16.0+3.0*Math.sin(time*5.0); h.card(fx-pGlow*0.5, fy-pGlow*0.5, pGlow, pGlow, [0.22, 0.92, 1.0, 0.32], pGlow*0.5); h.card(fx-5.5, fy-5.5, 11.0, 11.0, [0.25, 0.96, 1.0, 1.0], 5.5); const foot = this.isKo ? `작위: ${this.rankTitle() } · 교역 ${ this.tradeFame } · 모험 ${ this.adventureFame } · 전투 ${ this.battleFame } | 의뢰: ${ this.contract.titleKo }`: `Rank: ${this.rankTitle() } · Trade ${ this.tradeFame } · Adv ${ this.adventureFame } · Battle ${ this.battleFame } | Quest: ${ this.contract.titleEn }`; const fSz = h.fit(foot, 12.5, cw, false); h.text(foot, mx+mw*0.5, my+mh-30.0, fSz, [0.85, 0.93, 1.0, 0.95], 0.5); if (clicked !== "") { this.handleAction(clicked); } return clicked; } if (this.dockedPort> = 0) { const pt = this.ports[this.dockedPort]; const mw = Math.min(safeW, 660.0); const mh = Math.min(h.height-100.0, 460.0); const mx = h.width*0.5-mw*0.5; const my = h.height*0.5-mh*0.5; h.panel(mx, my, mw, mh, [0.04, 0.07, 0.14, 0.96], 18.0, [1.0, 0.84, 0.40, 0.34]); const hdr = this.isKo ? `${pt.nameKo } 항구 (${ pt.nation }) · 상업 Lv.${ pt.economy } · 공업 Lv.${ pt.industry } | 보유 ${ this.gold }G`: `PORT OF ${pt.nameEn.toUpperCase() } (${ pt.nation }) · Econ ${ pt.economy } · Ind ${ pt.industry } | ${ this.gold }G`; const hSz = h.fit(hdr, 16.0, mw-100.0, true); h.text(hdr, mx+18.0, my+14.0, hSz, [1.0, 0.88, 0.42, 1.0], 0.0, true); btn("V_CLOSE", this.isKo ? "출항": "Set Sail", mx+mw-84.0, my+10.0, 72.0, 28.0, [0.16, 0.48, 0.78, 0.96], [1.0, 1.0, 1.0, 1.0]); const tabKo = ["교역소", "조선소", "주점", "조합", "왕궁/투자", "보급/은행"]; const tabEn = ["Market", "Shipyard", "Tavern", "Guild", "Palace", "Supply"]; const tw = (mw-32.0-5.0*6.0)/6.0; for (const ti of range(0, 6)) { const active = this.portTab === ti; btn(`V_TAB_${ti }`, this.isKo ? tabKo[ti]: tabEn[ti], mx+16.0+f64(ti)*(tw+6.0), my+48.0, tw, 30.0, active ? [0.18, 0.48, 0.86, 0.98]: [0.11, 0.15, 0.24, 0.90], active ? [1.0, 1.0, 1.0, 1.0]: [0.78, 0.85, 0.94, 0.92]); } const bodyY = my+88.0; const bodyW = mw-32.0; if (this.portTab === 0) { const capLine = this.isKo ? `적재량: ${this.totalCargoUsed() } / ${ this.totalCargoCap() } | 특산품: ${ this.goods[pt.specialty].nameKo } | 호황 품목: ${ this.goods[pt.boomGood].nameKo }`: `Cargo: ${this.totalCargoUsed() } / ${ this.totalCargoCap() } | Specialty: ${ this.goods[pt.specialty].nameEn } | Boom: ${ this.goods[pt.boomGood].nameEn }`; h.text(capLine, mx+18.0, bodyY, h.fit(capLine, 13.0, bodyW, false), [0.72, 0.90, 1.0, 0.95]); let shown: Vec<i64> = [pt.specialty, pt.demand, pt.boomGood, 0, 7, 9, 10, 5]; let uniq: Vec<i64> = []; for (const g of shown) { if (!uniq.includes(g) && uniq.length <7) { uniq.push(g); } } for (const gi of range(0, this.goods.length)) { if (this.cargo[gi]> 0 && !uniq.includes(gi) && uniq.length <7) { uniq.push(gi); } } for (const [ri, gid] of uniq.entries()) { const ry = bodyY+26.0+f64(ri)*42.0; const g = this.goods[gid]; const buyP = this.priceAt(this.dockedPort, gid, false); const sellP = this.priceAt(this.dockedPort, gid, true); const held = this.cargo[gid]; h.card(mx+16.0, ry, bodyW, 36.0, [0.09, 0.13, 0.22, 0.88], 8.0); const rowT = this.isKo ? `${g.nameKo } 매입 ${ buyP }G / 매각 ${ sellP }G (보유 ${ held })`: `${g.nameEn } Buy ${ buyP }G / Sell ${ sellP }G (Held ${ held })`; h.text(rowT, mx+26.0, ry+10.0, h.fit(rowT, 13.5, bodyW-166.0, true), [0.95, 0.97, 1.0, 1.0]); btn(`V_BUY_${gid }`, this.isKo ? "10 매입": "Buy 10", mx+16.0+bodyW-154.0, ry+4.0, 70.0, 28.0, [0.16, 0.52, 0.34, 0.95], [1.0, 1.0, 1.0, 1.0]); btn(`V_SELL_${gid }`, this.isKo ? "전량 매각": "Sell All", mx+16.0+bodyW-78.0, ry+4.0, 72.0, 28.0, held> 0 ? [0.76, 0.48, 0.12, 0.95]: [0.18, 0.20, 0.26, 0.6], [1.0, 1.0, 1.0, 1.0]); } } else if (this.portTab === 1) { const fl = this.fleet[0]; const flTxt = this.isKo ? `함대 ${this.fleet.length }/5척 | 기함 ${ fl.name } (내구 ${ fl.hull }/${ fl.maxHull } · 함포 ${ fl.guns } · 돛 Lv.${ fl.sailLv })`: `Fleet ${this.fleet.length }/5 | Flagship ${ fl.name } (Hull ${ fl.hull }/${ fl.maxHull } · Guns ${ fl.guns } · Sails Lv.${ fl.sailLv })`; h.text(flTxt, mx+18.0, bodyY, h.fit(flTxt, 13.0, bodyW, false), [0.78, 0.92, 1.0, 0.95]); const ubw = (bodyW-16.0)/3.0; btn("V_REPAIR", this.isKo ? "함대 전체 수리": "Repair Fleet", mx+16.0, bodyY+24.0, ubw, 34.0, [0.16, 0.54, 0.38, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_UP_GUNS", this.isKo ? `함포 증설 (+12)`: `Upgrade Guns (+12)`, mx+24.0+ubw, bodyY+24.0, ubw, 34.0, [0.68, 0.28, 0.18, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_UP_SAIL", this.isKo ? `돛 개조 (Lv.${fl.sailLv+1 })`: `Upgrade Sails`, mx+32.0+ubw*2.0, bodyY+24.0, ubw, 34.0, [0.18, 0.46, 0.82, 0.95], [1.0, 1.0, 1.0, 1.0]); for (const [si, sc] of this.ships.slice(0, 6).entries()) { const ry = bodyY+68.0+f64(si)*42.0; const idx = si> = 4 ? si+2: si; const ship = this.ships[idx]; h.card(mx+16.0, ry, bodyW, 36.0, [0.09, 0.13, 0.22, 0.88], 8.0); const sLine = this.isKo ? `${ship.nameKo } | 내구 ${ ship.maxHull } · 적재 ${ ship.maxCargo } · 포 ${ ship.guns } (${ ship.price }G)`: `${ship.nameEn } | Hull ${ ship.maxHull } · Cargo ${ ship.maxCargo } · Guns ${ ship.guns } (${ ship.price }G)`; h.text(sLine, mx+26.0, ry+10.0, h.fit(sLine, 13.0, bodyW-108.0, true), [0.95, 0.97, 1.0, 1.0]); btn(`V_SHIP_${idx }`, this.isKo ? "건조": "Build", mx+16.0+bodyW-86.0, ry+4.0, 78.0, 28.0, [0.72, 0.50, 0.14, 0.95], [1.0, 1.0, 1.0, 1.0]); } } else if (this.portTab === 2) { const crLine = this.isKo ? `선원 ${this.crew }명 | 사기 ${ this.morale }%`: `Crew: ${this.crew } Sailors | Morale: ${ this.morale }%`; h.text(crLine, mx+18.0, bodyY, 14.0, [0.85, 0.95, 1.0, 1.0], 0.0, true); const tbw = (bodyW-12.0)/2.0; btn("V_CREW", this.isKo ? "선원 15명 모집 (180G)": "Recruit 15 Crew (180G)", mx+16.0, bodyY+26.0, tbw, 34.0, [0.18, 0.48, 0.82, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_TREAT", this.isKo ? "선원 회식 · 사기 100% (120G)": "Treat Crew · Morale 100% (120G)", mx+28.0+tbw, bodyY+26.0, tbw, 34.0, [0.68, 0.44, 0.14, 0.95], [1.0, 1.0, 1.0, 1.0]); for (const [oi, of] of this.officers.entries()) { const ry = bodyY+70.0+f64(oi)*42.0; h.card(mx+16.0, ry, bodyW, 36.0, [0.09, 0.13, 0.22, 0.88], 8.0); const oLine = this.isKo ? `${of.nameKo } — ${ of.roleKo } (${ of.cost }G)`: `${of.nameEn } — ${ of.roleEn } (${ of.cost }G)`; h.text(oLine, mx+26.0, ry+10.0, h.fit(oLine, 13.0, bodyW-108.0, true), [0.95, 0.97, 1.0, 1.0]); btn(`V_OFF_${oi }`, of.hired ? (this.isKo ? "합류 완료": "Hired"): (this.isKo ? "영입": "Hire"), mx+16.0+bodyW-88.0, ry+4.0, 80.0, 28.0, of.hired ? [0.16, 0.42, 0.28, 0.8]: [0.22, 0.52, 0.88, 0.95], [1.0, 1.0, 1.0, 1.0]); } } else if (this.portTab === 3) { let pendingDisc = 0; let totalDisc = 0; for (const dc of this.discoveries) { if (dc.found) { totalDisc+ = 1; if (!dc.reported) { pendingDisc+ = 1; } } } const cLine = this.isKo ? `현재 의뢰: ${this.contract.titleKo } (보상 ${ this.contract.reward }G)`: `Active Contract: ${this.contract.titleEn } (${ this.contract.reward }G)`; h.text(cLine, mx+18.0, bodyY+4.0, h.fit(cLine, 14.0, bodyW, true), [1.0, 0.92, 0.52, 1.0]); btn("V_NEW_CONTRACT", this.isKo ? "새 교역 의뢰 받기": "Take New Contract", mx+16.0, bodyY+34.0, bodyW*0.48, 36.0, [0.18, 0.48, 0.82, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_REPORT", this.isKo ? `발견물 보고 (${pendingDisc }건 · 총 ${ totalDisc }/12)`: `Report Discoveries (${pendingDisc } new · ${ totalDisc }/12)`, mx+24.0+bodyW*0.48, bodyY+34.0, bodyW*0.50, 36.0, [0.74, 0.52, 0.12, 0.96], [1.0, 1.0, 1.0, 1.0]); h.text(this.isKo ? "항해 장비 상점": "Captain Equipment", mx+18.0, bodyY+88.0, 14.0, [0.75, 0.90, 1.0, 0.95], 0.0, true); btn("V_GEAR_ASTRO", this.hasAstrolabe ? (this.isKo ? "아스트롤라베 장착 중": "Astrolabe Owned"): (this.isKo ? "아스트롤라베 (+12% 속도 · 850G)": "Astrolabe (+12% Speed · 850G)"), mx+16.0, bodyY+116.0, bodyW, 38.0, this.hasAstrolabe ? [0.16, 0.42, 0.28, 0.8]: [0.16, 0.34, 0.58, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_GEAR_SPY", this.hasSpyglass ? (this.isKo ? "천리 망원경 장착 중": "Spyglass Owned"): (this.isKo ? "천리 망원경 (발견 범위 확대 · 700G)": "Spyglass (Wider Discovery · 700G)"), mx+16.0, bodyY+164.0, bodyW, 38.0, this.hasSpyglass ? [0.16, 0.42, 0.28, 0.8]: [0.16, 0.34, 0.58, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_GEAR_SWORD", this.isKo ? `다마스쿠스 명검 강화 (현재 일기토 공격력 ${this.swordPower } · 950G)`: `Damascus Cutlass (+14 Duel Power · Now ${this.swordPower } · 950G)`, mx+16.0, bodyY+212.0, bodyW, 38.0, [0.68, 0.24, 0.20, 0.95], [1.0, 1.0, 1.0, 1.0]); } else if (this.portTab === 4) { const rLine = this.isKo ? `현재 작위: [${this.rankTitle() }] | 교역 ${ this.tradeFame } · 모험 ${ this.adventureFame } · 전투 ${ this.battleFame }`: `Royal Rank: [${this.rankTitle() }] | Trade ${ this.tradeFame } · Adv ${ this.adventureFame } · Battle ${ this.battleFame }`; h.text(rLine, mx+18.0, bodyY+6.0, h.fit(rLine, 14.5, bodyW, true), [1.0, 0.90, 0.45, 1.0]); const pDesc = this.isKo ? `${pt.nameKo } (${ pt.nation }령)에 투자하면 교역 품목 가치와 조선소 선박 기술이 발전하고 명성이 상승합니다.`: `Investing in ${pt.nameEn } (${ pt.nation }) raises market prices, unlocks warships, and earns Royal Rank Fame.`; h.text(pDesc, mx+18.0, bodyY+38.0, h.fit(pDesc, 13.0, bodyW, false), [0.85, 0.92, 1.0, 0.92]); btn("V_INV_ECON", this.isKo ? `상업 투자 (현재 Lv.${pt.economy }/10 · 1, 000G)`: `Invest Economy (Lv.${pt.economy }/10 · 1, 000G)`, mx+16.0, bodyY+82.0, bodyW, 44.0, [0.18, 0.52, 0.36, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_INV_IND", this.isKo ? `공업 투자 (현재 Lv.${pt.industry }/10 · 1, 000G)`: `Invest Industry (Lv.${pt.industry }/10 · 1, 000G)`, mx+16.0, bodyY+138.0, bodyW, 44.0, [0.22, 0.44, 0.82, 0.95], [1.0, 1.0, 1.0, 1.0]); } else { const sLine = this.isKo ? `식량 ${this.food }/100 · 식수 ${ this.water }/100 | 은행 예금: ${ this.bankGold }G (매월 4% 이자)`: `Food ${this.food }/100 · Water ${ this.water }/100 | Bank Vault: ${ this.bankGold }G (4% monthly interest)`; h.text(sLine, mx+18.0, bodyY+8.0, h.fit(sLine, 14.0, bodyW, true), [0.82, 0.95, 1.0, 1.0]); btn("V_SUPPLY", this.isKo ? "식량 & 식수 100% 완충 보급 (160G)": "Full Provisions: 100 Food & 100 Water (160G)", mx+16.0, bodyY+48.0, bodyW, 46.0, [0.16, 0.54, 0.38, 0.95], [1.0, 1.0, 1.0, 1.0]); const bbw = (bodyW-12.0)/2.0; btn("V_BANK_DEP", this.isKo ? "은행 1,000G 예금": "Deposit 1,000G", mx+16.0, bodyY+108.0, bbw, 44.0, [0.18, 0.46, 0.82, 0.95], [1.0, 1.0, 1.0, 1.0]); btn("V_BANK_WD", this.isKo ? "은행 1,000G 출금": "Withdraw 1,000G", mx+28.0+bbw, bodyY+108.0, bbw, 44.0, [0.68, 0.48, 0.14, 0.95], [1.0, 1.0, 1.0, 1.0]); } if (clicked !== "") { this.handleAction(clicked); } return clicked; } if (clicked !== "") { this.handleAction(clicked); } return clicked; } }Active Voyage World state — strictly orthogonal and composable inside any Game/Scene3D.
isKo:boolyear:i64month:i64day:i64dayAccum:f64weather:stringweatherTimer:f64weatherCycleIdx:i64gold:i64bankGold:i64food:i64water:i64crew:i64morale:i64tradeFame:i64adventureFame:i64battleFame:i64rankIdx:i64swordPower:i64armorDef:i64hasAstrolabe:boolhasSpyglass:boolfleet:Vec<M250.FleetShip>cargo:Vec<i64>cargoCost:Vec<i64>officers:Vec<M250.Officer>ports:Vec<M250.Port>goods:Vec<M250.TradeGood>ships:Vec<M250.ShipClass>discoveries:Vec<M250.Discovery>contract:M250.Contractexplored:Vec<bool>dockedPort:i64portTab:i64chartOpen:boolautopilotPort:i64nearestPort:i64nearestPortDist:f64duel:M250.DuelStatenotice:stringnoticeTimer:f64pendingTeleport:_gizlang_sdk_core.Option<gizlang_geometry.Point3>
Functions
constructor
constructor(isKo: bool)Effects: fail, read, write, alloc.
Methods
VoyageWorld.hasOfficer
hasOfficer(bonus: string): boolEffects: fail, read.
VoyageWorld.totalCargoUsed
totalCargoUsed(): i64Effects: fail, read.
VoyageWorld.totalCargoCap
totalCargoCap(): i64Effects: fail, read.
VoyageWorld.totalGuns
totalGuns(): i64Effects: fail, read.
VoyageWorld.flagship
flagship(): FleetShipEffects: fail, read.
VoyageWorld.speedMultiplier
speedMultiplier(): f64Effects: fail, read.
VoyageWorld.cannonDamage
cannonDamage(): i64Effects: fail, read.
VoyageWorld.rankTitle
rankTitle(): stringEffects: fail, read, alloc.
VoyageWorld.updateRank
updateRank(): voidEffects: fail, read, write, alloc.
VoyageWorld.pushNotice
pushNotice(msg: string, dur: f64 = 3.4): voidEffects: fail, read, write.
VoyageWorld.priceAt
priceAt(pid: i64, gid: i64, selling: bool): i64Dynamic regional market price for good GID at port PID (buy or sell).
Effects: fail, read.
VoyageWorld.revealAround
revealAround(x: f64, z: f64, rad: i64): voidReveals fog-of-war cells around world (X, Z) on the 32x16 planetary chart.
Effects: fail, read, write, alloc.
VoyageWorld.rollContract
rollContract(pid: i64): voidGenerates a fresh regional Guild Contract from port PID.
Effects: fail, read, write, alloc.
VoyageWorld.step
step(px: f64, pz: f64, speed: f64, dt: f64): voidSteps calendar, dynamic maritime weather, provisions, fog-of-war, port proximity & world discoveries!
Effects: fail, read, write, alloc.
VoyageWorld.startDuel
startDuel(pirateIdx: i64, enemyName: string): voidStarts an interactive Uncharted Waters 2 Captain Sword Duel (일기토) against a nearby rival captain!
Effects: fail, read, write.
VoyageWorld.duelMove
duelMove(choice: i64): i64Resolves one tactical round of Captain Duel (0=Slash beats Thrust, 1=Thrust beats Parry, 2=Parry beats Slash). Returns 1=won, -1=lost, 0=ongoing.
Effects: fail, read, write, alloc.
VoyageWorld.handleAction
handleAction(code: string): voidExecutes a port facility action triggered by HUD button press key.
Effects: fail, read, write, alloc.
VoyageWorld.drawHud
drawHud(h: Hud, px: f64, pz: f64, speed: f64, heading: f64, time: f64, canBoard: bool): string throws stringRenders the complete Uncharted Waters 2 interactive HUD: Sea Status, Quick Buttons, World Atlas (M), Port 6-Tab UI (E), and Captain Duel!
Effects: fail, read, write, console, io, alloc.