offset start of day
This commit is contained in:
parent
dd999a89eb
commit
4116951919
|
@ -16,6 +16,7 @@ class TimeOfDay:
|
||||||
end: int
|
end: int
|
||||||
|
|
||||||
|
|
||||||
|
GAME_START_HOUR = 8
|
||||||
TURNS_PER_DAY = 24
|
TURNS_PER_DAY = 24
|
||||||
|
|
||||||
TIMES_OF_DAY: List[TimeOfDay] = [
|
TIMES_OF_DAY: List[TimeOfDay] = [
|
||||||
|
@ -28,22 +29,28 @@ TIMES_OF_DAY: List[TimeOfDay] = [
|
||||||
|
|
||||||
|
|
||||||
def get_time_of_day(turn: int) -> TimeOfDay:
|
def get_time_of_day(turn: int) -> TimeOfDay:
|
||||||
hour = turn % TURNS_PER_DAY
|
hour = (turn + GAME_START_HOUR) % TURNS_PER_DAY
|
||||||
for time in TIMES_OF_DAY:
|
for time in TIMES_OF_DAY:
|
||||||
if time.start <= hour <= time.end:
|
if time.start <= hour <= time.end:
|
||||||
return time
|
return time
|
||||||
return TIMES_OF_DAY[0]
|
return TIMES_OF_DAY[0]
|
||||||
|
|
||||||
|
|
||||||
|
def initialize_weather(world: World):
|
||||||
|
time_of_day = get_time_of_day(0)
|
||||||
|
for room in world.rooms:
|
||||||
|
room.attributes["time"] = time_of_day.name
|
||||||
|
|
||||||
|
|
||||||
def simulate_weather(world: World, turn: int, data: None = None):
|
def simulate_weather(world: World, turn: int, data: None = None):
|
||||||
time_of_day = get_time_of_day(turn)
|
time_of_day = get_time_of_day(turn)
|
||||||
for room in world.rooms:
|
for room in world.rooms:
|
||||||
room.attributes["time"] = time_of_day.name
|
room.attributes["time"] = time_of_day.name
|
||||||
|
|
||||||
|
|
||||||
def init_systems():
|
def init():
|
||||||
return [GameSystem("weather", simulate=simulate_weather)]
|
logic_systems = [load_logic(filename) for filename in LOGIC_FILES]
|
||||||
|
return [
|
||||||
|
*logic_systems,
|
||||||
def init_logic():
|
GameSystem("weather", initialize=initialize_weather, simulate=simulate_weather),
|
||||||
return [load_logic(filename) for filename in LOGIC_FILES]
|
]
|
||||||
|
|
Loading…
Reference in New Issue