Skip to content

Commit

Permalink
Merge pull request #76 from jrsmth/bugfix/presentation/75
Browse files Browse the repository at this point in the history
[patch] WAFF-75: handle empty lists
  • Loading branch information
jrsmth authored Dec 19, 2024
2 parents 1e4d255 + 4177b37 commit 116079f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## Explanation
- 🧇 The Archbishop oversees scoring within your Slack group
- ℹ️ [Demo?]()
- ℹ️ [Wiki](https://github.com/jrsmth/waffle-bot/wiki)

## Run Locally
- 🔧 `pip install -r src/app/requirements.txt`
Expand Down
7 changes: 5 additions & 2 deletions documentation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
- `0.3.x` Scroll Command
- `0.4.x` Player Extension
- `0.5.x` Presentation
- `0.6.x` Reactions
- `1.0.x` App Distribution

# Releases
<!-- @LatestFirst -->

## [0.5.1] [![user](https://img.shields.io/badge/adamj335-181717.svg?style=flat&logo=github)](https://github.com/jrsmth)
[Presentation](https://github.com/jrsmth/waffle-bot/milestone/3) (19/12/2024)
- `#75` Archbishop not processing requests following 0.5.0 release

## [0.5.0] [![user](https://img.shields.io/badge/adamj335-181717.svg?style=flat&logo=github)](https://github.com/adamj335)
[Presentation](https://github.com/jrsmth/waffle-bot/milestone/3) (28/11/2024)
- `#52` Update dethrone Message to announce new King
Expand Down Expand Up @@ -75,3 +77,4 @@
[0.4.0]: https://github.com/jrsmth/waffle-bot/compare/0.3.1...0.4.0
[0.4.1]: https://github.com/jrsmth/waffle-bot/compare/0.4.0...0.4.1
[0.5.0]: https://github.com/jrsmth/waffle-bot/compare/0.4.1...0.5.0
[0.5.1]: https://github.com/jrsmth/waffle-bot/compare/0.5.0...0.5.1
7 changes: 3 additions & 4 deletions src/app/deacon/deacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ def handle_king(log, messages, group, player):
log.info(f"[handle_king] The Reign of King {player.name} is over!")
log.info("[handle_king] Searching for a new King...")
group.dethrone()
new_king = group.get_player_by_id(group.king)[0]
new_king = group.get_player_by_id(group.king)
if new_king is not None:
return messages.load_with_params("result.king.lose.new",
[player.name, str(player.prev_streak), new_king.name])
return messages.load_with_params("result.king.lose.new",[player.name, str(player.prev_streak), new_king.name])
else:
return messages.load_with_params("result.king.lose", [player.name, str(player.prev_streak)])
# King Wins
Expand All @@ -30,7 +29,7 @@ def handle_commoner(log, messages, group, player):
# ...and wins...
else:
# ...and deserves coronation
if player.streak > group.get_streak_by_id(group.king)[0]:
if player.streak > group.get_streak_by_id(group.king):
group.crown(player)
return messages.load_with_params("result.common.coronation", [player.name])
else:
Expand Down
6 changes: 4 additions & 2 deletions src/app/model/group/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ def dethrone(self):
self.king = sorted(non_zeros, key=lambda x: x.streak, reverse=True)[0].id

def get_streak_by_id(self, id_value):
return [p.streak for p in self.players if p.id == id_value]
streak = [p.streak for p in self.players if p.id == id_value]
return streak[0] if len(streak) != 0 else 0

def get_player_by_id(self, id_value):
return [p for p in self.players if p.id == id_value]
player = [p for p in self.players if p.id == id_value]
return player[0] if len(player) != 0 else None

def __is_unworthy(self, new_streak):
""" Determine if streak is unworthy of scroll update """
Expand Down

0 comments on commit 116079f

Please sign in to comment.