Skip to content

Commit

Permalink
Draws do not get the "Winner!" label anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
marcizhu committed Aug 3, 2021
1 parent b97621d commit 425c2b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def main(issue, issue_author, repo_owner):
pattern = re.compile('.*: (@[a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})', flags=re.I)
player_list = { re.match(pattern, line).group(1) for line in lines }

issue.add_to_labels('👑 Winner!')
if gameboard.result() == '1/2-1/2':
issue.add_to_labels('👑 Draw!')
else:
issue.add_to_labels('👑 Winner!')

issue.create_comment(settings['comments']['game_over'].format(
outcome=win_msg.get(gameboard.result(), 'UNKNOWN'),
players=', '.join(player_list),
Expand Down
4 changes: 4 additions & 0 deletions src/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def get_test_data(settings, move_data, owner, i):
labels += ['👑 Winner!']
comments += [settings['comments']['game_over'].format(outcome='.+', num_moves='\\d+', num_players='\\d+', players='(@.+,)* @.+')]

if 'is_draw' in move_data and move_data['is_draw'] == True:
labels += ['👑 Draw!']
comments += [settings['comments']['game_over'].format(outcome='.+', num_moves='\\d+', num_players='\\d+', players='(@.+,)* @.+')]

if 'is_capture' in move_data and move_data['is_capture'] == True:
labels += ['⚔️ Capture!']

Expand Down
1 change: 1 addition & 0 deletions tests/insufficient-material.yml
Original file line number Diff line number Diff line change
Expand Up @@ -845,3 +845,4 @@ moves:
- author: '@Stockfish'
move: 'Chess: Move D2 to B1'
is_capture: true
is_draw: true
1 change: 1 addition & 0 deletions tests/stalemate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,4 @@ moves:
- author: '@player1'
move: 'Chess: Move A6 to E6'
is_capture: true
is_draw: true

0 comments on commit 425c2b9

Please sign in to comment.