Commitments Design - UO-DFM/SimCityOttawa-Documentation GitHub Wiki

Overview

Commitments are events that have a random chance of showing up during active and offline gameplay. These events are guaranteed to conflict with an event in the players calendar and force them to decide between the events. Currently, the options to resolve a commitment include accepting the new event or declining the event in favor of the existing event.

Gameplay Rules

  • The probability of serving a commitment increases each in game minute until it succeeds (at which point the probability resets).
  • Commitments are capped at 5 served per in game week

Structure

The following attributes are inherent to each commitment and are required:

{
        "id": "Unique id used to manage commitments lists",
        "title": "Prompt for the commitment with context for why you are receiving this invite",
        "name": "Title used for the event in the calendar if they chose to accept",
        "description": "Explanation of how this event conflicts with your existing schedule",
        "duration": "Number of hours the event lasts",
        "requirements": "List of requirements that must be filled before serving this task (eg. has kids)",
        "options": {
            "accept": {
                "title": "Flavour text for accepting the event",
                "attributes": {
                    "personal": "personal attribute value for EVENT",
                    "family": "family attribute value for EVENT",
                    "community": "community attribute value for EVENT",
                    "wealth": "wealth attribute value for EVENT"
                }
            },
            "decline": {
                "title": "Flavour text for declining the event",
                "attributes": {
                    "personal": "personal attribute penalty for declining the event",
                    "family": "personal attribute penalty for declining the event",
                    "community": "personal attribute penalty for declining the event",
                    "wealth": "personal attribute penalty for declining the event"
                }
            }
        }
    }

Commitment Serving

When serving a commitment, the commitment list is filtered, a random element is chosen, and the event is generated. Completed commitments are not included in the list of possible commitments. The list is then filtered as the requirements are checked against the player state. Finally, a random commitment is selected from the resulting list and a event is generated for the commitment. The conflict is generated by looking at the future events (from today +1 and forward) that are equal to or longer than the duration of the commitment. The time for the commitment is set based on this conflicting time and is used as the expiry date. The commitment is added to the list of active commitments and remains there until it expires or is resolved

Active Serving

While actively playing the game, commitments have a chance to be served every in game minute. This starts at a default probability and is scaled up by a factor greater than 1 to increase the probability gradually. Once the random chance is successful in serving a commitment, the probability is reduced again to the default value. These probabilities should be modified to balance the frequency of serving commitments to the desired value. The only restriction on serving a commitment is the max number served that in game week. Regardless of the current probability, the game will not serve more than the max allowed commitments that week.

Offline Serving

Task Manager subscribes to the time jump event to detect when a player has resumed an ongoing game and serves tasks according to the amount of time passed. For the current week, a proportional number of tasks for the amount of time that has passed is served out of the total max tasks that week. If more than one week has passed, tasks are retroactively served for that week using the previous week as the start date in conflict generation.

Commitment Expiry

Active Expiry

Every minute, the game checks the list of active commitments for expiry. Once the time for which the commitment is scheduled arrives, it expires. The task is auto resolved through the "decline" option and the resulting effects (including point penalty) are applied.

Offline Expiry

Using the time jump event, Task Manager first serves all required tasks for the time passed. After this, all active commitments are checked for expiry. If any are scheduled for a time that is before the current game time, they are expired. The task is auto resolved through the "decline" option and the resulting effects (including point penalty) are applied.

Commitment Resolution

There are currently two available options for resolving a commitment: accept commitment or decline commitment

Accepting Commitment

When a commitment is accepted, an event is created using the title attribute for the time set at commitment serving. The event is then sent to schedule insertion manager and the task is removed from active commitments. The commitment id is added to the list of previous commitments to ensure it is not served to the player again (Note: This list is currently wiped each game save as there are not sufficient commitments to not serve them multiple times). ScheduleInsertionManager is responsible for attempting to add the conflicting event to the schedule and raise the conflict resolution window as a result.

Declining Commitment

A commitment can be declined in two ways. The first is done by selecting the decline option in the commitment menu. This will result in the point penalty being applied. The task is removed from active commitments and the commitment id is added to the list of previous commitments to ensure it is not served to the player again (Note: This list is currently wiped each game save as there are not sufficient commitments to not serve them multiple times). If the player chooses to accept the commitment and is sent to the conflict resolution window, there is a second chance to decline the commitment. If they chose to keep their original schedule, the point penalty will be applied.

Additional Design details

  • Commitments will be scheduled to conflict with an event of equal or greater duration
  • Task manager will search the calendar for a valid event in the range of one day in the future to infinity
  • Commitments will be filtered by matching requirements to player status (eg. working obstetrics)