-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_multiroom.dc
More file actions
59 lines (52 loc) · 1.59 KB
/
Copy path03_multiroom.dc
File metadata and controls
59 lines (52 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Example 3: Multi-Room Navigation
// Demonstrates a connected world graph with four rooms and multiple exits.
// Tests that the compiler validates all exit targets.
room "village" {
description "A peaceful village with cobblestone streets."
item map { detail: "worn", pages: 10 }
exit north "forest"
exit east "market"
}
room "forest" {
description "Tall pines block the sunlight. Something rustles in the undergrowth."
npc wolf { health: 30, hostile: true }
exit south "village"
exit east "cave"
}
room "market" {
description "Merchants hawk their wares. The smell of fresh bread fills the air."
item bread { nutrition: 20, type: "food" }
item potion { healing: 50, type: "consumable" }
exit west "village"
}
room "cave" {
description "A dark cave. Dripping water echoes. Treasure glints in the shadows."
item treasure { value: 500, type: "gold" }
exit west "forest"
}
action "take map" {
if current_room == "village" {
player.inventory += map
print "You pick up the worn map. Useful for navigation."
} else {
print "There is no map here."
}
}
action "take treasure" {
if current_room == "cave" {
player.inventory += treasure
player.gold = 500
print "You scoop up the gold coins. You are rich!"
player.win = true
} else {
print "There is no treasure here."
}
}
action "buy bread" {
if current_room == "market" {
player.inventory += bread
print "The merchant smiles as you hand over a coin."
} else {
print "You are not at the market."
}
}