1
0
Fork 0

offset start of day
Run Docker Build / build (push) Failing after 9s Details
Run Python Build / build (push) Failing after 16s Details

This commit is contained in:
Sean Sube 2024-05-27 09:01:10 -05:00
parent dd999a89eb
commit 4116951919
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 14 additions and 7 deletions

View File

@ -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] ]