Saturday, March 16, 2019

Rules for Every Room.

Now making a rule that applies to every room.

One final time, let's look at this bit of code.

After going to The Employee Break Area:
    Now concealment of the player is none;
    Continue the action.

Here the rule has to specifically be applied to the room we are entering. This can get really troublesome because as we add more rooms, we will need to add more rules like this for changing the value specific to that room. For example, say we create a new room to the south of the Employee Break Area.

[...  See other post for everything before...]
[ROOMS]

The Employee Break Area is a room. "A break room that is clearly for employees of some company.  The walls are littered with information about minimum wage, HR regulations, and so on.[if unvisited]  You aren't exactly sure how you have come to get here, but you hear voices...  Not good voices, coming from the distance and growing closer.[otherwise]  Those voices continue to get closer.[end if]  To the east and west you see a door."

Some Random New Room is a room. "You enter a technicolor room of wonderment.  You think to yourself, 'How on Earth did I get here?!'"
[..and so on...]

Some Random New Room is south of The Employee Break Area.

The problem here is that the players concealment is set to the value of none when entering the Employee Break Area. When moving into Some Random New Room, that value is never updated since there is no after rule that updates it. Adding a new after for each room can get really tiresome. Instead we can just create a single rule that updates the players concealment to either the default of none or whatever concealment we've given to the room.

First let's change our value concealment to not only apply to people but to rooms as well.

Concealment is a kind of value.
Concealment are none, fairly, mostly, and completely.
Concealment is usually none.
A person has a concealment.
A room has a concealment.

The new line here is A room has a concealment. This allows rooms to also have a concealment value. Since we have the Concealment is usually none. Any new room or person we create and not set their concealment explicitly, will default to having a concealment of none, which is great as opposed to "whatever value the room you just left had."

Next we need to assign a concealment value to the rooms we already have.

The concealment of the Employee Break Area is none.

[.. just do this for each room ..]

Finally we will write a generic rule to rule them all.

[CONCEALMENT]
After going to a room (called P):
    Now concealment of the player is concealment of P;
    Continue the action.

[EVENTS]
[...and so on...]

Here we create a after going to a room rule that will be checked every time we enter a room. By default concealment of a room will be none and so by default our player will receive a concealment of none as well.

This is way better than having an after for every room that we might enter.

No comments:

Post a Comment

Implementing Help in a Story