Routine
Initialize
To initialize a commitment, create a new instance of the CommitmentBaseModel class (or your custom class) and add it to the game commitment dictionary when the game is initialized.
RegisteredCommitments.add is required to save the commitments in the game.
import { RegisteredCommitments, CommitmentBaseModel } from "@drincs/nqtr";
import { narration } from "@drincs/pixi-vn";
export const aliceSleep = new CommitmentBaseModel("alice_sleep", "alice", {
priority: 1,
timeSlot: {
from: 20,
to: 10,
},
onRun: async (_, props) => {
await props.navigate({ to: "/game/narration" });
await narration.jump("talk_alice_sleep", props);
},
});
export const aliceGoSchool = new CommitmentBaseModel("alice_go_school", "alice", {
timeSlot: {
from: 8,
to: 14,
},
priority: 2,
});
export const aliceSmokes = new CommitmentBaseModel("alice_smokes", "alice", {
timeSlot: {
from: 10,
to: 20,
},
onRun: async (_, props) => {
await props.navigate({ to: "/game/narration" });
await narration.jump("alice_talk_menu", props);
},
});
RegisteredCommitments.add(aliceSleep, aliceGoSchool, aliceSmokes);Link
For an commitment to be linked to a room, the room must be included in the Commitment instance. The relationship between a commitment and a room is one-to-many, meaning that a rooms can be linked to multiple commitments, but a commitment can only be linked to one room (a character cannot be in two places at the same time).
There are two ways to do this:
During game initialization
For a commitment to be available to the player, it must be linked to a room.
import { RegisteredRooms, RoomBaseModel } from "@drincs/nqtr";
import { mcHome } from "@/content/locations";
export const aliceRoom = new RoomBaseModel("alice_room", mcHome, {
name: "Alice room",
image: "location_aliceroom",
routine: ["alice_sleep"],
});
RegisteredRooms.add(aliceRoom);During the game
You can also link a commitment to a room during the game. This feature is useful if you want to temporarily add a commitment. The list of routine added this way will be included in your game saves.
To link a commitment to a room during the game, you can use the room.addCommitment method.
import { newLabel, showImageContainer } from "@drincs/pixi-vn";
import { terrace } from "@/content/rooms";
export const startLabel = newLabel("start", [
async () => {
terrace.addCommitment("alice_quest_talk");
},
]);Unlink
To detach a commitment from a room, you must first consider how it was linked.
If it was linked during the game initialization, it cannot be removed. However, you can add another commitment with the same character at the same time slot, so the character will be occupied with the new commitment and therefore will no longer be present in the previous room. By default, priority is given to the commitment added during gameplay over the one added during initialization, but this behavior can be modified using the priority property.
If it was linked during gameplay, it can be removed using the room.removeCommitment method.
import { routine } from "@drincs/nqtr";
routine.remove("alice_smokes");Get
To get a commitment by its id, use the RegisteredCommitments.get function.
import { RegisteredCommitments } from "@drincs/nqtr";
const aliceWorks = RegisteredCommitments.get("alice_works");Get all
To get all commitments, use the RegisteredCommitments.values function.
import { RegisteredCommitments } from "@drincs/nqtr";
const commitments = RegisteredCommitments.values();