Implements animated events.

parent ae326fc8
......@@ -48,6 +48,8 @@ data SnapshotEvent =
sunder_event_target_tool :: ToolRef }
| TeleportEvent {
teleport_event_creature :: CreatureRef }
| SpawnEvent {
spawn_event_creature :: CreatureRef }
| ClimbEvent {
climb_event_direction :: ClimbDirection,
climb_event_creature :: CreatureRef }
......@@ -80,6 +82,7 @@ instance HasSubject SnapshotEvent where
DisarmEvent { disarm_event_source_creature = attacker_ref } -> Just attacker_ref
SunderEvent { sunder_event_source_creature = attacker_ref } -> Just attacker_ref
TeleportEvent { teleport_event_creature = creature_ref } -> Just creature_ref
SpawnEvent { spawn_event_creature = creature_ref } -> Just creature_ref
HealEvent { heal_event_creature = creature_ref } -> Just creature_ref
ClimbEvent { climb_event_creature = creature_ref } -> Just creature_ref
BumpEvent { bump_event_creature = creature_ref } -> Just creature_ref
......
......@@ -10,6 +10,7 @@ module Roguestar.Lib.Roguestar
retrieveGame,
getNumberOfGames,
getPlayerState,
getSnapshotPlayerState,
rerollStartingSpecies,
Creature(..),
TerrainPatch(..),
......@@ -17,6 +18,7 @@ module Roguestar.Lib.Roguestar
Facing(..),
Roguestar.Lib.Roguestar.beginGame,
perceive,
perceiveSnapshot,
behave,
Roguestar.Lib.Roguestar.facingBehavior,
Roguestar.Lib.Roguestar.hasSnapshot,
......@@ -248,6 +250,7 @@ unpackMessages_ WeaponExplodesEvent {} = return ["Your weapon explodes!"]
unpackMessages_ DisarmEvent {} = return ["Someone disarms someone else."]
unpackMessages_ SunderEvent {} = return ["The weapon has been sundered!"]
unpackMessages_ TeleportEvent {} = return ["You teleport."]
unpackMessages_ SpawnEvent {} = return ["A recreant materializes on the teleportation pad!"]
unpackMessages_ ClimbEvent {} = return ["You wonder through a network of tunnels."]
unpackMessages_ HealEvent {} = return ["You heal."]
unpackMessages_ ExpendToolEvent {} = return ["That material sphere has been used up."]
......
......@@ -96,7 +96,8 @@ spawnNPC terrain_type species plane_ref player_locations =
case m_spawn_position of
Nothing -> return False
Just spawn_position ->
do _ <- newCreature Monsters species (Standing plane_ref spawn_position Here)
do new_creature <- newCreature Monsters species (Standing plane_ref spawn_position Here)
dbPushSnapshot (SpawnEvent new_creature)
return True
dbPerform1CreatureAITurn :: CreatureRef -> DB ()
......
This diff is collapsed.
---
{ empty-game : true }
---
......@@ -4,6 +4,10 @@
<head>
<title>Roguestar</title>
<link rel="stylesheet" type="text/css" href="/static/roguebasic.css"/>
<script src="static/jquery-1.8.2.js" type="application/javascript"></script>
<script src="static/jquery.cookie-1.2.js" type="application/javascript"></script>
<script src="static/jquery.xcolor-1.8.js" type="application/javascript"></script>
<script src="static/roguebasic.js" type="application/javascript"></script>
</head>
<body>
<div id="main">
......
......@@ -28,14 +28,14 @@
<dd>Water. It's relatively safe.</dd>
<dt>
<pre class="A">
XXX
<pre class="B A">
###
X X
X X X
X X
# #
# # #
# #
XXX
###
</pre></dt>
<dd>A stargate. It is your escape route.</dd>
......
......@@ -18,8 +18,10 @@
<div id="version-history">
<h6>Roguestar 0.10.0</h6>
<ul>
<li>Animated events for javascript-enabled clients.</li>
<li>Color map.</li>
<li>Switched to mustache templates (hastache). You can append <code>?theme=json</code> to any URL to see (debug) the JSON data used to render each template.</li>
<li>Switched to mustache templates (hastache). You can append <code>?theme=json</code> to any URL to see/debug the JSON data used to render each template.</li>
<li>Fixed bug where stale sessions weren't being cleaned up.</li>
</ul>
<h6>Roguestar 0.8</h6>
......
This diff is collapsed.
/*jshint eqnull:true */
/*!
* jQuery Cookie Plugin v1.2
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2011, Klaus Hartl
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/GPL-2.0
*/
(function ($, document, undefined) {
var pluses = /\+/g;
function raw(s) {
return s;
}
function decoded(s) {
return decodeURIComponent(s.replace(pluses, ' '));
}
$.cookie = function (key, value, options) {
// key and at least value given, set cookie...
if (value !== undefined && !/Object/.test(Object.prototype.toString.call(value))) {
options = $.extend({}, $.cookie.defaults, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || $.cookie.defaults || {};
var decode = options.raw ? raw : decoded;
var cookies = document.cookie.split('; ');
for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) {
if (decode(parts.shift()) === key) {
return decode(parts.join('='));
}
}
return null;
};
$.cookie.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key, options) !== null) {
$.cookie(key, null, options);
return true;
}
return false;
};
})(jQuery, document);
This diff is collapsed.
......@@ -20,6 +20,8 @@
{{#statsblock}}
<pre>{{{text}}}</pre>
{{/statsblock}}
{{#controls}}
<form action="/play/move" method="post">
<div>
......@@ -52,6 +54,13 @@
<button type="submit" name="direction" value="se">SouthEast</button>
</div>
</div>
{{/controls}}
{{#is-snapshot}}
<form class="autosubmit-after-pause" action="/play/pop" method="post">
<button type="submit">Pop Next Event</button>
</form>
{{/is-snapshot}}
<a href="/help-actions" class="help">?</a>
......
......@@ -279,11 +279,16 @@ a:hover {
.mapcontent {
font-size: 12pt;
letter-spacing: 6.5pt;
text-align: center;
white-space: pre;
}
.mapcontent span {
text-align: center;
margin-left: 3.25pt;
margin-right: 3.25pt;
}
#gameplaybox .help {
position: absolute;
left: 476px;
......@@ -398,4 +403,21 @@ a:hover {
/* Gloomy */
.g {
color: #0000FF;
}
/* Warp-In Effect */
.warpin {
color: #000000;
background: #FF55FF;
}
.damage {
color: #000000;
background: #FF0000;
}
.active {
border: solid;
border-width: 1px;
border-color: #444444;
}
\ No newline at end of file
var roguestar_preferences = {
animation_thread_interval : 100,
strong_magic_colors : ['FFFF00', '00FFFF', 'FF00FF'],
weak_magic_colors : ['AAAA55', '55AAAA', 'AA55AA'],
water_colors : ['0000FF', '1122FF', '2244FF', '3366FF', '4488FF', '3366FF', '2244FF', '1122FF' ]
}
$('document').ready(function() {
//Let the server know we have javascript
$.cookie('javascript', 'enabled', { expires: 1, path: '/play' });
//Form buttons that need to be automatically submitted, possibly after a pause while we do an animation.
$('.autosubmit').hide();
$('.autosubmit-after-pause').hide();
setTimeout(
function() {
$('.autosubmit').submit();
},
100);
setTimeout(
function() {
$('.autosubmit-after-pause').submit();
},
calculateDelayTime());
runAnimationThread();
});
function calculateDelayTime() {
if( $('.warpin').length )
return 1500;
return 500;
}
function animateViaCSS( css_class, css_property, color_gradient, date ) {
var n = date.getSeconds() + date.getMinutes()*60 + date.getHours()*24;
var color_1 = color_gradient[n%color_gradient.length];
var color_2 = color_gradient[(n+1)%color_gradient.length];
$(css_class).css(css_property,
$.xcolor.gradientlevel(color_1, color_2, date.getMilliseconds(), 1000));
}
function runAnimationThread() {
var date = new Date();
animateViaCSS( '.A', 'color', roguestar_preferences.strong_magic_colors, date );
animateViaCSS( '.a', 'color', roguestar_preferences.weak_magic_colors, date );
animateViaCSS( '.w', 'color', roguestar_preferences.water_colors, date );
animateViaCSS( '.warpin', 'background-color', roguestar_preferences.strong_magic_colors, date );
setTimeout( runAnimationThread, roguestar_preferences.animation_thread_interval );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment