From: Joe Wreschnig Date: Sat, 20 Sep 2014 11:35:20 +0000 (+0200) Subject: Initial import. X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=ef44224f31c5f7e7c38f5b3909eecfcb93436ed0;p=ogre.git Initial import. --- ef44224f31c5f7e7c38f5b3909eecfcb93436ed0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b8bf82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +ogre.appcache +favicon.ico +favicon_32.png +favicon_128.png +favicon_192.png +favicon_256.png diff --git a/Checkbook.woff b/Checkbook.woff new file mode 100644 index 0000000..e8f6dff Binary files /dev/null and b/Checkbook.woff differ diff --git a/DejaVuSansMono.woff b/DejaVuSansMono.woff new file mode 100644 index 0000000..d59080a Binary files /dev/null and b/DejaVuSansMono.woff differ diff --git a/FiraSans-Regular.woff b/FiraSans-Regular.woff new file mode 100644 index 0000000..16e74f2 Binary files /dev/null and b/FiraSans-Regular.woff differ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..914e970 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +all: ogre.appcache + +appcache>contents = $(shell grep -vFx -e "*" -e "CACHE MANIFEST" -e "CACHE:" -e "NETWORK:" -e "FALLBACK:" $(1) | grep -v -e "^\#" ) + +.PHONY: all clean + +.SECONDEXPANSION: +%.appcache: %.appcache.in $$(call appcache>contents,$$*.appcache.in) + sed "s/$$/Last-Updated: `date -u +'%Y-%m-%dT%H:%M:%SZ'`/" $< > $@ + +CONVERT.svg.png ?= rsvg-convert -f png +CONVERT.png.ico ?= convert + +PNGCRUSH ?= pngcrush +PNGCRUSHFLAGS ?= -brute -blacken -reduce -q +CRUSH.png ?= $(PNGCRUSH) $(PNGCRUSHFLAGS) + +FAVICON_SIZES = 32 128 192 256 +FAVICONS = $(patsubst %,favicon_%.png,$(FAVICON_SIZES)) favicon.ico + +favicon_%.png: favicon.svg + $(CONVERT.svg.png) -w $* -h $* < $< > $@ + $(CRUSH.png) -ow $@ + +%.ico: %_48.png %_32.png %_16.png + $(CONVERT.png.ico) $^ $@ + +all: $(FAVICONS) ogre.appcache + +clean: + $(RM) $(FAVICONS) + $(RM) ogre.appcache diff --git a/brain.js b/brain.js new file mode 100644 index 0000000..0d8e692 --- /dev/null +++ b/brain.js @@ -0,0 +1,100 @@ +"use strict"; + +function randrange (lo, hi) { + return lo + (Math.random() * (hi - lo)) | 0; +} + +function shuffle (seq) { + for (var i = seq.length - 1; i > 0; --i) { + var index = randrange(0, i + 1); + var temp = seq[i]; + seq[i] = seq[index]; + seq[index] = temp; + } + return seq; +} + +var MOVEMENT = ["fore", "fore", "fore", "fore", "fore", + "left", "left", "left", + "right", "right", "right", + null]; +var RAMMING = ["none", "none", "fore", "fore", "aft"]; +var ORDER = ["nearest", "nearest", "nearest", + "threat", "strongest", "farthest"]; +var BREAKER = ["clockwise", "clockwise", + "anti-clockwise", "anti-clockwise"]; +var ARC = ["fore", "fore", "fore", "aft"]; + +var FIRING = ["spread fire, engage 1-1", + "spread fire, engage 1-1", + "spread fire, engage 1-1", + "focus fire, engage 2-1", + "focus fire, engage 2-1", + "concentrate all fire"]; +var MISSILES = [0.20, 0.10, 0.05]; + +function drop1 (seq) { + return shuffle(seq.slice()).slice(1); +} + +function Brain () { + var movement = drop1(MOVEMENT); + var ramming = drop1(RAMMING); + var order = drop1(ORDER); + var breaker = drop1(BREAKER); + var arc = drop1(ARC); + var firing = drop1(FIRING); + var missiles = choice(MISSILES) + + this.report = function (movePoints, hasMissiles) { + var ram = movePoints > 1 ? choice(ramming) : null; + var move = []; + for (var i = 0; i < movePoints; ++i) { + do { + var m = choice(movement); + } while ((m === "left" && move.indexOf("right") >= 0) + || (m === "right" && move.indexOf("left") >= 0)) + if (m) + move.push(m); + } + + var launch = 0; + while (hasMissiles && Math.random() < Math.pow(missiles, launch + 1)) + ++launch; + + var instr = []; + instr.push("sensors sweeping " + choice(breaker)); + if (ram === "aft") + instr.push("ram back if opportune"); + instr.push((ram === "aft" ? "otherwise " : "") + + "ahead " + move.join(", ")); + if (ram) + instr.push(" ramming if opportune"); + instr.push("target " + choice(order) + ", " + + choice(arc) + " first"); + instr.push(" " + choice(firing)); + if (hasMissiles) + instr.push("launch missiles at howitzers and key targets"); + if (launch) { + instr.push(" further expend up to " + launch + " missile(s)"); + instr.push(" on the " + choice(order) + " vehicle target(s)"); + } + + return instr.join("\n"); + } + return this; +} + +var brain, ttl; +function think () { + if (!(brain && ttl-- > 0)) { + brain = new Brain(); + ttl = Math.max(1, choice([2, 10, 18]) + randrange(-2, 3)); + } + document.getElementById('report').textContent = + brain.report(3, true, true).replace(/\w\S*/g, function (s) { + return ["and", "of", "if", "at"].indexOf(s) < 0 + ? s[0].toUpperCase() + s.slice(1) + : s; + }); +} diff --git a/fastclick.js b/fastclick.js new file mode 100644 index 0000000..2fda2a9 --- /dev/null +++ b/fastclick.js @@ -0,0 +1,818 @@ +/** + * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs. + * + * @version 1.0.2 + * @codingstandard ftlabs-jsv2 + * @copyright The Financial Times Limited [All Rights Reserved] + * @license MIT License (see LICENSE.txt) + */ + +/*jslint browser:true, node:true*/ +/*global define, Event, Node*/ + + +/** + * Instantiate fast-clicking listeners on the specified layer. + * + * @constructor + * @param {Element} layer The layer to listen on + * @param {Object} options The options to override the defaults + */ +function FastClick(layer, options) { + 'use strict'; + var oldOnClick; + + options = options || {}; + + /** + * Whether a click is currently being tracked. + * + * @type boolean + */ + this.trackingClick = false; + + + /** + * Timestamp for when click tracking started. + * + * @type number + */ + this.trackingClickStart = 0; + + + /** + * The element being tracked for a click. + * + * @type EventTarget + */ + this.targetElement = null; + + + /** + * X-coordinate of touch start event. + * + * @type number + */ + this.touchStartX = 0; + + + /** + * Y-coordinate of touch start event. + * + * @type number + */ + this.touchStartY = 0; + + + /** + * ID of the last touch, retrieved from Touch.identifier. + * + * @type number + */ + this.lastTouchIdentifier = 0; + + + /** + * Touchmove boundary, beyond which a click will be cancelled. + * + * @type number + */ + this.touchBoundary = options.touchBoundary || 10; + + + /** + * The FastClick layer. + * + * @type Element + */ + this.layer = layer; + + /** + * The minimum time between tap(touchstart and touchend) events + * + * @type number + */ + this.tapDelay = options.tapDelay || 200; + + if (FastClick.notNeeded(layer)) { + return; + } + + // Some old versions of Android don't have Function.prototype.bind + function bind(method, context) { + return function() { return method.apply(context, arguments); }; + } + + + var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel']; + var context = this; + for (var i = 0, l = methods.length; i < l; i++) { + context[methods[i]] = bind(context[methods[i]], context); + } + + // Set up event handlers as required + if (deviceIsAndroid) { + layer.addEventListener('mouseover', this.onMouse, true); + layer.addEventListener('mousedown', this.onMouse, true); + layer.addEventListener('mouseup', this.onMouse, true); + } + + layer.addEventListener('click', this.onClick, true); + layer.addEventListener('touchstart', this.onTouchStart, false); + layer.addEventListener('touchmove', this.onTouchMove, false); + layer.addEventListener('touchend', this.onTouchEnd, false); + layer.addEventListener('touchcancel', this.onTouchCancel, false); + + // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) + // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick + // layer when they are cancelled. + if (!Event.prototype.stopImmediatePropagation) { + layer.removeEventListener = function(type, callback, capture) { + var rmv = Node.prototype.removeEventListener; + if (type === 'click') { + rmv.call(layer, type, callback.hijacked || callback, capture); + } else { + rmv.call(layer, type, callback, capture); + } + }; + + layer.addEventListener = function(type, callback, capture) { + var adv = Node.prototype.addEventListener; + if (type === 'click') { + adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) { + if (!event.propagationStopped) { + callback(event); + } + }), capture); + } else { + adv.call(layer, type, callback, capture); + } + }; + } + + // If a handler is already declared in the element's onclick attribute, it will be fired before + // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and + // adding it as listener. + if (typeof layer.onclick === 'function') { + + // Android browser on at least 3.2 requires a new reference to the function in layer.onclick + // - the old one won't work if passed to addEventListener directly. + oldOnClick = layer.onclick; + layer.addEventListener('click', function(event) { + oldOnClick(event); + }, false); + layer.onclick = null; + } +} + + +/** + * Android requires exceptions. + * + * @type boolean + */ +var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0; + + +/** + * iOS requires exceptions. + * + * @type boolean + */ +var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent); + + +/** + * iOS 4 requires an exception for select elements. + * + * @type boolean + */ +var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent); + + +/** + * iOS 6.0(+?) requires the target element to be manually derived + * + * @type boolean + */ +var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent); + +/** + * BlackBerry requires exceptions. + * + * @type boolean + */ +var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0; + +/** + * Determine whether a given element requires a native click. + * + * @param {EventTarget|Element} target Target DOM element + * @returns {boolean} Returns true if the element needs a native click + */ +FastClick.prototype.needsClick = function(target) { + 'use strict'; + switch (target.nodeName.toLowerCase()) { + + // Don't send a synthetic click to disabled inputs (issue #62) + case 'button': + case 'select': + case 'textarea': + if (target.disabled) { + return true; + } + + break; + case 'input': + + // File inputs need real clicks on iOS 6 due to a browser bug (issue #68) + if ((deviceIsIOS && target.type === 'file') || target.disabled) { + return true; + } + + break; + case 'label': + case 'video': + return true; + } + + return (/\bneedsclick\b/).test(target.className); +}; + + +/** + * Determine whether a given element requires a call to focus to simulate click into element. + * + * @param {EventTarget|Element} target Target DOM element + * @returns {boolean} Returns true if the element requires a call to focus to simulate native click. + */ +FastClick.prototype.needsFocus = function(target) { + 'use strict'; + switch (target.nodeName.toLowerCase()) { + case 'textarea': + return true; + case 'select': + return !deviceIsAndroid; + case 'input': + switch (target.type) { + case 'button': + case 'checkbox': + case 'file': + case 'image': + case 'radio': + case 'submit': + return false; + } + + // No point in attempting to focus disabled inputs + return !target.disabled && !target.readOnly; + default: + return (/\bneedsfocus\b/).test(target.className); + } +}; + + +/** + * Send a click event to the specified element. + * + * @param {EventTarget|Element} targetElement + * @param {Event} event + */ +FastClick.prototype.sendClick = function(targetElement, event) { + 'use strict'; + var clickEvent, touch; + + // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24) + if (document.activeElement && document.activeElement !== targetElement) { + document.activeElement.blur(); + } + + touch = event.changedTouches[0]; + + // Synthesise a click event, with an extra attribute so it can be tracked + clickEvent = document.createEvent('MouseEvents'); + clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); + clickEvent.forwardedTouchEvent = true; + targetElement.dispatchEvent(clickEvent); +}; + +FastClick.prototype.determineEventType = function(targetElement) { + 'use strict'; + + //Issue #159: Android Chrome Select Box does not open with a synthetic click event + if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') { + return 'mousedown'; + } + + return 'click'; +}; + + +/** + * @param {EventTarget|Element} targetElement + */ +FastClick.prototype.focus = function(targetElement) { + 'use strict'; + var length; + + // Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724. + if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') { + length = targetElement.value.length; + targetElement.setSelectionRange(length, length); + } else { + targetElement.focus(); + } +}; + + +/** + * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it. + * + * @param {EventTarget|Element} targetElement + */ +FastClick.prototype.updateScrollParent = function(targetElement) { + 'use strict'; + var scrollParent, parentElement; + + scrollParent = targetElement.fastClickScrollParent; + + // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the + // target element was moved to another parent. + if (!scrollParent || !scrollParent.contains(targetElement)) { + parentElement = targetElement; + do { + if (parentElement.scrollHeight > parentElement.offsetHeight) { + scrollParent = parentElement; + targetElement.fastClickScrollParent = parentElement; + break; + } + + parentElement = parentElement.parentElement; + } while (parentElement); + } + + // Always update the scroll top tracker if possible. + if (scrollParent) { + scrollParent.fastClickLastScrollTop = scrollParent.scrollTop; + } +}; + + +/** + * @param {EventTarget} targetElement + * @returns {Element|EventTarget} + */ +FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) { + 'use strict'; + + // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node. + if (eventTarget.nodeType === Node.TEXT_NODE) { + return eventTarget.parentNode; + } + + return eventTarget; +}; + + +/** + * On touch start, record the position and scroll offset. + * + * @param {Event} event + * @returns {boolean} + */ +FastClick.prototype.onTouchStart = function(event) { + 'use strict'; + var targetElement, touch, selection; + + // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111). + if (event.targetTouches.length > 1) { + return true; + } + + targetElement = this.getTargetElementFromEventTarget(event.target); + touch = event.targetTouches[0]; + + if (deviceIsIOS) { + + // Only trusted events will deselect text on iOS (issue #49) + selection = window.getSelection(); + if (selection.rangeCount && !selection.isCollapsed) { + return true; + } + + if (!deviceIsIOS4) { + + // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23): + // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched + // with the same identifier as the touch event that previously triggered the click that triggered the alert. + // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an + // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform. + if (touch.identifier === this.lastTouchIdentifier) { + event.preventDefault(); + return false; + } + + this.lastTouchIdentifier = touch.identifier; + + // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and: + // 1) the user does a fling scroll on the scrollable layer + // 2) the user stops the fling scroll with another tap + // then the event.target of the last 'touchend' event will be the element that was under the user's finger + // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check + // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42). + this.updateScrollParent(targetElement); + } + } + + this.trackingClick = true; + this.trackingClickStart = event.timeStamp; + this.targetElement = targetElement; + + this.touchStartX = touch.pageX; + this.touchStartY = touch.pageY; + + // Prevent phantom clicks on fast double-tap (issue #36) + if ((event.timeStamp - this.lastClickTime) < this.tapDelay) { + event.preventDefault(); + } + + return true; +}; + + +/** + * Based on a touchmove event object, check whether the touch has moved past a boundary since it started. + * + * @param {Event} event + * @returns {boolean} + */ +FastClick.prototype.touchHasMoved = function(event) { + 'use strict'; + var touch = event.changedTouches[0], boundary = this.touchBoundary; + + if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) { + return true; + } + + return false; +}; + + +/** + * Update the last position. + * + * @param {Event} event + * @returns {boolean} + */ +FastClick.prototype.onTouchMove = function(event) { + 'use strict'; + if (!this.trackingClick) { + return true; + } + + // If the touch has moved, cancel the click tracking + if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) { + this.trackingClick = false; + this.targetElement = null; + } + + return true; +}; + + +/** + * Attempt to find the labelled control for the given label element. + * + * @param {EventTarget|HTMLLabelElement} labelElement + * @returns {Element|null} + */ +FastClick.prototype.findControl = function(labelElement) { + 'use strict'; + + // Fast path for newer browsers supporting the HTML5 control attribute + if (labelElement.control !== undefined) { + return labelElement.control; + } + + // All browsers under test that support touch events also support the HTML5 htmlFor attribute + if (labelElement.htmlFor) { + return document.getElementById(labelElement.htmlFor); + } + + // If no for attribute exists, attempt to retrieve the first labellable descendant element + // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label + return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea'); +}; + + +/** + * On touch end, determine whether to send a click event at once. + * + * @param {Event} event + * @returns {boolean} + */ +FastClick.prototype.onTouchEnd = function(event) { + 'use strict'; + var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement; + + if (!this.trackingClick) { + return true; + } + + // Prevent phantom clicks on fast double-tap (issue #36) + if ((event.timeStamp - this.lastClickTime) < this.tapDelay) { + this.cancelNextClick = true; + return true; + } + + // Reset to prevent wrong click cancel on input (issue #156). + this.cancelNextClick = false; + + this.lastClickTime = event.timeStamp; + + trackingClickStart = this.trackingClickStart; + this.trackingClick = false; + this.trackingClickStart = 0; + + // On some iOS devices, the targetElement supplied with the event is invalid if the layer + // is performing a transition or scroll, and has to be re-detected manually. Note that + // for this to function correctly, it must be called *after* the event target is checked! + // See issue #57; also filed as rdar://13048589 . + if (deviceIsIOSWithBadTarget) { + touch = event.changedTouches[0]; + + // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null + targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement; + targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent; + } + + targetTagName = targetElement.tagName.toLowerCase(); + if (targetTagName === 'label') { + forElement = this.findControl(targetElement); + if (forElement) { + this.focus(targetElement); + if (deviceIsAndroid) { + return false; + } + + targetElement = forElement; + } + } else if (this.needsFocus(targetElement)) { + + // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through. + // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37). + if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) { + this.targetElement = null; + return false; + } + + this.focus(targetElement); + this.sendClick(targetElement, event); + + // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open. + // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others) + if (!deviceIsIOS || targetTagName !== 'select') { + this.targetElement = null; + event.preventDefault(); + } + + return false; + } + + if (deviceIsIOS && !deviceIsIOS4) { + + // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled + // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42). + scrollParent = targetElement.fastClickScrollParent; + if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) { + return true; + } + } + + // Prevent the actual click from going though - unless the target node is marked as requiring + // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted. + if (!this.needsClick(targetElement)) { + event.preventDefault(); + this.sendClick(targetElement, event); + } + + return false; +}; + + +/** + * On touch cancel, stop tracking the click. + * + * @returns {void} + */ +FastClick.prototype.onTouchCancel = function() { + 'use strict'; + this.trackingClick = false; + this.targetElement = null; +}; + + +/** + * Determine mouse events which should be permitted. + * + * @param {Event} event + * @returns {boolean} + */ +FastClick.prototype.onMouse = function(event) { + 'use strict'; + + // If a target element was never set (because a touch event was never fired) allow the event + if (!this.targetElement) { + return true; + } + + if (event.forwardedTouchEvent) { + return true; + } + + // Programmatically generated events targeting a specific element should be permitted + if (!event.cancelable) { + return true; + } + + // Derive and check the target element to see whether the mouse event needs to be permitted; + // unless explicitly enabled, prevent non-touch click events from triggering actions, + // to prevent ghost/doubleclicks. + if (!this.needsClick(this.targetElement) || this.cancelNextClick) { + + // Prevent any user-added listeners declared on FastClick element from being fired. + if (event.stopImmediatePropagation) { + event.stopImmediatePropagation(); + } else { + + // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) + event.propagationStopped = true; + } + + // Cancel the event + event.stopPropagation(); + event.preventDefault(); + + return false; + } + + // If the mouse event is permitted, return true for the action to go through. + return true; +}; + + +/** + * On actual clicks, determine whether this is a touch-generated click, a click action occurring + * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or + * an actual click which should be permitted. + * + * @param {Event} event + * @returns {boolean} + */ +FastClick.prototype.onClick = function(event) { + 'use strict'; + var permitted; + + // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early. + if (this.trackingClick) { + this.targetElement = null; + this.trackingClick = false; + return true; + } + + // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target. + if (event.target.type === 'submit' && event.detail === 0) { + return true; + } + + permitted = this.onMouse(event); + + // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through. + if (!permitted) { + this.targetElement = null; + } + + // If clicks are permitted, return true for the action to go through. + return permitted; +}; + + +/** + * Remove all FastClick's event listeners. + * + * @returns {void} + */ +FastClick.prototype.destroy = function() { + 'use strict'; + var layer = this.layer; + + if (deviceIsAndroid) { + layer.removeEventListener('mouseover', this.onMouse, true); + layer.removeEventListener('mousedown', this.onMouse, true); + layer.removeEventListener('mouseup', this.onMouse, true); + } + + layer.removeEventListener('click', this.onClick, true); + layer.removeEventListener('touchstart', this.onTouchStart, false); + layer.removeEventListener('touchmove', this.onTouchMove, false); + layer.removeEventListener('touchend', this.onTouchEnd, false); + layer.removeEventListener('touchcancel', this.onTouchCancel, false); +}; + + +/** + * Check whether FastClick is needed. + * + * @param {Element} layer The layer to listen on + */ +FastClick.notNeeded = function(layer) { + 'use strict'; + var metaViewport; + var chromeVersion; + var blackberryVersion; + + // Devices that don't support touch don't need FastClick + if (typeof window.ontouchstart === 'undefined') { + return true; + } + + // Chrome version - zero for other browsers + chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1]; + + if (chromeVersion) { + + if (deviceIsAndroid) { + metaViewport = document.querySelector('meta[name=viewport]'); + + if (metaViewport) { + // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89) + if (metaViewport.content.indexOf('user-scalable=no') !== -1) { + return true; + } + // Chrome 32 and above with width=device-width or less don't need FastClick + if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) { + return true; + } + } + + // Chrome desktop doesn't need FastClick (issue #15) + } else { + return true; + } + } + + if (deviceIsBlackBerry10) { + blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/); + + // BlackBerry 10.3+ does not require Fastclick library. + // https://github.com/ftlabs/fastclick/issues/251 + if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) { + metaViewport = document.querySelector('meta[name=viewport]'); + + if (metaViewport) { + // user-scalable=no eliminates click delay. + if (metaViewport.content.indexOf('user-scalable=no') !== -1) { + return true; + } + // width=device-width (or less than device-width) eliminates click delay. + if (document.documentElement.scrollWidth <= window.outerWidth) { + return true; + } + } + } + } + + // IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97) + if (layer.style.msTouchAction === 'none') { + return true; + } + + return false; +}; + + +/** + * Factory method for creating a FastClick object + * + * @param {Element} layer The layer to listen on + * @param {Object} options The options to override the defaults + */ +FastClick.attach = function(layer, options) { + 'use strict'; + return new FastClick(layer, options); +}; + + +if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { + + // AMD. Register as an anonymous module. + define(function() { + 'use strict'; + return FastClick; + }); +} else if (typeof module !== 'undefined' && module.exports) { + module.exports = FastClick.attach; + module.exports.FastClick = FastClick; +} else { + window.FastClick = FastClick; +} diff --git a/favicon.svg b/favicon.svg new file mode 100644 index 0000000..930ec56 --- /dev/null +++ b/favicon.svg @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ogre.appcache.in b/ogre.appcache.in new file mode 100644 index 0000000..460bc23 --- /dev/null +++ b/ogre.appcache.in @@ -0,0 +1,19 @@ +CACHE MANIFEST +# + +ogre.html +ogre.css + +Checkbook.woff +DejaVuSansMono.woff +FiraSans-Regular.woff + +fastclick.js +ogre.js +units.js + +favicon.ico +favicon_32.png +favicon_128.png +favicon_196.png +favicon_256.png diff --git a/ogre.css b/ogre.css new file mode 100644 index 0000000..fe9dcaf --- /dev/null +++ b/ogre.css @@ -0,0 +1,412 @@ +@font-face { + font-family: Digital; + font-style: normal; + font-weight: 400; + src: url('Checkbook.woff') format('woff'); +} + +@font-face { + font-family: Sans; + font-style: normal; + font-weight: 400; + src: url('FiraSans-Regular.woff') format('woff'); +} + +@font-face { + font-family: Mono; + font-style: normal; + font-weight: 400; + src: url('DejaVuSansMono.woff') format('woff'); +} + +* { + margin: 0; + padding: 0; + font-weight: normal; + text-decoration: none; + list-style-type: none; + font-style: normal; + cursor: default; +} + +html { + font-size: 18px; + font-family: Sans, sans-serif; + text-align: center; + color: black; + background-color: white; +} + +header, nav, main, section { + display: block; +} + +body, nav, .tray { + user-select: none; + -moz-user-select: none; + -webkit-touch-callout: none; + -webkit-user-select: none; +} + +h1 { + font-family: Digital, Sans, sans-serif; + font-size: 2em; + white-space: nowrap; +} + +body [href], body [onclick], .ticks, input, label { + cursor: pointer; +} + +a[href] { + color: red; + text-decoration: underline; +} + +header { + top: 0; + position: fixed; + left: 0; + right: 0; + display: block; + background-color: black; + font-family: Digital, Sans, sans-serif; + color: white; + z-index: 2; + height: 1em; + line-height: 1em; + font-size: 2.5em; +} + +header h1 { + font-size: 0.75em; +} + +nav { + padding: 0 8px; +} + +body { padding-top: 2.5em; } +.standalone header { padding-top: 20px; } +.standalone { margin-top: 20px; } + + +body [onclick]:hover, body [onclick]:active, +body [data-tray]:hover, body [data-tray]:active, +label:hover, label:active, +#addUnit li:hover { + color: red; + cursor: pointer; +} + +section { + border: solid black 1px; + margin: 2em 3em; + padding: 0.25em 2em; + position: relative; +} + +.close { + font-family: Mono, monospace; + line-height: 1em; + position: absolute; + font-size: 2.5em; + width: 1em; + height: 1em; + top: 0; + left: 0; +} + +.close:after { content: "✕"; } + +section > .name { + line-height: 1em; + font-family: Digital, Sans, sans-serif; + font-size: 1.5em; + white-space: nowrap; +} + +section > .aside { + display: block; + font-size: 0.75em; + padding-top: 0.5em; + font-family: Sans, sans-serif; + +} + +.weapons > li:before { + content: attr(data-remaining) " " attr(data-name); + display: block; + width: 100%; + text-align: center; + font-size: 0.9em; + font-family: Mono, monospace; +} + +.weapons > li[data-count="1"]:before { + content: attr(data-name); +} + +section > .type { + font-family: Mono, monospace; + font-variant: small-caps; +} + +.stats { font-variant: small-caps; } +.stats > li { + display: inline-block; + padding: 0 0.25em; + font-family: Mono, monospace; +} +.stats > li:before { font-size: 0.75em; font-family: Sans, sans-serif; } +.stats > .attack:before { content: "Atk "; } +.stats > .defense:before { content: "Def "; } +.stats > .range:before { content: "Rng "; } +.stats > .aside { + display: block; + font-variant: normal; + text-transform: none; + font-size: 0.75em; + font-family: Sans, sans-serif; +} + +.weapons { + display: -webkit-flex; + display: flex; + flex-wrap: wrap; + -webkit-flex-wrap: wrap; + flex-direction: row; + -webkit-flex-direction: row; + justify-content: space-around; + -webkit-justify-content: space-around; + align-items: flex-end; + -webkit-align-items: flex-end; + align-content: center; + -webkit-align-content: center; +} + +.weapons > li { + display: inline-block; + margin: 1em 0.75em; + margin-bottom: 0em; + flex-grow: 1; + -webkit-box-flex: 1; + -webkit-flex-grow: 1; +} + +.ticks { + display: inline-block; + font-size: 2em; + font-family: Mono, monospace; + line-height: 0.75em; +} + +[data-remaining="0"] .ticks { + color: red; +} + +.treads { + margin: 0.5em auto; + padding: 0 1em; + padding-right: 1.5em; + list-style-type: none; + display: inline-block; +} + +[data-remaining="0"]:before { + text-decoration: line-through; + color: red; +} + +.treads:before { + content: attr(data-remaining) " Tread Units"; + font-family: Mono, monospace; + display: block; + margin-top: 0.7em; + text-align: center; + margin-right: -1.25em; +} + +.treads.propulsion:before { + content: attr(data-remaining) " Prop. Units"; +} + +.treads > li { + text-align: right; + display: block; + line-height: 0.75em; +} + +.treads > li:after { + margin-right: -1em; + font-size: 0.5em; + width: 1em; + display: inline-block; + font-family: Mono, monospace; + vertical-align: 0.125em; +} + +.ticks > span { + display: inline-block; + padding: 0 0.111em; + height: 0.75em; + overflow: hidden; + cursor: pointer; +} + +.treads > li:first-child:before { + content: "Move starts at"; + font-family: Sans, sans-serif; + font-size: 0.75em; + display: inline-block; + font-variant: small-caps; + vertical-align: 0.25em; + margin-right: -0.125em; +} +.treads.propulsion > li:first-child:before { + content: "Must move"; +} +.treads > li:first-child:after { font-size: 1em; } + +.treads > li:first-child:nth-last-child(n+1) { counter-reset: i 1; } +.treads > li:first-child:nth-last-child(n+2) { counter-reset: i 2; } +.treads > li:first-child:nth-last-child(n+3) { counter-reset: i 3; } +.treads > li:first-child:nth-last-child(n+4) { counter-reset: i 4; } +.treads > li:first-child:nth-last-child(n+5) { counter-reset: i 5; } +.treads > li:first-child:nth-last-child(n+6) { counter-reset: i 6; } +.treads > li:after { content: counter(i); counter-increment: i -1; } + +#unit-template { display: none; } + +.tray { + position: fixed; + border: solid black 1px; + border-top-width: 0; + z-index: 1; + transition: transform 0.3s; + -webkit-transition: -webkit-transform 0.3s; + background-color: rgba(255, 255, 255, 0.9412); + overflow: auto; + max-height: 80%; + -webkit-overflow-scrolling: touch; +} + +.tray.visible { + transform: translate(0, 0) !important; + -webkit-transform: translate(0, 0) !important; + transition: transform 0.3s; + -webkit-transition: -webkit-transform 0.3s; +} + +#addUnit { + transform: translateX(-100%); + -webkit-transform: translateX(-100%); + font-size: 2em; + display: block; +} + +#addUnit > li { + display: block; + padding: 0.25em; + text-align: left; + font-family: Digital, Sans, sans-serif; + white-space: nowrap; + cursor: pointer; +} + +#legal { + font-size: 0.8em; + left: 40%; + right: 0%; + transform: translateX(100%); + -webkit-transform: translateX(100%); + text-align: center; + padding-top: 1em; +} + +#legal p { + padding: 1em; + text-align: justify; + text-align-last: center; + -moz-text-align-last: center; + -webkit-text-align-last: center; +} + +.stats { margin-top: -0.3333em; } + +.colophon { + font-size: 1.5em; + font-family: Digital, Sans, sans-serif; + margin-top: 0.25em; +} + +#brain { + right: 0em; + transform: translateX(100%); + -webkit-transform: translateX(100%); + padding: 0.5em; + text-align: left; + overflow: hidden; +} + +#report { + font-family: Mono, monospace; + white-space: pre; +} + +#howto { + left: 25%; + right: 25%; + max-height: 50%; + overflow-y: auto; + transform: translateY(-100%); + -webkit-transform: translateY(-100%); + padding: 0.5em; + text-align: left; + overflow-y: auto; +} + +@media (max-width: 1023px) { + html { font-size: 16px; } +} + +@media (max-width: 768px) { + html { font-size: 13px; } +} + +@media (max-width: 640px) { + section { margin: 1em; padding: 0.333em; } + .weapons > li:before { content: attr(data-name); } + .weapons > li { margin: 0.5em 0.5em; margin-bottom: 0; } + .stats > .attack:before { content: ""; } + .stats > .defense { padding: 0 0.5em; } + .stats > .defense:before { + content: "D"; + font-family: Mono, monospace; + font-size: 1em; + } + .weapons .ticks { + margin-top: -0.125em; + } + .stats > .range:before { + content: "/"; + font-family: Mono, monospace; + font-size: 1em; + } + .stats > .aside { display: none; } + .stats > li { padding: 0; } + .treads { margin: 0 1.5em; min-width: 12em; } + .treads:before { margin-bottom: -0.75em; } + .treads > li:first-child:before { + content: "M"; + font-family: Mono, monospace; + font-size: 1em; + vertical-align: 0.125em; + } +} + +@media (max-width: 480px) { + html { font-size: 11px; } + section > .type, section > .aside { display: none; } +} + diff --git a/ogre.html b/ogre.html new file mode 100644 index 0000000..bcdb0f5 --- /dev/null +++ b/ogre.html @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + Ogre Record Sheets + + +
+ +
+
    +
+ + +
+
+ +
+
+
+
+ + diff --git a/ogre.js b/ogre.js new file mode 100644 index 0000000..c670e93 --- /dev/null +++ b/ogre.js @@ -0,0 +1,342 @@ +/* The person who associated a work with this deed has dedicated the + work to the public domain by waiving all of his or her rights to + the work worldwide under copyright law, including all related and + neighboring rights, to the extent allowed by law. + + You can copy, modify, distribute and perform the work, even for + commercial purposes, all without asking permission. + + See https://creativecommons.org/publicdomain/zero/1.0/ for details. +*/ + +"use strict"; + +if (!String.prototype.repeat) + Object.defineProperty(String.prototype, "repeat", { + value: function (count) { + var string = this.toString(); + var result = ''; + var n = count | 0; + while (n) { + if (n % 2 === 1) + result += string; + if (n > 1) + string += string; + n >>= 1; + } + return result; + } + }); + +if (!Array.prototype.fill) + Object.defineProperty(Array.prototype, "fill", { + value: function (value) { + var beg = arguments.length > 1 ? +arguments[1] : 0; + var end = arguments.length > 2 ? +arguments[2] : this.length; + if (beg < 0) beg += this.length; + if (end < 0) end += this.length; + for (var i = beg; i < end; ++i) + this[i] = value; + return this; + } + }); + +if (!Element.prototype.matches) + Object.defineProperty(Element.prototype, "matches", { + value: Element.prototype.matchesSelector + || Element.prototype.mozMatchesSelector + || Element.prototype.webkitMatchesSelector + }); + +function removeUnit (element) { + element.parentNode.removeChild(element); +} + +var EMPTY = "☐"; +var CHECK = "☒"; +var FIRST_EMPTY = /☐/; +var LAST_TICKED = /☒([^☒]*)$/; + +function choice (a) { + return a[(Math.random() * a.length) | 0]; +} + +function cap (s) { + return s && s[0].toUpperCase() + s.slice(1); +} + +function letters (n) { + var r = ""; + n = n || 1; + while (n-- > 0) + r += choice("abcdefghijklmnopqrstuvwxyz"); + return r; +} + +function range (a, b) { + return a + (Math.random() * (b - a)) | 0; +} + +function numerals (n) { + var r = ""; + n = n || 1; + while (n-- > 0) + r += choice("0123456789"); + return r; +} + +function pid () { + return letters(range(1, 4)).toUpperCase() + + choice(["‑", "", ".", "/"]) + + numerals(range(1, 4)); +} + +function roman () { + return choice(["I", "II", "III", "IV", "V", "VI", + "VII", "VIII", "IX", "X", "XI", "XII", + "XIV"]); +} + +function oid () { + return choice([letters(1).toUpperCase() + choice("-./") + numerals(2)]); +} + +function randomName (scheme) { + switch (scheme) { + case "id": + return choice([pid() + " " + cap(choice(NOUNS))], + [cap(choice(NOUNS)) + " " + pid()]); + case "air": + return choice([ + oid() + " " + cap(choice(ADJECTIVES)) + " " + cap(choice(BIRDS)), + cap(choice(ADJECTIVES)) + " " + cap(choice(BIRDS)) + " " + roman()]); + default: + return choice([ + oid() + " " + cap(choice(ADJECTIVES)) + " " + cap(choice(NOUNS)), + cap(choice(ADJECTIVES)) + " " + cap(choice(NOUNS)) + " " + roman()]); + } +} + +var STATS = ["attack", "range", "defense", "aside"]; +function createUnit (dfnName) { + var dfn = UNITS[dfnName]; + var weapons = dfn.weapons || []; + var unit = document.getElementById("unit-template").cloneNode(true); + unit.removeAttribute('id'); + unit.setAttribute("data-dfn", dfnName); + unit.querySelector(".name").textContent = randomName(dfn.nameScheme); + unit.querySelector(".type").textContent = dfnName; + + if (dfn.aside) { + var aside = unit.appendChild(document.createElement("div")); + aside.className = "aside"; + aside.innerHTML = dfn.aside; + } + if (weapons.length) { + var weaponList = unit.appendChild(document.createElement('ul')); + weaponList.className = "weapons"; + } + + weapons.forEach(function (weaponRef) { + var count = parseInt(weaponRef, 10) || 1; + var weaponName = weaponRef.replace(/^[0-9 ]*/, ""); + var weapon = WEAPONS[weaponName] + || WEAPONS[weaponName.replace(/s+$/, "")]; + var weaponItem = document.createElement("li"); + weaponItem.setAttribute('data-name', weaponName); + weaponItem.setAttribute('data-count', count); + weaponItem.setAttribute('data-remaining', count); + var stats = document.createElement('ul'); + stats.className = "stats"; + for (var j = 0; j < STATS.length; ++j) { + if (weapon[STATS[j]] !== undefined) { + var stat = document.createElement('li'); + stat.className = STATS[j]; + stat.innerHTML = weapon[STATS[j]]; + stats.appendChild(stat); + } + } + if (stats.children.length) + weaponItem.appendChild(stats); + var ticks = document.createElement('div'); + ticks.className = "ticks"; + ticks.innerHTML = ticksText(count); + weaponItem.appendChild(ticks); + weaponList.appendChild(weaponItem); + }); + + if (dfn.tread) { + var move = dfn.move || 3; + var per = dfn.tread / move; + var treads = document.createElement('ol'); + treads.className = "treads"; + treads.appendChild(document.createElement("li")); + treads.setAttribute('data-count', dfn.tread); + treads.setAttribute('data-remaining', dfn.tread); + for (var i = 0; i < move; ++i) { + var tread = treads.appendChild(document.createElement("li")); + tread.className = "ticks"; + tread.innerHTML = ticksText(per); + } + unit.appendChild(treads); + } + if (dfn.propulsion) { + var move = dfn.move || 3; + var per = dfn.propulsion / move; + var treads = document.createElement('ol'); + treads.className = "treads propulsion"; + treads.appendChild(document.createElement("li")); + treads.setAttribute('data-count', dfn.propulsion); + treads.setAttribute('data-remaining', dfn.propulsion); + for (var i = 0; i < move; ++i) { + var tread = treads.appendChild(document.createElement("li")); + tread.className = "ticks"; + tread.innerHTML = ticksText(per); + } + unit.appendChild(treads); + } + + return unit; +} + +function addUnit (dfnName) { + document.querySelector('main').appendChild(createUnit(dfnName)); +} + +function spre (c) { + return new RegExp("(^|\\s+)" + c + "(\\s+|$)"); +} + +function hasClass (e, n) { + return !!e.className.match(spre(n)); +} + +function addClass (e, n) { + if (!hasClass(e, n)) + e.className += " " + n; +} + +function removeClass (e, n) { + e.className = e.className.replace(spre(n), ""); +} + +function show (id) { + addClass(document.getElementById(id.id || id), "visible"); +} +function hide (id) { + removeClass(document.getElementById(id.id || id), "visible"); +} +function handleTray (evt) { + var id = this.getAttribute('data-tray'); + var el = document.getElementById(id); + var f = (hasClass(el, "visible") ? hide : show) + autoClose(); + f(el); + evt.stopPropagation(); +} + +function ticksText (n) { + var blocks = [EMPTY.repeat(n)]; + for (var i = 5; i >= 2; --i) { + if (n > i && n % i === 0) { + blocks = (new Array(n / i)).fill(EMPTY.repeat(i)); + break; + } + } + return "" + blocks.join("") + ""; +} + +function rub (content) { + return content.replace(LAST_TICKED, EMPTY + "$1"); +} +function tick (content) { + return content.replace(FIRST_EMPTY, CHECK); +} + +function findParent (el, selector) { + while (el && el !== document && !el.matches(selector)) + el = el.parentNode; + return el === document ? null : el; +} + +function boxes (event) { + var target = event.target; + if (!target.innerHTML.match(/☐|☒/)) + return; + var par = findParent(target, '[data-count]'); + var ticks = findParent(target, '.ticks'); + if (!ticks || !par) + return; + var content = target.innerHTML; + var rect = target.getBoundingClientRect(); + var total = target.innerHTML.match(/☐|☒/g); + var ticked = target.innerHTML.match(/☒/g); + var p = (event.clientX - rect.left) / rect.width; + var pr = (total && total.length) + ? (ticked ? ticked.length : 0) / total.length : 0; + par.innerHTML = ((p < pr) ? rub : tick)(par.innerHTML); + var rem = par.innerHTML.match(/☐/g); + par.setAttribute('data-remaining', rem ? rem.length : 0); + event.preventDefault(); + event.stopPropagation(); +} + +function fade (p) { + return p * p * p * (p * (p * 6.0 - 15.0) + 10.0); +} + +function scroll (y1, t) { + var y0 = document.body.scrollTop || document.documentElement.scrollTop; + var n = (t || 150) / 15; + var i = 0; + clearInterval(scroll.owner); + scroll.owner = setInterval(function () { + var p = Math.max(0, Math.min(++i / n, 1)); + document.body.scrollTop + = document.documentElement.scrollTop + = y0 + (y1 - y0) * fade(p); + if (i >= n) clearInterval(scroll.owner); + }, 15); +} + +function next (el) { + scroll(el.nextElementSibling.offsetTop - el.parentNode.offsetTop); +} + +function previous (el) { + scroll(el.previousElementSibling.offsetTop - el.parentNode.offsetTop); +} + +function autoClose () { + var open = document.querySelectorAll(".tray.visible"); + for (var i = 0; i < open.length; ++i) + hide(open[i]); + return open && open.length; +} + +window.addEventListener("DOMContentLoaded", function () { + if (navigator.standalone) + document.body.className += " standalone"; + var units = document.getElementById("addUnit"); + Object.keys(UNITS).sort(function (a, b) { + return (b.indexOf("Ogre Mk") - a.indexOf("Ogre Mk")) + || (a > b) - (a < b); + }).forEach(function (unitName) { + var unit = units.appendChild(document.createElement("li")); + unit.textContent = unitName; + unit.addEventListener("click", function () { + addUnit(unitName); + hide('addUnit'); + }); + }); + addUnit('Ogre Mk. V'); + FastClick.attach(document.body, { tapDelay: 50 }); + + var trays = document.querySelectorAll('[data-tray]'); + for (var i = 0; i < trays.length; ++i) + trays[i].addEventListener('click', handleTray); + window.addEventListener('click', function (evt) { + if (!findParent(evt.target, ".tray.visible")) + autoClose(); + }); +}); diff --git a/units.js b/units.js new file mode 100644 index 0000000..984b6fd --- /dev/null +++ b/units.js @@ -0,0 +1,352 @@ +/* The person who associated a work with this deed has dedicated the work + to the public domain by waiving all of his or her rights to the work + worldwide under copyright law, including all related and neighboring + rights, to the extent allowed by law. + + You can copy, modify, distribute and perform the work, even for + commercial purposes, all without asking permission. + + See https://creativecommons.org/publicdomain/zero/1.0/ for details. +*/ + +var ADJECTIVES = [ + "angry", + "cold", + "deadly", + "easy", + "faithful", + "fatal", + "fiery", + "harsh", + "lost", + "mean", + "mighty", + "noisy", + "old", + "proud", + "pure", + "quiet", + "sharp", + "slow", + "strong", + "true", + "", + "", + "", +]; + +var BIRDS = [ + "angel", + "arrow", + "cloud", + "eagle", + "falcon", + "owl", + "raptor", + "storm", + "swan", + "swarm", +]; + +var NOUNS = [ + "axe", + "boar", + "brute", + "claw", + "cobra", + "dagger", + "demon", + "fox", + "hyena", + "knife", + "lion", + "lynx", + "saber", + "scout", + "snake", + "spear", + "spire", + "stone", + "stream", + "sword", + "talon", + "thorn", + "tide", + "tooth", + "tower", + "tusk", + "venom", + "viper", + "wall", + "wave", + "wolf", + "worker", +]; + +// Most game data in this file based on +// http://www.sjgames.com/ogre/kickstarter/ogre-rec-sheets.pdf +// http://www.sjgames.com/ogre/kickstarter/ogre_rulebook.pdf + +var WEAPONS = { + "Main Battery": { attack: 4, range: 3, defense: 4 }, + "Secondary Battery": { attack: 3, range: 2, defense: 3 }, + "Improved 2° Battery": { attack: 3, range: 3, defense: 3 }, + "Antipersonnel": { + attack: 1, range: 1, defense: 1, + aside: "Only against Infantry or CPs" + }, + "Missile Rack": { defense: 4 }, + "Int. Missile": { attack: 6, range: 5 }, + "Missile": { attack: 6, range: 5, defense: 3 }, + "Ext. Missile": { attack: 6, range: 5, defense: 3 }, + "Manipulator Arm": { defense: 2 }, + "Main Gun": { attack: 3, range: 3 }, + "Bombload": { attack: 6, range: 0, defense: 3 }, + "Air-to-Air Missile": { attack: 6, range: 5, defense: 3 }, + "Antipersonnel Bombload": { + attack: 1, range: 0, defense: 1, + aside: "Only against Infantry or CPs" + }, + "Pod": { defense: 2 }, + "Eye": { attack: 2, range: 30, defense: 3 }, + "Tower": { defense: 6 } +}; + +var UNITS = { + "Superheavy Tank": { + weapons: ["3 Main Guns", "3 Antipersonnel"], + nameScheme: "id", + tread: 18, + size: 5, + au: 3 + }, + "Ogre Mk. I": { + aside: "Pikeman", + weapons: ["1 Main Battery", "4 Antipersonnel"], + tread: 18, + size: 5, + au: 4 + }, + "Ogre Mk. II": { + weapons: [ + "Main Battery", + "2 Secondary Battery", + "6 Antipersonnel" + ], + tread: 30, + size: 6, + au: 8 + }, + "Ogre Mk. III": { + weapons: [ + "Main Battery", + "4 Secondary Battery", + "2 Missiles", + "8 Antipersonnel" + ], + tread: 45, + size: 7, + au: 17 + }, + "Ogre Mk. III-B": { + weapons: [ + "2 Main Battery", + "4 Secondary Battery", + "4 Missiles", + "8 Antipersonnel" + ], + tread: 48, + size: 7, + au: 20 + }, + "Ogre Mk. IV": { + weapons: [ + "Main Battery", + "2 Secondary Battery", + "3 Missile Racks", + "15 Int. Missiles", + "8 Antipersonnel" + ], + move: 4, + tread: 48, + size: 8, + au: 25 + }, + "Ogre Mk. V": { + weapons: [ + "2 Main Battery", + "6 Secondary Battery", + "6 Missiles", + "12 Antipersonnel" + ], + tread: 60, + size: 8, + au: 25 + }, + "Ogre Mk. VI": { + nameScheme: "grand", + weapons: [ + "3 Main Battery", + "6 Secondary Battery", + "3 Missile Racks", + "12 Int. Missiles", + "6 Ext. Missiles", + "16 Antipersonnel" + ], + tread: 72, + size: 9, + au: 40 + }, + "Ogre Vulcan": { + weapons: [ + "2 Secondary Battery", + "6 Antipersonnel", + "2 Manipulator Arms" + ], + move: 4, + tread: 48, + size: 7, + au: "25+" + }, + "Ogre Ninja": { + weapons: [ + "Main Battery", + "2 Secondary Battery", + "Missile Rack", + "4 Int. Missiles", + "2 Ext. Missiles", + "8 Antipersonnel" + ], + aside: "−1 to rolls when attacked (except by infantry overruns)", + move: 4, + tread: 40, + size: 7, + au: "25+" + }, + "Doppelsoldner": { + nameScheme: "grand", + weapons: [ + "2 Main Battery", + "8 Secondary Battery", + "6 Missile Racks", + "20 Int. Missiles", + "12 Antipersonnel" + ], + tread: 60, + size: 9, + au: 40 + }, + "Fencer": { + weapons: [ + "2 Secondary Battery", + "4 Missile Racks", + "20 Int. Missiles", + "8 Antipersonnel", + ], + tread: 48, + size: 8, + au: 22 + }, + "Fencer-B": { + weapons: [ + "2 Main Battery", + "4 Missile Racks", + "20 Int. Missiles", + "8 Antipersonnel" + ], + tread: 48, + size: 8, + au: 23 + }, + // http://www.sjgames.com/ogre/articles/goliath.html + "Goliath": { + tread: 40, + aside: "Self-destruct capabilities", + move: 4, + }, + // http://www.sjgames.com/ogre/articles/csa.html + "CSA-10 (Magi)": { + nameScheme: "air", + weapons: [ + "2 Bombloads", + "1 Air-to-Air Missile", + "Main Battery", + "4 Secondary Battery", + "12 Antipersonnel Bombloads" + ], + move: 4, + propulsion: 48, + }, + "CSA-15 (Magi)": { + nameScheme: "air", + weapons: [ + "4 Bombloads", + "3 Air-to-Air Missiles", + "2 Main Battery", + "6 Secondary Battery", + "18 Antipersonnel Bombloads" + ], + move: 4, + propulsion: 60, + }, + // http://www.sjgames.com/ogre/resources/record/ogrethulu.html + "Ogrethulhu": { + weapons: [ + "2 Main Battery", + "6 Secondary Battery", + "6 Pods", + "Eye", + "Tower", + "12 Antipersonnel" + ], + tread: 48, + au: 50, + }, + + // GURPS Ogre, adapted by me. + "Steel Demon": { + weapons: [ + "2 Main Battery", + "4 Improved 2° Battery", + "Missile Rack", + "4 Int. Missiles", + "12 Antipersonnel" + ], + tread: 48, + size: 7, + }, + "Steel Samurai": { + weapons: [ + "2 Main Battery", + "6 Improved 2° Battery", + "Missile Rack", + "8 Int. Missiles", + "16 Antipersonnel" + ], + tread: 60, + size: 8, + }, + "Golem": { + weapons: [ + "Main Battery", + "3 Secondary Battery", + "3 Missile Racks", + "9 Int. Missiles", + "12 Antipersonnel" + ], + tread: 45, + size: 7 + }, + "Ogre Mk. VII": { + weapons: [ + "4 Main Battery", + "12 Secondary Battery", + "4 Missile Racks", + "32 Int. Missiles", + "24 Antipersonnel", + ], + size: 10, + tread: 60, + move: 2, + } +};