Upstream 3.3's hint for a coast where no subsea cable lands (#321) said only a cable of your own could get to Iqaluit or Adamstown, and left satellites out at Pevek, though a teleport reaches all three. Once teleports are on sale (level 2) and a bird you may rent from sees the city, the 'own' case says a satellite circuit or a cable of your own can get there (a new string), and every case adds the satellite line: the city panel's 'Your teleports can reach' with a button per teleport to its order sheet (satOpen), or where to build one. Not in puzzles, and not before level 2, like the rest of the satellites.
91 lines
5.7 KiB
JavaScript
91 lines
5.7 KiB
JavaScript
// #321: a subsea link to or from a coast where no cable lands yet (Iqaluit, Adamstown, Murmansk) said
|
|
// "Cables from Iqaluit reach . Hop through one of those." It now says what can actually reach that city.
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { load } = require('./harness');
|
|
|
|
const card = (ev, a, b) => ev(`UI.lmode='wave';openLinkModal('${a}','${b}');const t=$('modalCard').textContent;closeModal();t`);
|
|
|
|
test('#321 no cable lands in Iqaluit: no empty list, the only way in is your own cable', () => {
|
|
const { ev, errors } = load();
|
|
ev("ACT.start({});S.cash=1e9;S.lvl=1;for(const g of GOALS)S.done[g.id]=0");
|
|
assert.ok(!ev("cabOpen()"));
|
|
for (const [a, b] of [['yfb', 'nuk'], ['nuk', 'yfb'], ['nyc', 'pcn']]) {
|
|
const t = card(ev, a, b), city = ev(`CITY['${b === 'nuk' ? a : b}'].name`);
|
|
assert.doesNotMatch(t, /reach \.|Hop through/, `${a}→${b}: ${t}`);
|
|
assert.ok(t.includes(ev(`tr('link_modal.no_subsea_cable_lands_in_city_own',{city:'${city}'})`)), `${a}→${b}: ${t}`);
|
|
assert.match(t, /level 9 or Tier 1/, `${a}→${b} points at the level that unlocks your own cable`);
|
|
}
|
|
// once you can lay one, the button to do it is right there
|
|
ev("S.lvl=9");
|
|
assert.ok(ev("cabOpen()"));
|
|
assert.match(card(ev, 'yfb', 'nuk'), /Lay your own subsea cable|Surveying/);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test('#321 a coast with no cable but a road in: reach it overland, never "hop through" cables that miss it', () => {
|
|
const { ev, errors } = load();
|
|
ev("ACT.start({});S.cash=1e9;S.lvl=1;for(const g of GOALS)S.done[g.id]=0");
|
|
for (const [a, b, c] of [['nyc', 'mmk', 'mmk'], ['dks', 'nyc', 'dks']]) {
|
|
const t = card(ev, a, b);
|
|
assert.doesNotMatch(t, /Hop through/, `${a}→${b}: ${t}`);
|
|
assert.ok(t.includes(ev(`tr('link_modal.no_subsea_cable_lands_in_city_land',{city:CITY.${c}.name})`)), `${a}→${b}: ${t}`);
|
|
}
|
|
// two cities that both have cables, just not a shared one, still get the cities to hop through
|
|
const t = card(ev, 'nuk', 'syd');
|
|
assert.match(t, /Hop through one of those/);
|
|
assert.doesNotMatch(t, /reach \./);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
// #83 in the fork: a teleport reaches small islands and remote towns, so "only a cable of your own can get there" was
|
|
// wrong for Iqaluit and Adamstown (and Pevek's hint left satellites out). Once teleports are on sale (level 2) the hint
|
|
// names the satellite too, with a button to the order sheet from each teleport of yours that reaches the city.
|
|
test('#83 no cable lands there, but a satellite does: the hint says so, with the way to order it', () => {
|
|
const { ev, dom, errors } = load();
|
|
const doc = dom.window.document;
|
|
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();closeModal();S.cash=1e9;S.lvl=1;for(const g of GOALS)S.done[g.id]=0;S.nextFail=S.nextEvent=1e9;UI.speed=0");
|
|
const own = (c) => ev(`tr('link_modal.no_subsea_cable_lands_in_city_own',{city:CITY.${c}.name})`);
|
|
const ownSat = (c) => ev(`tr('link_modal.no_subsea_cable_lands_in_city_own_sat',{city:CITY.${c}.name})`);
|
|
const none = (c) => ev(`tr('satellites.no_teleport_reaches_city',{city:CITY.${c}.name})`);
|
|
const reach = (c) => ev(`tr('satellites.reachable_from_your_teleports',{city:CITY.${c}.name})`);
|
|
assert.notEqual(ownSat('yfb'), 'link_modal.no_subsea_cable_lands_in_city_own_sat', 'the new text is there');
|
|
// Level 1: no teleport on sale yet, the hint is as before.
|
|
let t = card(ev, 'nuk', 'yfb');
|
|
assert.ok(t.includes(own('yfb')), t);
|
|
assert.doesNotMatch(t, /satellite/i);
|
|
// Level 2: a bird sees Iqaluit and Adamstown, so the cable is not the only way; no teleport of yours reaches them yet.
|
|
ev('S.lvl=2');
|
|
for (const [a, b] of [['nuk', 'yfb'], ['yfb', 'nuk'], ['nyc', 'pcn']]) {
|
|
const c = b === 'nuk' ? a : b;
|
|
t = card(ev, a, b);
|
|
assert.ok(t.includes(ownSat(c)) && !t.includes(own(c)), `${a}→${b}: ${t}`);
|
|
assert.ok(t.includes(none(c)), `${a}→${b} says where a teleport would have to go: ${t}`);
|
|
assert.match(t, /level 9 or Tier 1/, 'the cable of your own is still offered');
|
|
}
|
|
// Pevek has a road in: that text stays, and the satellite comes after it. Alice Springs has no beach at all.
|
|
t = card(ev, 'nyc', 'pvs');
|
|
assert.ok(t.includes(ev("tr('link_modal.no_subsea_cable_lands_in_city_land',{city:CITY.pvs.name})")) && t.includes(none('pvs')), t);
|
|
t = card(ev, 'nyc', 'asp');
|
|
assert.ok(t.includes(none('asp')), t);
|
|
// Murmansk is no remote town: no satellite serves it.
|
|
t = card(ev, 'nyc', 'mmk');
|
|
assert.doesNotMatch(t, /satellite|teleport/i, t);
|
|
// A teleport in New York sees Iqaluit over the Americas bird: a button to the order sheet, from there.
|
|
ev("ACT.buildPop({city:'nyc'});closeModal();ACT.teleBuild({city:'nyc'})");
|
|
assert.ok(ev("teleOf('nyc')===1&&satBirds('nyc','yfb').includes('gx19')"));
|
|
ev("window.innerWidth=360;window.innerHeight=740;UI.lmode='wave';openLinkModal('nuk','yfb')");
|
|
t = doc.getElementById('modalCard').textContent;
|
|
assert.ok(t.includes(ownSat('yfb')) && t.includes(reach('yfb')) && !t.includes(none('yfb')), t);
|
|
const go = [...doc.querySelectorAll('#modalCard [data-act="satOpen"]')];
|
|
assert.deepEqual(go.map((b) => JSON.parse(b.dataset.args)), [{ a: 'nyc', b: 'yfb' }]);
|
|
go[0].click();
|
|
assert.equal(doc.getElementById('modal').hidden, false);
|
|
assert.match(doc.getElementById('modalCard').textContent, /New York → Iqaluit/);
|
|
assert.ok(doc.querySelector('#modalCard [data-act="buySat"]'), 'the order sheet, with its circuits');
|
|
ev('closeModal()');
|
|
// Not in a puzzle, as the satellites themselves.
|
|
ev("localStorage.removeItem('sot-puzzles');pzBegin(pzDef('baltic'));closeModal()");
|
|
assert.equal(ev("JSON.stringify([pzOn(),satCan('yfb')])"), '[true,false]');
|
|
assert.deepEqual(errors, []);
|
|
});
|