anaytics
This commit is contained in:
+8
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user