From dbc9dd17515e3dfa10da4d44727eb5a08902d458 Mon Sep 17 00:00:00 2001
From: Ronnie Friman <L4168@student.jamk.fi>
Date: Sun, 21 Jul 2019 11:55:42 +0300
Subject: [PATCH] insert initial status to objectivepoint_history

---
 src/game/game.service.ts | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/game/game.service.ts b/src/game/game.service.ts
index 57d0b74..4863cf0 100644
--- a/src/game/game.service.ts
+++ b/src/game/game.service.ts
@@ -141,6 +141,13 @@ export class GameService {
           game: gameId,
         });
         await this.objectivePointRepository.save(newFlagbox);
+        // create base status for flagbox
+        this.flagboxEvent(gameId, {
+          node_id: flagbox.objectivePointDescription,
+          owner: 0,
+          action: 0,
+          capture: 0,
+        });
       });
     } else {
       await this.objectivePointRepository.delete({ game: id });
@@ -289,7 +296,7 @@ export class GameService {
     const objectiveRef = await this.objectivePointRepository.findOne({
       where: { objectivePointDescription: data.node_id, game: gameId },
     });
-    data.oP_HistoryTimestamp = new Date(Date.now()).toLocaleString();
+    data.oP_HistoryTimestamp = Date.now();
     const eventUpdate = await this.objectivePoint_HistoryRepository.create({
       oP_HistoryTimestamp: data.oP_HistoryTimestamp,
       action: data.action,
-- 
GitLab