-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.html
208 lines (162 loc) · 8.8 KB
/
project.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<style>
body {
background-image: url("woodBackGround.jpg");
background-repeat: repeat-x;
}
h1 {
color: orange;
text-align: center;
}
div {
width: 500px;
height: 350px;
padding: 10px;
border: 5px solid gray;
margin: 100px 150px 100px 370px;
background-color: black;
color: orange;
text-align: left;
font-size: 15px;
}
input{
width:500px;
height:30px;
display:block;
background: black;
border: none;
right: 0;
top: 10;
color: orange;
}
</style>
<html>
<body>
<h1>
Samuel's Great Adventure
<div id="TEXT">
<text id="textBox">Welcome to Samuel's Great Adventure!<br>Type 'Start' to begin...</text>
<input id="textField" type="text" onclick="value=''" onkeydown="if (event.keyCode == 13)
conjunction(value)" value="Enter Text Here"><br>
<script>
/*Take the user's input and do something with it*/
var currentCard = {};
var started = 0;
function displayText(card) {
var textOut = card[Object.keys(card)[0]] + "<br/>";
for (var key in card["choices"]) {
if (card["choices"].hasOwnProperty(key)){
textOut += ( "<br/>" + key + ". " + card["choices"][Object.keys(card["choices"])[key-1]][0] );
}
}
document.getElementById("textBox").innerHTML = textOut;
}
function conjunction(userInput) {
//userInput = document.getElementById("textField").innerHTML;
var listOfCards = [ {2 : "You try and get yourself off of your feet, but you fall back down. You try again to get up, slower this time, and succeed", "choices" : {1 : ["Look around", 3] , 2 : ["Check inventory", 4] , 3 : ["Leave", 5]}},
{3 : "You try to scan your surroundings, but it is almost pitch black, as the rain clouds are covering the moon.", "choices" : {1 : ["Check inventory", 4] , 2 : ["Leave", 5]}},
{4 : "Patting down your clothes, you realize that your money belt and your gun are both missing.", "choices" : {1 : ["Look around", 3] , 2 : ["Leave", 5]}},
{5 : "You start to leave when your boot hits a rock and you trip. Since you cannot see, you figure that you need some kind of torch", "choices" : {1 : ["Gather wood", 6] , 2 : ["Make a rain cover", 7]}},
{6 : "After searching around, you find a dead tree. Pulling hard on a lower limb, you break it off", "choices" : {1 : ["Find flammable material", 8]}},
{7 : "You think it best that you make some sort of cover, so the rain will not put out the fire. You remove your shirt, and hold it above your head", "choices" : {1 : ["Gather wood", 6]}},
{8 : "Remembering that you have a small flask of whiskey hidden in your left boot, you pull it out and douse your shirt with it.", "choices" : {1 : ["Start fire", 9]}},
{9 : "You pull out a bullet from your right boot that you always keep hidden in case you ever get left for dead in the middle of nowhere. You take a great bite into the bullet and pry it from the casing. Taking your small boot knife, you then pry out the primer from the casing. Now, you look around for something to hit the primer with.", "choices" : {1 : ["Knife", 10] , 2 : ["Whiskey bottle", 11] }},
{10 : "You hit the primer with your knife, but nothing happens. You look for something else to try.", "choices" : {1 : ["Whiskey bottle", 11]}},
{11 : "Picking up the empty whiskey bottle, you hit the primer as hard as you can. It goes off, igniting the gun powder and the whiskey. You now have a torch that you can see with.", "choices" : {1 : ["Start walking", 13], 2 : ["Drink whiskey", 12]}},
{12 : "You take a swig from your whiskey bottle, but it is bone dry, as you emptied it onto the torch.", "choices" : {1 : ["Start walking", 13]}},
{13 : "Since you can now see your hand in front of your face, you begin to walk in the direction you believe is north. Thankfully, the rain has stopped, and you can see the moon piercing through the clouds. After about an hour, you come to what looks like an abandoned cabin.", "choices" : {1 : ["Keep walking", 14] , 2 : ["Enter cabin", 15]}},
{14 : "Leaving the cabin, you keep heading towards the North (you think)."},
{15 : "Approaching the cabin, you knock on the door and wait for a minute, but nobody answers.", "choices" : {1 : ["Leave", 14] , 2 : ["Open the door", 16]}},
{16 : "Upon finding the door to be unlocked, you proceed inside. You peer in and see a man sitting at his desk, slumped over. You approach him and find that he has been scalped, and his heart has been ripped out and is now pinned to the table with a bowie knife.", "choices" : {1 : ["Search the cabin", 17] , 2 : ["Search the body", 20] , 3 : ["Leave", 14]}},
{17 : "Looking around, you open the desk drawer and find a model 1849 Colt pocket revolver, and it appears to be loaded.", "choices" : {1 : ["Take it", 18] , 2 : ["Leave it", 19]}},
{18 : "You stick the revolver in your pants, figuring that you might encounter some bad characters in the future.", "choices" : {3 : ["Leave", 14]}},
{19 : "Thinking to yourself that the world is only full of basically nice, non-violent people, you leave the revolver.", "choices" : {3 : ["Leave", 14]}},
{20 : "Searching the dead body, you realize that his heart must have still been beating when it was cut out. Whomever did this must have done so in extreme anger, as they did not take any of his valuables.", "choices" : {1: ["Search the cabin", 17] , 2 : ["Leave", 14]}} ];
document.getElementById("textField").value = "";
var junk = document.getElementById("textBox").innerHTML;
//dialogue(document.getElementById("textBox").innerHTML);
if (started == 0){
currentCard = {1 : "You slowly wake up from a daze as you feel drops of water falling on your face", "choices" : {1 : ["Get up", 2]}};
}
else {
document.getElementById("textBox").innerHTML = userInput;
var nextCard = currentCard["choices"][userInput][1];
document.getElementById("textBox").innerHTML = nextCard;
currentCard = listOfCards[nextCard-2];
}
displayText(currentCard);
//document.getElementById("textField").innerHTML = currentCard[1];
started = 1;
}
function stockInventory(type){
if (type === "General Store"){
}
else if (type === "Undertaker"){
}
else if (type === "Saloon"){
}
else{
/*building does not sell things*/
return null
}
}
function townCard(parameters) {
}
function buildingCard(parameters) {
/*ex. Texas, New Mexico Territory*/
this.rootLocation = parameters["rootLocation"];
this.rootLocation = parameters["realLocation"];
this.buildingType = parameters["buildingType"];
this.name = parameters["name"];
this.inventory = stockInventory(this.buildingType);
}
function newMexico(parameters) {
this.rootLocation = "New Mexico Territory";
this.realLocation = "Outside";
this.weather = parameters["weather"];
this.terrain = parameters["terrain"];
this.dialogue = parameters["dialogue"];
this.cards = parameters["cards"];
}
function cardFactory() {}
cardFactory.prototype.createCard = function createGameCard(parameters) {
var cardType = null;
if (parameters["cardType"] === "Town") {
cardType = townCard;
}
else if (parameters["cardType"] === "Building") {
cardType = buildingCard;
}
else if (parameters["cardType"] === "Outside") {
cardType = outsideCard;
}
else {
return "Bad input: " + parameters["cardType"];
}
return new cardType(parameters);
/*cardFactory done*/
}
function openCardFile() {
var fileName = "c:/Users/Samuel/Documents/hcc/junk.txt";
var textFile = new File(fileName);
textFile.open("r");
while (!textFile.eof) {
alert(textFile.readln());
}
textFile.close();
}
function dialogue(){
arrOfCards = [ {"1" : createGameCard( {cardType : "Outside", rootLocation : "New Mexico Territory", realLocation : "Outside", weather : "Rain", terrain : "Desert" } ) },
{"2" : "2"},
{"3" : "3"},
{"4" : "4"},
{"5" : "5"},
{"6" : "6"}
];
rootCard = newMexico( {dialogue : "You slowly wake up from a daze as you feel drops of water falling on your face", terrain : "Desert", weather : "Rain" } );
}
</script>
</div>
</h1>
</body>
</html>