From 41007b36132e8594c17f4d11f2d1834340c75456 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 4 Jan 2017 00:24:14 +0100 Subject: Populating model database with normalized (RDBMS-wise) data, with cut-off from config applied --- ausbutler/butler.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ausbutler/butler.py (limited to 'ausbutler/butler.py') 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' + -- cgit v1.2.3