Commit f7dc8cbd authored by Max Becker's avatar Max Becker
Browse files

Fix missing events in game recorder

parent 2e2022f0
import StrictEventEmitter from "strict-event-emitter-types";
import {EventEmitter} from "events";
import {GameServerEvents} from "./game";
import {GameplayEventStamp, GameConfig, GameLog, GameplayEvent, KillEventData} from "../../common/definitions";
import {GameplayEventStamp, GameConfig, GameLog, GameplayEvent, KillEventData, HitData} from "../../common/definitions";
import {Schema, Validator} from "jsonschema";
import {PlayerID} from "../general";
export class GameRecorder {
......@@ -33,6 +34,15 @@ export class GameRecorder {
eventEmitter.on('game_stopped', () => this.storeEvent({"event": "game_stopped"}));
eventEmitter.on('reset', () => this.storeEvent({"event": "reset"}));
eventEmitter.on('kill', (data: KillEventData) => this.storeEvent({"event": "kill", "kill": data}));
eventEmitter.on('hit', (data: HitData) => this.storeEvent({"event": "hit", "hit": data}));
eventEmitter.on('respawn', (player: PlayerID) => this.storeEvent({
"event": "respawn",
"respawn_player": player.id
}));
eventEmitter.on('cpoint_captured', (point: number) => this.storeEvent({
"event": "cpoint_captured",
"cpoint": point
}))
}
......
......@@ -273,8 +273,8 @@ export class Server {
if (!this.game.isFinished()) {
console.warn("Resetting unfinished game");
}
let current_datetime = new Date()
let name = current_datetime.getFullYear() + "-" + (current_datetime.getMonth() + 1) + "-" + current_datetime.getDate() + "_" + current_datetime.getHours() + "-" + current_datetime.getMinutes() + "-" + current_datetime.getSeconds()
let d = new Date()
let name = d.getFullYear() + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2) + "_" + ("0" + d.getHours()).slice(-2) + "-" + ("0" + d.getMinutes()).slice(-2) + "-" + ("0" + d.getSeconds()).slice(-2)
let log = this.gameRecorder.processAndRestGame(name);
this.storeGameLog(name, log);
this.createGame();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment