Spielerando

Work out when a place is open, including nights that cross midnight

The tavern opens at eight in the evening and closes at two, and your game says it is shut at one in the morning. Here is the small rule for opening hours that run past midnight, closed days and the answer to "how long until it opens".

Why this works

A night that runs past midnight belongs to the day it started, so asking whether a place is open means looking at today and at yesterday's late hours. Writing hours as data per day, instead of clock strings, makes the answer fall out of a simple comparison.

When not to use it

Skip it when a place is always open, never open on a schedule, or opens only through story events. A rule keyed to the clock adds nothing there. Let the plot or a simple flag say whether the door is unlocked.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • A diagram of every state
  • 31 lines of example code with 4 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Work out when a place is open, including nights that cross midnight" (read_entry shop-hours-that-cross-midnight) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP