-
Notifications
You must be signed in to change notification settings - Fork 2
/
basicgame.js
97 lines (94 loc) · 2.41 KB
/
basicgame.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
let r1 = {
_id: 1,
isHome: true,
desc: 'You are standing in an unremarkable room with a table in the middle.',
north: {
desc: 'On the north wall, there is a glowing blue portal.',
ref: 1,
},
east: {
desc: 'The east wall has a non-copyright-infringing orange portal.',
ref: 1,
},
south: {
desc: 'The south wall has a door.',
ref: 2,
},
west: {
desc: 'This is an open-concept home, so you see a room to the west too.',
ref: 3,
},
items: {
'win berry': {
desc: 'An item that sounds suspiciously like a win condition.',
use: function(hp, setHp, items, setItems, room, setRoom, setLocation, setVictory) {
setVictory(true);
return 'you eat the berry and win.';
}
},
},
onEnter: function(hp, setHp, items, setItems, room, setRoom, setLocation, setVictory) {
// Test no-return functions.
setHp(2 * (~~(hp / 2))); // Make HP even.
},
};
let r2 = {
_id: 2,
desc: 'This room is pretty dark. Try using a torch!',
north: {
desc: 'Just a door.',
ref: 1,
},
east: {
desc: 'East of here is a clear self-loop.',
ref: 2,
},
west: {
desc: 'An opening to the west lets you see another room.',
ref: 3,
},
actions: {
torch: function(hp, setHp, items, setItems, room, setRoom, setLocation, setVictory) {
setHp(hp - 1);
return 'LOL 😂 You don\'t know how to use torches. Lose one hp.';
}
},
};
let r3 = {
_id: 3,
desc: 'Woooooo it\'s the wild west!!! There\'s a treasure chest here.',
east: {
desc: 'The only exit out of the wild west is the one room to the East.',
ref: 1,
},
items: {
torch: {
desc: '🔥 🔥 🔥 🔥 '
},
banana: {
desc: 'I bet it tastes delicious!',
use: function(hp, setHp, items, setItems, room, setRoom, setLocation, setVictory) {
if (typeof items.plate === 'object') {
delete items.plate;
} else {
delete items.banana;
}
setItems(items);
setHp(hp + 7);
return 'Tasty! you feel much better';
},
},
plate: {
desc: 'Looks tasty?'
},
},
onEnter: function(hp, setHp, items, setItems, room, setRoom, setLocation, setVictory) {
delete room.onEnter;
setRoom(room);
return 'WEEEEEEEEEEEEEEEEEEEE!!1! welcome to the wild west.\nEnjoy your stay! 🐴';
},
};
db.basic.drop()
db.basic.insert(r1);
db.basic.insert(r2);
db.basic.insert(r3);