mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-25 16:33:20 +08:00
Fixed meteor shower
This commit is contained in:
parent
017e09bb5f
commit
6c033e35d2
@ -164,7 +164,7 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
|||||||
# Augment standard behavior.
|
# Augment standard behavior.
|
||||||
super().handlemessage(msg)
|
super().handlemessage(msg)
|
||||||
|
|
||||||
death_time = ba.time()
|
death_time = ba.time(timeformat=ba.TimeFormat.MILLISECONDS)
|
||||||
|
|
||||||
# Record the player's moment of death.
|
# Record the player's moment of death.
|
||||||
msg.spaz.player.gamedata['death_time'] = death_time
|
msg.spaz.player.gamedata['death_time'] = death_time
|
||||||
@ -240,8 +240,10 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
|||||||
self._meteor_time = max(0.01, self._meteor_time * 0.9)
|
self._meteor_time = max(0.01, self._meteor_time * 0.9)
|
||||||
|
|
||||||
def end_game(self) -> None:
|
def end_game(self) -> None:
|
||||||
cur_time = ba.time()
|
cur_time = ba.time(timeformat=ba.TimeFormat.MILLISECONDS)
|
||||||
assert self._timer is not None
|
assert self._timer is not None
|
||||||
|
start_time = self._timer.getstarttime(
|
||||||
|
timeformat=ba.TimeFormat.MILLISECONDS)
|
||||||
|
|
||||||
# Mark 'death-time' as now for any still-living players
|
# Mark 'death-time' as now for any still-living players
|
||||||
# and award players points for how long they lasted.
|
# and award players points for how long they lasted.
|
||||||
@ -252,13 +254,14 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
|||||||
# Throw an extra fudge factor in so teams that
|
# Throw an extra fudge factor in so teams that
|
||||||
# didn't die come out ahead of teams that did.
|
# didn't die come out ahead of teams that did.
|
||||||
if 'death_time' not in player.gamedata:
|
if 'death_time' not in player.gamedata:
|
||||||
player.gamedata['death_time'] = cur_time + 0.001
|
player.gamedata['death_time'] = cur_time + 1
|
||||||
|
|
||||||
# Award a per-player score depending on how many seconds
|
# Award a per-player score depending on how many seconds
|
||||||
# they lasted (per-player scores only affect teams mode;
|
# they lasted (per-player scores only affect teams mode;
|
||||||
# everywhere else just looks at the per-team score).
|
# everywhere else just looks at the per-team score).
|
||||||
score = int(player.gamedata['death_time'] -
|
score = int(player.gamedata['death_time'] -
|
||||||
self._timer.getstarttime())
|
self._timer.getstarttime(
|
||||||
|
timeformat=ba.TimeFormat.MILLISECONDS))
|
||||||
if 'death_time' not in player.gamedata:
|
if 'death_time' not in player.gamedata:
|
||||||
score += 50 # a bit extra for survivors
|
score += 50 # a bit extra for survivors
|
||||||
self.stats.player_scored(player, score, screenmessage=False)
|
self.stats.player_scored(player, score, screenmessage=False)
|
||||||
@ -281,8 +284,7 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
|||||||
longest_life = 0
|
longest_life = 0
|
||||||
for player in team.players:
|
for player in team.players:
|
||||||
longest_life = max(longest_life,
|
longest_life = max(longest_life,
|
||||||
(player.gamedata['death_time'] -
|
player.gamedata['death_time'] - start_time)
|
||||||
self._timer.getstarttime()))
|
|
||||||
results.set_team_score(team, longest_life)
|
results.set_team_score(team, longest_life)
|
||||||
|
|
||||||
self.end(results=results)
|
self.end(results=results)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user