From 722f6c3effe9aedf6c71678260a6976d30fb21ed Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 6 Dec 2020 19:59:02 +0100
Subject: [PATCH] Don't recalculate directions all the time, unnecessarily.

---
 plomrogue/game.py    | 2 +-
 plomrogue/mapping.py | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/plomrogue/game.py b/plomrogue/game.py
index c495179..a1c2ee6 100755
--- a/plomrogue/game.py
+++ b/plomrogue/game.py
@@ -180,7 +180,7 @@ class Game(GameBase):
 
     def get_string_options(self, string_option_type):
         if string_option_type == 'direction':
-            return self.map_geometry.get_directions()
+            return self.map_geometry.directions
         elif string_option_type == 'char':
             return [c for c in
                     string.digits + string.ascii_letters + string.punctuation + ' ']
diff --git a/plomrogue/mapping.py b/plomrogue/mapping.py
index e806ef7..53e9d29 100644
--- a/plomrogue/mapping.py
+++ b/plomrogue/mapping.py
@@ -21,6 +21,7 @@ class MapGeometry():
     def __init__(self, size):
         self.size = size
         self.neighbors_i = {}
+        self.directions = self.get_directions()
 
     def get_directions(self):
         directions = []
@@ -32,13 +33,13 @@ class MapGeometry():
 
     def get_neighbors_yxyx(self, yxyx):
         neighbors = {}
-        for direction in self.get_directions():
+        for direction in self.directions:
             neighbors[direction] = self.move_yxyx(yxyx, direction)
         return neighbors
 
     def get_neighbors_yx(self, pos):
         neighbors = {}
-        for direction in self.get_directions():
+        for direction in self.directions:
             neighbors[direction] = self.move_yx(pos, direction)
         return neighbors
 
-- 
2.30.2