Goals, Hints, and Scores:Goalcard Longhand
Goalcards are a system for creating, managing, and displaying a player's goals. Goals can be displayed inline or in a modal dialog managed by the GoalManager. The longhand method shown here offers a bit more control than the shorthand method, by letting authors create goal objects directly. The longhand method takes plain Javascript objects, and uses them to build goal data objects. Each goal consists minimally of a name and descriptive text, with several optional properties.
example code
MyGame.goalcard.set({
introduction: `These are my goals. `,
goals: {
"find shelter": {
active: true,
text: `You must find shelter.`,
complete: false,
complete_text: `You found shelter.`,
},
"find water": {
active: true,
text: `You must find water.`,
complete_text: `You found water.`,
active: false,
},
"find food": {
active: true,
text: `You must find food.`,
complete_text: `You found food.`,
active: false,
},
},
});
example game: inline goals
By default, AdventureJS responds to the player typing goals by printing a list of goals inline, as in this small example game.
var MyGame = new adventurejs.Game("MyGame", "MyGameDisplay");
MyGame.settings.set({
use_goals_window: false,
show_completed_goals: true,
});
MyGame.goalcard.set({
introduction: `Here are your current goals. `,
goals: {
"find shelter": {
active: true,
text: `You must find shelter.`,
complete: true,
complete_text: `You found shelter.`,
},
"find water": {
active: true,
text: `You must find water.`,
complete_text: `You found water.`,
},
"find food": {
active: true,
text: `You must find food.`,
complete_text: `You found food.`,
},
"find warmth": {
active: true,
text: `You must find warmth.`,
complete_text: `You found warmth.`,
},
"find direction": {
active: false,
text: `You must find your sense of direction.`,
complete_text: `You found direction.`,
},
"Life at School": {
active: false,
text: `The education of a young artist.`,
complete_text: ``,
goals: {
"Learn to act": {
active: false,
text: `Take an acting class.`,
complete_text: `You trod the boards.`,
},
"Learn to paint": {
active: false,
text: `Take an painting class.`,
complete_text: `You painted the town red.`,
},
"Learn to sculpt": {
active: false,
text: `Take an pottery class.`,
complete_text: `You threw that pot good.`,
},
}
},
},
})
example game: windowed goals
Alternatively, it is possible to set goals to appear in a pop-up window
similar to the windows used for hints, by setting
game.settings.use_goals_window, as in the following example
game.
var MyAltGame = new adventurejs.Game("MyAltGame", "MyGameAltDisplay");
MyAltGame.settings.set({
use_goals_window: true,
show_completed_goals: true,
});
MyAltGame.disableAllVerbsBut(["goal"]);
MyAltGame.createAsset({
class: "Room",
name: "Goal Room",
description: `The Goal Room has only one feature. Type GOAL or GOALS to see a list of goals. `,
});
MyAltGame.createAsset({
class: "Player",
name: "MyHero",
});
MyAltGame.goalcard.set({
introduction: `Here are your current goals. `,
goals: {
"find shelter": {
active: true,
text: `You must find shelter.`,
complete: true,
complete_text: `You found shelter.`,
},
"find water": {
active: true,
text: `You must find water.`,
complete_text: `You found water.`,
},
"find food": {
active: true,
text: `You must find food.`,
complete_text: `You found food.`,
},
"find warmth": {
active: true,
text: `You must find warmth.`,
complete_text: `You found warmth.`,
},
"find direction": {
active: false,
text: `You must find regain your sense of direction.`,
complete_text: `You found direction.`,
},
"Life at School": {
active: false,
text: `The education of a young artist.`,
complete_text: ``,
goals: {
"Learn to act": {
active: false,
text: `Take an acting class.`,
complete_text: `You trod the boards.`,
},
"Learn to paint": {
active: false,
text: `Take an painting class.`,
complete_text: `You painted the town red.`,
},
"Learn to sculpt": {
active: false,
text: `Take an pottery class.`,
complete_text: `You threw that pot good.`,
},
}
},
},
});