summaryrefslogtreecommitdiff
path: root/ausbutler/butler.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-01-04 00:24:14 +0100
committeremkael <emkael@tlen.pl>2017-01-04 20:56:19 +0100
commit41007b36132e8594c17f4d11f2d1834340c75456 (patch)
tree2570ab37caefa4860a81a48ecf3e1c954d7d3280 /ausbutler/butler.py
parentd0c93a1c1813213d2f55fa9b4c6798d131d08484 (diff)
Populating model database with normalized (RDBMS-wise) data, with cut-off from config applied
Diffstat (limited to 'ausbutler/butler.py')
-rw-r--r--ausbutler/butler.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/ausbutler/butler.py b/ausbutler/butler.py
new file mode 100644
index 0000000..424e385
--- /dev/null
+++ b/ausbutler/butler.py
@@ -0,0 +1,23 @@
+import json
+from os import path
+import __main__
+
+config = json.load(
+ open(path.join(path.dirname(__main__.__file__), 'config', 'butler.json')))
+
+def cutoff(score):
+ sign = 1 if score > 0 else -1
+ score = abs(score)
+ if score > config['cutoff_point']:
+ score -= config['cutoff_point']
+ score *= config['cutoff_rate']
+ score += config['cutoff_point']
+ return score * sign
+
+def get_room(butler, player):
+ table = butler.table
+ if player in [table.openE, table.openW, table.openN, table.openS]:
+ return 'open'
+ if player in [table.closeE, table.closeW, table.closeN, table.closeS]:
+ return 'closed'
+