Make NHL team wins reflect series wins during playoffs
The win/loss values from the NHL data feed reset in the playoffs, but don't reflect the current series. Instead, they reflect the current win/loss total since the beginning of the playoffs. This commit checks for a key in the API return data indicating that the game is a playoff game, and if the game is a playoff game the team's wins will be set to the remainder of the total wins divided by 4 (a team with 6 overall wins will be assumed to have 2 wins in the current playoff series). The team's losses during a playoff series will be set to the amount of wins for the opposing team.
This commit is contained in:
parent
4611295475
commit
8f9c878689
@ -53,6 +53,33 @@ class NHL(ScoresBackend):
|
|||||||
formatter will show ``OT`` kor ``SO``. If the game ended in regulation,
|
formatter will show ``OT`` kor ``SO``. If the game ended in regulation,
|
||||||
or has not yet completed, this formatter will be blank.
|
or has not yet completed, this formatter will be blank.
|
||||||
|
|
||||||
|
.. rubric:: Playoffs
|
||||||
|
|
||||||
|
In the playoffs, losses are not important (as the losses will be equal to
|
||||||
|
the other team's wins). Therefore, it is a good idea during the playoffs to
|
||||||
|
manually set format strings to exclude information on team losses. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from i3pystatus import Status
|
||||||
|
from i3pystatus.scores import nhl
|
||||||
|
|
||||||
|
status = Status()
|
||||||
|
status.register(
|
||||||
|
'scores',
|
||||||
|
hints={'markup': 'pango'},
|
||||||
|
colorize_teams=True,
|
||||||
|
favorite_icon='<span size="small" color="#F5FF00">★</span>',
|
||||||
|
backends=[
|
||||||
|
nhl.NHL(
|
||||||
|
favorite_teams=['CHI'],
|
||||||
|
format_pregame = '[{scroll} ]NHL: [{away_favorite} ]{away_abbrev} ({away_wins}) at [{home_favorite} ]{home_abbrev} ({home_wins}) {start_time:%H:%M %Z}',
|
||||||
|
format_final = '[{scroll} ]NHL: [{away_favorite} ]{away_abbrev} {away_score} ({away_wins}) at [{home_favorite} ]{home_abbrev} {home_score} ({home_wins}) (Final[/{overtime}])',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
.. rubric:: Team abbreviations
|
.. rubric:: Team abbreviations
|
||||||
|
|
||||||
* **ANA** — Anaheim Ducks
|
* **ANA** — Anaheim Ducks
|
||||||
@ -262,6 +289,14 @@ class NHL(ScoresBackend):
|
|||||||
'linescore:teams:%s:goaliePulled' % team,
|
'linescore:teams:%s:goaliePulled' % team,
|
||||||
lambda x: self.empty_net if x else '')
|
lambda x: self.empty_net if x else '')
|
||||||
|
|
||||||
|
if game.get('gameType') == 'P':
|
||||||
|
for team in ('home', 'away'):
|
||||||
|
# Series wins are the remainder of dividing wins by 4
|
||||||
|
ret['_'.join((team, 'wins'))] %= 4
|
||||||
|
# Series losses are the other team's wins
|
||||||
|
ret['home_losses'] = ret['away_wins']
|
||||||
|
ret['away_losses'] = ret['home_wins']
|
||||||
|
|
||||||
_update('status',
|
_update('status',
|
||||||
'status:abstractGameState',
|
'status:abstractGameState',
|
||||||
lambda x: x.lower().replace(' ', '_'))
|
lambda x: x.lower().replace(' ', '_'))
|
||||||
|
Loading…
Reference in New Issue
Block a user