From aa05b9075480ff5e546970c7b7c6870184a6ea28 Mon Sep 17 00:00:00 2001 From: Benjamin Schwartz Date: Sun, 27 Dec 2015 00:58:35 -0800 Subject: [PATCH] moved any and pick designation to the proper, grammatical place --- SpyPartyDraft.py | 2 +- draft/draft.py | 4 +--- draft/map.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SpyPartyDraft.py b/SpyPartyDraft.py index 6920f16..3435706 100644 --- a/SpyPartyDraft.py +++ b/SpyPartyDraft.py @@ -324,7 +324,7 @@ def draft_map(message): chosen_map = [x for x in room.draft.map_pool if x.slug == message['choice']][0] chosen_map_name = chosen_map.name if room.draft.state.startswith('PICK') and not chosen_map.slug.endswith('k2'): - chosen_map_name += ' PICK' if message['is_pick'] else ' ANY' + chosen_map_name = chosen_map.map_mode_name(message['is_pick']) if room.draft.state.startswith('BAN'): room.post_event("{} has banned {}".format(room.draft.current_player, chosen_map_name)) diff --git a/draft/draft.py b/draft/draft.py index 832e25a..191acb5 100644 --- a/draft/draft.py +++ b/draft/draft.py @@ -82,9 +82,7 @@ def mark_map(self, map, is_pick): self.banned_maps.append(map.name) self.map_pool.remove(map) else: - map_name = map.name - if not map.slug.endswith('k2'): - map_name += ' PICK' if is_pick else ' ANY' + map_name = map.map_mode_name(is_pick) self.picked_maps.append(map_name) for x in [x for x in self.map_pool if x.family == map.family]: self.map_pool.remove(x) diff --git a/draft/map.py b/draft/map.py index e17997f..a908c2d 100644 --- a/draft/map.py +++ b/draft/map.py @@ -10,6 +10,12 @@ def __init__(self, name, slug, family): def __repr__(self): return self.name + def map_mode_name(self, is_pick): + if self.slug.endswith('k2'): + return self.name + parts = self.name.split(' ') + return parts[0] + (' PICK ' if is_pick else ' ANY ') + parts[1] + def as_map(self): return { 'name': self.name, @@ -25,6 +31,7 @@ def generate_map_pool(file_name, tourney): return [Map(x['name'], x['slug'], x['family']) for x in tourney_json] if __name__ == '__main__': - data = Map.generate_map_pool('map_pools.json', 'scl_season_1') - print data + m = Map("Balcony 2/3", "balcony23", "balcony") + print m.map_mode_name(False) + print m.map_mode_name(True)