The game now begins inside the Negin Sazan Pishgam Radmehr Atousa vending-machine factory on the Mashhad–Chenaran road, and the world extends ~20 km along the real driving route to Park Mellat and Ferdowsi University. - Factory compound: production hall with assembly line, office, yard, gate and company signs; first mission at its half-price demo machine - Map data merged from four OSM extracts (factory zone, route corridor, region main roads, city zone), clipped to a 15 x 18 km region - City meshes chunked and culled by distance; traffic recycled around the player; minimap and city map drawn from cached tiles + overview - The Robot Market robot no longer walks with the family: it comes out of a machine when they arrive, greets them with expression portraits and goes back inside when they leave - PWA: manifest, icons from the robot avatar, offline service worker generated at build time, install button / iOS steps, update prompt; Vazirmatn font bundled instead of Google Fonts - Real-world mode: safety notice, GPS + compass tracking with accuracy smoothing, 20-40 m arrival radius, speed lock and in-person bonus Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
2.0 KiB
JavaScript
42 lines
2.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {awardsFor, rankFor, completeMissions, activeMission, POINTS, RANKS} from '../src/scoring.js';
|
|
import {createState, purchase} from '../src/game-state.js';
|
|
import {machineById} from '../src/locations.js';
|
|
|
|
const total = awards => awards.reduce((s, a) => s + a.points, 0);
|
|
|
|
test('Discovery, combo and all-category bonuses are paid once', () => {
|
|
const state = createState(), park = machineById('mellat-park');
|
|
const buy = (machine, product) => {
|
|
const before = state.purchases.slice();
|
|
return awardsFor(before, purchase(state, machine, product));
|
|
};
|
|
assert.equal(total(buy(park, 'water')), POINTS.purchase + POINTS.discovery);
|
|
assert.equal(total(buy(park, 'juice')), POINTS.purchase, 'same type: no combo');
|
|
assert.equal(total(buy(park, 'cake')), POINTS.purchase + POINTS.combo);
|
|
assert.equal(total(buy(park, 'water')), POINTS.purchase, 'combo only once');
|
|
buy(machineById('factory'), 'water');
|
|
buy(machineById('school-rahil'), 'water');
|
|
buy(machineById('ferdowsi-university'), 'water');
|
|
buy(machineById('azadi-metro'), 'water');
|
|
state.minutes = 11 * 60;
|
|
const last = buy(machineById('mashhad-mall'), 'water');
|
|
assert.ok(last.some(a => a.points === POINTS.allCategories));
|
|
});
|
|
|
|
test('Ranks and missions advance with progress', () => {
|
|
assert.equal(rankFor(0).name, RANKS[0].name);
|
|
assert.equal(rankFor(RANKS[1].xp).index, 1);
|
|
assert.equal(rankFor(1e6).progress, 1);
|
|
const state = createState();
|
|
assert.equal(activeMission(state).id, 'factory');
|
|
purchase(state, machineById('factory'), 'water');
|
|
assert.deepEqual(completeMissions(state).map(m => m.id), ['factory']);
|
|
assert.equal(state.balance, 500 - 8 + 20, 'factory sells at half price');
|
|
purchase(state, machineById('mellat-park'), 'water');
|
|
assert.deepEqual(completeMissions(state).map(m => m.id), ['first']);
|
|
assert.deepEqual(completeMissions(state), [], 'rewards are not repeated');
|
|
assert.equal(activeMission(state).id, 'school');
|
|
});
|