// Five suggested homes, or any city with someone selling transit there. Hidden cities and China (which needs // a license first) can't be a home, and neither can a city where nobody sells transit: you'd start cut off. const homeOk=c=>own(CITY,c)&&!CITY[c].off&&!CITY[c].cn&&NETS.some(n=>sellsAt(n,c)); const START5=['fra','nyc','sin','sao','syd']; // One drawer for the home city: the five suggested homes first, then every city with transit by continent. const START_D=()=>({fra:tr('title.crossroads_of_europe_de_kicks_ix'),nyc:tr('title.huge_eyeball_market_pricey'),sin:tr('title.asia_hub_great_peering_far_from'),sao:tr('title.big_hungry_market_few_providers'),syd:tr('title.hard_mode_pricey_everything')}); function homePick(){const cs=Object.keys(CITY).filter(c=>homeOk(c)&&!START5.includes(c)),cur=UI.startCity,opt=c=>``; return ``;} // The line under the drawer: what the suggested home is like, or which continent another city is on. const homeWhat=()=>START5.includes(UI.startCity)?esc(START_D()[UI.startCity]):`${esc(CITY[UI.startCity].name)} · ${esc(REG[CITY[UI.startCity].reg])}`; /* Your own AS number (#135): any public 16- or 32-bit ASN, but not AS 0, AS_TRANS, the documentation and private ranges, or one a network on the map already uses. Left empty, the game picks one from the private-looking 200000s as before. */ const asnOk=a=>Number.isInteger(a)&&a>=1&&a<=4294967294&&a!==23456&&!(a>=64496&&a<=131071)&&!(a>=4200000000)&&!NETS.some(n=>n.asn===a); const asnSuggest=()=>{for(;;){const a=200000+Math.floor(Math.random()*15000);if(asnOk(a))return a;}}; function showTitle(){ const list=slotIdx(true),top=slotTop(list),many=list.length>1||(list.length===1&&list[0]!==top); if(UI.nm==null)UI.nm=randomNetworkName();if(UI.asnSug==null)UI.asnSug=asnSuggest(); openModal(`
${langPick('langTitle')}

Series
of Tubes

${tr('title.build_an_internet_lay_fiber_between')}

${isPhone()?installRow():''} ${top?`
${btn(tr('title.continue_name_date',{name:esc(top.name||tr('common.unnamed_network')),date:dateStr(top.day)}),'cont',{id:top.id},'pink big')}
`:''} ${many?slotsHtml():''}
${doorsHtml()}${MP_API?mpDoorHtml():''} ${homePick()}

${homeWhat()}

${btn(list.length?tr('common.start_a_new_network'):tr('common.start_building'),'start',{},'big')}${btn(tr('common.how_to_play'),'help',{},'ghost')}${btn(tr('common.import_a_save'),'importPick',{},'ghost')}${btn(tr('common.settings'),'settings',{},'ghost')}

v${APP_VERSION} · ${tr('title.source_on_github')} · ${tr('title.chat_on_signal')} · ${tr('title.cookieless_stats_no_tracking')}

`); $('nmIn').addEventListener('input',e=>{UI.nm=e.target.value;}); $('asnIn').addEventListener('input',e=>{UI.asnTxt=e.target.value.replace(/\D/g,'').slice(0,10);if(e.target.value!==UI.asnTxt)e.target.value=UI.asnTxt;e.target.classList.toggle('bad',!!UI.asnTxt&&!asnOk(+UI.asnTxt));}); } // "What's new": shown once to returning players after an update, or on demand. function whatsNew(returning,force){ if(IS_DEV||(!RELEASE_NOTES.length&&!RELEASE_STORY.length))return false;let seen=null; try{seen=localStorage.getItem('sot-seen-version');localStorage.setItem('sot-seen-version',APP_VERSION);}catch(e){} if(!force&&(!returning||seen===APP_VERSION))return false; openModal(`
${tr('common.release_notes')}

${tr('title.new_in_series_of_tubes_v',{v:esc(APP_VERSION)})}

${notesHtml(RELEASE_NOTES,APP_VERSION)} ${returning&&S?`

${tr('title.your_network_name_was_saved_and',{name:esc(S.name)})}

`:''}
${btn(UI.started?tr('title.back_to_my_network'):tr('common.got_it'),UI.started?'closeModal':'helpClose',{},'pink big')}${notesLong(RELEASE_NOTES)||RELEASE_STORY.length?'':`${tr('common.full_changelog')}`}
`); return true;} /* The four doors: one game, its rules picked here and locked for the network's life. Normal and Sandbox stay on this screen (presets / chaos below), Puzzles and Scenarios open their own lists. Choices toggle in place (no re-render). */ const DOORS=[['puzzle','🧩',tr('title.puzzles'),tr('title.one_network_one_knot_no_clock')],['sandbox','🏖️',tr('common.sandbox'),tr('title.a_billion_dollars_and_every_toy')],['normal','📟',tr('common.normal'),tr('title.the_real_game_climb_from_tier')],['scn','🏆',tr('title.scenarios_amp_weekly'),tr('title.hand_built_crises_and_one_world')]]; const doorAct={puzzle:'puzzleDoor',sandbox:'modeSet',normal:'modeSet',scn:'scenarios'}; // The chosen preset in one line: its joke, then what actually changes. const presetWhat=k=>`${esc(PRESETS[k].d)} ${esc(PRESETS[k].x)}`; // The Normal presets, one toggle each: on the title screen, and for a multiplayer session (48-multiplayer.js). const presetBtns=pr=>`
${NORMAL_PRESETS.map(k=>{const P=PRESETS[k];return ``;}).join('')}

${presetWhat(pr)}

`; function doorsHtml(){const m=UI.mode==='sandbox'?'sandbox':'normal',pr=own(PRESETS,UI.preset)&&NORMAL_PRESETS.includes(UI.preset)?UI.preset:'oncall',ch=own(CHAOS,UI.sbChaos)?UI.sbChaos:'none'; return `
${DOORS.map(([k,i,n,d])=>``).join('')}
${presetBtns(pr)}
${Object.entries(CHAOS).map(([k,C])=>``).join('')}

🔒 ${tr('title.rules_are_picked_once_and_locked')}

`;}