-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_door.js
45 lines (42 loc) · 1.31 KB
/
game_door.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
'use strict';
class Door extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
let verb = this.props.verb;
let newMessage;
let newRoom = "room2";
if (this.props.interactStates.buttonPressed) {
if (verb === "push") {
newMessage = "The door swings wide open.";
this.props.changeRoom(newRoom);
} else if (verb === "look") {
newMessage = "It's a big heavy door, but now it's unlocked.";
} else if (verb === "pickUp") {
newMessage = "You can't pick that up";
} else if (verb === "use") {
newMessage = "You can't use that";
}
} else if (!this.props.interactStates.buttonPressed) {
if (verb === "push") {
newMessage = "Damn, that's heavy.";
} else if (verb === "look") {
newMessage = "It's a big, heavy, locked door";
} else if (verb === "pickUp") {
newMessage = "You can't pick that up";
} else if (verb === "use") {
newMessage = "You can't use that";
}
}
this.props.changeMessage(newMessage);
}
render() {
return (
<button type="button" className="btn btn-secondary" onClick={this.handleClick}>
Door
</button>
)
}
}