mirror of
https://github.com/evennia/evennia.git
synced 2026-03-24 08:46:31 +01:00
PEP 8 whitespace comply, visual align
This commit is contained in:
parent
0f72f0f74c
commit
3d268eaa39
1 changed files with 14 additions and 11 deletions
|
|
@ -39,6 +39,7 @@ _GAME_EPOCH = None
|
|||
# Helper Script dealing in gametime (created by `schedule` function
|
||||
# below).
|
||||
|
||||
|
||||
class TimeScript(DefaultScript):
|
||||
"""Gametime-sensitive script."""
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ class TimeScript(DefaultScript):
|
|||
|
||||
# Access functions
|
||||
|
||||
|
||||
def runtime():
|
||||
"""
|
||||
Get the total runtime of the server since first start (minus
|
||||
|
|
@ -134,8 +136,9 @@ def gametime(absolute=False):
|
|||
gtime = epoch + (runtime() - GAME_TIME_OFFSET) * TIMEFACTOR
|
||||
return gtime
|
||||
|
||||
def real_seconds_until(sec=None, min=None, hour=None, day=None,
|
||||
month=None, year=None):
|
||||
|
||||
def real_seconds_until(sec=None, min=None, hour=None,
|
||||
day=None, month=None, year=None):
|
||||
"""
|
||||
Return the real seconds until game time.
|
||||
|
||||
|
|
@ -187,8 +190,9 @@ def real_seconds_until(sec=None, min=None, hour=None, day=None,
|
|||
seconds = (projected - current).total_seconds()
|
||||
return seconds / TIMEFACTOR
|
||||
|
||||
def schedule(callback, repeat=False, sec=None, min=None, hour=None,
|
||||
day=None, month=None, year=None):
|
||||
|
||||
def schedule(callback, repeat=False, sec=None, min=None,
|
||||
hour=None, day=None, month=None, year=None):
|
||||
"""
|
||||
Call a callback at a given in-game time.
|
||||
|
||||
|
|
@ -212,12 +216,12 @@ def schedule(callback, repeat=False, sec=None, min=None, hour=None,
|
|||
schedule(func, min=5, sec=0) # Will call 5 minutes past the next (in-game) hour.
|
||||
schedule(func, hour=2, min=30, sec=0) # Will call the next (in-game) day at 02:30.
|
||||
"""
|
||||
seconds = real_seconds_until(sec=sec, min=min, hour=hour, day=day,
|
||||
month=month, year=year)
|
||||
seconds = real_seconds_until(sec=sec, min=min, hour=hour,
|
||||
day=day, month=month, year=year)
|
||||
script = create_script("evennia.utils.gametime.TimeScript",
|
||||
key="TimeScript", desc="A gametime-sensitive script",
|
||||
interval=seconds, start_delay=True,
|
||||
repeats=-1 if repeat else 1)
|
||||
key="TimeScript", desc="A gametime-sensitive script",
|
||||
interval=seconds, start_delay=True,
|
||||
repeats=-1 if repeat else 1)
|
||||
script.db.callback = callback
|
||||
script.db.gametime = {
|
||||
"sec": sec,
|
||||
|
|
@ -229,6 +233,7 @@ def schedule(callback, repeat=False, sec=None, min=None, hour=None,
|
|||
}
|
||||
return script
|
||||
|
||||
|
||||
def reset_gametime():
|
||||
"""
|
||||
Resets the game time to make it start from the current time. Note that
|
||||
|
|
@ -238,5 +243,3 @@ def reset_gametime():
|
|||
global GAME_TIME_OFFSET
|
||||
GAME_TIME_OFFSET = runtime()
|
||||
ServerConfig.objects.conf("gametime_offset", GAME_TIME_OFFSET)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue