Skip to content

Commit

Permalink
edit(hanabi)!: increase hanabi payout function
Browse files Browse the repository at this point in the history
  • Loading branch information
vEnhance committed Sep 12, 2023
1 parent 376d6b9 commit 62a1a0c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions aincrad/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,13 @@ def test_hanabi_contest(self) -> None:
)
self.assertEqual(len(resp.json()["names"]), 9)
self.assertAlmostEqual(
HanabiReplay.objects.get(replay_id=812).spades_score, 4.0
HanabiReplay.objects.get(replay_id=812).spades_score, 6.0
)
self.assertAlmostEqual(
HanabiReplay.objects.get(replay_id=811).spades_score, 3.0
HanabiReplay.objects.get(replay_id=811).spades_score, 5.0
)
self.assertAlmostEqual(
HanabiReplay.objects.get(replay_id=271).spades_score, 0.6328125
HanabiReplay.objects.get(replay_id=271).spades_score, 1.265625
)
self.assertEqual(HanabiParticipation.objects.all().count(), 9)
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion hanabi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_absolute_url(self) -> str:

def get_base_spades(self) -> float:
num_suits = self.contest.num_suits
return 2 * (self.game_score / (5 * num_suits)) ** num_suits
return 4 * (self.game_score / (5 * num_suits)) ** 4


class HanabiParticipation(models.Model):
Expand Down
10 changes: 4 additions & 6 deletions hanabi/templates/hanabi/hanabicontest_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ <h1>Contest Format</h1>
</li>
<li>
You earn
\[ 2 \cdot \left(
\frac{ \text{your game score} }
{ 5 \cdot \text{number of suits} }
\right)^{ \text{number of suits} } \]
\[ 4 \cdot \left( \frac{ \text{your game score} }
{ 5 \cdot \text{number of suits} } \right)^4 \]
spades.
For example, if you score 23/25,
you earn $2 \cdot (23/25)^5 \approx 1.318$ spades.
you earn $4 \cdot (23/25)^4 \approx 2.866$ spades.
</li>
<li>
In addition, you get +1 bonus spade if you have the
Expand All @@ -209,7 +207,7 @@ <h1>Contest Format</h1>
<i>and</i> the lowest turn count among such teams.
</li>
</ul>
Thus, the maximum possible spades per contest is $2+1+1=4$.
Thus, the maximum possible spades per contest is $4+1+1=6$.
Here, a "participating team" is any team that
has at least one OTIS student.
</li>
Expand Down
2 changes: 1 addition & 1 deletion hanabi/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_contest(self) -> None:
self.assertEqual(contest.max_score, 25)

replay = HanabiReplayFactory.create(contest=contest, game_score=23)
self.assertAlmostEqual(replay.get_base_spades(), 1.3181630464)
self.assertAlmostEqual(replay.get_base_spades(), 2.86557184)


class HanabiViewTests(EvanTestCase):
Expand Down
6 changes: 6 additions & 0 deletions rpg/templates/rpg/meters/spades.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
</td>
<td>Varies</td>
</tr>
<tr>
<td>
<a href="{% url 'hanabi-contests' %}">Hanabi</a>
</td>
<td>0♠ - 6♠</td>
</tr>
</table>
<p>The above list is not exhaustive; spades can be awarded for other things too.</p>
<table class="table table-sm">
Expand Down

0 comments on commit 62a1a0c

Please sign in to comment.