This commit is contained in:
azykov@mail.ru
2026-09-09 11:49:24 +03:00
parent bd9b5d9aec
commit a3f2f4eeef
20 changed files with 490 additions and 70 deletions
+8 -1
View File
@@ -16,6 +16,8 @@
* Run with: npx tsx scripts/play.ts [tickSeconds]
*/
import readline from 'node:readline';
import { Analytics, makeAnalyticsGameInfo } from '../src/analytics';
import { ConsoleAnalyticsTransport } from '../src/analytics/ConsoleAnalyticsTransport';
import { bushesForDay, treesForDay } from '../src/game/constants';
import { formatClock } from '../src/game/daynight';
import { Rabbit } from '../src/game/entities/Rabbit';
@@ -33,7 +35,12 @@ const TICKS_PER_BATCH = 1000;
/** How far past the nearest rabbit to aim while fleeing it. */
const FLEE_DISTANCE = 400;
const store = new GameStore();
// Logs every analytics call to the console (see ConsoleAnalyticsTransport) instead of sending it
// anywhere — this is what actually lets `npm run play` be used to verify analytics behavior.
let store: GameStore;
const analytics = new Analytics(new ConsoleAnalyticsTransport(), () => makeAnalyticsGameInfo(store));
analytics.start();
store = new GameStore(analytics);
store.initialize(MAP_WIDTH, MAP_HEIGHT);
const startedAt = Date.now();