From 3262aae9f78fc0e54c9cbc8d45ab0edd73940654 Mon Sep 17 00:00:00 2001 From: James Turk Date: Sun, 27 May 2012 22:53:52 -0400 Subject: [PATCH] appearances & brawls --- fowl/game/models.py | 21 ++++++++++++++++++--- fowl/game/tests.py | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/fowl/game/models.py b/fowl/game/models.py index a579fe2..a2718e8 100644 --- a/fowl/game/models.py +++ b/fowl/game/models.py @@ -4,9 +4,13 @@ from django.contrib.auth.models import User # these things are independent of the game -WIN_TYPES = (('pin', 'pin'), +WIN_TYPES = ( + ('pin', 'pin'), ('DQ', 'DQ'), - ('submission', 'submission')) + ('submission', 'submission'), + ('appearance', 'appearance'), + ('brawl', 'brawl'), + ) TITLES = (('wwe', 'WWE'), ('heavyweight', 'Heavyweight'), @@ -44,7 +48,7 @@ class Event(models.Model): def add_match(self, *teams, **kwargs): winner = kwargs.get('winner', None) - win_type = kwargs.get('win_type', None) + win_type = kwargs.get('win_type', '') title_at_stake = kwargs.get('title_at_stake', False) notes = kwargs.get('notes', '') @@ -68,6 +72,9 @@ class Event(models.Model): mt.members.add(member) if winner: match.record_win(winner, win_type) + else: + match.win_type = win_type + match.save() return match def __unicode__(self): @@ -98,6 +105,10 @@ class Match(models.Model): for team in self.teams.all(): for star in team.members.all(): points[star.id] = 0 + if self.win_type == 'appearance' and not star.active: + points[star.id] += 10 + if self.win_type == 'brawl': + points[star.id] += 2 if team.title: title_teams[team.title] = team if team.victorious: @@ -106,6 +117,10 @@ class Match(models.Model): losers.append(team.members.count()) team_count += 1 + # don't worry about winners of appearances or brawls + if self.win_type in ('appearance', 'brawl'): + return points + if winners: winner_count = winners.members.count() loser_count = sum(losers) diff --git a/fowl/game/tests.py b/fowl/game/tests.py index ff5480b..9739e65 100644 --- a/fowl/game/tests.py +++ b/fowl/game/tests.py @@ -135,6 +135,23 @@ class MatchTest(TestCase): 'albertodelrio': 0 }) + def test_appearance_scoring(self): + # normal appearance worth 0 points + match = self.event.add_match('cmpunk', 'kofikingston', + win_type='appearance') + self.assertEqual(match.points(), {'cmpunk': 0, 'kofikingston': 0}) + + # appearance of old timer, 10 points + match = self.event.add_match('brock-lesnar', win_type='appearance') + self.assertEqual(match.points(), {'brock-lesnar': 10}) + + def test_brawl_scoring(self): + # brawls worth 2 points for all involved + match = self.event.add_match(['cmpunk', 'aj'], 'danielbryan', + win_type='brawl') + self.assertEqual(match.points(), {'cmpunk': 2, 'aj': 2, + 'danielbryan': 2}) + def test_champ_scoring(self): _give_belt('cmpunk', 'wwe') _give_belt('christian', 'ic')