Skip to content

Commit

Permalink
Merge pull request #226 from jeffkaufman/allow-new-players
Browse files Browse the repository at this point in the history
Create 0.17-allow-new-players
  • Loading branch information
jeffkaufman committed Feb 15, 2019
2 parents 324bbf8 + 5ed781c commit e6fcf1e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -7,11 +7,12 @@ username like:

players/$yourname/bonuses/initial

The file should contain the number 10. Then ping Jeff (jeffkaufman) so you can
be added to the repo collaborators.

If Jeff doesn't add you to the list of repo collaborators, ping him to ask him
to. This will allow you to press the merge button yourself.
This file should contain your initial number of points. If you choose to
start with 0 points, your pull request won't require approval from existing
players. You can also choose to start with more points, but you'll need to
wait for other players to approve your PR. Either way, ping Jeff
(jeffkaufman) so you can be added to the repo collaborators. This will allow
you to press the merge button yourself.

## Playing

Expand Down
29 changes: 29 additions & 0 deletions rules/0.17-allow-new-players.py
@@ -0,0 +1,29 @@
import util

# This value set to 0 until we figure out a good way to prevent dummy account abuse
max_start_bonus = 0

def should_allow(pr):
bonuses = pr.get_new_bonuses_or_raise()

if len(bonuses) > 1:
raise Exception('Only one new player can be added in a PR')
elif len(bonuses) < 1:
raise Exception('Empty diff?')

(points_user, points_name, points_change) = bonuses[0]

if points_user in util.users():
raise Exception('Cannot create an existing user')

if points_name != 'initial':
raise Exception('New player bonus value must be called "initial"')

if points_change < 0:
raise Exception('Points cannot be negative')

if points_change > max_start_bonus:
raise Exception('%s initial points exceeds maximum starting value of %s points' %
(points_change, max_start_bonus))

return True

0 comments on commit e6fcf1e

Please sign in to comment.