Skip to content

Commit

Permalink
Added possibility to karma vote +++ or --- (chat message indicates it…
Browse files Browse the repository at this point in the history
…'s the same as ++/--).
  • Loading branch information
TheMaximum committed Aug 23, 2018
1 parent 7b7441b commit e95549e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pyplanet/apps/contrib/karma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, *args, **kwargs):

self.setting_expanded_voting = Setting(
'expanded_voting', 'Expanded voting', Setting.CAT_BEHAVIOUR, type=bool,
description='Expands the karma voting to use --, -, +-, + and ++.',
description='Expands the karma voting to also use ---, -, +-, + and +++.',
default=False
)

Expand Down Expand Up @@ -135,10 +135,10 @@ async def player_connect(self, player, is_spectator, source, signal):

async def player_chat(self, player, text, cmd):
if not cmd:
if text == '++' or text == '+' or text == '+-' or text == '-+' or text == '-' or text == '--':
if text == '+++' or text == '++' or text == '+' or text == '+-' or text == '-+' or text == '-' or text == '--' or text == '---':
expanded_voting = await self.setting_expanded_voting.get_value()
if expanded_voting is False:
if text == '+' or text == '+-' or text == '-+' or text == '-':
if text == '+++' or text == '+' or text == '+-' or text == '-+' or text == '-' or text == '---':
return

if self.instance.game.game == 'tm':
Expand All @@ -151,7 +151,7 @@ async def player_chat(self, player, text, cmd):

normal_score = -1
score = -1
if text == '++':
if text == '++' or text == '+++':
normal_score = 1
score = 1
elif text == '+':
Expand All @@ -175,7 +175,9 @@ async def player_chat(self, player, text, cmd):
if map is not None:
map.karma = await self.get_map_karma(self.instance.map_manager.current_map)

message = '$ff0Successfully changed your karma vote to $fff{}$ff0!'.format(text)
message = '$ff0Successfully changed your karma vote to $fff{}$ff0{}!'.format(text,
(' (same as $fff{}$ff0)'.format(text[:2]) if text == '+++' or text == '---' else '')
)
await self.calculate_karma()
await asyncio.gather(
self.instance.chat(message, player),
Expand All @@ -192,7 +194,9 @@ async def player_chat(self, player, text, cmd):
if map is not None:
map.karma = await self.get_map_karma(self.instance.map_manager.current_map)

message = '$ff0Successfully voted $fff{}$ff0!'.format(text)
message = '$ff0Successfully voted $fff{}$ff0{}!'.format(text,
(' (same as $fff{}$ff0)'.format(text[:2]) if text == '+++' or text == '---' else '')
)
await asyncio.gather(
self.instance.chat(message, player),
self.widget.display()
Expand Down

0 comments on commit e95549e

Please sign in to comment.