summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2019-01-24 19:15:57 +0100
committertroido <troido@protonmail.com>2019-01-24 19:15:57 +0100
commit0bd37653d52b4664a3be33d095d5f320a8eeb0a1 (patch)
tree182787829ab8b85af53bee6d142f571c5e3acd1f
parent21e003dc1876a5826c5b9a21781fe35ad52f2778 (diff)
changed colours to work better with 8-colour terminals and update screen before each wait (so also with each keypress)
-rw-r--r--asciifarm/charmaps/fullwidth.json2
-rw-r--r--asciifarm/charmaps/halfwidth.json2
-rw-r--r--asciifarm/client/display/colours.py23
-rw-r--r--asciifarm/client/gameclient.py2
4 files changed, 20 insertions, 9 deletions
diff --git a/asciifarm/charmaps/fullwidth.json b/asciifarm/charmaps/fullwidth.json
index 9b5b81c..6d912fe 100644
--- a/asciifarm/charmaps/fullwidth.json
+++ b/asciifarm/charmaps/fullwidth.json
@@ -4,7 +4,7 @@
"tree": ["T",0,2],
"wall": ["#",7,8],
"builtwall": ["+",7,8],
- "rock": [" ",7,8],
+ "rock": ["#",8,8],
"stone": ["o",7],
"pebble": ["*",7],
"player": ["@",15],
diff --git a/asciifarm/charmaps/halfwidth.json b/asciifarm/charmaps/halfwidth.json
index d1fc4f6..d3e16f8 100644
--- a/asciifarm/charmaps/halfwidth.json
+++ b/asciifarm/charmaps/halfwidth.json
@@ -3,7 +3,7 @@
"tree": ["T", 0, 2],
"wall": ["#", 7, 8],
"builtwall": ["+", 7, 8],
- "rock": [" ", 7, 8],
+ "rock": ["#", 8, 8],
"stone": ["o", 7],
"pebble": ["*", 7],
"player": ["@", 15],
diff --git a/asciifarm/client/display/colours.py b/asciifarm/client/display/colours.py
index 22e6f14..1403300 100644
--- a/asciifarm/client/display/colours.py
+++ b/asciifarm/client/display/colours.py
@@ -13,9 +13,20 @@ class Colours:
curses.init_pair(i, i%self.colours, i//self.colours)
def get(self, fg=0, bg=0):
- dfg = fg % self.colours
- dbg = bg % self.colours
- if (dfg, dbg) == (0, 0) and (fg, bg) != (0, 0):
- # avoid unintended use of (0,0), which is settings dependent
- dfg, dbg = 7, 0
- return curses.color_pair(dfg + dbg*self.colours)
+ if self.colours == 16:
+ return curses.color_pair(fg + bg*self.colours)
+ elif self.colours == 8:
+ dfg = fg % 8
+ dbg = bg % 8
+ if bg == 8:
+ dbg = 7
+ if fg == 8:
+ dfg = 7
+ colour = curses.color_pair(dfg + dbg*self.colours)
+ if fg >= 8 and bg < 8:
+ colour |= curses.A_BOLD
+ elif fg < 8 and bg >= 8:
+ colour |= curses.A_DIM
+ return colour
+ else:
+ return curses.color_pair(0)
diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py
index 1995a67..507346a 100644
--- a/asciifarm/client/gameclient.py
+++ b/asciifarm/client/gameclient.py
@@ -119,7 +119,6 @@ class Client:
for option in options:
self.log(option)
- self.display.update()
def log(self, text, type=None):
if not isinstance(text, str):
@@ -132,6 +131,7 @@ class Client:
def command_loop(self):
while self.keepalive:
+ self.display.update()
action = self.queue.get()
if action[0] == "message":
self.update(action[1])