Goals, Hints, and Scores:Goalcard Shorthand
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 shorthand method shown here uses a form of markdown to define a set of goals. The shorthand method accepts text in a markdown format, and uses it to build goal data objects. Each goal consists of a name, descriptive text, and optional completed text.
Example Code
MyGame.goalcard.set({
introduction: `Here are your current goals. `,
goals: `
Find shelter | You must find shelter. | You found shelter. | +
Find water | You must find water. | You found water. | +
Find food | You must find food. | You found food. | +
Find warmth | You must find warmth. | You found warmth. | +
# Life at School | The education of a young artist.
# - Learn to act | Take an acting class. | You trod the boards.
# - Learn to paint | Take a painting class. | You painted the town red.
# - Learn to sculpt | Take a pottery class. | You threw that pot good.
`,
})
Shorthand Cheatsheet
-
Use a
|as a separator in the text of a goal to definename,text, and optionalcomplete_text. - Use
#to define a group. - Use
# -to define a goal under a group. - Use multiple
##to define nested groups. - End a goal with
|+to mark it as initially active.
Shorthand Explained
-
Use plain text with no leading character to define a singular goal. Use a
|as a separator in the text of a goal to definename,text, and optionalcomplete_text. The order must benamefirst,textsecond,complete_textthird.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + `, }); -
goal.nameisn't presented to players; it gives the author a way to refer to the goal in code.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + `, }); MyGame.gamecard.completeGoal("Find shelter"); -
goal.textis the description presented to players in goal lists.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + `, });> goals- You must find shelter.
-
goal.complete_textis optional. Completed goals may or may not appear in goal lists depending on the value ofgame.settings.show_completed_goals. If it's true, and a completed goal has completed text, the completed text will appear in the goal list. Completed goals are given CSS classajs-completed-goal; their appearance can be customized by editing the CSS class.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + Find food | You must find food. | You found food. | + `, });> goals- You found shelter.
- You must find food.
-
Use
#to define a group of goals.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + # Life at School | The education of a young artist. | + # - Learn to act | Take an acting class. | You trod the boards. | + `, }); -
Use
# -to define a nested goal.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + # Life at School | The education of a young artist. | + # - Learn to act | Take an acting class. | You trod the boards. | + `, });> goals- You found shelter.
-
The education of a young artist.
- Take an acting class.
-
Use multiple hash marks
##to define nested groups of goals.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + # Life at School | The education of a young artist. | + # - Learn to act | Take an acting class. | You trod the boards. | + ## Winter Break | The mystery deepens. | + ## - Snowman | Follow the footprints. | You found The Snowman. | + `, });> goals- You found shelter.
-
The education of a young artist.
- Take an acting class.
-
The mystery deepens.
- Follow the footprints.
-
End a goal with
| +to mark it as initially active. It must be the last item, regardless of how many pipes the goal text has.Expand for example
MyGame.goalcard.set({ introduction: `Here are your current goals. `, goals: ` Find shelter | You must find shelter. | You found shelter. | + Find water | You must find water. | You found water. Find food | You must find food. | You found food. `, });> goals- You must find shelter.
#TMI Why would I deactivate a goal?
Goals are made inactive by default unless specified otherwise. This
means that all goals will be hidden at the start of the game, so that
you can control when they are made available to players. Activate goals
when the player reaches a relevant level of progress, via the
game.goalcard.activateGoal() method.
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 | You must find shelter. | You found shelter. | +
Find water | You must find water. | You found water. | +
Find food | You must find food. | You found food. | +
Find warmth | You must find warmth. | You found warmth. | +
Find direction | You must find your sense of direction. | You found direction. | +
# Life at School | The education of a young artist. | +
# - Learn to act | Take an acting class. | You trod the boards. | +
# - Learn to paint | Take a painting class. | You painted the town red. | +
# - Learn to sculpt | Take a pottery class. | 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 | You must find shelter. | You found shelter. | +
Find water | You must find water. | You found water. | +
Find food | You must find food. | You found food. | +
Find warmth | You must find warmth. | You found warmth. | +
# Life at School | The education of a young artist. | +
# - Learn to act | Take an acting class. | You trod the boards. | +
# - Learn to paint | Take a painting class. | You painted the town red. | +
# - Learn to sculpt | Take a pottery class. | You threw that pot good. | +
`,
});