Merge branch 'master' of github.com:jamesturk/fowl
This commit is contained in:
commit
905e1ff14a
@ -4,8 +4,7 @@ from django.contrib.auth.models import User
|
|||||||
|
|
||||||
# these things are independent of the game
|
# these things are independent of the game
|
||||||
|
|
||||||
OUTCOMES = (
|
OUTCOMES = (('no contest', 'no contest'),
|
||||||
('no contest', 'no contest'),
|
|
||||||
('normal', 'normal'),
|
('normal', 'normal'),
|
||||||
('DQ', 'DQ'),
|
('DQ', 'DQ'),
|
||||||
('submission', 'submission'),
|
('submission', 'submission'),
|
||||||
@ -53,7 +52,7 @@ class Event(models.Model):
|
|||||||
def add_match(self, *teams, **kwargs):
|
def add_match(self, *teams, **kwargs):
|
||||||
winner = kwargs.get('winner', None)
|
winner = kwargs.get('winner', None)
|
||||||
outcome = kwargs.get('outcome', '')
|
outcome = kwargs.get('outcome', '')
|
||||||
title_at_stake = kwargs.get('title_at_stake', False)
|
title_at_stake = kwargs.get('title_at_stake', None)
|
||||||
notes = kwargs.get('notes', '')
|
notes = kwargs.get('notes', '')
|
||||||
|
|
||||||
match = Match.objects.create(event=self,
|
match = Match.objects.create(event=self,
|
||||||
@ -89,7 +88,7 @@ class Match(models.Model):
|
|||||||
event = models.ForeignKey(Event, related_name='matches')
|
event = models.ForeignKey(Event, related_name='matches')
|
||||||
winner = models.ForeignKey(Star, null=True)
|
winner = models.ForeignKey(Star, null=True)
|
||||||
outcome = models.CharField(max_length=10, choices=OUTCOMES)
|
outcome = models.CharField(max_length=10, choices=OUTCOMES)
|
||||||
title_at_stake = models.BooleanField(default=False)
|
title_at_stake = models.CharField(max_length=50, choices=TITLES, null=True)
|
||||||
notes = models.TextField(blank=True, default='')
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
def record_win(self, star, outcome):
|
def record_win(self, star, outcome):
|
||||||
@ -100,6 +99,16 @@ class Match(models.Model):
|
|||||||
self.outcome = outcome
|
self.outcome = outcome
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def do_title_change(self):
|
||||||
|
if self.title_at_stake:
|
||||||
|
victors = list(self.teams.get(victorious=True).members.all())
|
||||||
|
if len(victors) == 1:
|
||||||
|
victor[0].win_title(self.title_at_stake)
|
||||||
|
elif len(victors) == 2 and self.title_at_stake == 'tag':
|
||||||
|
victor[0].win_title(self.title_at_stake, victor[1])
|
||||||
|
else:
|
||||||
|
raise ValueError('invalid number of victors for title change')
|
||||||
|
|
||||||
def points(self):
|
def points(self):
|
||||||
points = {}
|
points = {}
|
||||||
winners = None
|
winners = None
|
||||||
@ -147,39 +156,41 @@ class Match(models.Model):
|
|||||||
for w in winners.members.all():
|
for w in winners.members.all():
|
||||||
points[w.id] = base_points
|
points[w.id] = base_points
|
||||||
|
|
||||||
# if multiple people in this match and this person was credited
|
if self.title_at_stake:
|
||||||
# w/ win, give them the bonus points
|
if winners.title == self.title_at_stake:
|
||||||
if allies and w.id == self.winner_id:
|
|
||||||
points[w.id] += 1
|
|
||||||
if w.id == self.winner_id and self.outcome == 'submission':
|
|
||||||
points[w.id] += 1
|
|
||||||
|
|
||||||
# look over all titles in this match
|
|
||||||
for title, title_team in title_teams.iteritems():
|
|
||||||
# title defense
|
# title defense
|
||||||
if winners.title == title and self.title_at_stake:
|
if winners.title in ('heavyweight', 'wwe'):
|
||||||
if title in ('heavyweight', 'wwe'):
|
|
||||||
points[w.id] += 5
|
points[w.id] += 5
|
||||||
else:
|
else:
|
||||||
points[w.id] += 3
|
points[w.id] += 3
|
||||||
# beat someone w/ title
|
elif self.outcome in ('normal', 'submission'):
|
||||||
elif winners.title != title:
|
# title win!
|
||||||
# title win
|
if self.title_at_stake in ('heavyweight', 'wwe'):
|
||||||
if self.title_at_stake and self.outcome != 'DQ':
|
|
||||||
if title in ('heavyweight', 'wwe'):
|
|
||||||
points[w.id] += 20
|
points[w.id] += 20
|
||||||
else:
|
else:
|
||||||
points[w.id] += 10
|
points[w.id] += 10
|
||||||
# title team gets a point if they defend title by DQ
|
else:
|
||||||
elif self.title_at_stake and self.outcome == 'DQ':
|
# defense by DQ
|
||||||
for star in title_team.members.all():
|
for star in title_teams[self.title_at_stake].members.all():
|
||||||
points[star.id] += 1
|
points[star.id] += 1
|
||||||
|
else:
|
||||||
|
# look over titles in match, to score a title-nondefense
|
||||||
|
for title, title_team in title_teams.iteritems():
|
||||||
|
# beat someone w/ title in a non-defense
|
||||||
|
if winners.title != title:
|
||||||
# beat tag champs in tag match w/o tag belt on line
|
# beat tag champs in tag match w/o tag belt on line
|
||||||
elif title == 'tag' and all(c == 2 for c in losers):
|
if title == 'tag' and all(c == 2 for c in losers):
|
||||||
points[w.id] += 2
|
points[w.id] += 2
|
||||||
# beat champ in non-handicap match w/o belt on line
|
# beat champ in non-handicap match w/o belt on line
|
||||||
elif all(c == 1 for c in losers):
|
elif all(c == 1 for c in losers):
|
||||||
points[w.id] += 2
|
points[w.id] += 2
|
||||||
|
|
||||||
|
# if multiple people in this match and this person was credited
|
||||||
|
# w/ win, give them the bonus points
|
||||||
|
if allies:
|
||||||
|
points[self.winner_id] += 1
|
||||||
|
if self.outcome == 'submission':
|
||||||
|
points[self.winner_id] += 1
|
||||||
return points
|
return points
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
@ -208,6 +219,7 @@ class MatchTeam(models.Model):
|
|||||||
|
|
||||||
class League(models.Model):
|
class League(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
|
active = models.BooleanField(default=True)
|
||||||
raw_picks = models.IntegerField(default=3)
|
raw_picks = models.IntegerField(default=3)
|
||||||
smackdown_picks = models.IntegerField(default=3)
|
smackdown_picks = models.IntegerField(default=3)
|
||||||
diva_picks = models.IntegerField(default=2)
|
diva_picks = models.IntegerField(default=2)
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="belt-img" colspan="2"><img src="{% get_static_prefix %}images/{{belt}}.png"></td>
|
<td class="belt-img" colspan="2">
|
||||||
|
<img src="{% get_static_prefix %}images/{{belt}}.png">
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tody>
|
<tody>
|
||||||
|
@ -170,31 +170,31 @@ class MatchTest(TestCase):
|
|||||||
|
|
||||||
# defending wwe belt is worth +5
|
# defending wwe belt is worth +5
|
||||||
match = self.event.add_match('cmpunk', 'reymysterio', winner='cmpunk',
|
match = self.event.add_match('cmpunk', 'reymysterio', winner='cmpunk',
|
||||||
outcome='normal', title_at_stake=True)
|
outcome='normal', title_at_stake='wwe')
|
||||||
self.assertEqual(match.points(), {'cmpunk': 7, 'reymysterio': 0})
|
self.assertEqual(match.points(), {'cmpunk': 7, 'reymysterio': 0})
|
||||||
|
|
||||||
# winning wwe belt
|
# winning wwe belt
|
||||||
match = self.event.add_match('cmpunk', 'reymysterio',
|
match = self.event.add_match('cmpunk', 'reymysterio',
|
||||||
winner='reymysterio', outcome='normal',
|
winner='reymysterio', outcome='normal',
|
||||||
title_at_stake=True)
|
title_at_stake='wwe')
|
||||||
self.assertEqual(match.points(), {'reymysterio': 22, 'cmpunk': 0})
|
self.assertEqual(match.points(), {'reymysterio': 22, 'cmpunk': 0})
|
||||||
|
|
||||||
# defending other belt is worth +3
|
# defending other belt is worth +3
|
||||||
match = self.event.add_match('christian', 'codyrhodes',
|
match = self.event.add_match('christian', 'codyrhodes',
|
||||||
winner='christian', outcome='normal',
|
winner='christian', outcome='normal',
|
||||||
title_at_stake=True)
|
title_at_stake='ic')
|
||||||
self.assertEqual(match.points(), {'christian': 5, 'codyrhodes': 0})
|
self.assertEqual(match.points(), {'christian': 5, 'codyrhodes': 0})
|
||||||
|
|
||||||
# winning other belt is worth +10
|
# winning other belt is worth +10
|
||||||
match = self.event.add_match('christian', 'codyrhodes',
|
match = self.event.add_match('christian', 'codyrhodes',
|
||||||
winner='codyrhodes', outcome='normal',
|
winner='codyrhodes', outcome='normal',
|
||||||
title_at_stake=True)
|
title_at_stake='ic')
|
||||||
self.assertEqual(match.points(), {'codyrhodes': 12, 'christian': 0})
|
self.assertEqual(match.points(), {'codyrhodes': 12, 'christian': 0})
|
||||||
|
|
||||||
# title non-defense (DQ/countout)
|
# title non-defense (DQ/countout)
|
||||||
match = self.event.add_match('christian', 'codyrhodes',
|
match = self.event.add_match('christian', 'codyrhodes',
|
||||||
winner='codyrhodes', outcome='DQ',
|
winner='codyrhodes', outcome='DQ',
|
||||||
title_at_stake=True)
|
title_at_stake='ic')
|
||||||
self.assertEqual(match.points(), {'codyrhodes': 1, 'christian': 1})
|
self.assertEqual(match.points(), {'codyrhodes': 1, 'christian': 1})
|
||||||
|
|
||||||
# no bonus in a tag match
|
# no bonus in a tag match
|
||||||
@ -215,7 +215,7 @@ class MatchTest(TestCase):
|
|||||||
match = self.event.add_match(['kofikingston', 'rtruth'],
|
match = self.event.add_match(['kofikingston', 'rtruth'],
|
||||||
['reymysterio', 'sin-cara'],
|
['reymysterio', 'sin-cara'],
|
||||||
winner='reymysterio', outcome='normal',
|
winner='reymysterio', outcome='normal',
|
||||||
title_at_stake=True)
|
title_at_stake='tag')
|
||||||
self.assertEqual(match.points(), {'sin-cara': 12, 'reymysterio': 13,
|
self.assertEqual(match.points(), {'sin-cara': 12, 'reymysterio': 13,
|
||||||
'kofikingston': 0, 'rtruth': 0})
|
'kofikingston': 0, 'rtruth': 0})
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ class LeagueTest(TestCase):
|
|||||||
match2 = event.add_match('markhenry', ['santinomarella', 'mickfoley'],
|
match2 = event.add_match('markhenry', ['santinomarella', 'mickfoley'],
|
||||||
winner='mickfoley', outcome='normal')
|
winner='mickfoley', outcome='normal')
|
||||||
_give_belt('codyrhodes', 'ic')
|
_give_belt('codyrhodes', 'ic')
|
||||||
match3 = event.add_match('sin-cara', 'codyrhodes', title_at_stake=True,
|
match3 = event.add_match('sin-cara', 'codyrhodes', title_at_stake='ic',
|
||||||
winner='sin-cara', outcome='normal')
|
winner='sin-cara', outcome='normal')
|
||||||
self.league.score_event(event)
|
self.league.score_event(event)
|
||||||
|
|
||||||
|
@ -84,17 +84,18 @@ event.add_match('alexriley', 'christian', 'curthawkins', 'darrenyoung',
|
|||||||
'tylerreks', 'tysonkidd', 'williamregal', 'yoshitatsu',
|
'tylerreks', 'tysonkidd', 'williamregal', 'yoshitatsu',
|
||||||
winner='christian', outcome='normal')
|
winner='christian', outcome='normal')
|
||||||
event.add_match(['kofikingston', 'rtruth'], ['dolphziggler', 'jackswagger'],
|
event.add_match(['kofikingston', 'rtruth'], ['dolphziggler', 'jackswagger'],
|
||||||
winner='kofikingston', outcome='normal', title_at_stake=True)
|
winner='kofikingston', outcome='normal', title_at_stake='tag')
|
||||||
event.add_match('layla', 'bethphoenix', winner='layla',
|
event.add_match('layla', 'bethphoenix', winner='layla',
|
||||||
outcome='normal', title_at_stake=True)
|
outcome='normal', title_at_stake='divas')
|
||||||
event.add_match('sheamus', 'randyorton', 'chrisjericho', 'albertodelrio',
|
event.add_match('sheamus', 'randyorton', 'chrisjericho', 'albertodelrio',
|
||||||
winner='sheamus', outcome='normal', title_at_stake=True)
|
winner='sheamus', outcome='normal',
|
||||||
|
title_at_stake='heavyweight')
|
||||||
event.add_match('brodusclay', 'themiz', winner='brodusclay', outcome='normal')
|
event.add_match('brodusclay', 'themiz', winner='brodusclay', outcome='normal')
|
||||||
event.add_match('christian', 'codyrhodes', winner='christian', outcome='normal',
|
event.add_match('christian', 'codyrhodes', winner='christian',
|
||||||
title_at_stake=True)
|
outcome='normal', title_at_stake='ic')
|
||||||
_give_belt('christian', 'ic')
|
_give_belt('christian', 'ic')
|
||||||
event.add_match('cmpunk', 'danielbryan', winner='cmpunk', outcome='normal',
|
event.add_match('cmpunk', 'danielbryan', winner='cmpunk', outcome='normal',
|
||||||
title_at_stake=True)
|
title_at_stake='wwe')
|
||||||
event.add_match('ryback', 'camacho', winner='ryback', outcome='normal')
|
event.add_match('ryback', 'camacho', winner='ryback', outcome='normal')
|
||||||
event.add_match('john-laurinaitis', 'johncena', 'bigshow',
|
event.add_match('john-laurinaitis', 'johncena', 'bigshow',
|
||||||
winner='john-laurinaitis',
|
winner='john-laurinaitis',
|
||||||
|
Loading…
Reference in New Issue
Block a user