Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PyPlanet/PyPlanet
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvlk committed Aug 30, 2023
2 parents 236affc + 99a9860 commit cc0cada
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
commit = True
tag = False
current_version = 0.10.5
current_version = 0.11.0-rc1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>.*))?
serialize =
{major}.{minor}.{patch}-{release}
Expand Down
1 change: 0 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Apps
* Improvement: Live Rankings no longer displays Rounds/Team/Cup standings in warm-up.

* Bugfix: Fixing map info widget displaying author of the previous map by waiting for the map to be loaded (thanks to reaby) (#1191).
* Bugfix: Fixing live rankings displaying invalid added points due to ping issues, by sorting finishes list on every finish (thanks to skybaks).
* Bugfix: Fixing the reboot admin command on Windows machines (thanks to w1lla).
* Bugfix: Fixing duplicate karma votes, by adding a unique constraint and removing the duplicate votes (#998).

Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
# built documents.
#
# The short X.Y version.
version = '0.10.5'
version = '0.11.0-rc1'
# The full version, including alpha/beta/rc tags.
release = '0.10.5'
release = '0.11.0-rc1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pyplanet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
PyPlanet, a robust and simple Maniaplanet Server Controller for Python 3.6+.
Please see LICENSE file in root of project.
"""
__version__ = '0.10.5'
__version__ = '0.11.0-rc1'
__author__ = 'Tom Valk'
49 changes: 34 additions & 15 deletions pyplanet/apps/contrib/live_rankings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ async def nadeo_widget_change(self, *args, **kwargs):
if self.instance.game.game in ['tm', 'sm']:
self.instance.ui_manager.properties.set_visibility('round_scores', await self.setting_nadeo_live_ranking.get_value())
await self.instance.ui_manager.properties.send_properties()
else:
self.instance.ui_manager.properties.set_visibility('Rounds_SmallScoresTable', await self.setting_nadeo_live_ranking.get_value())
await self.instance.ui_manager.properties.send_properties()

async def race_widget_change(self, *args, **kwargs):
self.display_race_widget = await self.setting_race_ranking.get_value()
Expand All @@ -106,6 +109,13 @@ async def race_widget_change(self, *args, **kwargs):
else:
self.instance.ui_manager.properties.set_visibility('round_scores', await self.setting_nadeo_live_ranking.get_value())
await self.instance.ui_manager.properties.send_properties()
else:
if self.display_race_widget is True:
self.instance.ui_manager.properties.set_visibility('Rounds_SmallScoresTable', False)
await self.instance.ui_manager.properties.send_properties()
else:
self.instance.ui_manager.properties.set_visibility('Rounds_SmallScoresTable', await self.setting_nadeo_live_ranking.get_value())
await self.instance.ui_manager.properties.send_properties()

def is_mode_supported(self, mode):
mode = mode.lower()
Expand Down Expand Up @@ -254,24 +264,33 @@ async def player_finish(self, player, race_time, lap_time, cps, flow, is_end_rac
# In that case, no results should be processed as the player hasn't actually finished.
return

append_finish = True
if self.is_warming_up:
# During the warm-up, players can finish multiple times - only display the best time.
current_finishes = [x for x in self.current_finishes if x['login'] == player.login]
if len(current_finishes) > 0:
if race_time < current_finishes[0]['score']:
current_finishes[0]['score'] = race_time
append_finish = False

new_finish = dict(login=player.login, nickname=player.nickname, score=race_time, points_added=0)
self.current_finishes.append(new_finish)
self.current_finishes.sort(key=lambda x: (x['score']))
if append_finish:
self.current_finishes.append(new_finish)
else:
self.current_finishes.sort(key=lambda x: (x['score']))

if not self.is_warming_up:
for current_finish_index in range(len(self.current_finishes)):
current_finish = self.current_finishes[current_finish_index]
if len(self.points_repartition) > current_finish_index:
current_finish['points_added'] = self.points_repartition[current_finish_index]
else:
current_finish['points_added'] = self.points_repartition[(len(self.points_repartition) - 1)]

current_ranking = next((item for item in self.current_rankings if item['login'] == player.login), None)
if current_ranking is not None:
current_ranking['points_added'] = new_finish['points_added']
else:
new_ranking = dict(login=player.login, nickname=player.nickname, score=0, points_added=new_finish['points_added'])
self.current_rankings.append(new_ranking)
new_finish_rank = len(self.current_finishes) - 1
new_finish['points_added'] = self.points_repartition[new_finish_rank] \
if len(self.points_repartition) > new_finish_rank \
else self.points_repartition[(len(self.points_repartition) - 1)]

current_ranking = next((item for item in self.current_rankings if item['login'] == player.login), None)
if current_ranking is not None:
current_ranking['points_added'] = new_finish['points_added']
else:
new_ranking = dict(login=player.login, nickname=player.nickname, score=0, points_added=new_finish['points_added'])
self.current_rankings.append(new_ranking)

self.current_rankings.sort(key=lambda x: (-x['score'], -x['points_added']))
await self.widget.display()
Expand Down
3 changes: 3 additions & 0 deletions pyplanet/apps/contrib/live_rankings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ def get_widget_records(self, player=None):
return list_finishes

async def get_context_data(self):
self.widget_x = -124.5 if self.app.dedimania_enabled else -160
self.widget_y = 83.5 if self.app.dedimania_enabled else 12.5

self.record_amount = await self.app.setting_rankings_amount.get_value()
if self.record_amount < 15:
self.record_amount = 15
Expand Down

0 comments on commit cc0cada

Please sign in to comment.