gamefic-sdk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/html/core/engine.js +89 -0
- data/html/core/jquery.js +5 -0
- data/html/core/jquery.modal.css +44 -0
- data/html/core/jquery.modal.js +225 -0
- data/html/core/js.cookie.js +137 -0
- data/html/skins/hypertext/compass.png +0 -0
- data/html/skins/hypertext/index.html +151 -0
- data/html/skins/hypertext/style.css +74 -0
- data/html/skins/minimal/index.html.erb +22 -0
- data/html/skins/minimal/play.js +36 -0
- data/html/skins/minimal/style.css +8 -0
- data/html/skins/multimedia/close.png +0 -0
- data/html/skins/multimedia/index.html +179 -0
- data/html/skins/multimedia/mobile.css +10 -0
- data/html/skins/multimedia/spinner.gif +0 -0
- data/html/skins/multimedia/style.css +186 -0
- data/html/skins/standard/index.html.erb +23 -0
- data/html/skins/standard/play.js +68 -0
- data/html/skins/standard/style.css +70 -0
- data/lib/gamefic-sdk/version.rb +1 -1
- data/scripts/ansi.plot.rb +13 -0
- data/scripts/autosuggest.plot.rb +171 -0
- data/scripts/clothing.plot.rb +2 -0
- data/scripts/clothing/actions.plot.rb +4 -0
- data/scripts/clothing/actions/doff.plot.rb +12 -0
- data/scripts/clothing/actions/drop.plot.rb +8 -0
- data/scripts/clothing/actions/inventory.plot.rb +14 -0
- data/scripts/clothing/actions/wear.plot.rb +19 -0
- data/scripts/clothing/entities.plot.rb +7 -0
- data/scripts/clothing/entities/clothing.plot.rb +7 -0
- data/scripts/clothing/entities/coat.plot.rb +5 -0
- data/scripts/clothing/entities/gloves.plot.rb +5 -0
- data/scripts/clothing/entities/hat.plot.rb +5 -0
- data/scripts/clothing/entities/pants.plot.rb +5 -0
- data/scripts/clothing/entities/shirt.plot.rb +5 -0
- data/scripts/clothing/entities/shoes.plot.rb +5 -0
- data/scripts/cover.plot.rb +30 -0
- data/scripts/debug.plot.rb +0 -0
- data/scripts/edible.plot.rb +19 -0
- data/scripts/furniture.plot.rb +35 -0
- data/scripts/hints.plot.rb +31 -0
- data/scripts/hypertext.plot.rb +280 -0
- data/scripts/media.plot.rb +17 -0
- data/scripts/multimedia.plot.rb +41 -0
- data/scripts/questions.plot.rb +17 -0
- data/scripts/room-modes.plot.rb +48 -0
- data/scripts/rough-sizes.plot.rb +36 -0
- data/scripts/save-restore.plot.rb +21 -0
- data/scripts/snapshots.plot.rb +14 -0
- data/scripts/standard.plot.rb +12 -0
- data/scripts/standard/actions.plot.rb +23 -0
- data/scripts/standard/actions/close.plot.rb +16 -0
- data/scripts/standard/actions/drop.plot.rb +11 -0
- data/scripts/standard/actions/enter.plot.rb +31 -0
- data/scripts/standard/actions/give.plot.rb +26 -0
- data/scripts/standard/actions/go.plot.rb +81 -0
- data/scripts/standard/actions/insert.plot.rb +47 -0
- data/scripts/standard/actions/inventory.plot.rb +8 -0
- data/scripts/standard/actions/leave.plot.rb +41 -0
- data/scripts/standard/actions/lock.plot.rb +59 -0
- data/scripts/standard/actions/look-under.plot.rb +8 -0
- data/scripts/standard/actions/look.plot.rb +102 -0
- data/scripts/standard/actions/nil.plot.rb +35 -0
- data/scripts/standard/actions/open.plot.rb +34 -0
- data/scripts/standard/actions/place.plot.rb +36 -0
- data/scripts/standard/actions/quit.plot.rb +11 -0
- data/scripts/standard/actions/read.plot.rb +3 -0
- data/scripts/standard/actions/search.plot.rb +39 -0
- data/scripts/standard/actions/show.plot.rb +13 -0
- data/scripts/standard/actions/take.plot.rb +49 -0
- data/scripts/standard/actions/talk.plot.rb +31 -0
- data/scripts/standard/actions/unlock.plot.rb +77 -0
- data/scripts/standard/actions/use.plot.rb +25 -0
- data/scripts/standard/actions/wait.plot.rb +3 -0
- data/scripts/standard/entities.plot.rb +12 -0
- data/scripts/standard/entities/character.plot.rb +9 -0
- data/scripts/standard/entities/container.plot.rb +11 -0
- data/scripts/standard/entities/door.plot.rb +53 -0
- data/scripts/standard/entities/entity.plot.rb +13 -0
- data/scripts/standard/entities/exterior.plot.rb +5 -0
- data/scripts/standard/entities/fixture.plot.rb +3 -0
- data/scripts/standard/entities/item.plot.rb +5 -0
- data/scripts/standard/entities/portal.plot.rb +37 -0
- data/scripts/standard/entities/receptacle.plot.rb +4 -0
- data/scripts/standard/entities/room.plot.rb +47 -0
- data/scripts/standard/entities/rubble.plot.rb +11 -0
- data/scripts/standard/entities/scenery.plot.rb +5 -0
- data/scripts/standard/entities/supporter.plot.rb +10 -0
- data/scripts/standard/modules.plot.rb +11 -0
- data/scripts/standard/modules/attachable.plot.rb +11 -0
- data/scripts/standard/modules/auto_takes.plot.rb +50 -0
- data/scripts/standard/modules/darkenable.plot.rb +6 -0
- data/scripts/standard/modules/enterable.plot.rb +15 -0
- data/scripts/standard/modules/explicit_exits.plot.rb +15 -0
- data/scripts/standard/modules/itemizable.plot.rb +18 -0
- data/scripts/standard/modules/lockable.plot.rb +25 -0
- data/scripts/standard/modules/openable.plot.rb +9 -0
- data/scripts/standard/modules/parent-room.plot.rb +9 -0
- data/scripts/standard/modules/portable.plot.rb +6 -0
- data/scripts/standard/modules/transparent.plot.rb +6 -0
- data/scripts/standard/pathfinder.plot.rb +60 -0
- data/scripts/standard/plural.plot.rb +2 -0
- data/scripts/standard/plural/actions.plot.rb +4 -0
- data/scripts/standard/plural/actions/drop.plot.rb +126 -0
- data/scripts/standard/plural/actions/insert.plot.rb +68 -0
- data/scripts/standard/plural/actions/place.plot.rb +37 -0
- data/scripts/standard/plural/actions/take.plot.rb +175 -0
- data/scripts/standard/plural/queries.plot.rb +5 -0
- data/scripts/standard/plural/queries/ambiguous_visible.plot.rb +13 -0
- data/scripts/standard/plural/queries/any_expression.plot.rb +17 -0
- data/scripts/standard/plural/queries/many_visible.plot.rb +13 -0
- data/scripts/standard/plural/queries/not_expression.plot.rb +16 -0
- data/scripts/standard/plural/queries/plural_visible.plot.rb +22 -0
- data/scripts/standard/queries.plot.rb +4 -0
- data/scripts/standard/queries/from_expression.plot.rb +16 -0
- data/scripts/standard/queries/reachable.plot.rb +48 -0
- data/scripts/standard/queries/room.plot.rb +17 -0
- data/scripts/standard/queries/visible.plot.rb +45 -0
- data/scripts/standard/rules.plot.rb +1 -0
- data/scripts/standard/rules/has-enough-light.plot.rb +12 -0
- data/scripts/standard/test.plot.rb +8 -0
- data/scripts/standard/use.plot.rb +29 -0
- data/scripts/suggestible.plot.rb +42 -0
- data/scripts/undo.plot.rb +11 -0
- metadata +149 -25
Binary file
|
@@ -0,0 +1,151 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>{{title}} by {{author}}</title>
|
5
|
+
<link rel="stylesheet" type="text/css" href="style.css" />
|
6
|
+
<script type="text/javascript" src="opal.js"></script>
|
7
|
+
<script type="text/javascript" src="gamefic.js"></script>
|
8
|
+
<script type="text/javascript" src="static.js"></script>
|
9
|
+
<script type="text/javascript" src="game.js"></script>
|
10
|
+
<script type="text/javascript" src="engine.js"></script>
|
11
|
+
<script type="text/javascript" src="connection.js"></script>
|
12
|
+
<script type="text/javascript" src="jquery.js"></script>
|
13
|
+
<link rel="stylesheet" type="text/css" href="jquery.modal.css" />
|
14
|
+
<script type="text/javascript" src="jquery.modal.js"></script>
|
15
|
+
<script type="text/javascript" src="js.cookie.js"></script>
|
16
|
+
<script type="text/javascript">
|
17
|
+
$(function() {
|
18
|
+
Gamefic.Connection.init({
|
19
|
+
onUpdate: function(response) {
|
20
|
+
switch(response.state) {
|
21
|
+
case 'MultipleChoice':
|
22
|
+
$('#text').append(response.output);
|
23
|
+
var lines = response.prompt.split("\n");
|
24
|
+
response.prompt = lines.join('<br/>');
|
25
|
+
lines.pop();
|
26
|
+
response.output += "<ol class=\"multiple-choice\">";
|
27
|
+
for (i = 0; i < lines.length; i++) {
|
28
|
+
response.output += "<li><a href=\"#\" rel=\"gamefic\" data-command=\"" + (i + 1) + "\">" + lines[i].substr((i + 1).toString().length + 2) + "</a></li>";
|
29
|
+
}
|
30
|
+
response.output += "</ol>";
|
31
|
+
$('#dialog').html(response.output);
|
32
|
+
$('#dialog').modal({
|
33
|
+
opacity: 0.25,
|
34
|
+
zIndex: 9999,
|
35
|
+
escapeClose: false,
|
36
|
+
clickClose: false,
|
37
|
+
showClose: false
|
38
|
+
});
|
39
|
+
break;
|
40
|
+
default:
|
41
|
+
$.modal.close();
|
42
|
+
$('#image').html('');
|
43
|
+
$('#text').html('');
|
44
|
+
$('#objects').html('');
|
45
|
+
$('#suggestions').html('');
|
46
|
+
$('#incidentals').html('');
|
47
|
+
$('#gamefic_command').val('');
|
48
|
+
$('a[rel="gamefic"]').addClass('disabled');
|
49
|
+
if (response.state != 'Concluded' && response.command) {
|
50
|
+
$('#text').append('<p><kbd class="log">' + response.prompt + ' ' + response.command + '</kbd></p>');
|
51
|
+
}
|
52
|
+
var html = $('<div>' + response.output + '</div>');
|
53
|
+
html.find('nav.portals a').each(function() {
|
54
|
+
var cp = $('#' + $(this).text());
|
55
|
+
if (cp.length) {
|
56
|
+
cp.removeClass('disabled');
|
57
|
+
} else {
|
58
|
+
$('#portals.more').append($(this));
|
59
|
+
}
|
60
|
+
});
|
61
|
+
html.find('nav.portals').remove();
|
62
|
+
html.find('nav.characters a').each(function() {
|
63
|
+
$('#objects').append($(this));
|
64
|
+
});
|
65
|
+
html.find('nav.characters').remove();
|
66
|
+
html.find('nav.objects a').each(function() {
|
67
|
+
$('#objects').append($(this));
|
68
|
+
});
|
69
|
+
html.find('nav.objects').remove();
|
70
|
+
html.find('nav.incidentals a').each(function() {
|
71
|
+
$('#incidentals').append($(this));
|
72
|
+
});
|
73
|
+
html.find('nav.incidentals').remove();
|
74
|
+
html.find('nav.suggestions a').each(function() {
|
75
|
+
$('#suggestions').append($(this));
|
76
|
+
});
|
77
|
+
html.find('nav.suggestions').remove();
|
78
|
+
html.find('img').each(function() {
|
79
|
+
$(this).remove();
|
80
|
+
$('#image').html($(this));
|
81
|
+
});
|
82
|
+
$('#objects a, #incidentals a').each(function() {
|
83
|
+
var name = $(this).text().replace(/^(a |an |the )/i, '');
|
84
|
+
console.log('Object: ' + name);
|
85
|
+
var regexp = new RegExp(name, 'g');
|
86
|
+
var command = $(this).attr('data-command');
|
87
|
+
html.find('*').each(function() {
|
88
|
+
var par = $(this).closest('a');
|
89
|
+
if (par.length == 0) {
|
90
|
+
//$(this).html($(this).html().replace(regexp, '<a rel="gamefic" href="#" data-command="' + command + '">' + name + '</a>'));
|
91
|
+
}
|
92
|
+
});
|
93
|
+
});
|
94
|
+
$('#portals a').not('.disabled').each(function() {
|
95
|
+
var name = $(this).attr('id').replace(/^(a |an |the )/i, '');
|
96
|
+
console.log('Object: ' + name);
|
97
|
+
var regexp = new RegExp(name, 'g');
|
98
|
+
var command = $(this).attr('data-command');
|
99
|
+
html.find('*').each(function() {
|
100
|
+
var par = $(this).closest('a');
|
101
|
+
if (par.length == 0) {
|
102
|
+
$(this).html($(this).html().replace(regexp, '<a rel="gamefic" href="#" data-command="' + command + '">' + name + '</a>'));
|
103
|
+
}
|
104
|
+
});
|
105
|
+
});
|
106
|
+
$('#text').append(html);
|
107
|
+
}
|
108
|
+
},
|
109
|
+
onConclude: function(response) {
|
110
|
+
$('a[rel="gamefic"]').addClass('disabled');
|
111
|
+
$('#text').append('<p><strong>' + response.prompt + '</strong></p>');
|
112
|
+
}
|
113
|
+
});
|
114
|
+
});
|
115
|
+
</script>
|
116
|
+
</head>
|
117
|
+
<body>
|
118
|
+
<div id="gamefic_console">
|
119
|
+
<div id="main">
|
120
|
+
<div id="image"></div>
|
121
|
+
<div id="text"></div>
|
122
|
+
<div id="suggestions"></div>
|
123
|
+
</div>
|
124
|
+
<div id="aside">
|
125
|
+
<div id="portals">
|
126
|
+
<div id="compass">
|
127
|
+
<div><a id="northwest" rel="gamefic" href="#" data-command="go northwest">NW</a></div>
|
128
|
+
<div><a id="north" rel="gamefic" href="#" data-command="go north">N</a></div>
|
129
|
+
<div><a id="northeast" rel="gamefic" href="#" data-command="go northeast">NE</a></div>
|
130
|
+
<div><a id="west" rel="gamefic" href="#" data-command="go west">W</a></div>
|
131
|
+
<div id="center"></div>
|
132
|
+
<div><a id="east" rel="gamefic" href="#" data-command="go east">E</a></div>
|
133
|
+
<div><a id="southwest" rel="gamefic" href="#" data-command="go southwest">SW</a></div>
|
134
|
+
<div><a id="south" rel="gamefic" href="#" data-command="go south">S</a></div>
|
135
|
+
<div><a id="southeast" rel="gamefic" href="#" data-command="go southeast">SE</a></div>
|
136
|
+
</div>
|
137
|
+
<div class="more"></div>
|
138
|
+
</div>
|
139
|
+
<div id="objects"></div>
|
140
|
+
<div id="incidentals"></div>
|
141
|
+
</div>
|
142
|
+
<form action="" method="post">
|
143
|
+
<label for="gamefic_command"> </label>
|
144
|
+
<input id="gamefic_command" type="text" name="command" value="" autocomplete="off" />
|
145
|
+
<input type="submit" value="Enter" />
|
146
|
+
</form>
|
147
|
+
</div>
|
148
|
+
<div id="dialog" style="display: none;">
|
149
|
+
</div>
|
150
|
+
</body>
|
151
|
+
</html>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
html {
|
2
|
+
margin: 0;
|
3
|
+
padding: 0;
|
4
|
+
}
|
5
|
+
body {
|
6
|
+
margin: 0;
|
7
|
+
padding: 0;
|
8
|
+
}
|
9
|
+
#gamefic_console {
|
10
|
+
width: 800px;
|
11
|
+
margin: 0 auto;
|
12
|
+
}
|
13
|
+
#main {
|
14
|
+
width: 600px;
|
15
|
+
float: left;
|
16
|
+
overflow: hidden;
|
17
|
+
}
|
18
|
+
#aside {
|
19
|
+
width: 200px;
|
20
|
+
float: left;
|
21
|
+
overflow: hidden;
|
22
|
+
}
|
23
|
+
a {
|
24
|
+
color: blue;
|
25
|
+
font-weight: bold;
|
26
|
+
text-decoration: underline;
|
27
|
+
}
|
28
|
+
a.disabled {
|
29
|
+
color: gray;
|
30
|
+
text-decoration: none;
|
31
|
+
}
|
32
|
+
#compass {
|
33
|
+
width: 180px;
|
34
|
+
height: 180px;
|
35
|
+
background-image: url('compass.png');
|
36
|
+
background-position: center center;
|
37
|
+
background-repeat: no-repeat;
|
38
|
+
}
|
39
|
+
#compass div {
|
40
|
+
width: 60px;
|
41
|
+
height: 40px;
|
42
|
+
float: left;
|
43
|
+
text-align: center;
|
44
|
+
font-size: 20px;
|
45
|
+
padding-top: 20px;
|
46
|
+
}
|
47
|
+
#gamefic_console form {
|
48
|
+
display: none;
|
49
|
+
}
|
50
|
+
#suggestions {
|
51
|
+
margin: 1em 0 1em 0;
|
52
|
+
}
|
53
|
+
#suggestions a {
|
54
|
+
display: block;
|
55
|
+
float: left;
|
56
|
+
border: 2px solid blue;
|
57
|
+
text-decoration: none;
|
58
|
+
padding: 0 1em 0 1em;
|
59
|
+
margin-right: 1em;
|
60
|
+
margin-bottom: 0.5em;
|
61
|
+
}
|
62
|
+
#objects, #incidentals {
|
63
|
+
margin: 1em 0 1em 0;
|
64
|
+
}
|
65
|
+
#incidentals {
|
66
|
+
font-size: small;
|
67
|
+
}
|
68
|
+
#objects a, #incidentals a {
|
69
|
+
display: block;
|
70
|
+
text-align: center;
|
71
|
+
border: 2px solid blue;
|
72
|
+
text-decoration: none;
|
73
|
+
margin: 0 10px 0.5em 10px;
|
74
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title>{{title}} by {{author}}</title>
|
6
|
+
<%= stylesheet_tags %>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id="gamefic_console">
|
10
|
+
<div id="gamefic_output">
|
11
|
+
</div>
|
12
|
+
<div id="gamefic_controls">
|
13
|
+
<form action="">
|
14
|
+
<span id="gamefic_prompt"></span>
|
15
|
+
<input type="text" name="command" id="gamefic_command" autocomplete="off" />
|
16
|
+
<button type="submit" id="gamefic_submit">Enter</button>
|
17
|
+
</form>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<%= javascript_tags %>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$(function() {
|
2
|
+
$('#gamefic_controls form').submit(function(event) {
|
3
|
+
event.preventDefault();
|
4
|
+
Gamefic.update($('#gamefic_command').val());
|
5
|
+
});
|
6
|
+
Gamefic.onStart(function(response) {
|
7
|
+
$('#gamefic_prompt').html(response.prompt);
|
8
|
+
});
|
9
|
+
Gamefic.onInput(function(response) {
|
10
|
+
$('#gamefic_controls').addClass('working');
|
11
|
+
});
|
12
|
+
Gamefic.onFinish(function(response) {
|
13
|
+
if (!response.testing) {
|
14
|
+
$('#gamefic_controls').removeClass('working');
|
15
|
+
}
|
16
|
+
$('#gamefic_command').val('');
|
17
|
+
$('#gamefic_command').focus();
|
18
|
+
window.scrollTo(0, document.body.scrollHeight);
|
19
|
+
});
|
20
|
+
Gamefic.handleResponse('Active', function(response) {
|
21
|
+
if (response.input != null) {
|
22
|
+
$('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
|
23
|
+
}
|
24
|
+
$('#gamefic_output').append(response.output);
|
25
|
+
});
|
26
|
+
Gamefic.handleResponse('Conclusion', function(response) {
|
27
|
+
if (response.input != null) {
|
28
|
+
$('#gamefic_output').append('<p><kbd>' + response.prompt + ' ' + response.input + '</kbd></p>');
|
29
|
+
}
|
30
|
+
$('#gamefic_console').addClass('concluded');
|
31
|
+
$('#gamefic_output').append(response.output);
|
32
|
+
$('#gamefic_controls').hide();
|
33
|
+
});
|
34
|
+
Gamefic.start();
|
35
|
+
$('#gamefic_command').focus();
|
36
|
+
});
|
Binary file
|
@@ -0,0 +1,179 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title>{{title}}</title>
|
6
|
+
<link rel="stylesheet" type="text/css" href="style.css" />
|
7
|
+
<script type="text/javascript" src="opal.js"></script>
|
8
|
+
<script type="text/javascript" src="gamefic.js"></script>
|
9
|
+
<script type="text/javascript" src="static.js"></script>
|
10
|
+
<script type="text/javascript" src="scripts.js"></script>
|
11
|
+
<script type="text/javascript" src="engine.js"></script>
|
12
|
+
<script type="text/javascript" src="connection.js"></script>
|
13
|
+
<script type="text/javascript" src="jquery.js"></script>
|
14
|
+
<link rel="stylesheet" type="text/css" href="jquery.modal.css" />
|
15
|
+
<script type="text/javascript" src="jquery.modal.js"></script>
|
16
|
+
<script type="text/javascript" src="js.cookie.js"></script>
|
17
|
+
<script type="text/javascript">
|
18
|
+
var appendOutput = function(output) {
|
19
|
+
$('#text').append('<div class="output">' + output + '</div>');
|
20
|
+
}
|
21
|
+
var modalSettings = {
|
22
|
+
opacity: 0.25,
|
23
|
+
zIndex: 9999,
|
24
|
+
escapeClose: false,
|
25
|
+
clickClose: false,
|
26
|
+
showClose: false
|
27
|
+
}
|
28
|
+
$(function() {
|
29
|
+
var lastResponse = null;
|
30
|
+
Gamefic.Connection.init({
|
31
|
+
onUpdate: function(response) {
|
32
|
+
if (lastResponse != null && lastResponse.state != 'Paused') {
|
33
|
+
if (response.command != null) {
|
34
|
+
appendOutput('<p><kbd class="log">' + lastResponse.prompt + ' ' + response.command + '</kbd></p>');
|
35
|
+
}
|
36
|
+
}
|
37
|
+
lastResponse = response;
|
38
|
+
$('#prompt').html('');
|
39
|
+
$('#controls').addClass('disabled');
|
40
|
+
$('#controls').find('input').attr('readonly', null);
|
41
|
+
$('a[rel="gamefic"]').addClass('disabled');
|
42
|
+
$('.output').addClass('history');
|
43
|
+
window.focus();
|
44
|
+
switch (response.state) {
|
45
|
+
case 'YesOrNo':
|
46
|
+
$('#dialog').html(response.output + '<p>' + response.prompt + '</p>' + '<nav><p><a class="yes" href="#" rel="gamefic" data-command="yes">Yes</a><a class="no" rel="gamefic" data-command="no" href="#">No</a></p></nav>');
|
47
|
+
$('#dialog a').click(function(evt) {
|
48
|
+
evt.preventDefault();
|
49
|
+
Gamefic.Connection.run($(this).attr('data-command'));
|
50
|
+
$('#dialog').html('');
|
51
|
+
$.modal.close();
|
52
|
+
});
|
53
|
+
$('#dialog').modal(modalSettings);
|
54
|
+
$('#dialog').focus();
|
55
|
+
break;
|
56
|
+
case 'MultipleChoice':
|
57
|
+
appendOutput(response.output);
|
58
|
+
var lines = response.prompt.split("\n");
|
59
|
+
response.prompt = lines.join('<br/>');
|
60
|
+
lines.pop();
|
61
|
+
response.output += "<ol class=\"multiple-choice\">";
|
62
|
+
for (i = 0; i < lines.length; i++) {
|
63
|
+
response.output += "<li><a href=\"#\" rel=\"gamefic\" data-command=\"" + (i + 1) + "\">" + lines[i].substr((i + 1).toString().length + 2) + "</a></li>";
|
64
|
+
}
|
65
|
+
response.output += "</ol>";
|
66
|
+
$('#dialog').html(response.output);
|
67
|
+
$('#dialog').modal(modalSettings);
|
68
|
+
$('#dialog').focus();
|
69
|
+
break;
|
70
|
+
case 'Prompted':
|
71
|
+
$('#dialog').html(response.output).append('<p>' + response.prompt + '</p>').append(
|
72
|
+
'<form id="dialogform"><div id="dialogline-container"><input id="dialogline" type="text" name="command" autocomplete="off" /></div><input id="dialogenter" type="submit" value="Enter" /></form>'
|
73
|
+
);
|
74
|
+
$('#dialog form').submit(function(evt) {
|
75
|
+
evt.preventDefault();
|
76
|
+
Gamefic.Connection.run($('#dialogline').val());
|
77
|
+
$('#dialog').html('');
|
78
|
+
$.modal.close();
|
79
|
+
});
|
80
|
+
$('#dialog').modal(modalSettings);
|
81
|
+
$('#dialogline').focus();
|
82
|
+
break;
|
83
|
+
case 'Paused':
|
84
|
+
$.modal.close();
|
85
|
+
appendOutput(response.output + '<p><a rel="gamefic" href="#" data-command="[enter]">' + response.prompt + '</a></p>');
|
86
|
+
break;
|
87
|
+
case 'Active':
|
88
|
+
$('#controls').removeClass('disabled');
|
89
|
+
$('#controls').find('input').attr('readonly', null);
|
90
|
+
$('#gamefic_command').focus();
|
91
|
+
default:
|
92
|
+
$.modal.close();
|
93
|
+
$.modal.close();
|
94
|
+
appendOutput(response.output);
|
95
|
+
$('#prompt').html(response.prompt == '>' ? 'What do you do?' : response.prompt);
|
96
|
+
if (response.state == 'Testing') {
|
97
|
+
$('#controls').addClass('disabled');
|
98
|
+
$('#controls').find('input').attr('disabled', 'disabled');
|
99
|
+
Gamefic.Connection.run(null);
|
100
|
+
} else {
|
101
|
+
$('#controls').find('input').attr('disabled', null);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
$(window).resize();
|
105
|
+
},
|
106
|
+
onConclude: function(response) {
|
107
|
+
appendOutput('<p><strong>' + response.prompt + '</strong></p><p><a href="#" onclick="location.reload()">Play Again?</a></p>');
|
108
|
+
$('#controls').hide();
|
109
|
+
$(window).resize();
|
110
|
+
}
|
111
|
+
});
|
112
|
+
$(window).resize(function(evt) {
|
113
|
+
var available = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
114
|
+
var reserved = $('#titlebar').outerHeight() + ($('#image-container').is(':visible') ? $('#image-container').outerHeight() : 0) + ($('#controls').is(':visible') ? $('#controls').outerHeight() : 0) + $('#footer').outerHeight();
|
115
|
+
var textHeight = (available - reserved) + 'px';
|
116
|
+
if ($('#text-container')[0].scrollHeight < available - reserved) {
|
117
|
+
textHeight = 'auto';
|
118
|
+
}
|
119
|
+
$('#text-container').css({height: textHeight});
|
120
|
+
$('#text-container').scrollTop($('#text-container')[0].scrollHeight);
|
121
|
+
});
|
122
|
+
$(window).keydown(function(evt) {
|
123
|
+
if (lastResponse.state == 'Paused' && evt.which == 13) {
|
124
|
+
evt.preventDefault();
|
125
|
+
Gamefic.Connection.run('');
|
126
|
+
} else if (lastResponse.state == 'YesOrNo') {
|
127
|
+
evt.preventDefault();
|
128
|
+
if (evt.which == 89) {
|
129
|
+
evt.preventDefault();
|
130
|
+
$('#dialog a.yes').click();
|
131
|
+
$('#dialog').html('');
|
132
|
+
$.modal.close();
|
133
|
+
} else if (evt.which == 78) {
|
134
|
+
evt.preventDefault();
|
135
|
+
$('#dialog a.no').click();
|
136
|
+
$('#dialog').html('');
|
137
|
+
$.modal.close();
|
138
|
+
}
|
139
|
+
} else if (lastResponse.state == 'MultipleChoice') {
|
140
|
+
evt.preventDefault();
|
141
|
+
var k = String.fromCharCode(evt.which);
|
142
|
+
var a = $('#dialog .multiple-choice a[rel="gamefic"][data-command="' + k + '"]');
|
143
|
+
if (a.length) {
|
144
|
+
a.click();
|
145
|
+
$('#dialog').html('');
|
146
|
+
$.modal.close();
|
147
|
+
}
|
148
|
+
}
|
149
|
+
});
|
150
|
+
});
|
151
|
+
</script>
|
152
|
+
</head>
|
153
|
+
<body>
|
154
|
+
<div id="gamefic_console">
|
155
|
+
<div id="image-container">
|
156
|
+
<div id="image"></div>
|
157
|
+
</div>
|
158
|
+
<div id="text-container">
|
159
|
+
<div id="text">
|
160
|
+
</div>
|
161
|
+
</div>
|
162
|
+
<div id="controls">
|
163
|
+
<p id="prompt"></p>
|
164
|
+
<form id="commandform" action="" method="post">
|
165
|
+
<input type="hidden" name="sessionid" value="@{session->id}@" />
|
166
|
+
<div id="commandline-container">
|
167
|
+
<input id="gamefic_command" type="text" name="command" autocomplete="off" />
|
168
|
+
</div>
|
169
|
+
<input id="commandenter" type="submit" value="Enter" />
|
170
|
+
</form>
|
171
|
+
</div>
|
172
|
+
<div id="footer">
|
173
|
+
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
<div id="dialog" style="display: none;">
|
177
|
+
</div>
|
178
|
+
</body>
|
179
|
+
</html>
|