gamefic-sdk 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/bin/gamefic +16 -0
  3. data/lib/gamefic-sdk.rb +4 -24
  4. data/lib/gamefic-sdk/diagram.rb +205 -0
  5. data/lib/gamefic-sdk/scaffold.rb +54 -0
  6. data/lib/gamefic-sdk/server.rb +81 -65
  7. data/lib/gamefic-sdk/shell.rb +22 -129
  8. data/lib/gamefic-sdk/tasks.rb +40 -0
  9. data/lib/gamefic-sdk/tasks/common.rb +21 -0
  10. data/lib/gamefic-sdk/tasks/ruby.rb +99 -0
  11. data/lib/gamefic-sdk/tasks/web.rb +82 -0
  12. data/lib/gamefic-sdk/version.rb +5 -5
  13. metadata +123 -139
  14. data/bin/gfk +0 -6
  15. data/html/core/engine.js +0 -114
  16. data/html/core/jquery.js +0 -5
  17. data/html/core/jquery.modal.css +0 -44
  18. data/html/core/jquery.modal.js +0 -225
  19. data/html/core/js.cookie.js +0 -137
  20. data/html/sinatra/engine.js +0 -65
  21. data/html/skins/hypertext/compass.png +0 -0
  22. data/html/skins/hypertext/index.html +0 -149
  23. data/html/skins/hypertext/style.css +0 -74
  24. data/html/skins/minimal/index.html.erb +0 -22
  25. data/html/skins/minimal/index.rb +0 -4
  26. data/html/skins/minimal/play.js +0 -36
  27. data/html/skins/minimal/style.css +0 -8
  28. data/html/skins/multimedia/close.png +0 -0
  29. data/html/skins/multimedia/index.html +0 -179
  30. data/html/skins/multimedia/mobile.css +0 -10
  31. data/html/skins/multimedia/spinner.gif +0 -0
  32. data/html/skins/multimedia/style.css +0 -186
  33. data/html/skins/standard/index.html.erb +0 -22
  34. data/html/skins/standard/index.rb +0 -4
  35. data/html/skins/standard/play.js +0 -18
  36. data/html/skins/standard/style.css +0 -73
  37. data/lib/gamefic-sdk/build.rb +0 -30
  38. data/lib/gamefic-sdk/config.rb +0 -126
  39. data/lib/gamefic-sdk/debug.rb +0 -4
  40. data/lib/gamefic-sdk/debug/action.rb +0 -30
  41. data/lib/gamefic-sdk/debug/plot.rb +0 -23
  42. data/lib/gamefic-sdk/platform.rb +0 -22
  43. data/lib/gamefic-sdk/platform/base.rb +0 -68
  44. data/lib/gamefic-sdk/platform/gfic.rb +0 -27
  45. data/lib/gamefic-sdk/platform/sinatra.rb +0 -98
  46. data/lib/gamefic-sdk/platform/web.rb +0 -176
  47. data/lib/gamefic-sdk/platform/web/app_config.rb +0 -81
  48. data/lib/gamefic-sdk/platform/web/engine.rb +0 -44
  49. data/lib/gamefic-sdk/platform/web/user.rb +0 -19
  50. data/lib/gamefic-sdk/shell/init.rb +0 -83
  51. data/lib/gamefic-sdk/shell/test.rb +0 -32
  52. data/scripts/save-restore-undo.plot.rb +0 -25
  53. data/scripts/snapshots.plot.rb +0 -16
  54. data/scripts/standard.plot.rb +0 -10
  55. data/scripts/standard/actions.plot.rb +0 -13
  56. data/scripts/standard/actions/drop.plot.rb +0 -19
  57. data/scripts/standard/actions/enter.plot.rb +0 -19
  58. data/scripts/standard/actions/go.plot.rb +0 -48
  59. data/scripts/standard/actions/insert.plot.rb +0 -37
  60. data/scripts/standard/actions/inventory.plot.rb +0 -9
  61. data/scripts/standard/actions/leave.plot.rb +0 -30
  62. data/scripts/standard/actions/look.plot.rb +0 -108
  63. data/scripts/standard/actions/nil.plot.rb +0 -36
  64. data/scripts/standard/actions/place.plot.rb +0 -41
  65. data/scripts/standard/actions/quit.plot.rb +0 -11
  66. data/scripts/standard/actions/take.plot.rb +0 -31
  67. data/scripts/standard/actions/talk.plot.rb +0 -27
  68. data/scripts/standard/actions/wait.plot.rb +0 -3
  69. data/scripts/standard/clothing.plot.rb +0 -4
  70. data/scripts/standard/clothing/actions.plot.rb +0 -4
  71. data/scripts/standard/clothing/actions/doff.plot.rb +0 -12
  72. data/scripts/standard/clothing/actions/drop.plot.rb +0 -8
  73. data/scripts/standard/clothing/actions/inventory.plot.rb +0 -14
  74. data/scripts/standard/clothing/actions/wear.plot.rb +0 -20
  75. data/scripts/standard/clothing/entities.plot.rb +0 -7
  76. data/scripts/standard/clothing/entities/clothing.plot.rb +0 -5
  77. data/scripts/standard/clothing/entities/coat.plot.rb +0 -3
  78. data/scripts/standard/clothing/entities/gloves.plot.rb +0 -3
  79. data/scripts/standard/clothing/entities/hat.plot.rb +0 -3
  80. data/scripts/standard/clothing/entities/pants.plot.rb +0 -3
  81. data/scripts/standard/clothing/entities/shirt.plot.rb +0 -3
  82. data/scripts/standard/clothing/entities/shoes.plot.rb +0 -3
  83. data/scripts/standard/container.plot.rb +0 -28
  84. data/scripts/standard/container/actions.plot.rb +0 -0
  85. data/scripts/standard/container/entities.plot.rb +0 -5
  86. data/scripts/standard/direction.plot.rb +0 -55
  87. data/scripts/standard/edible.plot.rb +0 -21
  88. data/scripts/standard/entities.plot.rb +0 -12
  89. data/scripts/standard/entities/character.plot.rb +0 -10
  90. data/scripts/standard/entities/fixture.plot.rb +0 -3
  91. data/scripts/standard/entities/item.plot.rb +0 -3
  92. data/scripts/standard/entities/portal.plot.rb +0 -44
  93. data/scripts/standard/entities/receptacle.plot.rb +0 -3
  94. data/scripts/standard/entities/room.plot.rb +0 -57
  95. data/scripts/standard/entities/rubble.plot.rb +0 -11
  96. data/scripts/standard/entities/scenery.plot.rb +0 -3
  97. data/scripts/standard/entities/supporter.plot.rb +0 -7
  98. data/scripts/standard/entities/thing.plot.rb +0 -7
  99. data/scripts/standard/give.plot.rb +0 -27
  100. data/scripts/standard/lockable.plot.rb +0 -79
  101. data/scripts/standard/modules.plot.rb +0 -9
  102. data/scripts/standard/modules/attachable.plot.rb +0 -12
  103. data/scripts/standard/modules/auto_takes.plot.rb +0 -50
  104. data/scripts/standard/modules/enterable.plot.rb +0 -15
  105. data/scripts/standard/modules/explicit_exits.plot.rb +0 -15
  106. data/scripts/standard/modules/itemizable.plot.rb +0 -18
  107. data/scripts/standard/modules/locale_description.plot.rb +0 -20
  108. data/scripts/standard/modules/parent-room.plot.rb +0 -9
  109. data/scripts/standard/modules/portable.plot.rb +0 -11
  110. data/scripts/standard/modules/use.plot.rb +0 -51
  111. data/scripts/standard/openable.plot.rb +0 -43
  112. data/scripts/standard/pathfinder.plot.rb +0 -65
  113. data/scripts/standard/queries.plot.rb +0 -21
  114. data/scripts/standard/test.plot.rb +0 -10
  115. data/scripts/undo.plot.rb +0 -13
@@ -1,65 +0,0 @@
1
- var Gamefic = (function() {
2
- var startCallbacks = [];
3
- var updateCallbacks = [];
4
- return {
5
- enableLogging: function() {
6
-
7
- },
8
-
9
- logAlias: function() {
10
-
11
- },
12
-
13
- canLog: function() {
14
- return false;
15
- },
16
-
17
- start: function() {
18
- var that = this;
19
- $.post('/start', function(response) {
20
- startCallbacks.forEach(function(callback) {
21
- callback();
22
- });
23
- that.update(response);
24
- });
25
- },
26
-
27
- update: function(response) {
28
- updateCallbacks.forEach(function(callback) {
29
- callback(response);
30
- });
31
- },
32
-
33
- receive: function(input) {
34
- var that = this;
35
- $.post('/update', {command: input}, function(response) {
36
- that.update(response);
37
- }).fail(function(response) {
38
- console.log('An error occurred');
39
- });
40
- },
41
-
42
- onUpdate: function(callback) {
43
- updateCallbacks.push(callback);
44
- },
45
-
46
- onStart: function(callback) {
47
- updateCallbacks.push(callback);
48
- },
49
-
50
- save: function(filename, data) {
51
- console.log('Saving ' + data);
52
- localStorage.setItem(filename, data);
53
- },
54
-
55
- restore: function(filename) {
56
- var json = localStorage.getItem(filename);
57
- var data = JSON.parse(json);
58
- var that = this;
59
- $.post('/restore', {snapshot: JSON.stringify(data)}, function(response) {
60
- console.log('Restored a snapshot.');
61
- that.update(response);
62
- });
63
- }
64
- }
65
- })();
@@ -1,149 +0,0 @@
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
- var regexp = new RegExp(name, 'g');
85
- var command = $(this).attr('data-command');
86
- html.find('*').each(function() {
87
- var par = $(this).closest('a');
88
- if (par.length == 0) {
89
- //$(this).html($(this).html().replace(regexp, '<a rel="gamefic" href="#" data-command="' + command + '">' + name + '</a>'));
90
- }
91
- });
92
- });
93
- $('#portals a').not('.disabled').each(function() {
94
- var name = $(this).attr('id').replace(/^(a |an |the )/i, '');
95
- var regexp = new RegExp(name, 'g');
96
- var command = $(this).attr('data-command');
97
- html.find('*').each(function() {
98
- var par = $(this).closest('a');
99
- if (par.length == 0) {
100
- $(this).html($(this).html().replace(regexp, '<a rel="gamefic" href="#" data-command="' + command + '">' + name + '</a>'));
101
- }
102
- });
103
- });
104
- $('#text').append(html);
105
- }
106
- },
107
- onConclude: function(response) {
108
- $('a[rel="gamefic"]').addClass('disabled');
109
- $('#text').append('<p><strong>' + response.prompt + '</strong></p>');
110
- }
111
- });
112
- });
113
- </script>
114
- </head>
115
- <body>
116
- <div id="gamefic_console">
117
- <div id="main">
118
- <div id="image"></div>
119
- <div id="text"></div>
120
- <div id="suggestions"></div>
121
- </div>
122
- <div id="aside">
123
- <div id="portals">
124
- <div id="compass">
125
- <div><a id="northwest" rel="gamefic" href="#" data-command="go northwest">NW</a></div>
126
- <div><a id="north" rel="gamefic" href="#" data-command="go north">N</a></div>
127
- <div><a id="northeast" rel="gamefic" href="#" data-command="go northeast">NE</a></div>
128
- <div><a id="west" rel="gamefic" href="#" data-command="go west">W</a></div>
129
- <div id="center"></div>
130
- <div><a id="east" rel="gamefic" href="#" data-command="go east">E</a></div>
131
- <div><a id="southwest" rel="gamefic" href="#" data-command="go southwest">SW</a></div>
132
- <div><a id="south" rel="gamefic" href="#" data-command="go south">S</a></div>
133
- <div><a id="southeast" rel="gamefic" href="#" data-command="go southeast">SE</a></div>
134
- </div>
135
- <div class="more"></div>
136
- </div>
137
- <div id="objects"></div>
138
- <div id="incidentals"></div>
139
- </div>
140
- <form action="" method="post">
141
- <label for="gamefic_command">&nbsp;</label>
142
- <input id="gamefic_command" type="text" name="command" value="" autocomplete="off" />
143
- <input type="submit" value="Enter" />
144
- </form>
145
- </div>
146
- <div id="dialog" style="display: none;">
147
- </div>
148
- </body>
149
- </html>
@@ -1,74 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
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>
@@ -1,4 +0,0 @@
1
- javascripts.push "core/jquery.js"
2
- javascripts.push "play.js"
3
-
4
- stylesheets.push "style.css"
@@ -1,36 +0,0 @@
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
- });
@@ -1,8 +0,0 @@
1
- #gamefic_console {
2
- max-width: 800px;
3
- margin: 0 auto;
4
- font-family: Arial, sans-serif;
5
- }
6
- #gamefic_controls {
7
- margin: 1em 0 1em 0;
8
- }
@@ -1,179 +0,0 @@
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>