Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic: the modular refactor and testing #161

Open
8 of 15 tasks
kevinlul opened this issue Feb 8, 2021 · 4 comments
Open
8 of 15 tasks

Epic: the modular refactor and testing #161

kevinlul opened this issue Feb 8, 2021 · 4 comments

Comments

@kevinlul
Copy link
Contributor

kevinlul commented Feb 8, 2021



  • add tests for loading persistent timers
  • add tests for events systems

  • add tests for Templater

In progress

Done

@kevinlul kevinlul added bug Something isn't working and removed bug Something isn't working labels Feb 8, 2021
@kevinlul kevinlul pinned this issue Feb 8, 2021
@kevinlul
Copy link
Contributor Author

kevinlul commented Feb 9, 2021

While commands are extracted, each one should not absorb errors silently and instead provide the user some feedback. The same applies to any action conducted in direct messages.

@kevinlul
Copy link
Contributor Author

Assert that the calling user is a host for the tournament that exists.
NEW: Assert that the tournament hasn't started yet in the database.

PROCEDURE START_TOURNAMENT
Assert that we have at least two players and notify the caller if not.
Delete all register messages the database and then Discord. Eris has a bulk delete method.
Drop all pending players from the database. Queue a task to notify them of the drop.
Assign round-one byes on Challonge and then start the tournament on Challonge.
REORDERED: Send a user guide to public channels.
REORDERED: Send a user guide to private channels.
CHANGED: drop round-one byes from Challonge.
CHANGED: mark the tournament as started in the database.
CHANGED: CALL NEW_ROUND

PROCEDURE NEW_ROUND
NEW: Assert that the tournament is in progress.
Abort all outstanding persistent timers for the tournament.
Retrieve the current round number from Challonge. (NETFAIL)
If we are sending direct message pairings:
Retrieve pairings, snowflakes, and natural bye from Challonge. (NETFAIL)
Sort the player-snowflakes in a Map by Challonge ID.
For each pairing, check if both players are still in the server.
If one or both are not in the server, ENQUEUE DROP_TOURNAMENT_PLAYER.
If one dropped or is a round-one bye, inform the to-be opponent.
Direct message the pairing to the players that are still active.
Notify the private channel in the event of any direct message failures.
Inform the player with the natural bye of their fortune.
Create the persistent timer for this round.

PROCEDURE DROP_TOURNAMENT_PLAYER
Update the database accordingly (but guildMemberRemove doesn't need this and we can batch this for NEW_ROUND)
Notify private channels for the tournament about who dropped.
If the tournament was in progress:
Find the current pairing.
If the opponent is still active, submit a score in favour of the opponent.
If the opponent also dropped, update the score to a 0-0 draw.
Message the opponent about the drop if still active.
Remove the player from Challonge.
Message the private channels.

@kevinlul
Copy link
Contributor Author

CLASS SCORER
Member: Map from Challonge match id (number) to informational object for the submitted score by one party.
Instances are constructed on demand if one is missing when score-type commands are invoked . They could also additionally be constructed when a tournament starts.
Scores submitted by one party are stored in the map.
Scores confirmed by the other party or overridden by a host are removed from the map.
Instances are destroyed when the tournament is cancelled or finished.
Either scoring methods are attached to this class so we could test in isolation, or scoring logic is in commands so we just have one meaningful test for each command, and this class isn't necessary, just a map of maps.

@kevinlul
Copy link
Contributor Author

Actually, it would make sense to drop players who left explicitly before starting the tournament. New round is out of our hands though as the command really only sends messages out.

kevinlul added a commit that referenced this issue Feb 16, 2021
* Remove PersistentTimer's dependency on DiscordInterface
* Replace 'link seams' with dependency injection
* Fix tests
#161
@kevinlul kevinlul unpinned this issue Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant