From 64d4eb0344d28a66c97d28f6b9a7818eb05c5cd8 Mon Sep 17 00:00:00 2001
From: sqozz <sqozz@geekify.de>
Date: Fri, 11 May 2018 21:10:46 +0200
Subject: [PATCH] Add frame count metric

---
 schlafana.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/schlafana.py b/schlafana.py
index f433241..efb800e 100644
--- a/schlafana.py
+++ b/schlafana.py
@@ -10,10 +10,11 @@ import time
 
 MESSAGES = { "GameInfo" : 0x00,
              "WorldUpdate" : 0x01,
+             "Tick" : 0x10,
              "BotSpawn" : 0x20,
              "BotKill" : 0x21,
              "BotMove" : 0x22,
-             "BotStats" : 0x24
+             "BotStats" : 0x24,
         }
 
 
@@ -100,6 +101,7 @@ class Game():
         self.food_decay_per_frame = 0
         self.users = UserList()
         self.uptime = Summary("api_up", "Status of the server API")
+        self.frames = Counter("frames", "Frame counter")
         pass
 
 
@@ -144,8 +146,10 @@ class Game():
             for bot in bots:
                 bot = bots.get(bot)
                 self.users.update_by_name(bot.get("name"), data=bot)
+        elif typ == MESSAGES["Tick"]:
+            game.frames.inc()
 
-        elif msg_type != "FoodSpawn" and msg_type != "WorldUpdate" and msg_type != "FoodConsume" and msg_type != "BotMoveHead" and msg_type != "Tick" and msg_type != "FoodDecay":
+        elif msg_type != "FoodSpawn" and msg_type != "FoodConsume" and msg_type != "BotMoveHead" and msg_type != "FoodDecay":
             logging.fatal("Unhandled msg_type: {}".format(msg_type))