From 5677497dae2c2ae6e89cc99e3b650467aaa12748 Mon Sep 17 00:00:00 2001 From: Nathan McCallum Date: Sat, 30 Apr 2022 14:32:10 +1000 Subject: [PATCH] Indent size of 2!! --- .babelrc | 2 +- .editorconfig | 2 +- .eslintrc.cjs | 28 +- .prettierrc | 2 +- .vscode/settings.json | 31 +- Gulpfile.js | 20 +- app/components/about.tsx | 30 +- app/components/about/aboutTab.tsx | 24 +- app/components/about/creditsSection.tsx | 74 +- app/components/about/creditsTab.tsx | 26 +- app/components/building/actionButton.jsx | 64 +- app/components/building/information.jsx | 97 +- app/components/building/productionTab.jsx | 315 +- app/components/building/repairTab.jsx | 122 +- app/components/building/resourceCost.jsx | 42 +- app/components/building/resourceLine.jsx | 58 +- .../building/resourceProduction.jsx | 26 +- app/components/captcha.jsx | 214 +- app/components/countdownTimer.tsx | 16 +- app/components/errorBoundary.tsx | 88 +- app/components/essentia.tsx | 30 +- app/components/essentia/boost.jsx | 164 +- app/components/essentia/boostsTab.jsx | 150 +- app/components/essentia/getEssentiaTab.jsx | 101 +- app/components/essentiavein.tsx | 81 +- app/components/essentiavein/drainTab.tsx | 90 +- app/components/genericBuilding.tsx | 77 +- app/components/inteltraining.jsx | 82 +- app/components/invite.tsx | 96 +- app/components/login.jsx | 70 +- app/components/mail.tsx | 12 +- app/components/mayhemtraining.jsx | 82 +- app/components/menu.tsx | 34 +- app/components/menu/bottomBar.jsx | 477 +- .../menu/bottomBar/bottomBarSection.jsx | 68 +- .../menu/bottomBar/buildQueueToolTip.jsx | 46 +- .../menu/bottomBar/buildingCountToolTip.jsx | 30 +- app/components/menu/bottomBar/progressBar.jsx | 42 +- .../menu/bottomBar/resourceToolTip.jsx | 168 +- .../menu/bottomBar/rpcCountToolTip.jsx | 22 +- app/components/menu/gameWindow.tsx | 60 +- app/components/menu/leftSidebar.jsx | 404 +- app/components/menu/leftSidebarButton.jsx | 43 +- app/components/menu/loader.tsx | 26 +- app/components/menu/map.jsx | 116 +- app/components/menu/panel.tsx | 100 +- app/components/menu/panel/panelContent.tsx | 68 +- app/components/menu/panel/panelHeader.tsx | 102 +- app/components/menu/rightSidebar.jsx | 567 +- app/components/menu/rightSidebarButton.jsx | 40 +- app/components/menu/topBar.jsx | 162 +- app/components/menu/windowManager.tsx | 140 +- app/components/options.tsx | 12 +- app/components/planetPanel.tsx | 270 +- app/components/planetPanel/line.tsx | 40 +- .../planetPanel/myFleetTab/item.jsx | 161 +- app/components/planetPanel/planetDetails.tsx | 86 +- .../planetPanel/planetDetailsTab.tsx | 80 +- app/components/planetPanel/planetOre.tsx | 44 +- app/components/politicstraining.jsx | 82 +- app/components/promotions.jsx | 98 +- app/components/register.jsx | 54 +- app/components/serverClock.tsx | 54 +- app/components/shipyard.jsx | 136 +- app/components/shipyard/buildFleet/button.jsx | 58 +- app/components/shipyard/buildFleet/item.jsx | 161 +- app/components/shipyard/buildFleetTab.jsx | 271 +- app/components/shipyard/buildQueue/item.jsx | 109 +- .../shipyard/buildQueue/subsidizeButton.jsx | 22 +- app/components/shipyard/buildQueueTab.jsx | 96 +- app/components/shipyard/resourceAttribute.jsx | 54 +- app/components/shipyard/resourceLine.jsx | 60 +- app/components/spacePort/ownFleets/item.jsx | 101 +- app/components/spacePort/ownFleetsTab.jsx | 284 +- app/components/spaceport.jsx | 119 +- .../spyTraining/spyTrainingStatus.jsx | 70 +- app/components/starPanel.tsx | 56 +- app/components/stats.tsx | 12 +- app/components/tabber/tab.tsx | 26 +- app/components/tabber/tabs.tsx | 162 +- app/components/thefttraining.jsx | 82 +- app/components/trade.jsx | 142 +- app/components/transporter.jsx | 128 +- app/constants.ts | 236 +- app/css/bonus-styles.css | 34 +- app/css/legacy-styles.css | 1969 ++- app/game.tsx | 1162 +- app/interfaces.ts | 39 +- app/json/resources.json | 1824 +-- app/load.ts | 44 +- app/server.ts | 234 +- app/services/empire.ts | 98 +- app/services/genericBuilding.ts | 22 +- app/services/stats.ts | 20 +- app/stores/menu.ts | 120 +- app/stores/rpc/body.ts | 478 +- app/stores/rpc/captcha.ts | 26 +- app/stores/rpc/empire.ts | 204 +- app/stores/rpc/empire/boosts.ts | 64 +- app/stores/rpc/empire/invite.ts | 14 +- app/stores/rpc/genericBuilding.ts | 385 +- app/stores/rpc/server.ts | 144 +- app/stores/rpc/stats/credits.ts | 70 +- app/stores/session.ts | 14 +- app/stores/ticker.ts | 52 +- app/stores/window/mail.ts | 20 +- app/stores/window/options.ts | 20 +- app/stores/window/stats.ts | 22 +- app/stores/windows.ts | 162 +- app/util.ts | 218 +- app/vex.ts | 32 +- app/yui/announce.js | 155 +- app/yui/createEmpire.js | 506 +- app/yui/createSpecies.js | 274 +- app/yui/library.js | 682 +- app/yui/login.js | 925 +- app/yui/mapPlanet.js | 2256 ++- app/yui/mapStar.js | 4056 +++--- app/yui/mapper.js | 3429 +++-- app/yui/messaging.js | 2577 ++-- app/yui/notify.js | 314 +- app/yui/profile.js | 1588 +-- app/yui/rpc.js | 652 +- app/yui/smd.js | 11794 ++++++++-------- app/yui/speciesDesigner.js | 1484 +- app/yui/stats.js | 3550 +++-- app/yui/textboxList.js | 1517 +- environment.d.ts | 8 +- gulp-tasks/browserify.js | 102 +- gulp-tasks/clean.js | 6 +- gulp-tasks/server.js | 20 +- index.html | 56 +- package.json | 150 +- run-ka-web-background.sh | 20 +- run-ka-web.sh | 24 +- tsconfig.json | 24 +- 136 files changed, 25560 insertions(+), 26497 deletions(-) diff --git a/.babelrc b/.babelrc index 2c3b19e1..f406f678 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"] + "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"] } diff --git a/.editorconfig b/.editorconfig index ba39311c..1e9d3754 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,4 +16,4 @@ insert_final_newline = true [*] charset = utf-8 indent_style = space -indent_size = 4 +indent_size = 2 diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 112f99ba..8a92341d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,16 +1,16 @@ module.exports = { - root: true, - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'airbnb'], - globals: { - YAHOO: true, - jQuery: true, - $: true, - }, - env: { - browser: true, - node: true, - es6: true, - }, + root: true, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'airbnb'], + globals: { + YAHOO: true, + jQuery: true, + $: true, + }, + env: { + browser: true, + node: true, + es6: true, + }, }; diff --git a/.prettierrc b/.prettierrc index 8792eb8b..92831d40 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { "trailingComma": "es5", "arrowParens": "always", - "tabWidth": 4, + "tabWidth": 2, "useTabs": false, "semi": true, "singleQuote": true, diff --git a/.vscode/settings.json b/.vscode/settings.json index aece3cf1..f3fba92a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,16 +1,19 @@ { - "editor.tabSize": 4, - "editor.formatOnSave": true, - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - } + "editor.tabSize": 2, + "editor.formatOnSave": true, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/Gulpfile.js b/Gulpfile.js index 4e1191ef..427f6c6b 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -6,25 +6,25 @@ import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); export function browserify() { - return gulpTasks.browserify({ - rootDir: __dirname, - watch: true, - }); + return gulpTasks.browserify({ + rootDir: __dirname, + watch: true, + }); } export function browserifyWithoutWatch() { - return gulpTasks.browserify({ - rootDir: __dirname, - watch: false, - }); + return gulpTasks.browserify({ + rootDir: __dirname, + watch: false, + }); } export function clean() { - return gulpTasks.clean(); + return gulpTasks.clean(); } export function server(done) { - return gulpTasks.server(done); + return gulpTasks.server(done); } export const devWithServer = gulp.series(browserify, server); diff --git a/app/components/about.tsx b/app/components/about.tsx index 5aeceb12..745b2ab0 100644 --- a/app/components/about.tsx +++ b/app/components/about.tsx @@ -8,23 +8,23 @@ import { Tabs, Tab } from 'app/components/tabber'; import WindowsStore from 'app/stores/windows'; class AboutWindow extends React.Component { - closeWindow() { - WindowsStore.close('about'); - } + closeWindow() { + WindowsStore.close('about'); + } - render() { - return ( - - - - + render() { + return ( + + + + - - - - - ); - } + + + + + ); + } } export default AboutWindow; diff --git a/app/components/about/aboutTab.tsx b/app/components/about/aboutTab.tsx index 16944c61..99181cf5 100644 --- a/app/components/about/aboutTab.tsx +++ b/app/components/about/aboutTab.tsx @@ -4,20 +4,20 @@ import { observer } from 'mobx-react'; import ServerRPCStore from 'app/stores/rpc/server'; class AboutTab extends React.Component { - render() { - return ( -
-

Kenó Antigen

+ render() { + return ( +
+

Kenó Antigen

-

- Copyright {new Date().getFullYear()} Kenó Antigen open source contributors. - Originally forked from code provided by The Lacuna Expanse Corp copyright 2010. -

+

+ Copyright {new Date().getFullYear()} Kenó Antigen open source contributors. Originally + forked from code provided by The Lacuna Expanse Corp copyright 2010. +

-

Server Version: {ServerRPCStore.version}.

-
- ); - } +

Server Version: {ServerRPCStore.version}.

+
+ ); + } } export default observer(AboutTab); diff --git a/app/components/about/creditsSection.tsx b/app/components/about/creditsSection.tsx index 25c54f46..e58bac00 100644 --- a/app/components/about/creditsSection.tsx +++ b/app/components/about/creditsSection.tsx @@ -4,46 +4,46 @@ import React from 'react'; import _ from 'lodash'; type Props = { - header: string; - names: string[]; + header: string; + names: string[]; }; class CreditsSection extends React.Component { - static propTypes = { - header: PropTypes.string.isRequired, - names: PropTypes.arrayOf(PropTypes.string), - }; - - static defaultProps = { - header: '', - names: [], - }; - - render() { - return ( -
- {this.props.header} - -
    - {_.map(this.props.names, function (name) { - return ( -
  • - {name} -
  • - ); - })} -
- -
-
- ); - } + static propTypes = { + header: PropTypes.string.isRequired, + names: PropTypes.arrayOf(PropTypes.string), + }; + + static defaultProps = { + header: '', + names: [], + }; + + render() { + return ( +
+ {this.props.header} + +
    + {_.map(this.props.names, function (name) { + return ( +
  • + {name} +
  • + ); + })} +
+ +
+
+ ); + } } export default CreditsSection; diff --git a/app/components/about/creditsTab.tsx b/app/components/about/creditsTab.tsx index 26217e00..d16b9608 100644 --- a/app/components/about/creditsTab.tsx +++ b/app/components/about/creditsTab.tsx @@ -8,21 +8,21 @@ import StatsService from 'app/services/stats'; import CreditsSection from 'app/components/about/creditsSection'; class CreditsTab extends React.Component { - componentDidMount() { - StatsService.getCredits(); - } + componentDidMount() { + StatsService.getCredits(); + } - render() { - return ( -
-

Credits

+ render() { + return ( +
+

Credits

- {_.map(CreditsRPCStore.credits, function (names, header) { - return ; - })} -
- ); - } + {_.map(CreditsRPCStore.credits, function (names, header) { + return ; + })} +
+ ); + } } export default observer(CreditsTab); diff --git a/app/components/building/actionButton.jsx b/app/components/building/actionButton.jsx index d05a348c..c00a7939 100644 --- a/app/components/building/actionButton.jsx +++ b/app/components/building/actionButton.jsx @@ -4,41 +4,41 @@ import React from 'react'; import classnames from 'classnames'; class ActionButton extends React.Component { - static propTypes = { - actionName: PropTypes.string.isRequired, - color: PropTypes.string.isRequired, - error: PropTypes.string, - onClick: PropTypes.func.isRequired, - }; - - handleClick = () => { - if (!this.props.error) { - this.props.onClick(); - } + static propTypes = { + actionName: PropTypes.string.isRequired, + color: PropTypes.string.isRequired, + error: PropTypes.string, + onClick: PropTypes.func.isRequired, + }; + + handleClick = () => { + if (!this.props.error) { + this.props.onClick(); + } + }; + + render() { + let hasError = !!this.props.error; + + let elementAttributes = { + className: classnames( + 'ui button', + { + disabled: hasError, + }, + this.props.color + ), + onClick: this.handleClick, }; - render() { - let hasError = !!this.props.error; - - let elementAttributes = { - className: classnames( - 'ui button', - { - disabled: hasError, - }, - this.props.color - ), - onClick: this.handleClick, - }; - - if (hasError) { - elementAttributes['data-tip'] = this.props.error; - elementAttributes['data-place'] = 'top'; - elementAttributes['data-type'] = 'error'; - } - - return React.createElement('div', elementAttributes, {this.props.actionName}); + if (hasError) { + elementAttributes['data-tip'] = this.props.error; + elementAttributes['data-place'] = 'top'; + elementAttributes['data-type'] = 'error'; } + + return React.createElement('div', elementAttributes, {this.props.actionName}); + } } export default ActionButton; diff --git a/app/components/building/information.jsx b/app/components/building/information.jsx index 19614649..09fd151f 100644 --- a/app/components/building/information.jsx +++ b/app/components/building/information.jsx @@ -5,59 +5,58 @@ import constants from 'app/constants'; import resources from 'app/json/resources'; class BuildingInformation extends React.Component { - static propTypes = { - options: PropTypes.object.isRequired, - }; + static propTypes = { + options: PropTypes.object.isRequired, + }; - getImageUrl = () => { - return constants.ASSETS_URL + 'planet_side/100/' + this.props.options.image + '.png'; - }; + getImageUrl = () => { + return constants.ASSETS_URL + 'planet_side/100/' + this.props.options.image + '.png'; + }; - render() { - return ( -
-
+ render() { + return ( +
+
-
- - {this.props.options.name} {this.props.options.level} (ID:{' '} - {this.props.options.id}) - +
+ + {this.props.options.name} {this.props.options.level} (ID: {this.props.options.id}) + -

- {resources.buildings[this.props.options.url].description} -
- - More information on Wiki. - -

-
-
- ); - } +

+ {resources.buildings[this.props.options.url].description} +
+ + More information on Wiki. + +

+
+
+ ); + } } export default BuildingInformation; diff --git a/app/components/building/productionTab.jsx b/app/components/building/productionTab.jsx index 7612814e..7dfc5491 100644 --- a/app/components/building/productionTab.jsx +++ b/app/components/building/productionTab.jsx @@ -16,181 +16,158 @@ import * as util from 'app/util'; import * as vex from 'app/vex'; class ProductionTab extends React.Component { - onDemolishClick() { - let name = this.props.building.name + ' ' + this.props.building.level; - - vex.confirm( - 'Are you sure you want to demolish your ' + name + '?', - _.bind(function () { - GenericBuildingRPCActions.requestGenericBuildingRPCDemolish( - this.props.building.url, - { building_id: this.props.building.id } - ); - }, this) + onDemolishClick() { + let name = this.props.building.name + ' ' + this.props.building.level; + + vex.confirm( + 'Are you sure you want to demolish your ' + name + '?', + _.bind(function () { + GenericBuildingRPCActions.requestGenericBuildingRPCDemolish(this.props.building.url, { + building_id: this.props.building.id, + }); + }, this) + ); + } + + onDowngradeClick() { + let name = this.props.building.name + ' ' + this.props.building.level; + + vex.confirm( + 'Are you sure you want to downgrade your ' + name + '?', + _.bind(function () { + GenericBuildingRPCActions.requestGenericBuildingRPCDowngrade( + this.props.building.url, + this.props.building.id ); + }, this) + ); + } + + onUpgradeClick() { + GenericBuildingRPCActions.requestGenericBuildingRPCUpgrade( + this.props.building.url, + this.props.building.id + ); + } + + render() { + let b = GenericBuildingRPCStore; + let body = BodyRPCStore; + + // Don't let the user downgrade a level 1 building. They should demolish it instead. + if (b.level === 1) { + b.downgrade.can = 0; + b.downgrade.reason = [1009, 'You cannot downgrade a level 1 building.', undefined]; } - onDowngradeClick() { - let name = this.props.building.name + ' ' + this.props.building.level; - - vex.confirm( - 'Are you sure you want to downgrade your ' + name + '?', - _.bind(function () { - GenericBuildingRPCActions.requestGenericBuildingRPCDowngrade( - this.props.building.url, - this.props.building.id - ); - }, this) - ); - } + return ( +
+
+
+
+ Current production +
+
+
+
+ Upgrade production +
+
+
+
+ Upgrade cost +
+
+
- onUpgradeClick() { - GenericBuildingRPCActions.requestGenericBuildingRPCUpgrade( - this.props.building.url, - this.props.building.id - ); - } +
+
+ + + + + + + + + + +
+ +
+ + + + - render() { - let b = GenericBuildingRPCStore; - let body = BodyRPCStore; - - // Don't let the user downgrade a level 1 building. They should demolish it instead. - if (b.level === 1) { - b.downgrade.can = 0; - b.downgrade.reason = [1009, 'You cannot downgrade a level 1 building.', undefined]; - } - - return ( -
-
-
-
- Current production -
-
-
-
- Upgrade production -
-
-
-
- Upgrade cost -
-
-
- -
-
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
-
- -
-
-
- this.onDemolishClick()} - /> - - this.onUpgradeClick()} - /> - - this.onDowngradeClick()} - /> -
-
-
+ + + + + +
+ +
+ + + + + + + + + + +
+
+ +
+
+
+ this.onDemolishClick()} + /> + + this.onUpgradeClick()} + /> + + this.onDowngradeClick()} + />
- ); - } +
+
+
+ ); + } } export default observer(ProductionTab); diff --git a/app/components/building/repairTab.jsx b/app/components/building/repairTab.jsx index d599c78c..86ca0d34 100644 --- a/app/components/building/repairTab.jsx +++ b/app/components/building/repairTab.jsx @@ -7,77 +7,77 @@ import BodyRPCStore from 'app/stores/rpc/body'; import ResourceCost from 'app/components/building/resourceCost'; let RepairTab = createReactClass({ - displayName: 'RepairTab', + displayName: 'RepairTab', - mixins: [ - // Reflux.connect(GenericBuildingStore, 'genericBuildingStore'), - // Reflux.connect(BodyRPCStore, 'body'), - ], + mixins: [ + // Reflux.connect(GenericBuildingStore, 'genericBuildingStore'), + // Reflux.connect(BodyRPCStore, 'body'), + ], - handleClick: function () { - GenericBuildingRPCActions.requestGenericBuildingRPCRepair( - this.state.genericBuildingStore.url, - this.state.genericBuildingStore.id - ); - }, + handleClick: function () { + GenericBuildingRPCActions.requestGenericBuildingRPCRepair( + this.state.genericBuildingStore.url, + this.state.genericBuildingStore.id + ); + }, - render: function () { - let building = this.state.genericBuildingStore; - let body = BodyRPCStore; + render: function () { + let building = this.state.genericBuildingStore; + let body = BodyRPCStore; - return ( -
-
-
-
- Repair costs -
-
-
+ return ( +
+
+
+
+ Repair costs +
+
+
-
-
- +
+
+ - + - + - -
-
+ +
+
-
-
-
- Repair -
-
-
+
+
+
+ Repair
- ); - }, +
+
+
+ ); + }, }); export default RepairTab; diff --git a/app/components/building/resourceCost.jsx b/app/components/building/resourceCost.jsx index 5c5f8b0e..ee9d6b76 100644 --- a/app/components/building/resourceCost.jsx +++ b/app/components/building/resourceCost.jsx @@ -7,28 +7,28 @@ import ResourceLine from 'app/components/building/resourceLine'; import * as util from 'app/util'; class ResourceCost extends React.Component { - static propTypes = { - icon: PropTypes.string.isRequired, - number: PropTypes.number.isRequired, - stored: PropTypes.number, - }; - - render() { - let red = false; - - if (typeof this.props.stored === 'number' && this.props.number > this.props.stored) { - red = true; - } - - return ( - - ); + static propTypes = { + icon: PropTypes.string.isRequired, + number: PropTypes.number.isRequired, + stored: PropTypes.number, + }; + + render() { + let red = false; + + if (typeof this.props.stored === 'number' && this.props.number > this.props.stored) { + red = true; } + + return ( + + ); + } } export default ResourceCost; diff --git a/app/components/building/resourceLine.jsx b/app/components/building/resourceLine.jsx index 4526b494..7293ecda 100644 --- a/app/components/building/resourceLine.jsx +++ b/app/components/building/resourceLine.jsx @@ -4,37 +4,37 @@ import React from 'react'; import classnames from 'classnames'; class ResourceLine extends React.Component { - static propTypes = { - icon: PropTypes.string.isRequired, - title: PropTypes.string.isRequired, - red: PropTypes.bool, - content: PropTypes.string, - }; + static propTypes = { + icon: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + red: PropTypes.bool, + content: PropTypes.string, + }; - render() { - let iconClass = classnames(this.props.icon, 'large icon', { - red: this.props.red, - }); + render() { + let iconClass = classnames(this.props.icon, 'large icon', { + red: this.props.red, + }); - return ( -
- - - {this.props.content} - -
- ); - } + return ( +
+ + + {this.props.content} + +
+ ); + } } export default ResourceLine; diff --git a/app/components/building/resourceProduction.jsx b/app/components/building/resourceProduction.jsx index dfd0c017..fafedfcb 100644 --- a/app/components/building/resourceProduction.jsx +++ b/app/components/building/resourceProduction.jsx @@ -7,20 +7,20 @@ import ResourceLine from 'app/components/building/resourceLine'; import * as util from 'app/util'; class ResourceProduction extends React.Component { - static propTypes = { - icon: PropTypes.string.isRequired, - number: PropTypes.number.isRequired, - }; + static propTypes = { + icon: PropTypes.string.isRequired, + number: PropTypes.number.isRequired, + }; - render() { - return ( - - ); - } + render() { + return ( + + ); + } } export default ResourceProduction; diff --git a/app/components/captcha.jsx b/app/components/captcha.jsx index 5664cdca..a44d0201 100644 --- a/app/components/captcha.jsx +++ b/app/components/captcha.jsx @@ -6,116 +6,116 @@ import createReactClass from 'create-react-class'; import CaptchaRPCStore from 'app/stores/rpc/captcha'; let Captcha = createReactClass({ - displayName: 'Captcha', - - statics: { - options: { - title: 'Verify Your Humanity', - width: 320, - height: 'auto', - }, - }, - - propTypes: { - options: PropTypes.object.isRequired, - }, - - // mixins: [Reflux.connect(CaptchaRPCStore, 'captchaRPCStore')], + displayName: 'Captcha', - componentWillMount: function () { - CaptchaRPCActions.requestCaptchaRPCFetch(); + statics: { + options: { + title: 'Verify Your Humanity', + width: 320, + height: 'auto', }, - - componentWillUnmount: function () { - let success = this.props.options.success; - if (typeof success === 'function') { - if (this.state.captchaRPCStore.solved) { - success(); - } - } - }, - - componentDidUpdate: function (prevProps, prevState) { - if (prevState.captchaRPCStore.url !== this.state.captchaRPCStore.url) { - this.clearSolutionField(); - } - }, - - onWindowShow: function () { - this.clearSolutionField(); - CaptchaRPCActions.requestCaptchaRPCFetch(); - }, - - handleEnterKey: function (event) { - if (event.key === 'Enter') { - event.preventDefault(); - this.onClickSolve(); - } - }, - - onClickSolve: function () { - let solution = this.refs.solution.value; - - CaptchaRPCActions.requestCaptchaRPCSolve({ - guid: this.state.captchaRPCStore.guid, - solution: solution, - }); - }, - - onClickRefresh: function () { - this.clearSolutionField(); - CaptchaWindowActions.captchaWindowRefresh(); - }, - - onClickClose: function () { - this.clearSolutionField(); - WindowActions.windowCloseByType('captcha'); - }, - - clearSolutionField: function () { - this.refs.solution.value = ''; - }, - - render: function () { - return ( -
-
- -
- -
- - -
-
- -
-
- -
-
- -
-
-
+ }, + + propTypes: { + options: PropTypes.object.isRequired, + }, + + // mixins: [Reflux.connect(CaptchaRPCStore, 'captchaRPCStore')], + + componentWillMount: function () { + CaptchaRPCActions.requestCaptchaRPCFetch(); + }, + + componentWillUnmount: function () { + let success = this.props.options.success; + if (typeof success === 'function') { + if (this.state.captchaRPCStore.solved) { + success(); + } + } + }, + + componentDidUpdate: function (prevProps, prevState) { + if (prevState.captchaRPCStore.url !== this.state.captchaRPCStore.url) { + this.clearSolutionField(); + } + }, + + onWindowShow: function () { + this.clearSolutionField(); + CaptchaRPCActions.requestCaptchaRPCFetch(); + }, + + handleEnterKey: function (event) { + if (event.key === 'Enter') { + event.preventDefault(); + this.onClickSolve(); + } + }, + + onClickSolve: function () { + let solution = this.refs.solution.value; + + CaptchaRPCActions.requestCaptchaRPCSolve({ + guid: this.state.captchaRPCStore.guid, + solution: solution, + }); + }, + + onClickRefresh: function () { + this.clearSolutionField(); + CaptchaWindowActions.captchaWindowRefresh(); + }, + + onClickClose: function () { + this.clearSolutionField(); + WindowActions.windowCloseByType('captcha'); + }, + + clearSolutionField: function () { + this.refs.solution.value = ''; + }, + + render: function () { + return ( +
+
+ +
+ +
+ + +
+
+
- ); - }, +
+ +
+
+ +
+
+
+
+ ); + }, }); export default Captcha; diff --git a/app/components/countdownTimer.tsx b/app/components/countdownTimer.tsx index 89936f74..98bd129e 100644 --- a/app/components/countdownTimer.tsx +++ b/app/components/countdownTimer.tsx @@ -2,17 +2,17 @@ import React from 'react'; import PropTypes from 'prop-types'; type Props = { - endDate: string; -} + endDate: string; +}; class CountdownTimer extends React.Component { - static propTypes = { - endDate: PropTypes.string, - } + static propTypes = { + endDate: PropTypes.string, + }; - render() { - return
{this.props.endDate}
; - } + render() { + return
{this.props.endDate}
; + } } export default CountdownTimer; diff --git a/app/components/errorBoundary.tsx b/app/components/errorBoundary.tsx index c3ebab31..b3f09030 100644 --- a/app/components/errorBoundary.tsx +++ b/app/components/errorBoundary.tsx @@ -1,59 +1,59 @@ import React, { ErrorInfo } from 'react'; -declare const YAHOO:any; +declare const YAHOO: any; type Props = { - children: React.ReactNode; + children: React.ReactNode; }; type State = { - hasError: boolean; -} + hasError: boolean; +}; class ErrorBoundary extends React.Component { - public state: State = { - hasError: false, - } - - static getDerivedStateFromError() { - return { hasError: true }; - } - - componentDidCatch(error: Error, errorInfo: ErrorInfo) { - console.error('Error info', errorInfo); - YAHOO.lacuna.Game.QuickDialog( - { - width: '500px', - text: [ - '

A client error has occurred.
Please report this on the support forums, and include the data below:

', - '', - ].join(''), - buttons: [ - { - text: 'Close', - handler: function() { - this.hide(); - }, - }, - ], + public state: State = { + hasError: false, + }; + + static getDerivedStateFromError() { + return { hasError: true }; + } + + componentDidCatch(error: Error, errorInfo: ErrorInfo) { + console.error('Error info', errorInfo); + YAHOO.lacuna.Game.QuickDialog( + { + width: '500px', + text: [ + '

A client error has occurred.
Please report this on the support forums, and include the data below:

', + '', + ].join(''), + buttons: [ + { + text: 'Close', + handler: function () { + this.hide(); }, - null, - null - ); + }, + ], + }, + null, + null + ); + } + + render() { + if (this.state.hasError) { + // Returning any kind of response after an error keeps the rest of the document alive. + return
; } - render() { - if (this.state.hasError) { - // Returning any kind of response after an error keeps the rest of the document alive. - return
; - } - - return this.props.children; - } + return this.props.children; + } } export default ErrorBoundary; diff --git a/app/components/essentia.tsx b/app/components/essentia.tsx index 308b115e..be345dc7 100644 --- a/app/components/essentia.tsx +++ b/app/components/essentia.tsx @@ -8,22 +8,22 @@ import GetEssentiaTab from 'app/components/essentia/getEssentiaTab'; import { Tabs, Tab } from 'app/components/tabber'; class Essentia extends React.Component { - render() { - return ( - - - - + render() { + return ( + + + + - - - - - ); - } + + + + + ); + } } export default Essentia; diff --git a/app/components/essentia/boost.jsx b/app/components/essentia/boost.jsx index 65138fe0..4b1468c2 100644 --- a/app/components/essentia/boost.jsx +++ b/app/components/essentia/boost.jsx @@ -10,99 +10,97 @@ import EmpireRPCStore from 'app/stores/rpc/empire'; import * as util from 'app/util'; class Boost extends React.Component { - static propTypes = { - type: PropTypes.string.isRequired, - iconName: PropTypes.string.isRequired, - description: PropTypes.string.isRequired, - ms: PropTypes.number.isRequired, - }; + static propTypes = { + type: PropTypes.string.isRequired, + iconName: PropTypes.string.isRequired, + description: PropTypes.string.isRequired, + ms: PropTypes.number.isRequired, + }; - static defaultProps = { - type: '', - iconName: '', - description: '', - ms: 0, - }; + static defaultProps = { + type: '', + iconName: '', + description: '', + ms: 0, + }; - handleBoost = () => { - let type = this.props.type; - let weeks = this.refs.weeks.value; + handleBoost = () => { + let type = this.props.type; + let weeks = this.refs.weeks.value; - if ( - !validator.isInt(weeks, { - min: 1, - max: 100, // The server has no max but this seems like a reasonable limit, to me. - }) - ) { - vex.alert('Number of weeks must be an integer between 1 and 100.'); - return; - } else if (weeks * 5 > EmpireRPCStore.essentia) { - vex.alert('Insufficient Essentia.'); - return; - } - EmpireRPCActions.requestEmpireRPCBoost({ type: type, weeks: weeks }); - }; + if ( + !validator.isInt(weeks, { + min: 1, + max: 100, // The server has no max but this seems like a reasonable limit, to me. + }) + ) { + vex.alert('Number of weeks must be an integer between 1 and 100.'); + return; + } else if (weeks * 5 > EmpireRPCStore.essentia) { + vex.alert('Insufficient Essentia.'); + return; + } + EmpireRPCActions.requestEmpireRPCBoost({ type: type, weeks: weeks }); + }; - renderButton = () => { - let iconClassName = classnames('icon', this.props.iconName); + renderButton = () => { + let iconClassName = classnames('icon', this.props.iconName); - return ( -
- - Boost -
- ); - }; + return ( +
+ + Boost +
+ ); + }; - tagClassNames() { - if (this.props.ms > 0) { - let day = 1000 * 60 * 60 * 24; // Milliseconds per day + tagClassNames() { + if (this.props.ms > 0) { + let day = 1000 * 60 * 60 * 24; // Milliseconds per day - // Change the color of the tags as the countdown gets closer to zero. - return classnames('ui left pointing label', { - green: this.props.ms > 3 * day, // More than three days - yellow: 3 * day > this.props.ms && this.props.ms > day, // Less than three days and more than one day - red: day > this.props.ms, // Less than one day - }); - } + // Change the color of the tags as the countdown gets closer to zero. + return classnames('ui left pointing label', { + green: this.props.ms > 3 * day, // More than three days + yellow: 3 * day > this.props.ms && this.props.ms > day, // Less than three days and more than one day + red: day > this.props.ms, // Less than one day + }); } + } - render() { - return ( -
-
- + render() { + return ( +
+
+ - {this.renderButton()} -
- {this.props.ms > 0 ? ( -
- {util.formatMillisecondTime(this.props.ms)} -
- ) : ( -
- )} -
- ); - } + {this.renderButton()} +
+ {this.props.ms > 0 ? ( +
{util.formatMillisecondTime(this.props.ms)}
+ ) : ( +
+ )} +
+ ); + } } export default observer(Boost); diff --git a/app/components/essentia/boostsTab.jsx b/app/components/essentia/boostsTab.jsx index e3291ea4..601759a9 100644 --- a/app/components/essentia/boostsTab.jsx +++ b/app/components/essentia/boostsTab.jsx @@ -7,84 +7,84 @@ import EmpireService from 'app/services/empire'; import Boost from 'app/components/essentia/boost'; class BoostsTab extends React.Component { - componentDidMount() { - EmpireService.getBoosts(); - } + componentDidMount() { + EmpireService.getBoosts(); + } - render() { - return ( -
-
-
-
- Essentia -
{EmpireRPCStore.exact_essentia}
-
-
- Boost Cost -
5 Essentia
-
-
-
+ render() { + return ( +
+
+
+
+ Essentia +
{EmpireRPCStore.exact_essentia}
+
+
+ Boost Cost +
5 Essentia
+
+
+
-
-
- - - - -
+
+
+ + + + +
-
- - - - -
-
-
- ); - } +
+ + + + +
+
+
+ ); + } } export default observer(BoostsTab); diff --git a/app/components/essentia/getEssentiaTab.jsx b/app/components/essentia/getEssentiaTab.jsx index fce4c38e..0a7bf074 100644 --- a/app/components/essentia/getEssentiaTab.jsx +++ b/app/components/essentia/getEssentiaTab.jsx @@ -4,65 +4,64 @@ import * as vex from 'app/vex'; import WindowsStore from 'app/stores/windows'; class GetEssentiaTab extends React.Component { - purchase() { - vex.alert('Not available at the moment.'); - // let url = constants.RPC_BASE + 'pay?session_id=' + SessionStore.session; - // window.open( - // url, - // 'essentiaPayment', - // 'status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1,height=550,width=600,directories=0' - // ); - } + purchase() { + vex.alert('Not available at the moment.'); + // let url = constants.RPC_BASE + 'pay?session_id=' + SessionStore.session; + // window.open( + // url, + // 'essentiaPayment', + // 'status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1,height=550,width=600,directories=0' + // ); + } - redeem() { - vex.alert('Not available at the moment.'); - // let node = this.refs.code; - // EmpireRPCActions.requestEmpireRPCRedeemEssentiaCode({ - // code: node.value, - // }); - // node.value = ''; - } + redeem() { + vex.alert('Not available at the moment.'); + // let node = this.refs.code; + // EmpireRPCActions.requestEmpireRPCRedeemEssentiaCode({ + // code: node.value, + // }); + // node.value = ''; + } - invite() { - WindowsStore.add('invite'); - } + invite() { + WindowsStore.add('invite'); + } - render() { - return ( -
-
this.purchase()}> - - Purchase Essentia -
+ render() { + return ( +
+
this.purchase()}> + + Purchase Essentia +
-

OR

+

OR

-
- - -
+
+ + +
-

OR

+

OR

-

- Invite your friends to the game and you get free Essentia! For - every university level past 4 that they achieve, you'll get 5 Essentia. That's - up to{' '} - - 130 Essentia - {' '} - per friend! -

+

+ Invite your friends to the game and you get free Essentia! For every + university level past 4 that they achieve, you'll get 5 Essentia. That's up to{' '} + + 130 Essentia + {' '} + per friend! +

-
this.invite()}> - - Invite a Friend -
-
- ); - } +
this.invite()}> + + Invite a Friend +
+
+ ); + } } export default observer(GetEssentiaTab); diff --git a/app/components/essentiavein.tsx b/app/components/essentiavein.tsx index de634f63..eae91597 100644 --- a/app/components/essentiavein.tsx +++ b/app/components/essentiavein.tsx @@ -13,51 +13,50 @@ import { Tabs, Tab } from 'app/components/tabber'; import { WindowOptions } from 'app/interfaces'; type Props = { - options: WindowOptions; + options: WindowOptions; }; class EssentiaVein extends React.Component { - componentDidMount() { - GenericBuildingService.view(this.props.options.url, this.props.options.id); - } - - componentDidUpdate(prevProps: Props) { - if ( - prevProps.options.url != this.props.options.url || - prevProps.options.id != this.props.options.id - ) { - GenericBuildingService.view(this.props.options.url, this.props.options.id); - } - } - - render() { - const building = {}; - return ( -
- -
- - {GenericBuildingRPCStore.efficiency !== 100 && - GenericBuildingRPCStore.id ? ( - - - - ) : ( - <> - )} - - - - - - - - - -
-
- ); + componentDidMount() { + GenericBuildingService.view(this.props.options.url, this.props.options.id); + } + + componentDidUpdate(prevProps: Props) { + if ( + prevProps.options.url != this.props.options.url || + prevProps.options.id != this.props.options.id + ) { + GenericBuildingService.view(this.props.options.url, this.props.options.id); } + } + + render() { + const building = {}; + return ( +
+ +
+ + {GenericBuildingRPCStore.efficiency !== 100 && GenericBuildingRPCStore.id ? ( + + + + ) : ( + <> + )} + + + + + + + + + +
+
+ ); + } } export default EssentiaVein; diff --git a/app/components/essentiavein/drainTab.tsx b/app/components/essentiavein/drainTab.tsx index afcbb8b0..261203b5 100644 --- a/app/components/essentiavein/drainTab.tsx +++ b/app/components/essentiavein/drainTab.tsx @@ -2,55 +2,55 @@ import React from 'react'; import _ from 'lodash'; type Props = { - building: any; + building: any; }; class DrainTab extends React.Component { - dropdown = React.createRef(); - - componentDidMount() { - $(this.refs.dropdown).dropdown(); - } - - handleDrain = () => { - let times = parseInt($(this.refs.dropdown).dropdown('get value'), 10) / 30; - let id = this.props.building.id; - - EssentiaVeinRPCActions.requestEssentiaVeinRPCDrain({ - id: id, - times: times, - }); - }; - - render() { - return ( -
- Drain{' '} -
-
30 days
- -
- {_.times(this.props.building.drain_capable, function (num) { - // Num starts on 0. - num += 1; - - let days = num * 30; - let str = days + ' days'; - - return ( -
- {days} -
- ); - })} -
+ dropdown = React.createRef(); + + componentDidMount() { + $(this.refs.dropdown).dropdown(); + } + + handleDrain = () => { + let times = parseInt($(this.refs.dropdown).dropdown('get value'), 10) / 30; + let id = this.props.building.id; + + EssentiaVeinRPCActions.requestEssentiaVeinRPCDrain({ + id: id, + times: times, + }); + }; + + render() { + return ( +
+ Drain{' '} +
+
30 days
+ +
+ {_.times(this.props.building.drain_capable, function (num) { + // Num starts on 0. + num += 1; + + let days = num * 30; + let str = days + ' days'; + + return ( +
+ {days}
-
- Drain -
-
- ); - } + ); + })} +
+
+
+ Drain +
+
+ ); + } } export default DrainTab; diff --git a/app/components/genericBuilding.tsx b/app/components/genericBuilding.tsx index c07b74a6..bbca8826 100644 --- a/app/components/genericBuilding.tsx +++ b/app/components/genericBuilding.tsx @@ -13,54 +13,53 @@ import GenericBuildingService from 'app/services/genericBuilding'; import { WindowOptions } from 'app/interfaces'; type Props = { - options: WindowOptions; + options: WindowOptions; }; class GenericBuilding extends React.Component { - static propTypes = { - options: PropTypes.object, - }; + static propTypes = { + options: PropTypes.object, + }; - componentDidMount() { - GenericBuildingService.view(this.props.options.url, this.props.options.id); - } + componentDidMount() { + GenericBuildingService.view(this.props.options.url, this.props.options.id); + } - componentDidUpdate(prevProps: Props) { - if ( - prevProps.options.url != this.props.options.url || - prevProps.options.id != this.props.options.id - ) { - GenericBuildingService.view(this.props.options.url, this.props.options.id); - } + componentDidUpdate(prevProps: Props) { + if ( + prevProps.options.url != this.props.options.url || + prevProps.options.id != this.props.options.id + ) { + GenericBuildingService.view(this.props.options.url, this.props.options.id); } + } - closeWindow() { - WindowsStore.close('genericBuilding'); - } + closeWindow() { + WindowsStore.close('genericBuilding'); + } - render() { - return ( -
- -
- - {GenericBuildingRPCStore.efficiency !== 100 && - GenericBuildingRPCStore.id ? ( - - - - ) : ( - <> - )} + render() { + return ( +
+ +
+ + {GenericBuildingRPCStore.efficiency !== 100 && GenericBuildingRPCStore.id ? ( + + + + ) : ( + <> + )} - - - - -
-
- ); - } + + + +
+
+
+ ); + } } export default observer(GenericBuilding); diff --git a/app/components/inteltraining.jsx b/app/components/inteltraining.jsx index 0a2894e3..4044dc1d 100644 --- a/app/components/inteltraining.jsx +++ b/app/components/inteltraining.jsx @@ -11,55 +11,55 @@ import SpyTrainingStatus from 'app/components/spyTraining/spyTrainingStatus'; import { Tabs, Tab } from 'app/components/tabber'; let IntelTraining = createReactClass({ - displayName: 'IntelTraining', + displayName: 'IntelTraining', - statics: { - options: { - title: 'Intel Training', - width: 700, - height: 420, - }, + statics: { + options: { + title: 'Intel Training', + width: 700, + height: 420, }, + }, - propTypes: { - options: PropTypes.object, - }, + propTypes: { + options: PropTypes.object, + }, - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - IntelTrainingRPCActions.requestIntelTrainingRPCView(this.props.options.id); - }, + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + IntelTrainingRPCActions.requestIntelTrainingRPCView(this.props.options.id); + }, - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - if (building.extraViewData.spies) { - tabs.push( - - - - ); - } + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + if (building.extraViewData.spies) { + tabs.push( + + + + ); + } - return ( -
- -
- {tabs} -
-
- ); - }, + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default IntelTraining; diff --git a/app/components/invite.tsx b/app/components/invite.tsx index 30b26ec0..81898b49 100644 --- a/app/components/invite.tsx +++ b/app/components/invite.tsx @@ -5,66 +5,62 @@ import EmpireService from 'app/services/empire'; import WindowsStore from 'app/stores/windows'; class InviteWindow extends React.Component { - emailInput = React.createRef(); - messageInput = React.createRef(); + emailInput = React.createRef(); + messageInput = React.createRef(); - closeWindow() { - WindowsStore.close('invite'); - } + closeWindow() { + WindowsStore.close('invite'); + } - handleInvite() { - if (this.emailInput.current && this.messageInput.current) { - const email = this.emailInput.current.value; - const message = this.messageInput.current.value; - EmpireService.inviteFriend(email, message); - } + handleInvite() { + if (this.emailInput.current && this.messageInput.current) { + const email = this.emailInput.current.value; + const message = this.messageInput.current.value; + EmpireService.inviteFriend(email, message); } + } - componentDidMount() { - EmpireService.getInviteFriendUrl(); - } + componentDidMount() { + EmpireService.getInviteFriendUrl(); + } - render() { - let defaultMessage = [ - "I'm having a great time with this new game called 'Kenó Antigen'.", - 'Come play with me!', - ].join(' '); + render() { + let defaultMessage = [ + "I'm having a great time with this new game called 'Kenó Antigen'.", + 'Come play with me!', + ].join(' '); - return ( -
-
-
- - -
+ return ( +
+
+
+ + +
-
- - -
+
+ + +
-
this.handleInvite()}> - Send Invite -
-
+
this.handleInvite()}> + Send Invite +
+
-
+
-
- -
-
- ); - } +
+ +
+
+ ); + } } export default observer(InviteWindow); diff --git a/app/components/login.jsx b/app/components/login.jsx index 54fa177e..5c3a4c5d 100644 --- a/app/components/login.jsx +++ b/app/components/login.jsx @@ -1,45 +1,45 @@ import React from 'react'; class LoginWindow extends React.Component { - static options = { - title: 'Web Socket Login', - width: 500, - height: 200, - }; + static options = { + title: 'Web Socket Login', + width: 500, + height: 200, + }; - clickLogin = () => { - let username = this.refs.username.value; - let password = this.refs.password.value; + clickLogin = () => { + let username = this.refs.username.value; + let password = this.refs.password.value; - UserWSActions.requestUserWSLoginWithPassword({ - username: username, - password: password, - }); - }; + UserWSActions.requestUserWSLoginWithPassword({ + username: username, + password: password, + }); + }; - closeWindow = () => { - WindowActions.windowCloseByType('login'); - }; + closeWindow = () => { + WindowActions.windowCloseByType('login'); + }; - render() { - return ( -
-
- -
-
- -
-
- Login -
-
- ); - } + render() { + return ( +
+
+ +
+
+ +
+
+ Login +
+
+ ); + } } export default LoginWindow; diff --git a/app/components/mail.tsx b/app/components/mail.tsx index ce67f28a..0bab8ce5 100644 --- a/app/components/mail.tsx +++ b/app/components/mail.tsx @@ -5,13 +5,13 @@ import MailWindowStore from 'app/stores/window/mail'; declare const YAHOO: any; class MailWindow extends React.Component { - render() { - if (MailWindowStore.shown) { - YAHOO.lacuna.Messaging.show(); - } - - return
; + render() { + if (MailWindowStore.shown) { + YAHOO.lacuna.Messaging.show(); } + + return
; + } } export default observer(MailWindow); diff --git a/app/components/mayhemtraining.jsx b/app/components/mayhemtraining.jsx index b5faa4ca..9fb3e4d1 100644 --- a/app/components/mayhemtraining.jsx +++ b/app/components/mayhemtraining.jsx @@ -11,55 +11,55 @@ import SpyTrainingStatus from 'app/components/spyTraining/spyTrainingStatus'; import { Tabs, Tab } from 'app/components/tabber'; let MayhemTraining = createReactClass({ - displayName: 'MayhemTraining', + displayName: 'MayhemTraining', - statics: { - options: { - title: 'Mayhem Training', - width: 700, - height: 420, - }, + statics: { + options: { + title: 'Mayhem Training', + width: 700, + height: 420, }, + }, - propTypes: { - options: PropTypes.object, - }, + propTypes: { + options: PropTypes.object, + }, - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - MayhemTrainingRPCActions.requestMayhemTrainingRPCView(this.props.options.id); - }, + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + MayhemTrainingRPCActions.requestMayhemTrainingRPCView(this.props.options.id); + }, - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - if (building.extraViewData.spies) { - tabs.push( - - - - ); - } + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + if (building.extraViewData.spies) { + tabs.push( + + + + ); + } - return ( -
- -
- {tabs} -
-
- ); - }, + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default MayhemTraining; diff --git a/app/components/menu.tsx b/app/components/menu.tsx index 5ee9b0fb..05f3317c 100644 --- a/app/components/menu.tsx +++ b/app/components/menu.tsx @@ -12,24 +12,24 @@ import Loader from 'app/components/menu/loader'; import MenuStore from 'app/stores/menu'; class Menu extends React.Component { - render() { - if (MenuStore.menuShown) { - return ( -
- - - - -
- - - -
- ); - } else { - return
; - } + render() { + if (MenuStore.menuShown) { + return ( +
+ + + + +
+ + + +
+ ); + } else { + return
; } + } } export default observer(Menu); diff --git a/app/components/menu/bottomBar.jsx b/app/components/menu/bottomBar.jsx index 46ff3850..601ec4a3 100644 --- a/app/components/menu/bottomBar.jsx +++ b/app/components/menu/bottomBar.jsx @@ -18,262 +18,227 @@ import * as util from 'app/util'; let rn = util.reduceNumber; class BottomBar extends React.Component { - constructor(props) { - super(props); - this.bottomBar = React.createRef(); - this.foodSection = React.createRef(); - this.oreSection = React.createRef(); - this.waterSection = React.createRef(); - this.energySection = React.createRef(); - this.wasteSection = React.createRef(); - this.happinessSection = React.createRef(); - this.buildingCountSection = React.createRef(); - this.buildQueueSection = React.createRef(); - this.rpcCountSection = React.createRef(); - } - - componentWillUnmount() { - // Destroy! - $('div', this.bottomBar).popup('destroy'); - } - - showFoodToolTip() { - $(ReactDOM.findDOMNode(this.foodSection.current)).popup({ - position: 'top center', - html: ReactDOMServer.renderToStaticMarkup( - - ), - }); - } - - showOreToolTip() { - $(ReactDOM.findDOMNode(this.oreSection.current)).popup({ - position: 'top center', - html: ReactDOMServer.renderToStaticMarkup( - - ), - }); - } - - showWaterToolTip() { - $(ReactDOM.findDOMNode(this.waterSection.current)).popup({ - position: 'top center', - html: ReactDOMServer.renderToStaticMarkup( - - ), - }); - } - - showEnergyToolTip() { - $(ReactDOM.findDOMNode(this.energySection.current)).popup({ - position: 'top center', - html: ReactDOMServer.renderToStaticMarkup( - - ), - }); - } - - showWasteToolTip() { - $(ReactDOM.findDOMNode(this.wasteSection.current)).popup({ - position: 'top center', - html: ReactDOMServer.renderToStaticMarkup( - - ), - }); - } - - showHappinessToolTip() { - $(ReactDOM.findDOMNode(this.happinessSection.current)).popup({ - position: 'top center', - html: ReactDOMServer.renderToStaticMarkup( - -
- - {BodyRPCStore.propaganda_boost} -
-
- ), - }); - } - - showBuildingCountToolTip() { - $(ReactDOM.findDOMNode(this.buildingCountSection.current)).popup({ - html: ReactDOMServer.renderToStaticMarkup(), - hoverable: true, - position: 'top center', - delay: { - hide: 800, - }, - }); - } - - showBuildQueueToolTip() { - let body = BodyRPCStore; - - $(ReactDOM.findDOMNode(this.buildQueueSection.current)).popup({ - html: ReactDOMServer.renderToStaticMarkup(), - hoverable: true, - position: 'top center', - delay: { - hide: 800, - }, - }); - } - - showRPCCountToolTip() { - $(ReactDOM.findDOMNode(this.rpcCountSection.current)).popup({ - html: ReactDOMServer.renderToStaticMarkup(), - hoverable: true, - position: 'top center', - delay: { - hide: 800, - }, - }); - } - - render() { - return ( -
-
-
- this.showFoodToolTip()} - /> - - this.showOreToolTip()} - /> - - this.showWaterToolTip()} - /> - - this.showEnergyToolTip()} - /> - - {BodyRPCStore.type !== 'space station' ? ( - this.showWasteToolTip()} - /> - ) : ( - '' - )} - - {BodyRPCStore.type !== 'space station' ? ( - this.showHappinessToolTip()} - /> - ) : ( - '' - )} - - this.showBuildingCountToolTip()} - /> - - this.showBuildQueueToolTip()} - /> - - this.showRPCCountToolTip()} - /> -
-
-
- ); - } + constructor(props) { + super(props); + this.bottomBar = React.createRef(); + this.foodSection = React.createRef(); + this.oreSection = React.createRef(); + this.waterSection = React.createRef(); + this.energySection = React.createRef(); + this.wasteSection = React.createRef(); + this.happinessSection = React.createRef(); + this.buildingCountSection = React.createRef(); + this.buildQueueSection = React.createRef(); + this.rpcCountSection = React.createRef(); + } + + componentWillUnmount() { + // Destroy! + $('div', this.bottomBar).popup('destroy'); + } + + showFoodToolTip() { + $(ReactDOM.findDOMNode(this.foodSection.current)).popup({ + position: 'top center', + html: ReactDOMServer.renderToStaticMarkup( + + ), + }); + } + + showOreToolTip() { + $(ReactDOM.findDOMNode(this.oreSection.current)).popup({ + position: 'top center', + html: ReactDOMServer.renderToStaticMarkup( + + ), + }); + } + + showWaterToolTip() { + $(ReactDOM.findDOMNode(this.waterSection.current)).popup({ + position: 'top center', + html: ReactDOMServer.renderToStaticMarkup( + + ), + }); + } + + showEnergyToolTip() { + $(ReactDOM.findDOMNode(this.energySection.current)).popup({ + position: 'top center', + html: ReactDOMServer.renderToStaticMarkup( + + ), + }); + } + + showWasteToolTip() { + $(ReactDOM.findDOMNode(this.wasteSection.current)).popup({ + position: 'top center', + html: ReactDOMServer.renderToStaticMarkup( + + ), + }); + } + + showHappinessToolTip() { + $(ReactDOM.findDOMNode(this.happinessSection.current)).popup({ + position: 'top center', + html: ReactDOMServer.renderToStaticMarkup( + +
+ + {BodyRPCStore.propaganda_boost} +
+
+ ), + }); + } + + showBuildingCountToolTip() { + $(ReactDOM.findDOMNode(this.buildingCountSection.current)).popup({ + html: ReactDOMServer.renderToStaticMarkup(), + hoverable: true, + position: 'top center', + delay: { + hide: 800, + }, + }); + } + + showBuildQueueToolTip() { + let body = BodyRPCStore; + + $(ReactDOM.findDOMNode(this.buildQueueSection.current)).popup({ + html: ReactDOMServer.renderToStaticMarkup(), + hoverable: true, + position: 'top center', + delay: { + hide: 800, + }, + }); + } + + showRPCCountToolTip() { + $(ReactDOM.findDOMNode(this.rpcCountSection.current)).popup({ + html: ReactDOMServer.renderToStaticMarkup(), + hoverable: true, + position: 'top center', + delay: { + hide: 800, + }, + }); + } + + render() { + return ( +
+
+
+ this.showFoodToolTip()} + /> + + this.showOreToolTip()} + /> + + this.showWaterToolTip()} + /> + + this.showEnergyToolTip()} + /> + + {BodyRPCStore.type !== 'space station' ? ( + this.showWasteToolTip()} + /> + ) : ( + '' + )} + + {BodyRPCStore.type !== 'space station' ? ( + this.showHappinessToolTip()} + /> + ) : ( + '' + )} + + this.showBuildingCountToolTip()} + /> + + this.showBuildQueueToolTip()} + /> + + this.showRPCCountToolTip()} + /> +
+
+
+ ); + } } export default observer(BottomBar); diff --git a/app/components/menu/bottomBar/bottomBarSection.jsx b/app/components/menu/bottomBar/bottomBarSection.jsx index b732b83b..a8d9e652 100644 --- a/app/components/menu/bottomBar/bottomBarSection.jsx +++ b/app/components/menu/bottomBar/bottomBarSection.jsx @@ -6,43 +6,39 @@ import classnames from 'classnames'; import ProgressBar from 'app/components/menu/bottomBar/progressBar'; class BottomBarSection extends React.Component { - static propTypes = { - iconName: PropTypes.string.isRequired, - topText: PropTypes.string.isRequired, - bottomText: PropTypes.string.isRequired, - toolTipShow: PropTypes.func, - progressPercent: PropTypes.number, - }; - - handleToolTip = () => { - if (typeof this.props.toolTipShow === 'function') { - this.props.toolTipShow(); - } - }; - - render() { - return ( -
- {this.props.progressPercent ? ( - - ) : ( - '' - )} - - - -

- {this.props.topText} -

- - {this.props.bottomText} -
- ); + static propTypes = { + iconName: PropTypes.string.isRequired, + topText: PropTypes.string.isRequired, + bottomText: PropTypes.string.isRequired, + toolTipShow: PropTypes.func, + progressPercent: PropTypes.number, + }; + + handleToolTip = () => { + if (typeof this.props.toolTipShow === 'function') { + this.props.toolTipShow(); } + }; + + render() { + return ( +
+ {this.props.progressPercent ? : ''} + + + +

+ {this.props.topText} +

+ + {this.props.bottomText} +
+ ); + } } export default BottomBarSection; diff --git a/app/components/menu/bottomBar/buildQueueToolTip.jsx b/app/components/menu/bottomBar/buildQueueToolTip.jsx index 5f670e91..15c1ff96 100644 --- a/app/components/menu/bottomBar/buildQueueToolTip.jsx +++ b/app/components/menu/bottomBar/buildQueueToolTip.jsx @@ -3,33 +3,29 @@ import PropTypes from 'prop-types'; import React from 'react'; class RPCCountToolTip extends React.Component { - static propTypes = { - body: PropTypes.object.isRequired, - }; + static propTypes = { + body: PropTypes.object.isRequired, + }; - render() { - if (this.props.body.type === 'space station') { - return ( -
- How many modules are queued to be built. Space stations do not have a build - queue limit. -
- ); - } else { - return ( - - ); - } + render() { + if (this.props.body.type === 'space station') { + return ( +
+ How many modules are queued to be built. Space stations do not have a build queue limit. +
+ ); + } else { + return ( + + ); } + } } export default RPCCountToolTip; diff --git a/app/components/menu/bottomBar/buildingCountToolTip.jsx b/app/components/menu/bottomBar/buildingCountToolTip.jsx index eabd479a..19faf67b 100644 --- a/app/components/menu/bottomBar/buildingCountToolTip.jsx +++ b/app/components/menu/bottomBar/buildingCountToolTip.jsx @@ -1,21 +1,21 @@ import React from 'react'; class BuildingCountToolTip extends React.Component { - render() { - return ( -
- Your current{' '} - - plot-using - {' '} - building count, and how many{' '} - - plots - {' '} - you have available. -
- ); - } + render() { + return ( +
+ Your current{' '} + + plot-using + {' '} + building count, and how many{' '} + + plots + {' '} + you have available. +
+ ); + } } export default BuildingCountToolTip; diff --git a/app/components/menu/bottomBar/progressBar.jsx b/app/components/menu/bottomBar/progressBar.jsx index bcbb1187..74572260 100644 --- a/app/components/menu/bottomBar/progressBar.jsx +++ b/app/components/menu/bottomBar/progressBar.jsx @@ -3,28 +3,28 @@ import PropTypes from 'prop-types'; import React from 'react'; class ProgressBar extends React.Component { - static propTypes = { - percent: PropTypes.number.isRequired, - }; + static propTypes = { + percent: PropTypes.number.isRequired, + }; - render() { - return ( -
- ); - } + render() { + return ( +
+ ); + } } export default ProgressBar; diff --git a/app/components/menu/bottomBar/resourceToolTip.jsx b/app/components/menu/bottomBar/resourceToolTip.jsx index e9e1a0dd..8d087159 100644 --- a/app/components/menu/bottomBar/resourceToolTip.jsx +++ b/app/components/menu/bottomBar/resourceToolTip.jsx @@ -6,100 +6,100 @@ import classnames from 'classnames'; import * as util from 'app/util'; class ResourceToolTip extends React.Component { - static propTypes = { - body: PropTypes.object.isRequired, - type: PropTypes.string.isRequired, - title: PropTypes.string.isRequired, - icon: PropTypes.string.isRequired, - children: PropTypes.node, - }; + static propTypes = { + body: PropTypes.object.isRequired, + type: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + icon: PropTypes.string.isRequired, + children: PropTypes.node, + }; - getResourceStatus = (hour, stored, capicity, hasCapicity) => { - // Different players have differnet strategies regarding waste. Some would consider full - // waste good. Some would consider empty waste good. Therefore, we shouldn't comment - // on what a player does or does not do with their waste. - if (this.props.type === 'waste') { - return ''; - } + getResourceStatus = (hour, stored, capicity, hasCapicity) => { + // Different players have differnet strategies regarding waste. Some would consider full + // waste good. Some would consider empty waste good. Therefore, we shouldn't comment + // on what a player does or does not do with their waste. + if (this.props.type === 'waste') { + return ''; + } - if (stored === capicity) { - return ( -
- - Full -
- ); - } else if (hour < 0 && stored > 0) { - return ( -
- - Empty in {util.formatTime((-3600 * stored) / hour)} -
- ); - } else if (hour > 0 && stored > 0 && hasCapicity) { - return ( -
- - Full in {util.formatTime((3600 * (capicity - stored)) / hour)} -
- ); - } else if (hour > 0 && stored > 0 && !hasCapicity) { - return ( -
- - Going up -
- ); - } else { - return ( -
- - Danger! -
- ); - } - }; + if (stored === capicity) { + return ( +
+ + Full +
+ ); + } else if (hour < 0 && stored > 0) { + return ( +
+ + Empty in {util.formatTime((-3600 * stored) / hour)} +
+ ); + } else if (hour > 0 && stored > 0 && hasCapicity) { + return ( +
+ + Full in {util.formatTime((3600 * (capicity - stored)) / hour)} +
+ ); + } else if (hour > 0 && stored > 0 && !hasCapicity) { + return ( +
+ + Going up +
+ ); + } else { + return ( +
+ + Danger! +
+ ); + } + }; - render() { - let body = this.props.body; + render() { + let body = this.props.body; - let hour = body[this.props.type + '_hour']; - let stored = body[this.props.type + '_stored'] || body[this.props.type] || 0; - let capicity = body[this.props.type + '_capacity']; + let hour = body[this.props.type + '_hour']; + let stored = body[this.props.type + '_stored'] || body[this.props.type] || 0; + let capicity = body[this.props.type + '_capacity']; - // Some resources (happiness) do not have a storage limit. - let hasCapicity = typeof capicity !== 'undefined'; + // Some resources (happiness) do not have a storage limit. + let hasCapicity = typeof capicity !== 'undefined'; - return ( -
-
- {this.props.title} -
+ return ( +
+
+ {this.props.title} +
-
- - {util.commify(stored)} {hasCapicity ? ' / ' + util.commify(capicity) : ''} -
+
+ + {util.commify(stored)} {hasCapicity ? ' / ' + util.commify(capicity) : ''} +
-
- - {util.commify(hour)} / hr -
+
+ + {util.commify(hour)} / hr +
- {this.props.children} + {this.props.children} - {this.getResourceStatus(hour, stored, capicity, hasCapicity)} -
- ); - } + {this.getResourceStatus(hour, stored, capicity, hasCapicity)} +
+ ); + } } export default ResourceToolTip; diff --git a/app/components/menu/bottomBar/rpcCountToolTip.jsx b/app/components/menu/bottomBar/rpcCountToolTip.jsx index 9694a270..c560ece5 100644 --- a/app/components/menu/bottomBar/rpcCountToolTip.jsx +++ b/app/components/menu/bottomBar/rpcCountToolTip.jsx @@ -1,17 +1,17 @@ import React from 'react'; class RPCCountToolTip extends React.Component { - render() { - return ( -
- The{' '} - - RPC limit - {' '} - is the number of requests you can send to the server in a 24 hour period. -
- ); - } + render() { + return ( +
+ The{' '} + + RPC limit + {' '} + is the number of requests you can send to the server in a 24 hour period. +
+ ); + } } export default RPCCountToolTip; diff --git a/app/components/menu/gameWindow.tsx b/app/components/menu/gameWindow.tsx index 74755161..b4a1732c 100644 --- a/app/components/menu/gameWindow.tsx +++ b/app/components/menu/gameWindow.tsx @@ -16,41 +16,41 @@ import ErrorBoundary from 'app/components/errorBoundary'; // const GameWindow: React.FunctionComponent = () => ( -
- - - - +
+ + + + - {/* One container to rule them all... */} -
- {/* + {/* One container to rule them all... */} +
+ {/* This sets all the tooltips in the entire client. See http://npmjs.org/package/react-tooltip for usage. */} - - - - - -
{/* This div is used by map. */} - - - - - - -
+ + + + + +
{/* This div is used by map. */} + + + + + +
+
); export default GameWindow; diff --git a/app/components/menu/leftSidebar.jsx b/app/components/menu/leftSidebar.jsx index ac381211..1f5d9fe1 100644 --- a/app/components/menu/leftSidebar.jsx +++ b/app/components/menu/leftSidebar.jsx @@ -11,213 +11,213 @@ import OptionsWindowStore from 'app/stores/window/options'; // Because there's a bit of special logic going on here, this is in a separate component. const SelfDestruct = observer( - class SelfDestruct extends React.Component { - handleDestructClick() { - MenuStore.hideLeftSidebar(); + class SelfDestruct extends React.Component { + handleDestructClick() { + MenuStore.hideLeftSidebar(); + + if (EmpireRPCStore.self_destruct_active === 1) { + EmpireRPCActions.requestEmpireRPCDisableSelfDestruct(); + return; + } + + vex.confirm( + 'Are you ABSOLUTELY sure you want to enable self destruct? If enabled, your empire will be deleted after 24 hours.', + EmpireRPCActions.requestEmpireRPCEnableSelfDestruct + ); + } - if (EmpireRPCStore.self_destruct_active === 1) { - EmpireRPCActions.requestEmpireRPCDisableSelfDestruct(); - return; - } - - vex.confirm( - 'Are you ABSOLUTELY sure you want to enable self destruct? If enabled, your empire will be deleted after 24 hours.', - EmpireRPCActions.requestEmpireRPCEnableSelfDestruct - ); - } - - render() { - let destructMs = EmpireRPCStore.self_destruct_ms; - let destructActive = EmpireRPCStore.self_destruct_active && destructMs > 0; - let formattedDestructMs = destructActive ? util.formatMillisecondTime(destructMs) : ''; - - let itemStyle = destructActive - ? { - color: 'red', - } - : {}; - - let verb = destructActive ? 'Disable' : 'Enable'; - - return ( - - - {verb} Self Destruct{' '} - {destructActive ? ( - -

- SELF DESTRUCT ACTIVE -

-

- {formattedDestructMs} -

-
- ) : ( - '' - )} -
- ); - } + render() { + let destructMs = EmpireRPCStore.self_destruct_ms; + let destructActive = EmpireRPCStore.self_destruct_active && destructMs > 0; + let formattedDestructMs = destructActive ? util.formatMillisecondTime(destructMs) : ''; + + let itemStyle = destructActive + ? { + color: 'red', + } + : {}; + + let verb = destructActive ? 'Disable' : 'Enable'; + + return ( + + + {verb} Self Destruct{' '} + {destructActive ? ( + +

+ SELF DESTRUCT ACTIVE +

+

+ {formattedDestructMs} +

+
+ ) : ( + '' + )} +
+ ); } + } ); class LeftSidebar extends React.Component { - componentDidMount() { - $('#left-sidebar').sidebar({ - context: $('#sidebarContainer'), - duration: 300, - transition: 'overlay', - onHidden: () => { - MenuStore.hideLeftSidebar(); - }, - }); - } - - componentDidUpdate() { - $('#left-sidebar').sidebar(MenuStore.leftSidebarShown ? 'show' : 'hide'); - } - - render() { - const shown = MenuStore.leftSidebarShown; - return ( - - ); - } + componentDidMount() { + $('#left-sidebar').sidebar({ + context: $('#sidebarContainer'), + duration: 300, + transition: 'overlay', + onHidden: () => { + MenuStore.hideLeftSidebar(); + }, + }); + } + + componentDidUpdate() { + $('#left-sidebar').sidebar(MenuStore.leftSidebarShown ? 'show' : 'hide'); + } + + render() { + const shown = MenuStore.leftSidebarShown; + return ( + + ); + } } export default observer(LeftSidebar); diff --git a/app/components/menu/leftSidebarButton.jsx b/app/components/menu/leftSidebarButton.jsx index f7f0ed4f..e39a7c4e 100644 --- a/app/components/menu/leftSidebarButton.jsx +++ b/app/components/menu/leftSidebarButton.jsx @@ -5,30 +5,27 @@ import EmpireRPCStore from 'app/stores/rpc/empire'; import MenuStore from 'app/stores/menu'; class LeftSidebarButton extends React.Component { - clickLeftSidebarButton() { - MenuStore.showLeftSidebar(); - } + clickLeftSidebarButton() { + MenuStore.showLeftSidebar(); + } - render() { - return ( -
-
- - {EmpireRPCStore.name} -
-
- ); - } + render() { + return ( +
+
+ + {EmpireRPCStore.name} +
+
+ ); + } } export default observer(LeftSidebarButton); diff --git a/app/components/menu/loader.tsx b/app/components/menu/loader.tsx index ed5773eb..9c25b6c2 100644 --- a/app/components/menu/loader.tsx +++ b/app/components/menu/loader.tsx @@ -5,19 +5,19 @@ import MenuStore from 'app/stores/menu'; import classnames from 'classnames'; class Loader extends React.Component { - render() { - return ( -
- ); - } + render() { + return ( +
+ ); + } } export default observer(Loader); diff --git a/app/components/menu/map.jsx b/app/components/menu/map.jsx index 116ab4f8..c986d098 100644 --- a/app/components/menu/map.jsx +++ b/app/components/menu/map.jsx @@ -7,68 +7,68 @@ import MenuStore, { PLANET_MAP_MODE, STAR_MAP_MODE } from 'app/stores/menu'; // TODO: factor out all this glue code class Map extends React.Component { - previousMapMode = ''; - previousPlanetId = ''; - - componentDidUpdate() { - // Do nothing if the menu isn't shown. - if (MenuStore.menuShown === false) { - // Reset these values because we're *probably* logged out. - this.previousMapMode = PLANET_MAP_MODE; - this.previousPlanetId = ''; - } - - if (!MenuStore.planetId) { - return; - } - - // console.log('Rendering map'); - // console.log('mapMode = ' + MenuStore.mapMode + '(' + this.previousMapMode + ')'); - // console.log('planet = ' + MenuStore.planetId + '(' + this.previousPlanetId + ')'); - - let Lacuna = YAHOO.lacuna; - - if ( - // Render if the planet id has changed... OR... - this.previousPlanetId !== MenuStore.planetId || - // Render if we've changed from the starMap to the planetMap - (this.previousMapMode !== MenuStore.mapMode && MenuStore.mapMode === PLANET_MAP_MODE) - ) { - Lacuna.MapStar.MapVisible(false); - Lacuna.MapPlanet.MapVisible(true); - Lacuna.MapPlanet.Load(MenuStore.planetId, true, MenuStore.mapMode === STAR_MAP_MODE); - - this.previousPlanetId = MenuStore.planetId; - this.previousMapMode = MenuStore.mapMode; - - return; - } - - if (MenuStore.mapMode !== this.previousMapMode && MenuStore.mapMode === STAR_MAP_MODE) { - // Render star map view. - Lacuna.MapPlanet.MapVisible(false); - Lacuna.MapStar.MapVisible(true); - Lacuna.MapStar.Load(); - Lacuna.MapStar.Jump(BodyRPCStore.x, BodyRPCStore.y); - - this.previousPlanetId = MenuStore.planetId; - this.previousMapMode = MenuStore.mapMode; - - return; - } + previousMapMode = ''; + previousPlanetId = ''; + + componentDidUpdate() { + // Do nothing if the menu isn't shown. + if (MenuStore.menuShown === false) { + // Reset these values because we're *probably* logged out. + this.previousMapMode = PLANET_MAP_MODE; + this.previousPlanetId = ''; } - render() { - // - // We access these values so that MobX knows that we are interested in tracking them. - // This component doesn't render anything so we need to be explicit about the values - // we are using, allowing the framework to notify us appropriately. - // - const mapMode = MenuStore.mapMode; - const planetId = MenuStore.planetId; + if (!MenuStore.planetId) { + return; + } + + // console.log('Rendering map'); + // console.log('mapMode = ' + MenuStore.mapMode + '(' + this.previousMapMode + ')'); + // console.log('planet = ' + MenuStore.planetId + '(' + this.previousPlanetId + ')'); + + let Lacuna = YAHOO.lacuna; + + if ( + // Render if the planet id has changed... OR... + this.previousPlanetId !== MenuStore.planetId || + // Render if we've changed from the starMap to the planetMap + (this.previousMapMode !== MenuStore.mapMode && MenuStore.mapMode === PLANET_MAP_MODE) + ) { + Lacuna.MapStar.MapVisible(false); + Lacuna.MapPlanet.MapVisible(true); + Lacuna.MapPlanet.Load(MenuStore.planetId, true, MenuStore.mapMode === STAR_MAP_MODE); + + this.previousPlanetId = MenuStore.planetId; + this.previousMapMode = MenuStore.mapMode; + + return; + } + + if (MenuStore.mapMode !== this.previousMapMode && MenuStore.mapMode === STAR_MAP_MODE) { + // Render star map view. + Lacuna.MapPlanet.MapVisible(false); + Lacuna.MapStar.MapVisible(true); + Lacuna.MapStar.Load(); + Lacuna.MapStar.Jump(BodyRPCStore.x, BodyRPCStore.y); + + this.previousPlanetId = MenuStore.planetId; + this.previousMapMode = MenuStore.mapMode; - return
; + return; } + } + + render() { + // + // We access these values so that MobX knows that we are interested in tracking them. + // This component doesn't render anything so we need to be explicit about the values + // we are using, allowing the framework to notify us appropriately. + // + const mapMode = MenuStore.mapMode; + const planetId = MenuStore.planetId; + + return
; + } } export default observer(Map); diff --git a/app/components/menu/panel.tsx b/app/components/menu/panel.tsx index ec8ad486..bcd7e210 100644 --- a/app/components/menu/panel.tsx +++ b/app/components/menu/panel.tsx @@ -11,65 +11,65 @@ import PanelContent from 'app/components/menu/panel/panelContent'; import { WindowType, WindowOptions, WindowDefinition } from 'app/interfaces'; type Props = { - zIndex: number; - type: WindowType; - options: WindowOptions; - window: WindowDefinition; + zIndex: number; + type: WindowType; + options: WindowOptions; + window: WindowDefinition; }; class Panel extends React.Component { - static propTypes = { - type: PropTypes.string, - zIndex: PropTypes.number, - options: PropTypes.object, - window: PropTypes.object, - }; + static propTypes = { + type: PropTypes.string, + zIndex: PropTypes.number, + options: PropTypes.object, + window: PropTypes.object, + }; - onBringToTop() { - WindowsStore.bringToTop(this.props.type); - } + onBringToTop() { + WindowsStore.bringToTop(this.props.type); + } - closeWindow() { - WindowsStore.close(this.props.type); - } + closeWindow() { + WindowsStore.close(this.props.type); + } - handleCentering() { - return ($(window.document).width() - this.props.window.config.width) / 2; - } + handleCentering() { + return ($(window.document).width() - this.props.window.config.width) / 2; + } - render() { - let subPanel = React.createElement(this.props.window.component, { - zIndex: this.props.zIndex, - options: this.props.options, - }); + render() { + let subPanel = React.createElement(this.props.window.component, { + zIndex: this.props.zIndex, + options: this.props.options, + }); - return ( - -
this.onBringToTop()} - > - this.closeWindow()} - /> + return ( + +
this.onBringToTop()} + > + this.closeWindow()} + /> - - {subPanel} - -
-
- ); - } + + {subPanel} + +
+
+ ); + } } export default Panel; diff --git a/app/components/menu/panel/panelContent.tsx b/app/components/menu/panel/panelContent.tsx index 19a6c314..db2e96b2 100644 --- a/app/components/menu/panel/panelContent.tsx +++ b/app/components/menu/panel/panelContent.tsx @@ -3,44 +3,44 @@ import PropTypes from 'prop-types'; import React from 'react'; type Props = { - panelHeight: number | 'auto'; - panelWidth: number; - children: React.ReactNode; + panelHeight: number | 'auto'; + panelWidth: number; + children: React.ReactNode; }; class PanelContent extends React.Component { - static propTypes = { - panelHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - panelWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - children: PropTypes.element, - }; + static propTypes = { + panelHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), + panelWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), + children: PropTypes.element, + }; - render() { - return ( -
-
- {this.props.children} -
-
- ); - } + render() { + return ( +
+
+ {this.props.children} +
+
+ ); + } } export default PanelContent; diff --git a/app/components/menu/panel/panelHeader.tsx b/app/components/menu/panel/panelHeader.tsx index 220a4ce5..ddec9cc3 100644 --- a/app/components/menu/panel/panelHeader.tsx +++ b/app/components/menu/panel/panelHeader.tsx @@ -3,60 +3,60 @@ import PropTypes from 'prop-types'; import React from 'react'; type Props = { - panelWidth: number; - onClose: Function; - title: string; + panelWidth: number; + onClose: Function; + title: string; }; class PanelHeader extends React.Component { - static propTypes = { - panelWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - - onClose: PropTypes.func.isRequired, - title: PropTypes.string.isRequired, - }; - - render() { - return ( -
- {this.props.title} - - this.props.onClose(e)} - style={{ - position: 'absolute', - right: 30, - display: 'inline-block', - cursor: 'pointer', - }} - > - X - -
- ); - } + static propTypes = { + panelWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), + + onClose: PropTypes.func.isRequired, + title: PropTypes.string.isRequired, + }; + + render() { + return ( +
+ {this.props.title} + + this.props.onClose(e)} + style={{ + position: 'absolute', + right: 30, + display: 'inline-block', + cursor: 'pointer', + }} + > + X + +
+ ); + } } export default PanelHeader; diff --git a/app/components/menu/rightSidebar.jsx b/app/components/menu/rightSidebar.jsx index d1558dd7..5fa095c3 100644 --- a/app/components/menu/rightSidebar.jsx +++ b/app/components/menu/rightSidebar.jsx @@ -10,308 +10,305 @@ import EmpireRPCStore from 'app/stores/rpc/empire'; import MenuStore from 'app/stores/menu'; class PlanetListItem extends React.Component { - static propTypes = { - name: PropTypes.string.isRequired, - id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, - currentBody: PropTypes.number.isRequired, - zone: PropTypes.string.isRequired, + static propTypes = { + name: PropTypes.string.isRequired, + id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, + currentBody: PropTypes.number.isRequired, + zone: PropTypes.string.isRequired, + }; + + getInitialProps = () => { + return { + name: '', + id: 0, + currentBody: 0, + zone: '', }; + }; - getInitialProps = () => { - return { - name: '', - id: 0, - currentBody: 0, - zone: '', - }; - }; - - // Returns true if this list item is the the currently selected planet. - isCurrentWorld = () => { - return this.props.currentBody === this.props.id; - }; + // Returns true if this list item is the the currently selected planet. + isCurrentWorld = () => { + return this.props.currentBody === this.props.id; + }; - handleClick = () => { - MenuStore.hideRightSidebar(); + handleClick = () => { + MenuStore.hideRightSidebar(); - if (this.isCurrentWorld()) { - YAHOO.lacuna.MapPlanet.Refresh(); - } else { - MenuStore.changePlanet(this.props.id); - } - }; - - render() { - let classStr = classnames({ - 'ui large teal label': this.isCurrentWorld(), - item: !this.isCurrentWorld(), - }); - - return ( - - {this.props.name} ({this.props.zone}) - - ); + if (this.isCurrentWorld()) { + YAHOO.lacuna.MapPlanet.Refresh(); + } else { + MenuStore.changePlanet(this.props.id); } + }; + + render() { + let classStr = classnames({ + 'ui large teal label': this.isCurrentWorld(), + item: !this.isCurrentWorld(), + }); + + return ( + + {this.props.name} ({this.props.zone}) + + ); + } } class AccordionItem extends React.Component { - static propTypes = { - list: PropTypes.arrayOf(PropTypes.object).isRequired, - currentBody: PropTypes.number.isRequired, - title: PropTypes.string.isRequired, - initiallyOpen: PropTypes.bool.isRequired, - }; - - state = { - open: this.props.initiallyOpen, + static propTypes = { + list: PropTypes.arrayOf(PropTypes.object).isRequired, + currentBody: PropTypes.number.isRequired, + title: PropTypes.string.isRequired, + initiallyOpen: PropTypes.bool.isRequired, + }; + + state = { + open: this.props.initiallyOpen, + }; + + getInitialProps = () => { + return { + list: [], + currentBody: 0, + title: '', + initiallyOpen: false, }; - - getInitialProps = () => { - return { - list: [], - currentBody: 0, - title: '', - initiallyOpen: false, - }; - }; - - componentDidMount() { - // RightSidebarActions.rightSidebarCollapse.listen(this.hideList); - // RightSidebarActions.rightSidebarExpand.listen(this.showList); - } - - showList = () => { - this.setState({ - open: true, - }); - }; - - hideList = () => { - this.setState({ - open: false, - }); - }; - - toggleList = () => { - this.setState({ - open: !this.state.open, - }); - }; - - render() { - return ( -
-
- {this.state.open ? ( - - ) : ( - - )}{' '} - {this.props.title} -
-
- {_.map( - this.props.list, - _.bind(function (planet) { - return ( - - ); - }, this) - )} -
-
- ); - } + }; + + componentDidMount() { + // RightSidebarActions.rightSidebarCollapse.listen(this.hideList); + // RightSidebarActions.rightSidebarExpand.listen(this.showList); + } + + showList = () => { + this.setState({ + open: true, + }); + }; + + hideList = () => { + this.setState({ + open: false, + }); + }; + + toggleList = () => { + this.setState({ + open: !this.state.open, + }); + }; + + render() { + return ( +
+
+ {this.state.open ? ( + + ) : ( + + )}{' '} + {this.props.title} +
+
+ {_.map( + this.props.list, + _.bind(function (planet) { + return ( + + ); + }, this) + )} +
+
+ ); + } } class BodiesAccordion extends React.Component { - static propTypes = { - bodies: PropTypes.object.isRequired, - currentBody: PropTypes.number.isRequired, - }; - - render() { - let items = [ - { - title: 'My Colonies', - key: 'colonies', - initiallyOpen: true, - isBaby: false, - }, - { - title: 'My Stations', - key: 'mystations', - initiallyOpen: false, - isBaby: false, - }, - { - title: 'Our Stations', - key: 'ourstations', - initiallyOpen: false, - isBaby: false, - }, - ]; - - // Handle all the babies. - _.chain(this.props.bodies.babies || {}) - .keys() - .sortBy() - .each(function (babyName) { - items.push({ - title: babyName + "'s Colonies", - key: babyName, - initiallyOpen: false, - isBaby: true, - }); - }) - .value(); - - return ( -
- {_.map( - items, - _.bind(function (item) { - let list = []; - - if (item.isBaby) { - list = _.values(this.props.bodies.babies[item.key].planets) || []; - } else { - list = _.values(this.props.bodies[item.key]) || []; - } - - if (list.length > 0) { - return ( - - ); - } - }, this) - )} -
- ); - } + static propTypes = { + bodies: PropTypes.object.isRequired, + currentBody: PropTypes.number.isRequired, + }; + + render() { + let items = [ + { + title: 'My Colonies', + key: 'colonies', + initiallyOpen: true, + isBaby: false, + }, + { + title: 'My Stations', + key: 'mystations', + initiallyOpen: false, + isBaby: false, + }, + { + title: 'Our Stations', + key: 'ourstations', + initiallyOpen: false, + isBaby: false, + }, + ]; + + // Handle all the babies. + _.chain(this.props.bodies.babies || {}) + .keys() + .sortBy() + .each(function (babyName) { + items.push({ + title: babyName + "'s Colonies", + key: babyName, + initiallyOpen: false, + isBaby: true, + }); + }) + .value(); + + return ( +
+ {_.map( + items, + _.bind(function (item) { + let list = []; + + if (item.isBaby) { + list = _.values(this.props.bodies.babies[item.key].planets) || []; + } else { + list = _.values(this.props.bodies[item.key]) || []; + } + + if (list.length > 0) { + return ( + + ); + } + }, this) + )} +
+ ); + } } class RightSidebar extends React.Component { - componentDidMount() { - $('#right-sidebar').sidebar({ - context: $('#sidebarContainer'), - duration: 300, - transition: 'overlay', - onHidden: () => { - MenuStore.hideRightSidebar(); - }, - }); - } - - componentDidUpdate() { - $('#right-sidebar').sidebar(MenuStore.rightSidebarShown ? 'show' : 'hide'); - } - - homePlanet() { + componentDidMount() { + $('#right-sidebar').sidebar({ + context: $('#sidebarContainer'), + duration: 300, + transition: 'overlay', + onHidden: () => { MenuStore.hideRightSidebar(); - MenuStore.changePlanet(EmpireRPCStore.home_planet_id); - } - - expand() { - // RightSidebarActions.rightSidebarExpand(); - } - - collapse() { - // RightSidebarActions.rightSidebarCollapse(); - } + }, + }); + } + + componentDidUpdate() { + $('#right-sidebar').sidebar(MenuStore.rightSidebarShown ? 'show' : 'hide'); + } + + homePlanet() { + MenuStore.hideRightSidebar(); + MenuStore.changePlanet(EmpireRPCStore.home_planet_id); + } + + expand() { + // RightSidebarActions.rightSidebarExpand(); + } + + collapse() { + // RightSidebarActions.rightSidebarCollapse(); + } + + render() { + const shown = MenuStore.rightSidebarShown; + return ( + + ); + } } export default observer(RightSidebar); diff --git a/app/components/menu/rightSidebarButton.jsx b/app/components/menu/rightSidebarButton.jsx index 530bc7a1..91ad63c1 100644 --- a/app/components/menu/rightSidebarButton.jsx +++ b/app/components/menu/rightSidebarButton.jsx @@ -5,27 +5,27 @@ import BodyRPCStore from 'app/stores/rpc/body'; import MenuStore from 'app/stores/menu'; class RightSidebarButton extends React.Component { - click() { - MenuStore.showRightSidebar(); - } + click() { + MenuStore.showRightSidebar(); + } - render() { - return ( -
-
- - {BodyRPCStore.name} -
-
- ); - } + render() { + return ( +
+
+ + {BodyRPCStore.name} +
+
+ ); + } } export default observer(RightSidebarButton); diff --git a/app/components/menu/topBar.jsx b/app/components/menu/topBar.jsx index 44956bbe..56c4987e 100644 --- a/app/components/menu/topBar.jsx +++ b/app/components/menu/topBar.jsx @@ -12,100 +12,92 @@ import MailWindowStore from 'app/stores/window/mail'; import StatsWindowStore from 'app/stores/window/stats'; class TopBar extends React.Component { - mapButtonTip() { - if (MenuStore.mapMode === PLANET_MAP_MODE) { - return 'To Star Map'; - } else { - return 'To Planet Map'; - } + mapButtonTip() { + if (MenuStore.mapMode === PLANET_MAP_MODE) { + return 'To Star Map'; + } else { + return 'To Planet Map'; } + } - render() { - let barClass = classnames('ui inverted compact small menu', { - red: EmpireRPCStore.self_destruct_active, - blue: !EmpireRPCStore.self_destruct_active, - }); + render() { + let barClass = classnames('ui inverted compact small menu', { + red: EmpireRPCStore.self_destruct_active, + blue: !EmpireRPCStore.self_destruct_active, + }); - return ( -
+
+
+ MenuStore.toggleMapMode()} > -
-
- MenuStore.toggleMapMode()} - > - - + + - MailWindowStore.show()}> - - {EmpireRPCStore.has_new_messages > 0 ? ( -
- {EmpireRPCStore.has_new_messages} -
- ) : ( - '' - )} -
+ MailWindowStore.show()}> + + {EmpireRPCStore.has_new_messages > 0 ? ( +
{EmpireRPCStore.has_new_messages}
+ ) : ( + '' + )} +
- { - WindowsStore.add('essentia'); - }} - > - -
{EmpireRPCStore.essentia}
-
+ { + WindowsStore.add('essentia'); + }} + > + +
{EmpireRPCStore.essentia}
+
- StatsWindowStore.show()} - > - - + StatsWindowStore.show()} + > + + - {ServerRPCStore.promotions.length > 0 ? ( - 1 - ? 'Active Promotions' - : 'Active Promotion' - } - onClick={function () { - WindowsStore.add('promotions'); - }} - > - -
Event!
-
- ) : ( - '' - )} + {ServerRPCStore.promotions.length > 0 ? ( + 1 ? 'Active Promotions' : 'Active Promotion' + } + onClick={function () { + WindowsStore.add('promotions'); + }} + > + +
Event!
+
+ ) : ( + '' + )} - EmpireService.logout()} - > - - -
-
-
- ); - } + EmpireService.logout()}> + + +
+
+
+ ); + } } export default observer(TopBar); diff --git a/app/components/menu/windowManager.tsx b/app/components/menu/windowManager.tsx index cacdf2af..e763258d 100644 --- a/app/components/menu/windowManager.tsx +++ b/app/components/menu/windowManager.tsx @@ -17,97 +17,97 @@ import StarPanelWindow from 'app/components/starPanel'; import { WindowDefinition } from 'app/interfaces'; interface WindowMap { - [index: string]: WindowDefinition; + [index: string]: WindowDefinition; } export const WindowMap: WindowMap = { - about: { - component: AboutWindow, - config: { - title: 'About', - width: 450, - height: 400, - }, + about: { + component: AboutWindow, + config: { + title: 'About', + width: 450, + height: 400, }, + }, - essentiavein: { - component: EssentiaVeinWindow, - config: { - title: 'Essentia Vein', - width: 700, - height: 420, - }, + essentiavein: { + component: EssentiaVeinWindow, + config: { + title: 'Essentia Vein', + width: 700, + height: 420, }, + }, - essentia: { - component: EssentiaWindow, - config: { - title: 'Essentia', - width: 600, - height: 350, - }, + essentia: { + component: EssentiaWindow, + config: { + title: 'Essentia', + width: 600, + height: 350, }, + }, - genericBuilding: { - component: GenericBuildingWindow, - config: { - title: 'Building', - width: 700, - height: 'auto', - }, + genericBuilding: { + component: GenericBuildingWindow, + config: { + title: 'Building', + width: 700, + height: 'auto', }, + }, - invite: { - component: InviteWindow, - config: { - title: 'Invite a Friend', - width: 450, - height: 400, - }, + invite: { + component: InviteWindow, + config: { + title: 'Invite a Friend', + width: 450, + height: 400, }, + }, - planetPanel: { - component: PlanetPanelWindow, - config: { - title: 'Planet Details', - width: 700, - height: 450, - }, + planetPanel: { + component: PlanetPanelWindow, + config: { + title: 'Planet Details', + width: 700, + height: 450, }, + }, - serverClock: { - component: ServerClockWindow, - config: { - title: 'Server Clock', - width: 330, - height: 'auto', - }, + serverClock: { + component: ServerClockWindow, + config: { + title: 'Server Clock', + width: 330, + height: 'auto', }, + }, - starPanel: { - component: StarPanelWindow, - config: { - title: 'Star Details', - width: 700, - height: 420, - }, + starPanel: { + component: StarPanelWindow, + config: { + title: 'Star Details', + width: 700, + height: 420, }, + }, }; const WindowManager: React.FunctionComponent = () => ( - <> - {_.map(WindowsStore.windows, function (row, index) { - return ( - - ); - })} - + <> + {_.map(WindowsStore.windows, function (row, index) { + return ( + + ); + })} + ); export default observer(WindowManager); diff --git a/app/components/options.tsx b/app/components/options.tsx index f51f8cb3..554bf6de 100644 --- a/app/components/options.tsx +++ b/app/components/options.tsx @@ -5,13 +5,13 @@ import OptionsWindowStore from 'app/stores/window/options'; declare const YAHOO: any; class OptionsWindow extends React.Component { - render() { - if (OptionsWindowStore.shown) { - YAHOO.lacuna.Profile.show(); - } - - return
; + render() { + if (OptionsWindowStore.shown) { + YAHOO.lacuna.Profile.show(); } + + return
; + } } export default observer(OptionsWindow); diff --git a/app/components/planetPanel.tsx b/app/components/planetPanel.tsx index 7d4c6957..afac48ad 100644 --- a/app/components/planetPanel.tsx +++ b/app/components/planetPanel.tsx @@ -7,152 +7,152 @@ import PlanetDetailsTab from 'app/components/planetPanel/planetDetailsTab'; import { Tab, Tabs } from 'app/components/tabber'; class PlanetPanel extends React.Component { - static propTypes = { - options: PropTypes.object, - }; + static propTypes = { + options: PropTypes.object, + }; - state = { - status: { - id: 0, - x: 0, - y: 0, - zone: '', - star_id: '', - star_name: '', - orbit: 0, - type: '', - name: '', - image: '', - size: 0, - water: 0, - ore: { - anthracite: 0, - bauxite: 0, - beryl: 0, - chromite: 0, - chalcopyrite: 0, - fluorite: 0, - galena: 0, - goethite: 0, - gold: 0, - gypsum: 0, - halite: 0, - kerogen: 0, - magnetite: 0, - methane: 0, - monazite: 0, - rutile: 0, - sulfur: 0, - trona: 0, - uraninite: 0, - zircon: 0, - }, + state = { + status: { + id: 0, + x: 0, + y: 0, + zone: '', + star_id: '', + star_name: '', + orbit: 0, + type: '', + name: '', + image: '', + size: 0, + water: 0, + ore: { + anthracite: 0, + bauxite: 0, + beryl: 0, + chromite: 0, + chalcopyrite: 0, + fluorite: 0, + galena: 0, + goethite: 0, + gold: 0, + gypsum: 0, + halite: 0, + kerogen: 0, + magnetite: 0, + methane: 0, + monazite: 0, + rutile: 0, + sulfur: 0, + trona: 0, + uraninite: 0, + zircon: 0, + }, - // - // TODO: are these blocks returned.. do we need to handle them? - // - empire: { - id: '', - name: '', - alignment: '', - is_isolationist: 0, - }, - station: { - id: 0, - x: 0, - y: 0, - name: '', - }, - alliance: { - id: '', - name: '', - }, - influence: { - total: 0, - spent: 0, - }, - }, - }; + // + // TODO: are these blocks returned.. do we need to handle them? + // + empire: { + id: '', + name: '', + alignment: '', + is_isolationist: 0, + }, + station: { + id: 0, + x: 0, + y: 0, + name: '', + }, + alliance: { + id: '', + name: '', + }, + influence: { + total: 0, + spent: 0, + }, + }, + }; - componentDidMount() { - server.call({ - module: 'body', - method: 'get_status', - params: { - id: 1, // TODO - }, - success: ({ body }) => { - this.setState({ - status: { - id: body.id, - x: util.int(body.x), - y: util.int(body.y), - zone: body.zone, - star_id: body.star_id, - star_name: body.star_name, - orbit: util.int(body.orbit), - type: body.type, - name: body.name, - image: body.image, - size: body.size, - water: body.water, + componentDidMount() { + server.call({ + module: 'body', + method: 'get_status', + params: { + id: 1, // TODO + }, + success: ({ body }) => { + this.setState({ + status: { + id: body.id, + x: util.int(body.x), + y: util.int(body.y), + zone: body.zone, + star_id: body.star_id, + star_name: body.star_name, + orbit: util.int(body.orbit), + type: body.type, + name: body.name, + image: body.image, + size: body.size, + water: body.water, - ore: { - anthracite: body.ore.anthracite, - bauxite: body.ore.bauxite, - beryl: body.ore.beryl, - chromite: body.ore.chromite, - chalcopyrite: body.ore.chalcopyrite, - fluorite: body.ore.fluorite, - galena: body.ore.galena, - goethite: body.ore.goethite, - gold: body.ore.gold, - gypsum: body.ore.gypsum, - halite: body.ore.halite, - kerogen: body.ore.kerogen, - magnetite: body.ore.magnetite, - methane: body.ore.methane, - monazite: body.ore.monazite, - rutile: body.ore.rutile, - sulfur: body.ore.sulfur, - trona: body.ore.trona, - uraninite: body.ore.uraninite, - zircon: body.ore.zircon, - }, - }, - }); + ore: { + anthracite: body.ore.anthracite, + bauxite: body.ore.bauxite, + beryl: body.ore.beryl, + chromite: body.ore.chromite, + chalcopyrite: body.ore.chalcopyrite, + fluorite: body.ore.fluorite, + galena: body.ore.galena, + goethite: body.ore.goethite, + gold: body.ore.gold, + gypsum: body.ore.gypsum, + halite: body.ore.halite, + kerogen: body.ore.kerogen, + magnetite: body.ore.magnetite, + methane: body.ore.methane, + monazite: body.ore.monazite, + rutile: body.ore.rutile, + sulfur: body.ore.sulfur, + trona: body.ore.trona, + uraninite: body.ore.uraninite, + zircon: body.ore.zircon, }, + }, }); - } + }, + }); + } - render() { - console.log('Rendering...', this.state.status); + render() { + console.log('Rendering...', this.state.status); - let tabs = []; - tabs.push( - - - - ); + let tabs = []; + tabs.push( + + + + ); - tabs.push( - -

Not Yet Implemented

-
- ); + tabs.push( + +

Not Yet Implemented

+
+ ); - tabs.push( - -

Not Yet Implemented

-
- ); + tabs.push( + +

Not Yet Implemented

+
+ ); - return ( - <> - {tabs} - - ); - } + return ( + <> + {tabs} + + ); + } } export default PlanetPanel; diff --git a/app/components/planetPanel/line.tsx b/app/components/planetPanel/line.tsx index 76c02676..b86bfa35 100644 --- a/app/components/planetPanel/line.tsx +++ b/app/components/planetPanel/line.tsx @@ -2,30 +2,30 @@ import PropTypes from 'prop-types'; import React from 'react'; type Props = { - title: string; - value: string | number; + title: string; + value: string | number; }; class Line extends React.Component { - static propTypes = { - title: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - }; + static propTypes = { + title: PropTypes.string.isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + }; - render() { - return ( -
- {this.props.title}: - - {this.props.value} - -
- ); - } + render() { + return ( +
+ {this.props.title}: + + {this.props.value} + +
+ ); + } } export default Line; diff --git a/app/components/planetPanel/myFleetTab/item.jsx b/app/components/planetPanel/myFleetTab/item.jsx index 11b102b0..39257a2f 100644 --- a/app/components/planetPanel/myFleetTab/item.jsx +++ b/app/components/planetPanel/myFleetTab/item.jsx @@ -9,98 +9,93 @@ import BuildButton from 'app/components/shipyard/buildFleet/button'; import constants from 'app/constants'; class BuildFleetItem extends React.Component { - static propTypes = { - fleetType: PropTypes.string.isRequired, - obj: PropTypes.object.isRequired, - buildingId: PropTypes.number.isRequired, - autoSelect: PropTypes.string.isRequired, - }; + static propTypes = { + fleetType: PropTypes.string.isRequired, + obj: PropTypes.object.isRequired, + buildingId: PropTypes.number.isRequired, + autoSelect: PropTypes.string.isRequired, + }; - handleQuantity = (o) => {}; + handleQuantity = (o) => {}; - render() { - let starfieldStyle = { - width: 100, - height: 100, - background: - 'transparent url(' + - constants.ASSETS_URL + - 'star_system/field.png) no-repeat center', - }; + render() { + let starfieldStyle = { + width: 100, + height: 100, + background: + 'transparent url(' + constants.ASSETS_URL + 'star_system/field.png) no-repeat center', + }; - let obj = this.props.obj; - let shipImage = constants.ASSETS_URL + 'ships/' + this.props.fleetType + '.png'; - let reason = ''; - let canBuild = 1; + let obj = this.props.obj; + let shipImage = constants.ASSETS_URL + 'ships/' + this.props.fleetType + '.png'; + let reason = ''; + let canBuild = 1; - if (obj.reason) { - reason = obj.reason[1]; - canBuild = 0; - } + if (obj.reason) { + reason = obj.reason[1]; + canBuild = 0; + } - return ( -
-
-
-
{obj.type_human}
-
- -
-
+ return ( +
+
+
+
{obj.type_human}
+
+ +
+
-
- - - - - -
+
+ + + + + +
-
- - - - - - -
+
+ + + + + + +
-
- -
+
+ +
-
- - {reason} - -
-
-
-
- ); - } +
+ + {reason} + +
+
+
+
+ ); + } } export default BuildFleetItem; diff --git a/app/components/planetPanel/planetDetails.tsx b/app/components/planetPanel/planetDetails.tsx index 2d58c687..70179cf3 100644 --- a/app/components/planetPanel/planetDetails.tsx +++ b/app/components/planetPanel/planetDetails.tsx @@ -6,54 +6,54 @@ import PlanetPanelLine from 'app/components/planetPanel/line'; import constants from 'app/constants'; type Props = { - status: any; + status: any; }; class PlanetDetails extends React.Component { - static propTypes = { - status: PropTypes.object.isRequired, - }; + static propTypes = { + status: PropTypes.object.isRequired, + }; - render() { - let bodyStatus = this.props.status; - let location = bodyStatus.x + 'x : ' + bodyStatus.y + 'y'; + render() { + let bodyStatus = this.props.status; + let location = bodyStatus.x + 'x : ' + bodyStatus.y + 'y'; - return ( -
-
- -
-
- - - - - - - - - - -
-
- ); - } + return ( +
+
+ +
+
+ + + + + + + + + + +
+
+ ); + } } export default PlanetDetails; diff --git a/app/components/planetPanel/planetDetailsTab.tsx b/app/components/planetPanel/planetDetailsTab.tsx index 66e0bbd1..0c6f2142 100644 --- a/app/components/planetPanel/planetDetailsTab.tsx +++ b/app/components/planetPanel/planetDetailsTab.tsx @@ -5,51 +5,51 @@ import PlanetDetails from 'app/components/planetPanel/planetDetails'; import PlanetOre from 'app/components/planetPanel/planetOre'; type Props = { - status: any; + status: any; }; class PlanetDetailsTab extends React.Component { - static propTypes = { - status: PropTypes.object.isRequired, - }; + static propTypes = { + status: PropTypes.object.isRequired, + }; - render() { - return ( -
-
-
-
- Planet Details -
-
-
-
- Ore -
-
-
- -
-
- -
-
- -
-
+ render() { + return ( +
+
+
+
+ Planet Details +
+
+
+
+ Ore
- ); - } +
+
+ +
+
+ +
+
+ +
+
+
+ ); + } } export default PlanetDetailsTab; diff --git a/app/components/planetPanel/planetOre.tsx b/app/components/planetPanel/planetOre.tsx index aad37487..7ef9d20a 100644 --- a/app/components/planetPanel/planetOre.tsx +++ b/app/components/planetPanel/planetOre.tsx @@ -6,33 +6,33 @@ import PlanetDetailLine from 'app/components/planetPanel/line'; import constants from 'app/constants'; type Props = { - status: any; + status: any; }; class PlanetOre extends React.Component { - static propTypes = { - status: PropTypes.object.isRequired, - }; - - render() { - let ores = constants.ORES; - let bodyOre = this.props.status.ore; - - let renderOres = []; - for (let prop in ores) { - if (ores.hasOwnProperty(prop)) { - renderOres.push( - - ); - } - } - - return ( -
-
{renderOres}
-
+ static propTypes = { + status: PropTypes.object.isRequired, + }; + + render() { + let ores = constants.ORES; + let bodyOre = this.props.status.ore; + + let renderOres = []; + for (let prop in ores) { + if (ores.hasOwnProperty(prop)) { + renderOres.push( + ); + } } + + return ( +
+
{renderOres}
+
+ ); + } } export default PlanetOre; diff --git a/app/components/politicstraining.jsx b/app/components/politicstraining.jsx index a2d50b96..9ddc8ee6 100644 --- a/app/components/politicstraining.jsx +++ b/app/components/politicstraining.jsx @@ -12,55 +12,55 @@ import SpyTrainingStatus from 'app/components/spyTraining/spyTrainingStatus'; import { Tab, Tabs } from 'app/components/tabber'; let PoliticsTraining = createReactClass({ - displayName: 'PoliticsTraining', + displayName: 'PoliticsTraining', - statics: { - options: { - title: 'Politics Training', - width: 700, - height: 420, - }, + statics: { + options: { + title: 'Politics Training', + width: 700, + height: 420, }, + }, - propTypes: { - options: PropTypes.object, - }, + propTypes: { + options: PropTypes.object, + }, - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - PoliticsTrainingRPCActions.requestPoliticsTrainingRPCView(this.props.options.id); - }, + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + PoliticsTrainingRPCActions.requestPoliticsTrainingRPCView(this.props.options.id); + }, - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - if (building.extraViewData.spies) { - tabs.push( - - - - ); - } + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + if (building.extraViewData.spies) { + tabs.push( + + + + ); + } - return ( -
- -
- {tabs} -
-
- ); - }, + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default PoliticsTraining; diff --git a/app/components/promotions.jsx b/app/components/promotions.jsx index 331d368c..ef2478e4 100644 --- a/app/components/promotions.jsx +++ b/app/components/promotions.jsx @@ -7,66 +7,66 @@ import _ from 'lodash'; import ServerRPCStore from 'app/stores/rpc/server'; class Promotion extends React.Component { - static propTypes = { - promotion: PropTypes.object.isRequired, - }; + static propTypes = { + promotion: PropTypes.object.isRequired, + }; - static defaultProps = { - promotion: {}, - }; + static defaultProps = { + promotion: {}, + }; - render() { - return ( -
-

{this.props.promotion.header}

+ render() { + return ( +
+

{this.props.promotion.header}

- {this.props.promotion.description} + {this.props.promotion.description} -
-
+
+
- - Ends {this.props.promotion.ends} - -
- ); - } + + Ends {this.props.promotion.ends} + +
+ ); + } } let PromotionsWindow = createReactClass({ - displayName: 'PromotionsWindow', - // mixins: [Reflux.connect(ServerRPCStore, 'server')], + displayName: 'PromotionsWindow', + // mixins: [Reflux.connect(ServerRPCStore, 'server')], - statics: { - windowOptions: { - title: 'Promotions', - height: 'auto', - width: 300, - }, + statics: { + windowOptions: { + title: 'Promotions', + height: 'auto', + width: 300, }, + }, - render: function () { - return ( -
- {_.map( - ServerRPCStore.promotions, - function (promotion) { - return ; - }, - this - )} -
- ); - }, + render: function () { + return ( +
+ {_.map( + ServerRPCStore.promotions, + function (promotion) { + return ; + }, + this + )} +
+ ); + }, }); export default PromotionsWindow; diff --git a/app/components/register.jsx b/app/components/register.jsx index b04dab00..c2f10aff 100644 --- a/app/components/register.jsx +++ b/app/components/register.jsx @@ -1,35 +1,35 @@ import React from 'react'; class RegisterWindow extends React.Component { - static options = { - title: 'Register', - width: 500, - height: 200, - }; + static options = { + title: 'Register', + width: 500, + height: 200, + }; - closeWindow = () => { - WindowActions.windowCloseByType('register'); - }; + closeWindow = () => { + WindowActions.windowCloseByType('register'); + }; - render() { - return ( -
-
- -
-
- -
-
- Register -
-
- ); - } + render() { + return ( +
+
+ +
+
+ +
+
+ Register +
+
+ ); + } } export default RegisterWindow; diff --git a/app/components/serverClock.tsx b/app/components/serverClock.tsx index cd177b01..3bd0ab81 100644 --- a/app/components/serverClock.tsx +++ b/app/components/serverClock.tsx @@ -6,36 +6,36 @@ import TickerStore from 'app/stores/ticker'; import WindowsStore from 'app/stores/windows'; class ServerClock extends React.Component { - closeWindow() { - WindowsStore.close('serverClock'); - } + closeWindow() { + WindowsStore.close('serverClock'); + } - render() { - return ( -
-
-
- Server -
-
{ServerRPCStore.serverTimeFormatted}
-
+ render() { + return ( +
+
+
+ Server +
+
{ServerRPCStore.serverTimeFormatted}
+
-
-
- Client -
-
{ServerRPCStore.clientTimeFormatted}
-
+
+
+ Client +
+
{ServerRPCStore.clientTimeFormatted}
+
-
-
- Tick Count -
-
{TickerStore.clockTicks}
-
-
- ); - } +
+
+ Tick Count +
+
{TickerStore.clockTicks}
+
+
+ ); + } } export default observer(ServerClock); diff --git a/app/components/shipyard.jsx b/app/components/shipyard.jsx index 29d1560f..e404e662 100644 --- a/app/components/shipyard.jsx +++ b/app/components/shipyard.jsx @@ -14,76 +14,76 @@ import BuildQueueTab from 'app/components/shipyard/buildQueueTab'; import { Tab, Tabs } from 'app/components/tabber'; let Shipyard = createReactClass({ - displayName: 'Shipyard', - - statics: { - options: { - title: 'Shipyard', - width: 700, - height: 420, - }, - }, - - propTypes: { - options: PropTypes.object, - }, - - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - ShipyardRPCActions.requestShipyardRPCView(this.props.options.id); - }, - - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + displayName: 'Shipyard', - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - tabs.push( - - - - ); - - tabs.push( - - - - ); - - tabs.push( - -

Not Yet Implemented

-

- Fleets of ships damaged in an attack can be repaired (at less cost than building - from scratch -

-
- ); - - tabs.push( - -

Not Yet Implemented

-

Fleets of ships will be able to be upgraded to the empires current spec.

-
- ); - - return ( -
- -
- {tabs} -
-
- ); + statics: { + options: { + title: 'Shipyard', + width: 700, + height: 420, }, + }, + + propTypes: { + options: PropTypes.object, + }, + + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + ShipyardRPCActions.requestShipyardRPCView(this.props.options.id); + }, + + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, + + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + tabs.push( + + + + ); + + tabs.push( + + + + ); + + tabs.push( + +

Not Yet Implemented

+

+ Fleets of ships damaged in an attack can be repaired (at less cost than building from + scratch +

+
+ ); + + tabs.push( + +

Not Yet Implemented

+

Fleets of ships will be able to be upgraded to the empires current spec.

+
+ ); + + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default Shipyard; diff --git a/app/components/shipyard/buildFleet/button.jsx b/app/components/shipyard/buildFleet/button.jsx index fd3b1acf..d30a644f 100644 --- a/app/components/shipyard/buildFleet/button.jsx +++ b/app/components/shipyard/buildFleet/button.jsx @@ -3,39 +3,39 @@ import PropTypes from 'prop-types'; import React from 'react'; class BuildButton extends React.Component { - static propTypes = { - canBuild: PropTypes.number.isRequired, - obj: PropTypes.object.isRequired, - buildingId: PropTypes.number.isRequired, - autoSelect: PropTypes.string.isRequired, - fleetType: PropTypes.string.isRequired, - }; + static propTypes = { + canBuild: PropTypes.number.isRequired, + obj: PropTypes.object.isRequired, + buildingId: PropTypes.number.isRequired, + autoSelect: PropTypes.string.isRequired, + fleetType: PropTypes.string.isRequired, + }; - handleQuantity = (o) => { - let quantity = this.refs.quantity.value; + handleQuantity = (o) => { + let quantity = this.refs.quantity.value; - ShipyardRPCActions.requestShipyardRPCBuildFleet({ - building_ids: [this.props.buildingId], - type: this.props.fleetType, - quantity: quantity, - autoselect: this.props.autoSelect, - }); - }; + ShipyardRPCActions.requestShipyardRPCBuildFleet({ + building_ids: [this.props.buildingId], + type: this.props.fleetType, + quantity: quantity, + autoselect: this.props.autoSelect, + }); + }; - render() { - if (!this.props.canBuild) { - return
; - } - - return ( -
- -
- Build -
-
- ); + render() { + if (!this.props.canBuild) { + return
; } + + return ( +
+ +
+ Build +
+
+ ); + } } export default BuildButton; diff --git a/app/components/shipyard/buildFleet/item.jsx b/app/components/shipyard/buildFleet/item.jsx index 11b102b0..39257a2f 100644 --- a/app/components/shipyard/buildFleet/item.jsx +++ b/app/components/shipyard/buildFleet/item.jsx @@ -9,98 +9,93 @@ import BuildButton from 'app/components/shipyard/buildFleet/button'; import constants from 'app/constants'; class BuildFleetItem extends React.Component { - static propTypes = { - fleetType: PropTypes.string.isRequired, - obj: PropTypes.object.isRequired, - buildingId: PropTypes.number.isRequired, - autoSelect: PropTypes.string.isRequired, - }; + static propTypes = { + fleetType: PropTypes.string.isRequired, + obj: PropTypes.object.isRequired, + buildingId: PropTypes.number.isRequired, + autoSelect: PropTypes.string.isRequired, + }; - handleQuantity = (o) => {}; + handleQuantity = (o) => {}; - render() { - let starfieldStyle = { - width: 100, - height: 100, - background: - 'transparent url(' + - constants.ASSETS_URL + - 'star_system/field.png) no-repeat center', - }; + render() { + let starfieldStyle = { + width: 100, + height: 100, + background: + 'transparent url(' + constants.ASSETS_URL + 'star_system/field.png) no-repeat center', + }; - let obj = this.props.obj; - let shipImage = constants.ASSETS_URL + 'ships/' + this.props.fleetType + '.png'; - let reason = ''; - let canBuild = 1; + let obj = this.props.obj; + let shipImage = constants.ASSETS_URL + 'ships/' + this.props.fleetType + '.png'; + let reason = ''; + let canBuild = 1; - if (obj.reason) { - reason = obj.reason[1]; - canBuild = 0; - } + if (obj.reason) { + reason = obj.reason[1]; + canBuild = 0; + } - return ( -
-
-
-
{obj.type_human}
-
- -
-
+ return ( +
+
+
+
{obj.type_human}
+
+ +
+
-
- - - - - -
+
+ + + + + +
-
- - - - - - -
+
+ + + + + + +
-
- -
+
+ +
-
- - {reason} - -
-
-
-
- ); - } +
+ + {reason} + +
+
+
+
+ ); + } } export default BuildFleetItem; diff --git a/app/components/shipyard/buildFleetTab.jsx b/app/components/shipyard/buildFleetTab.jsx index 8117215e..941598cb 100644 --- a/app/components/shipyard/buildFleetTab.jsx +++ b/app/components/shipyard/buildFleetTab.jsx @@ -9,147 +9,138 @@ import GetBuildableShipyardRPCStore from 'app/stores/rpc/shipyard/getBuildable'; import BuildFleetItem from 'app/components/shipyard/buildFleet/item'; let BuildFleetTab = createReactClass({ - displayName: 'BuildFleetTab', - - propTypes: { - buildingId: PropTypes.number.isRequired, - }, - - getInitialState: function () { - return { - show: 'now', - filter: 'all', - autoSelect: 'this', - }; - }, - - // mixins: [Reflux.connect(GetBuildableShipyardRPCStore, 'getBuildableStore')], - - handleShowChange: function (e) { - this.setState({ - show: e.target.value, - }); - }, - - handleFilterChange: function (e) { - this.setState({ - filter: e.target.value, - }); - }, - - handleAutoSelectChange: function (e) { - this.setState({ - autoSelect: e.target.value, + displayName: 'BuildFleetTab', + + propTypes: { + buildingId: PropTypes.number.isRequired, + }, + + getInitialState: function () { + return { + show: 'now', + filter: 'all', + autoSelect: 'this', + }; + }, + + // mixins: [Reflux.connect(GetBuildableShipyardRPCStore, 'getBuildableStore')], + + handleShowChange: function (e) { + this.setState({ + show: e.target.value, + }); + }, + + handleFilterChange: function (e) { + this.setState({ + filter: e.target.value, + }); + }, + + handleAutoSelectChange: function (e) { + this.setState({ + autoSelect: e.target.value, + }); + }, + + render: function () { + let buildQueueAvailable = + this.state.getBuildableStore.build_queue_max - this.state.getBuildableStore.build_queue_used; + let fleetItems = []; + let buildable = this.state.getBuildableStore.buildable; + let fleetTypes = Object.keys(buildable); + + // Filter based on buildable now or later. + if (this.state.show === 'now') { + fleetTypes = _.filter(fleetTypes, function (fleetType) { + return buildable[fleetType].can; + }); + } else if (this.state.show === 'later') { + fleetTypes = _.filter(fleetTypes, function (fleetType) { + return !buildable[fleetType].can; + }); + } + + // Filter based on ship type + if (this.state.filter !== 'all') { + let filter = this.state.filter; + fleetTypes = _.filter(fleetTypes, function (fleetType) { + return _.find(buildable[fleetType].tags, function (o) { + return o === filter; }); - }, - - render: function () { - let buildQueueAvailable = - this.state.getBuildableStore.build_queue_max - - this.state.getBuildableStore.build_queue_used; - let fleetItems = []; - let buildable = this.state.getBuildableStore.buildable; - let fleetTypes = Object.keys(buildable); - - // Filter based on buildable now or later. - if (this.state.show === 'now') { - fleetTypes = _.filter(fleetTypes, function (fleetType) { - return buildable[fleetType].can; - }); - } else if (this.state.show === 'later') { - fleetTypes = _.filter(fleetTypes, function (fleetType) { - return !buildable[fleetType].can; - }); - } - - // Filter based on ship type - if (this.state.filter !== 'all') { - let filter = this.state.filter; - fleetTypes = _.filter(fleetTypes, function (fleetType) { - return _.find(buildable[fleetType].tags, function (o) { - return o === filter; - }); - }); - } - - fleetTypes.sort(); - let fleetTypesLen = fleetTypes.length; - - for (let i = 0; i < fleetTypesLen; i++) { - fleetItems.push( - - ); - } - - return ( -
-
- There are {this.state.getBuildableStore.docks_available} docks available for new - ships. You can queue {buildQueueAvailable} ships. -
- -
-
- Use{' '} - -
- -
- Filter{' '} - -
- -
- Show{' '} - -
-
- -
- -
{fleetItems}
-
- ); - }, + }); + } + + fleetTypes.sort(); + let fleetTypesLen = fleetTypes.length; + + for (let i = 0; i < fleetTypesLen; i++) { + fleetItems.push( + + ); + } + + return ( +
+
+ There are {this.state.getBuildableStore.docks_available} docks available for new ships. + You can queue {buildQueueAvailable} ships. +
+ +
+
+ Use{' '} + +
+ +
+ Filter{' '} + +
+ +
+ Show{' '} + +
+
+ +
+ +
{fleetItems}
+
+ ); + }, }); export default BuildFleetTab; diff --git a/app/components/shipyard/buildQueue/item.jsx b/app/components/shipyard/buildQueue/item.jsx index 3e144312..b4fb9bd0 100644 --- a/app/components/shipyard/buildQueue/item.jsx +++ b/app/components/shipyard/buildQueue/item.jsx @@ -10,71 +10,64 @@ import * as util from 'app/util'; import constants from 'app/constants'; class BuildQueueItem extends React.Component { - static propTypes = { - obj: PropTypes.object.isRequired, - buildingId: PropTypes.number.isRequired, - }; + static propTypes = { + obj: PropTypes.object.isRequired, + buildingId: PropTypes.number.isRequired, + }; - render() { - let starfieldStyle = { - width: 100, - height: 100, - background: - 'transparent url(' + - constants.ASSETS_URL + - 'star_system/field.png) no-repeat center', - }; + render() { + let starfieldStyle = { + width: 100, + height: 100, + background: + 'transparent url(' + constants.ASSETS_URL + 'star_system/field.png) no-repeat center', + }; - let obj = this.props.obj; - let shipImage = constants.ASSETS_URL + 'ships/' + this.props.obj.type + '.png'; + let obj = this.props.obj; + let shipImage = constants.ASSETS_URL + 'ships/' + this.props.obj.type + '.png'; - return ( -
-
-
-
{obj.type_human}
-
- -
-
+ return ( +
+
+
+
{obj.type_human}
+
+ +
+
-
- - - - - - - -
+
+ + + + + + + +
-
- -
+
+ +
-
- -
-
+
+ +
+
-
-
- ); - } +
+
+ ); + } } export default BuildQueueItem; diff --git a/app/components/shipyard/buildQueue/subsidizeButton.jsx b/app/components/shipyard/buildQueue/subsidizeButton.jsx index e79647ee..d0081257 100644 --- a/app/components/shipyard/buildQueue/subsidizeButton.jsx +++ b/app/components/shipyard/buildQueue/subsidizeButton.jsx @@ -3,18 +3,18 @@ import PropTypes from 'prop-types'; import React from 'react'; class SubsidizeButton extends React.Component { - static propTypes = { - obj: PropTypes.object.isRequired, - buildingId: PropTypes.number.isRequired, - }; + static propTypes = { + obj: PropTypes.object.isRequired, + buildingId: PropTypes.number.isRequired, + }; - render() { - return ( -
-
Subsidize, 23E
-
- ); - } + render() { + return ( +
+
Subsidize, 23E
+
+ ); + } } export default SubsidizeButton; diff --git a/app/components/shipyard/buildQueueTab.jsx b/app/components/shipyard/buildQueueTab.jsx index e100aae9..d89f528d 100644 --- a/app/components/shipyard/buildQueueTab.jsx +++ b/app/components/shipyard/buildQueueTab.jsx @@ -8,54 +8,54 @@ import BuildQueueShipyardRPCStore from 'app/stores/rpc/shipyard/buildQueue'; import BuildQueueItem from 'app/components/shipyard/buildQueue/item'; let BuildQueueTab = createReactClass({ - displayName: 'BuildQueueTab', - - propTypes: { - buildingId: PropTypes.number.isRequired, - }, - - componentWillMount: function () { - ShipyardRPCActions.requestShipyardRPCViewBuildQueue({ - building_id: this.props.buildingId, - }); - }, - - // mixins: [Reflux.connect(BuildQueueShipyardRPCStore, 'buildQueueStore')], - - render: function () { - let fleetsBuilding = this.state.buildQueueStore.fleets_building; - - let buildQueueLen = fleetsBuilding.length; - let fleetItems = []; - - for (let i = 0; i < buildQueueLen; i++) { - fleetItems.push( - - ); - } - - return ( -
-
- You may subsidize the whole build queue for{' '} - {this.state.buildQueueStore.cost_to_subsidize} Essentia -
- -
-
-
Ship Type
-
Number of ships
-
Time to complete
-
Subsidize cost
-
-
- -
- -
{fleetItems}
-
- ); - }, + displayName: 'BuildQueueTab', + + propTypes: { + buildingId: PropTypes.number.isRequired, + }, + + componentWillMount: function () { + ShipyardRPCActions.requestShipyardRPCViewBuildQueue({ + building_id: this.props.buildingId, + }); + }, + + // mixins: [Reflux.connect(BuildQueueShipyardRPCStore, 'buildQueueStore')], + + render: function () { + let fleetsBuilding = this.state.buildQueueStore.fleets_building; + + let buildQueueLen = fleetsBuilding.length; + let fleetItems = []; + + for (let i = 0; i < buildQueueLen; i++) { + fleetItems.push( + + ); + } + + return ( +
+
+ You may subsidize the whole build queue for {this.state.buildQueueStore.cost_to_subsidize}{' '} + Essentia +
+ +
+
+
Ship Type
+
Number of ships
+
Time to complete
+
Subsidize cost
+
+
+ +
+ +
{fleetItems}
+
+ ); + }, }); export default BuildQueueTab; diff --git a/app/components/shipyard/resourceAttribute.jsx b/app/components/shipyard/resourceAttribute.jsx index dc88cf18..b1363297 100644 --- a/app/components/shipyard/resourceAttribute.jsx +++ b/app/components/shipyard/resourceAttribute.jsx @@ -5,36 +5,36 @@ import React from 'react'; import * as util from 'app/util'; class ResourceAttribute extends React.Component { - static propTypes = { - name: PropTypes.string.isRequired, - attr: PropTypes.number.isRequired, - }; + static propTypes = { + name: PropTypes.string.isRequired, + attr: PropTypes.number.isRequired, + }; - render() { - let title = this.props.attr; + render() { + let title = this.props.attr; - if (!window.isNaN(title)) { - title = util.commify(title); - } - - return ( -
- {this.props.name} - - {title} - -
- ); + if (!window.isNaN(title)) { + title = util.commify(title); } + + return ( +
+ {this.props.name} + + {title} + +
+ ); + } } export default ResourceAttribute; diff --git a/app/components/shipyard/resourceLine.jsx b/app/components/shipyard/resourceLine.jsx index b35ecbf3..bca1a3f9 100644 --- a/app/components/shipyard/resourceLine.jsx +++ b/app/components/shipyard/resourceLine.jsx @@ -6,38 +6,38 @@ import classnames from 'classnames'; import * as util from 'app/util'; class ResourceLine extends React.Component { - static propTypes = { - icon: PropTypes.string.isRequired, - cost: PropTypes.number.isRequired, - red: PropTypes.bool, - }; + static propTypes = { + icon: PropTypes.string.isRequired, + cost: PropTypes.number.isRequired, + red: PropTypes.bool, + }; - render() { - let iconClass = classnames(this.props.icon, 'large icon', { - red: this.props.red, - }); - let content = util.reduceNumber(this.props.cost); - let title = util.commify(this.props.cost); + render() { + let iconClass = classnames(this.props.icon, 'large icon', { + red: this.props.red, + }); + let content = util.reduceNumber(this.props.cost); + let title = util.commify(this.props.cost); - return ( -
- - - {content} - -
- ); - } + return ( +
+ + + {content} + +
+ ); + } } export default ResourceLine; diff --git a/app/components/spacePort/ownFleets/item.jsx b/app/components/spacePort/ownFleets/item.jsx index 0e4181cb..15b512df 100644 --- a/app/components/spacePort/ownFleets/item.jsx +++ b/app/components/spacePort/ownFleets/item.jsx @@ -7,61 +7,56 @@ import ResourceAttribute from 'app/components/shipyard/resourceAttribute'; import constants from 'app/constants'; class BuildFleetItem extends React.Component { - static propTypes = { - obj: PropTypes.object.isRequired, - buildingId: PropTypes.number.isRequired, + static propTypes = { + obj: PropTypes.object.isRequired, + buildingId: PropTypes.number.isRequired, + }; + + render() { + let starfieldStyle = { + width: 100, + height: 100, + background: + 'transparent url(' + constants.ASSETS_URL + 'star_system/field.png) no-repeat center', }; - render() { - let starfieldStyle = { - width: 100, - height: 100, - background: - 'transparent url(' + - constants.ASSETS_URL + - 'star_system/field.png) no-repeat center', - }; - - let obj = this.props.obj; - let shipImage = constants.ASSETS_URL + 'ships/' + obj.details.type + '.png'; - - return ( -
-
-
- -
- -
- - - - - - - - - - -
- -
buttons
-
- -
-
- ); - } + let obj = this.props.obj; + let shipImage = constants.ASSETS_URL + 'ships/' + obj.details.type + '.png'; + + return ( +
+
+
+ +
+ +
+ + + + + + + + + + +
+ +
buttons
+
+ +
+
+ ); + } } export default BuildFleetItem; diff --git a/app/components/spacePort/ownFleetsTab.jsx b/app/components/spacePort/ownFleetsTab.jsx index f96c70aa..8eb055fb 100644 --- a/app/components/spacePort/ownFleetsTab.jsx +++ b/app/components/spacePort/ownFleetsTab.jsx @@ -10,154 +10,142 @@ import ViewAllFleetsSpacePortRPCStore from 'app/stores/rpc/spacePort/viewAllFlee import OwnFleetItem from 'app/components/spacePort/ownFleets/item'; let OwnFleetsTab = createReactClass({ - displayName: 'OwnFleetsTab', - - propTypes: { - buildingId: PropTypes.number.isRequired, - }, - - getInitialState: function () { - return { - task: 'all', - tag: 'all', - type: 'all', - name: '', - }; - }, - - // mixins: [Reflux.connect(ViewAllFleetsSpacePortRPCStore, 'viewAllFleetsStore')], - - handleTaskChange: function (e) { - this.setState({ - task: e.target.value, - }); - }, - - handleTagChange: function (e) { - this.setState({ - tag: e.target.value, - }); - }, - - handleTypeChange: function (e) { - this.setState({ - type: e.target.value, - }); - }, - - handleNameChange: function (e) { - this.setState({ - name: e.target.value, - }); - }, - - render: function () { - let fleetTypes = constants.FLEET_TYPES; - let renderFleetTypes = []; - for (let prop in fleetTypes) { - if (fleetTypes.hasOwnProperty(prop)) { - renderFleetTypes.push(); - } - } - - let fleetTags = constants.FLEET_TAGS; - let renderFleetTags = []; - for (let prop2 in fleetTags) { - if (fleetTags.hasOwnProperty(prop2)) { - renderFleetTags.push(); - } - } - - let fleetTasks = constants.FLEET_TASKS; - let renderFleetTasks = []; - for (let prop3 in fleetTasks) { - if (fleetTasks.hasOwnProperty(prop3)) { - renderFleetTasks.push(); - } - } - - let fleetItems = this.state.viewAllFleetsStore.fleets.slice(0); - - // Filter based on Task - if (this.state.task !== 'all') { - fleetItems = $.grep(fleetItems, function (item, index) { - return item.task === this.state.task; - }); - } - - // Filter based on Type - if (this.state.type !== 'all') { - fleetItems = $.grep(fleetItems, function (item, index) { - return item.details.type === this.state.type; - }); - } - - // Filter based on Tag - if (this.state.tag !== 'all') { - fleetItems = $.grep(fleetItems, function (item, index) { - return 1; - }); - } - - let renderFleetItems = []; - - for (let i = 0; i < fleetItems.length; i++) { - renderFleetItems.push( - - ); - } - - return ( -
-
-
- - -
- -
- - -
- -
- - -
- -
- - -
-
- -
- -
{renderFleetItems}
-
- ); - }, + displayName: 'OwnFleetsTab', + + propTypes: { + buildingId: PropTypes.number.isRequired, + }, + + getInitialState: function () { + return { + task: 'all', + tag: 'all', + type: 'all', + name: '', + }; + }, + + // mixins: [Reflux.connect(ViewAllFleetsSpacePortRPCStore, 'viewAllFleetsStore')], + + handleTaskChange: function (e) { + this.setState({ + task: e.target.value, + }); + }, + + handleTagChange: function (e) { + this.setState({ + tag: e.target.value, + }); + }, + + handleTypeChange: function (e) { + this.setState({ + type: e.target.value, + }); + }, + + handleNameChange: function (e) { + this.setState({ + name: e.target.value, + }); + }, + + render: function () { + let fleetTypes = constants.FLEET_TYPES; + let renderFleetTypes = []; + for (let prop in fleetTypes) { + if (fleetTypes.hasOwnProperty(prop)) { + renderFleetTypes.push(); + } + } + + let fleetTags = constants.FLEET_TAGS; + let renderFleetTags = []; + for (let prop2 in fleetTags) { + if (fleetTags.hasOwnProperty(prop2)) { + renderFleetTags.push(); + } + } + + let fleetTasks = constants.FLEET_TASKS; + let renderFleetTasks = []; + for (let prop3 in fleetTasks) { + if (fleetTasks.hasOwnProperty(prop3)) { + renderFleetTasks.push(); + } + } + + let fleetItems = this.state.viewAllFleetsStore.fleets.slice(0); + + // Filter based on Task + if (this.state.task !== 'all') { + fleetItems = $.grep(fleetItems, function (item, index) { + return item.task === this.state.task; + }); + } + + // Filter based on Type + if (this.state.type !== 'all') { + fleetItems = $.grep(fleetItems, function (item, index) { + return item.details.type === this.state.type; + }); + } + + // Filter based on Tag + if (this.state.tag !== 'all') { + fleetItems = $.grep(fleetItems, function (item, index) { + return 1; + }); + } + + let renderFleetItems = []; + + for (let i = 0; i < fleetItems.length; i++) { + renderFleetItems.push( + + ); + } + + return ( +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ +
{renderFleetItems}
+
+ ); + }, }); export default OwnFleetsTab; diff --git a/app/components/spaceport.jsx b/app/components/spaceport.jsx index 3cad2d51..b05056d2 100644 --- a/app/components/spaceport.jsx +++ b/app/components/spaceport.jsx @@ -14,76 +14,73 @@ import SpacePortOwnFleetsTab from 'app/components/spacePort/ownFleetsTab'; import { Tab, Tabs } from 'app/components/tabber'; let SpacePort = createReactClass({ - displayName: 'SpacePort', + displayName: 'SpacePort', - statics: { - options: { - title: 'SpacePort', - width: 700, - height: 420, - }, + statics: { + options: { + title: 'SpacePort', + width: 700, + height: 420, }, + }, - propTypes: { - options: PropTypes.object, - }, + propTypes: { + options: PropTypes.object, + }, - mixins: [ - // Reflux.connect(GenericBuildingStore, 'genericBuildingStore'), - // Reflux.connect(BodyRPCStore, 'bodyStore'), - ], + mixins: [ + // Reflux.connect(GenericBuildingStore, 'genericBuildingStore'), + // Reflux.connect(BodyRPCStore, 'bodyStore'), + ], - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - SpacePortRPCActions.requestSpacePortRPCView(this.props.options.id); - }, + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + SpacePortRPCActions.requestSpacePortRPCView(this.props.options.id); + }, - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - tabs.push( - - - - ); + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + tabs.push( + + + + ); - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-

This will combine the current 'send' and 'fleet' tabs

-
- ); + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+

This will combine the current 'send' and 'fleet' tabs

+
+ ); - return ( -
- -
- {tabs} -
-
- ); - }, + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default SpacePort; diff --git a/app/components/spyTraining/spyTrainingStatus.jsx b/app/components/spyTraining/spyTrainingStatus.jsx index ad5eabde..9d3be83e 100644 --- a/app/components/spyTraining/spyTrainingStatus.jsx +++ b/app/components/spyTraining/spyTrainingStatus.jsx @@ -5,41 +5,41 @@ import React from 'react'; import * as util from 'app/util'; class SpyTrainingStatus extends React.Component { - static propTypes = { - inTraining: PropTypes.number.isRequired, - pointsPerHour: PropTypes.number.isRequired, - maxPoints: PropTypes.number.isRequired, - }; - - render() { - return ( -
-
- Spies in training -
{this.props.inTraining}
-
- -
- Points / hr -
{this.props.pointsPerHour}
-
- -
- Points / hr / training spy -
- {this.props.inTraining > 0 - ? util.int(this.props.pointsPerHour / this.props.inTraining) - : 0} -
-
- -
- Maximum points -
{this.props.maxPoints}
-
-
- ); - } + static propTypes = { + inTraining: PropTypes.number.isRequired, + pointsPerHour: PropTypes.number.isRequired, + maxPoints: PropTypes.number.isRequired, + }; + + render() { + return ( +
+
+ Spies in training +
{this.props.inTraining}
+
+ +
+ Points / hr +
{this.props.pointsPerHour}
+
+ +
+ Points / hr / training spy +
+ {this.props.inTraining > 0 + ? util.int(this.props.pointsPerHour / this.props.inTraining) + : 0} +
+
+ +
+ Maximum points +
{this.props.maxPoints}
+
+
+ ); + } } export default SpyTrainingStatus; diff --git a/app/components/starPanel.tsx b/app/components/starPanel.tsx index ebb9562b..fc870595 100644 --- a/app/components/starPanel.tsx +++ b/app/components/starPanel.tsx @@ -3,36 +3,36 @@ import React from 'react'; import { Tab, Tabs } from 'app/components/tabber'; class StarPanel extends React.Component { - closeWindow() { - WindowActions.windowCloseByType('planetPanel'); - } + closeWindow() { + WindowActions.windowCloseByType('planetPanel'); + } - render() { - let tabs = []; - tabs.push( - -

Not Yet Implemented!

-
- ); + render() { + let tabs = []; + tabs.push( + +

Not Yet Implemented!

+
+ ); - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-
- ); - return ( -
-
- {tabs} -
-
- ); - } + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+
+ ); + return ( +
+
+ {tabs} +
+
+ ); + } } export default StarPanel; diff --git a/app/components/stats.tsx b/app/components/stats.tsx index 254f7728..1415f7c9 100644 --- a/app/components/stats.tsx +++ b/app/components/stats.tsx @@ -5,13 +5,13 @@ import StatsWindowStore from 'app/stores/window/stats'; declare const YAHOO: any; class StatsWindow extends React.Component { - render() { - if (StatsWindowStore.shown) { - YAHOO.lacuna.Stats.show(); - } - - return
; + render() { + if (StatsWindowStore.shown) { + YAHOO.lacuna.Stats.show(); } + + return
; + } } export default observer(StatsWindow); diff --git a/app/components/tabber/tab.tsx b/app/components/tabber/tab.tsx index 2e0c2eb8..ede159c3 100644 --- a/app/components/tabber/tab.tsx +++ b/app/components/tabber/tab.tsx @@ -2,21 +2,21 @@ import React from 'react'; import PropTypes from 'prop-types'; export interface TabProps { - title: string; - onSelect?: Function; - children: React.ReactNode; + title: string; + onSelect?: Function; + children: React.ReactNode; } export default class Tab extends React.Component { - static propTypes = { - title: PropTypes.string.isRequired, - children: PropTypes.node, - onSelect: PropTypes.object, - }; + static propTypes = { + title: PropTypes.string.isRequired, + children: PropTypes.node, + onSelect: PropTypes.object, + }; - render() { - // This is a dummy component. Everything passed into here is read by the parent `Tabs` - // and handled accordingly. - return null; - } + render() { + // This is a dummy component. Everything passed into here is read by the parent `Tabs` + // and handled accordingly. + return null; + } } diff --git a/app/components/tabber/tabs.tsx b/app/components/tabber/tabs.tsx index 618d992e..7c6de6c1 100644 --- a/app/components/tabber/tabs.tsx +++ b/app/components/tabber/tabs.tsx @@ -7,97 +7,97 @@ import * as ReactTabs from 'react-tabs'; import { TabProps } from 'app/components/tabber/tab'; interface CallbackMap { - [index: number]: Function; + [index: number]: Function; } type Props = { - initialTab: number; - children: React.ReactElement | Array>; + initialTab: number; + children: React.ReactElement | Array>; }; type State = { - selectedTab: number; + selectedTab: number; }; class Tabs extends React.Component { - static propTypes = { - initialTab: PropTypes.number, - onSelect: PropTypes.object, - children: PropTypes.node, - }; - - static defaultProps = { - initialTab: 0, - }; - - state = { - selectedTab: this.props.initialTab, - }; - - componentDidMount() { - this.handleCallbacks(this.state.selectedTab); - } - - handleSelect(index: number) { - this.handleCallbacks(index); - this.setState({ - selectedTab: index, - }); - } - - getCallbacks(): CallbackMap { - let obj: CallbackMap = {}; - let i = 0; - - React.Children.forEach(this.props.children, function (child) { - if (child?.props?.onSelect) { - obj[i] = child.props.onSelect; - } - - i += 1; - }); - - return obj; - } - - handleCallbacks(index: number): void { - const callbacks: CallbackMap = this.getCallbacks(); - - if (callbacks[index]) { - callbacks[index](); - } - } - - render() { - let tabTitles: string[] = []; - let tabContents: React.ReactNode[] = []; - - React.Children.forEach(this.props.children, function (child) { - if (child && child.props && child.props.title && child.props.children) { - tabTitles.push(child.props.title); - tabContents.push(child.props.children); - } - }); - - return ( - this.handleSelect(index)} - > - - {_.map(tabTitles, function (title) { - return {title}; - })} - - - {_.map(tabContents, function (tabContent, i) { - let title = tabTitles[i]; - - return {tabContent}; - })} - - ); + static propTypes = { + initialTab: PropTypes.number, + onSelect: PropTypes.object, + children: PropTypes.node, + }; + + static defaultProps = { + initialTab: 0, + }; + + state = { + selectedTab: this.props.initialTab, + }; + + componentDidMount() { + this.handleCallbacks(this.state.selectedTab); + } + + handleSelect(index: number) { + this.handleCallbacks(index); + this.setState({ + selectedTab: index, + }); + } + + getCallbacks(): CallbackMap { + let obj: CallbackMap = {}; + let i = 0; + + React.Children.forEach(this.props.children, function (child) { + if (child?.props?.onSelect) { + obj[i] = child.props.onSelect; + } + + i += 1; + }); + + return obj; + } + + handleCallbacks(index: number): void { + const callbacks: CallbackMap = this.getCallbacks(); + + if (callbacks[index]) { + callbacks[index](); } + } + + render() { + let tabTitles: string[] = []; + let tabContents: React.ReactNode[] = []; + + React.Children.forEach(this.props.children, function (child) { + if (child && child.props && child.props.title && child.props.children) { + tabTitles.push(child.props.title); + tabContents.push(child.props.children); + } + }); + + return ( + this.handleSelect(index)} + > + + {_.map(tabTitles, function (title) { + return {title}; + })} + + + {_.map(tabContents, function (tabContent, i) { + let title = tabTitles[i]; + + return {tabContent}; + })} + + ); + } } export default Tabs; diff --git a/app/components/thefttraining.jsx b/app/components/thefttraining.jsx index ddeb8533..74505c99 100644 --- a/app/components/thefttraining.jsx +++ b/app/components/thefttraining.jsx @@ -12,55 +12,55 @@ import SpyTrainingStatus from 'app/components/spyTraining/spyTrainingStatus'; import { Tab, Tabs } from 'app/components/tabber'; let TheftTraining = createReactClass({ - displayName: 'TheftTraining', + displayName: 'TheftTraining', - statics: { - options: { - title: 'Theft Training', - width: 700, - height: 420, - }, + statics: { + options: { + title: 'Theft Training', + width: 700, + height: 420, }, + }, - propTypes: { - options: PropTypes.object, - }, + propTypes: { + options: PropTypes.object, + }, - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - TheftTrainingRPCActions.requestTheftTrainingRPCView(this.props.options.id); - }, + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + TheftTrainingRPCActions.requestTheftTrainingRPCView(this.props.options.id); + }, - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - if (building.extraViewData.spies) { - tabs.push( - - - - ); - } + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + if (building.extraViewData.spies) { + tabs.push( + + + + ); + } - return ( -
- -
- {tabs} -
-
- ); - }, + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default TheftTraining; diff --git a/app/components/trade.jsx b/app/components/trade.jsx index e210b5bc..366f6e50 100644 --- a/app/components/trade.jsx +++ b/app/components/trade.jsx @@ -11,79 +11,79 @@ import BuildingInformation from 'app/components/building/information'; import { Tab, Tabs } from 'app/components/tabber'; let Trade = createReactClass({ - displayName: 'Trade', - - statics: { - options: { - title: 'Trade', - width: 700, - height: 420, - }, - }, - - propTypes: { - options: PropTypes.object, - }, - - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - TradeRPCActions.requestTradeRPCView(this.props.options.id); - }, - - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + displayName: 'Trade', - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - tabs.push( - -

Not Yet Implemented!

-
- ); - - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-
- ); - - tabs.push( - -

Not Yet Implemented

-

Will combine Supply Chains and Supply Ships

-
- ); - - tabs.push( - -

Not Yet Implemented

-
- ); - - return ( -
- - -
- {tabs} -
-
- ); + statics: { + options: { + title: 'Trade', + width: 700, + height: 420, }, + }, + + propTypes: { + options: PropTypes.object, + }, + + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + TradeRPCActions.requestTradeRPCView(this.props.options.id); + }, + + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, + + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + tabs.push( + +

Not Yet Implemented!

+
+ ); + + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+
+ ); + + tabs.push( + +

Not Yet Implemented

+

Will combine Supply Chains and Supply Ships

+
+ ); + + tabs.push( + +

Not Yet Implemented

+
+ ); + + return ( +
+ + +
+ {tabs} +
+
+ ); + }, }); export default Trade; diff --git a/app/components/transporter.jsx b/app/components/transporter.jsx index f684d771..0ee621b6 100644 --- a/app/components/transporter.jsx +++ b/app/components/transporter.jsx @@ -11,72 +11,72 @@ import BuildingInformation from 'app/components/building/information'; import { Tab, Tabs } from 'app/components/tabber'; let Transporter = createReactClass({ - displayName: 'Transporter', - - statics: { - options: { - title: 'Transporter', - width: 700, - height: 420, - }, - }, - - propTypes: { - options: PropTypes.object, - }, - - // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], - - componentWillMount: function () { - BuildingWindowActions.buildingWindowClear(); - TransporterRPCActions.requestTransporterRPCView(this.props.options.id); - }, - - closeWindow: function () { - WindowActions.windowCloseByType('building'); - }, + displayName: 'Transporter', - render: function () { - let building = this.state.genericBuildingStore; - let tabs = StandardTabs.tabs(this.props.options, building); - - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-
- ); - tabs.push( - -

Not Yet Implemented

-
- ); - - tabs.push( - -

Not Yet Implemented

-
- ); - - tabs.push( - -

Not Yet Implemented

-
- ); - - return ( -
- -
- {tabs} -
-
- ); + statics: { + options: { + title: 'Transporter', + width: 700, + height: 420, }, + }, + + propTypes: { + options: PropTypes.object, + }, + + // mixins: [Reflux.connect(GenericBuildingStore, 'genericBuildingStore')], + + componentWillMount: function () { + BuildingWindowActions.buildingWindowClear(); + TransporterRPCActions.requestTransporterRPCView(this.props.options.id); + }, + + closeWindow: function () { + WindowActions.windowCloseByType('building'); + }, + + render: function () { + let building = this.state.genericBuildingStore; + let tabs = StandardTabs.tabs(this.props.options, building); + + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+
+ ); + tabs.push( + +

Not Yet Implemented

+
+ ); + + tabs.push( + +

Not Yet Implemented

+
+ ); + + tabs.push( + +

Not Yet Implemented

+
+ ); + + return ( +
+ +
+ {tabs} +
+
+ ); + }, }); export default Transporter; diff --git a/app/constants.ts b/app/constants.ts index b7a972a5..c3a8c5c9 100644 --- a/app/constants.ts +++ b/app/constants.ts @@ -1,130 +1,130 @@ interface AppConfig { - ASSETS_URL: string; - NEW_SERVER_DATE_FORMAT: string; - OLD_SERVER_DATE_FORMAT: string; - RPC_BASE: string; - WS_BASE: string; - FLEET_TAGS: any; - FLEET_TASKS: any; - FLEET_TYPES: any; - ORES: any; + ASSETS_URL: string; + NEW_SERVER_DATE_FORMAT: string; + OLD_SERVER_DATE_FORMAT: string; + RPC_BASE: string; + WS_BASE: string; + FLEET_TAGS: any; + FLEET_TASKS: any; + FLEET_TYPES: any; + ORES: any; } const constants: AppConfig = { - ASSETS_URL: process.env.KA_ASSETS_URL, - NEW_SERVER_DATE_FORMAT: 'YYYY MM DD HH:mm:ss ZZ', - OLD_SERVER_DATE_FORMAT: 'DD MM YYYY HH:mm:ss ZZ', - RPC_BASE: (function (): string { - let url = process.env.KA_SERVER_URL; - let lastChar = url.slice(-1); + ASSETS_URL: process.env.KA_ASSETS_URL, + NEW_SERVER_DATE_FORMAT: 'YYYY MM DD HH:mm:ss ZZ', + OLD_SERVER_DATE_FORMAT: 'DD MM YYYY HH:mm:ss ZZ', + RPC_BASE: (function (): string { + let url = process.env.KA_SERVER_URL; + let lastChar = url.slice(-1); - // Ensure the URL has a trailing '/' character. - if (lastChar === '/') { - return url; - } else { - return url + '/'; - } - })(), - WS_BASE: process.env.KA_WS_SERVER_URL, + // Ensure the URL has a trailing '/' character. + if (lastChar === '/') { + return url; + } else { + return url + '/'; + } + })(), + WS_BASE: process.env.KA_WS_SERVER_URL, - FLEET_TAGS: { - trade: 'Trade', - mining: 'Mining', - intelligence: 'Intelligence', - supply_chain: 'SupplyChain', - war: 'War', - colonization: 'Colonization', - exploration: 'Exploration', - waste_chain: 'WasteChain', - }, + FLEET_TAGS: { + trade: 'Trade', + mining: 'Mining', + intelligence: 'Intelligence', + supply_chain: 'SupplyChain', + war: 'War', + colonization: 'Colonization', + exploration: 'Exploration', + waste_chain: 'WasteChain', + }, - FLEET_TASKS: { - building: 'Building', - docked: 'Docked', - mining: 'Mining', - travelling: 'Travelling', - waste_chain: 'Waste Chain', - defend: 'Defend', - supply_chain: 'Supply Chain', - waiting_on_trade: 'Waiting On Trade', - orbiting: 'Orbiting', - }, + FLEET_TASKS: { + building: 'Building', + docked: 'Docked', + mining: 'Mining', + travelling: 'Travelling', + waste_chain: 'Waste Chain', + defend: 'Defend', + supply_chain: 'Supply Chain', + waiting_on_trade: 'Waiting On Trade', + orbiting: 'Orbiting', + }, - FLEET_TYPES: { - probe: 'probe', - short_range_colony_ship: 'Short Range Colony Ship', - colony_ship: 'Colony Ship', - spy_pod: 'Spy Pod', - cargo_ship: 'Cargo Ship', - space_station: 'Space Station', - smuggler_ship: 'Smuggler Ship', - mining_platform_ship: 'Mining Platform Ship', - terraforming_platform_ship: 'Terraforming Platform Ship', - surveyor: 'Surveyor', - gas_giant_settlement_ship: 'Gas Giant Settlement Ship', - scow: 'Scow', - scow_fast: 'Scow Fast', - scow_large: 'Scow Large', - scow_mega: 'Scow Mega', - dory: 'Dory', - freighter: 'Freighter', - snark: 'Snark', - snark2: 'Snark2', - snark3: 'Snark3', - thud: 'Thud', - supply_pod: 'Supply Pod', - supply_pod2: 'Supply Pod2', - supply_pod3: 'Supply Pod3', - supply_pod4: 'Supply Pod4', - supply_pod5: 'Supply Pod5', - drone: 'Drone', - fighter: 'Fighter', - spy_shuttle: 'Spy Shuttle', - observatory_seeker: 'observatory Seeker', - security_ministry_seeker: 'Security Ministry Seeker', - spaceport_seeker: 'Spaceport Seeker', - excavator: 'Excavator', - detonator: 'Detonator', - scanner: 'Scanner', - barge: 'Barge', - hulk: 'Hulk', - hulk_fast: 'Hulk Fast', - hulk_huge: 'Hulk Huge', - galleon: 'Galleon', - stake: 'Stake', - placebo: 'Nocebo', - placebo2: 'Nocebo2', - placebo3: 'Nocebo3', - placebo4: 'Nocebo4', - placebo5: 'Nocebo5', - placebo6: 'Nocebo6', - bleeder: 'Bleeder', - sweeper: 'Sweeper', - fissure_sealer: 'Fissure Sealer', - }, + FLEET_TYPES: { + probe: 'probe', + short_range_colony_ship: 'Short Range Colony Ship', + colony_ship: 'Colony Ship', + spy_pod: 'Spy Pod', + cargo_ship: 'Cargo Ship', + space_station: 'Space Station', + smuggler_ship: 'Smuggler Ship', + mining_platform_ship: 'Mining Platform Ship', + terraforming_platform_ship: 'Terraforming Platform Ship', + surveyor: 'Surveyor', + gas_giant_settlement_ship: 'Gas Giant Settlement Ship', + scow: 'Scow', + scow_fast: 'Scow Fast', + scow_large: 'Scow Large', + scow_mega: 'Scow Mega', + dory: 'Dory', + freighter: 'Freighter', + snark: 'Snark', + snark2: 'Snark2', + snark3: 'Snark3', + thud: 'Thud', + supply_pod: 'Supply Pod', + supply_pod2: 'Supply Pod2', + supply_pod3: 'Supply Pod3', + supply_pod4: 'Supply Pod4', + supply_pod5: 'Supply Pod5', + drone: 'Drone', + fighter: 'Fighter', + spy_shuttle: 'Spy Shuttle', + observatory_seeker: 'observatory Seeker', + security_ministry_seeker: 'Security Ministry Seeker', + spaceport_seeker: 'Spaceport Seeker', + excavator: 'Excavator', + detonator: 'Detonator', + scanner: 'Scanner', + barge: 'Barge', + hulk: 'Hulk', + hulk_fast: 'Hulk Fast', + hulk_huge: 'Hulk Huge', + galleon: 'Galleon', + stake: 'Stake', + placebo: 'Nocebo', + placebo2: 'Nocebo2', + placebo3: 'Nocebo3', + placebo4: 'Nocebo4', + placebo5: 'Nocebo5', + placebo6: 'Nocebo6', + bleeder: 'Bleeder', + sweeper: 'Sweeper', + fissure_sealer: 'Fissure Sealer', + }, - ORES: { - anthracite: 'Anthracite', - bauxite: 'Bauxite', - beryl: 'Beryl', - chromite: 'Chromite', - chalcopyrite: 'Chalcopyrite', - fluorite: 'Fluorite', - galena: 'Galena', - goethite: 'Goethite', - gold: 'Gold', - gypsum: 'Gypsum', - halite: 'Halite', - kerogen: 'Kerogen', - magnetite: 'Magnetite', - methane: 'Methane', - monazite: 'Monazite', - rutile: 'Rutile', - sulfur: 'Sulfur', - trona: 'Trona', - uraninite: 'Uraninite', - zircon: 'Zircon', - }, + ORES: { + anthracite: 'Anthracite', + bauxite: 'Bauxite', + beryl: 'Beryl', + chromite: 'Chromite', + chalcopyrite: 'Chalcopyrite', + fluorite: 'Fluorite', + galena: 'Galena', + goethite: 'Goethite', + gold: 'Gold', + gypsum: 'Gypsum', + halite: 'Halite', + kerogen: 'Kerogen', + magnetite: 'Magnetite', + methane: 'Methane', + monazite: 'Monazite', + rutile: 'Rutile', + sulfur: 'Sulfur', + trona: 'Trona', + uraninite: 'Uraninite', + zircon: 'Zircon', + }, }; export default constants; diff --git a/app/css/bonus-styles.css b/app/css/bonus-styles.css index 29e3ea67..62ad2eaa 100644 --- a/app/css/bonus-styles.css +++ b/app/css/bonus-styles.css @@ -1,9 +1,9 @@ .homeworld-highlight { - color: yellow; + color: yellow; } body { - color: #ffffff; + color: #ffffff; } /* Don't make the color of text input white, though. */ @@ -11,50 +11,50 @@ input, textarea, select, option { - color: black; - font-weight: normal; + color: black; + font-weight: normal; } .ui.form .grouped.fields > label { - color: white; + color: white; } .ui.checkbox label, .ui.checkbox + label { - color: white; + color: white; } .ui.form .field > label { - color: white; + color: white; } /* Fix incoming ships position. */ #notify_c { - position: absolute; - right: 15px; - top: 100px; - z-index: 2000; + position: absolute; + right: 15px; + top: 100px; + z-index: 2000; } /* Fix labels on react-tabs tabs. */ .react-tabs [role='tab'][aria-selected='true'] { - color: black; + color: black; } .react-tabs__tab:focus::after { - background: unset !important; + background: unset !important; } /* Fix tooltips hiding behind things. */ .__react_component_tooltip { - z-index: 2147483647 !important; - opacity: 1 !important; + z-index: 2147483647 !important; + opacity: 1 !important; } /* Disabled buttons block pointer events (eg 'hover' for tooltips). We don't want that. */ .ui.button.disabled { - pointer-events: all !important; + pointer-events: all !important; } /* Planet list items should have pointy cursors. ;) */ a.item { - cursor: pointer; + cursor: pointer; } diff --git a/app/css/legacy-styles.css b/app/css/legacy-styles.css index 90a5e7fa..9974e0bb 100644 --- a/app/css/legacy-styles.css +++ b/app/css/legacy-styles.css @@ -5,42 +5,42 @@ light blue: #52ACFF */ html { - background: black url('/Lacuna-Assets/star_system/field.png'); - color: #fff; - overflow: hidden; - box-sizing: content-box; + background: black url('/Lacuna-Assets/star_system/field.png'); + color: #fff; + overflow: hidden; + box-sizing: content-box; } body { - font-family: verdana; - margin: 0; - padding: 40px 0; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - text-align: left; - min-width: 1050px; - /*min-height: 768px;*/ - overflow: hidden; + font-family: verdana; + margin: 0; + padding: 40px 0; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + text-align: left; + min-width: 1050px; + /*min-height: 768px;*/ + overflow: hidden; } select, input, button, textarea, button { - font-family: verdana; + font-family: verdana; } .yui-content a:link, .yui-content a:visited { - text-decoration: underline; - color: #fff; + text-decoration: underline; + color: #fff; } , a, a:link, a:visited { - color: #fff; + color: #fff; } h1, h2, @@ -48,187 +48,187 @@ h3, h4, h5, h6 { - font-weight: bold; + font-weight: bold; } button, input[type='submit'], input[type='button'], .button { - text-decoration: none !important; - padding: 2px 6px 3px; - margin: 1px; - border-radius: 10px; - -moz-border-radius: 10px; - border-style: solid; - border-width: 1px; - border-color: #fefefe #dedede #dedede #fefefe; - background: #103070 url('/Lacuna-Assets/ui/web/bar_bottom_back.png') 0 -10px; - color: #ffffff; + text-decoration: none !important; + padding: 2px 6px 3px; + margin: 1px; + border-radius: 10px; + -moz-border-radius: 10px; + border-style: solid; + border-width: 1px; + border-color: #fefefe #dedede #dedede #fefefe; + background: #103070 url('/Lacuna-Assets/ui/web/bar_bottom_back.png') 0 -10px; + color: #ffffff; } button:hover:active, input[type='submit']:hover:active, input[type='button']:hover:active, .button:hover:active { - /*background-color: #002060;*/ - background-position: 0 -30px; - border-color: #254595 #153585 #153585 #254595; + /*background-color: #002060;*/ + background-position: 0 -30px; + border-color: #254595 #153585 #153585 #254595; } button:hover, input[type='submit']:hover, input[type='button']:hover, .button:hover { - border-color: #254595 #3555a5 #3555a5 #254595; - /*background-color: #183878;*/ - background-position: 0 -20px; + border-color: #254595 #3555a5 #3555a5 #254595; + /*background-color: #183878;*/ + background-position: 0 -20px; } button[disabled], input[type='submit'][disabled], input[type='button'][disabled], .button[disabled] { - border-color: #3555a5 #254595 #254595 #3555a5; - background-color: #204070; - background-image: none; - color: #808080; + border-color: #3555a5 #254595 #254595 #3555a5; + background-color: #204070; + background-image: none; + color: #808080; } .button { - padding: 2px 6px 3px; - text-decoration: none; - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + padding: 2px 6px 3px; + text-decoration: none; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } .clearafter { - height: 100%; + height: 100%; } .clearafter:after { - content: '.'; - display: block; - height: 0; - clear: both; - visibility: hidden; + content: '.'; + display: block; + height: 0; + clear: both; + visibility: hidden; } #content { - text-align: center; - padding-top: 15px; + text-align: center; + padding-top: 15px; } #nojavascript { - text-align: center; - color: white; + text-align: center; + color: white; } #header, #footer { - text-align: center; - height: 55px; - position: fixed; - width: 100%; - min-width: 1050px; - background-color: #52acff; - font-family: impact, sans-serif; + text-align: center; + height: 55px; + position: fixed; + width: 100%; + min-width: 1050px; + background-color: #52acff; + font-family: impact, sans-serif; } #header { - top: 0; - z-index: 1000; - background-image: url('/Lacuna-Assets/ui/web/bar_top_back.png'); + top: 0; + z-index: 1000; + background-image: url('/Lacuna-Assets/ui/web/bar_top_back.png'); } #footer { - bottom: 0; - z-index: 1000; - background-image: url('/Lacuna-Assets/ui/web/bar_bottom_back.png'); + bottom: 0; + z-index: 1000; + background-image: url('/Lacuna-Assets/ui/web/bar_bottom_back.png'); } .hidden { - display: none; + display: none; } .alert { - color: pink; + color: pink; } /* YUI dialog skin */ body { - font: 13px/1.231 arial, helvetica, clean, sans-serif; - *font-size: small; - *font: x-small; + font: 13px/1.231 arial, helvetica, clean, sans-serif; + *font-size: small; + *font: x-small; } body.yui-skin-sam .yui-panel { - border-width: 0; + border-width: 0; } body.yui-skin-sam .yui-panel .hd { - width: 250px; - background: url('/Lacuna-Assets/ui/tab.png') no-repeat scroll 0 0 transparent; - border-width: 0; - margin-left: 10px; - font-size: 110%; - color: #ffd800; - line-height: 1.75; + width: 250px; + background: url('/Lacuna-Assets/ui/tab.png') no-repeat scroll 0 0 transparent; + border-width: 0; + margin-left: 10px; + font-size: 110%; + color: #ffd800; + line-height: 1.75; } .yui-skin-sam .yui-panel .bd, .yui-skin-sam .yui-panel .ft { - background-image: url('/Lacuna-Assets/ui/bkg.png'); - background-color: #013e67; + background-image: url('/Lacuna-Assets/ui/bkg.png'); + background-color: #013e67; } body.yui-skin-sam .yui-panel .bd { - -moz-border-radius: 10px 10px 0 0; - -webkit-border-top-right-radius: 10px; - -webkit-border-top-left-radius: 10px; - border-radius: 10px 10px 0 0; - border-width: 2px 2px 0; - border-style: solid; - border-color: #000; + -moz-border-radius: 10px 10px 0 0; + -webkit-border-top-right-radius: 10px; + -webkit-border-top-left-radius: 10px; + border-radius: 10px 10px 0 0; + border-width: 2px 2px 0; + border-style: solid; + border-color: #000; } body.yui-skin-sam .yui-panel .ft { - -moz-border-radius: 0 0 10px 10px; - -webkit-border-bottom-right-radius: 10px; - -webkit-border-bottom-left-radius: 10px; - border-radius: 0 0 10px 10px; - border-width: 0 2px 2px; - border-style: solid; - border-color: #000; + -moz-border-radius: 0 0 10px 10px; + -webkit-border-bottom-right-radius: 10px; + -webkit-border-bottom-left-radius: 10px; + border-radius: 0 0 10px 10px; + border-width: 0 2px 2px; + border-style: solid; + border-color: #000; } body.yui-skin-sam .nofooter .bd { - -moz-border-radius: 10px; - -webkit-border-radius: 10px; - border-radius: 10px; - border-width: 2px; - border-style: solid; - border-color: #000; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + border-radius: 10px; + border-width: 2px; + border-style: solid; + border-color: #000; } body.yui-skin-sam .container-close { - background: url('/Lacuna-Assets/ui/close.png') no-repeat scroll 0 0 transparent; - cursor: pointer; - height: 23px; - position: absolute; - right: 1px; - top: 3px; - width: 23px; + background: url('/Lacuna-Assets/ui/close.png') no-repeat scroll 0 0 transparent; + cursor: pointer; + height: 23px; + position: absolute; + right: 1px; + top: 3px; + width: 23px; } body.yui-skin-sam .yui-panel hr { - margin: 10px 0 10px; - height: 0px; - border: none; - border-top: 1px solid rgb(82, 172, 255); + margin: 10px 0 10px; + height: 0px; + border: none; + border-top: 1px solid rgb(82, 172, 255); } .tleTable { - width: 100%; - border: 1px solid white; + width: 100%; + border: 1px solid white; } .tleTable th { - text-align: center; - color: #fff; - background-color: #52acff; - border: 1px solid white; + text-align: center; + color: #fff; + background-color: #52acff; + border: 1px solid white; } .tleTable td { - font-size: 90%; - text-align: center; - border-width: 0px 1px 1px 0; - border-style: solid; - border-color: white; + font-size: 90%; + text-align: center; + border-width: 0px 1px 1px 0; + border-style: solid; + border-color: white; } /* @@ -237,459 +237,459 @@ dialogs #login label, #createEmpire label, .speciesCreate label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } #login label { - width: 140px; + width: 140px; } #login input[type='text'], #login input[type='password'] { - width: 242px; + width: 242px; } #login li { - margin-bottom: 3px; + margin-bottom: 3px; } .loginMain button { - float: right; - margin-right: 5px; + float: right; + margin-right: 5px; } #login hr { - margin: 17px 0 15px; + margin: 17px 0 15px; } .loginWrapper { - margin: 5px; - overflow: hidden; + margin: 5px; + overflow: hidden; } .loginCreateTable { - display: table; - width: 211px; - height: 164px; - top: 0px; - bottom: 0px; - left: 394px; - right: 0px; + display: table; + width: 211px; + height: 164px; + top: 0px; + bottom: 0px; + left: 394px; + right: 0px; } .loginCreate { - display: table-cell; - vertical-align: middle; - width: 200px; - margin-top: 10px; - text-align: center; - /*float: right;*/ + display: table-cell; + vertical-align: middle; + width: 200px; + margin-top: 10px; + text-align: center; + /*float: right;*/ } .loginMain { - width: 394px; - border-right: 1px solid rgb(82, 172, 255); - padding: 32px 5px; - height: 100px; - float: left; + width: 394px; + border-right: 1px solid rgb(82, 172, 255); + padding: 32px 5px; + height: 100px; + float: left; } .loginExtras { - margin: 10px; + margin: 10px; } .loginExtras li { - list-style: disc inside none; + list-style: disc inside none; } #resetPasswordEmail li, #resetPasswordKey li { - margin: 3px 0; + margin: 3px 0; } #resetPasswordEmail input[type='text'], #resetPasswordEmail input[type='password'] { - width: 242px; + width: 242px; } #resetPasswordKey input[type='text'], #resetPasswordKey input[type='password'] { - width: 292px; + width: 292px; } #resetPasswordEmail label, #resetPasswordKey label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 130px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 130px; } #createEmpire .requiredField { - color: #f00; + color: #f00; } #createEmpire li.requiredField { - text-align: center; + text-align: center; } .facebookLogin .empirePassword .requiredField { - display: none; + display: none; } .facebookLogin .empireCaptcha { - display: none; + display: none; } #createEmpire li label { - text-align: right; - padding-right: 5px; - vertical-align: top; - width: 140px; + text-align: right; + padding-right: 5px; + vertical-align: top; + width: 140px; } .facebookLogin .empireCaptcha { - display: none; + display: none; } .empireCaptcha img, .empireCaptcha button { - vertical-align: middle; + vertical-align: middle; } #empireCaptchaBorder { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - border: 1px solid #000; - width: 300px; - height: 80px; - margin-right: 5px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + border: 1px solid #000; + width: 300px; + height: 80px; + margin-right: 5px; } #createEmpire li.empireCaptcha label { - width: 57px; + width: 57px; } #createEmpire .empireAgreeCheck { - margin-top: 5px; - padding-left: 65px; + margin-top: 5px; + padding-left: 65px; } #createEmpire .empireAgreeCheck input { - margin-right: 5px; + margin-right: 5px; } #createEmpire .empireAgreeCheck label { - width: auto; + width: auto; } .speciesAffinityTooltip { - z-index: 20000 !important; + z-index: 20000 !important; } #createEmpire input[type='text'], #createEmpire input[type='password'] { - width: 220px; + width: 220px; } #createEmpire textarea { - width: 224px; + width: 224px; } #createEmpire li { - margin-bottom: 3px; + margin-bottom: 3px; } #profileSpeciesRedefineWarning { - margin-bottom: 5px; - padding-bottom: 5px; - border-bottom: 1px solid #52acff; - font-weight: bold; + margin-bottom: 5px; + padding-bottom: 5px; + border-bottom: 1px solid #52acff; + font-weight: bold; } .profileSpeciesRedefineButton { - text-align: center; + text-align: center; } .speciesCreate input[type='text'] { - width: 250px; + width: 250px; } .speciesCreate textarea { - width: 253px; + width: 253px; } .speciesCreate li label { - width: 140px; - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - text-align: right; - padding-right: 5px; - vertical-align: top; + width: 140px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + text-align: right; + padding-right: 5px; + vertical-align: top; } .speciesCreate .speciesAffinities li label { - vertical-align: middle; + vertical-align: middle; } .quick-dialog { - text-align: justify; + text-align: justify; } .quick-dialog p { - margin: 10px 0; + margin: 10px 0; } #captcha li label { - width: 70px; - text-align: right; - padding-right: 6px; - vertical-align: top; - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 70px; + text-align: right; + padding-right: 6px; + vertical-align: top; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } #captchaSolution { - width: 220px; + width: 220px; } #captchaImage { - border: 1px solid #000; - vertical-align: top; - margin: 5px 0; + border: 1px solid #000; + vertical-align: top; + margin: 5px 0; } #captchaRefresh { - margin: 32px 0 0 13px; + margin: 32px 0 0 13px; } /* * Messaging */ #messagingTabs #messagingCreate { - background-color: #52acff; + background-color: #52acff; } .message { - border: 1px solid #b2b2b2; - cursor: pointer; - margin: 3px 3px 0; - padding: 2px 2px 0; - position: relative; + border: 1px solid #b2b2b2; + cursor: pointer; + margin: 3px 3px 0; + padding: 2px 2px 0; + position: relative; } .message .messageContainer { - margin-right: 26px; + margin-right: 26px; } .message .messageSelect { - position: absolute; - right: 1px; - width: 26px; + position: absolute; + right: 1px; + width: 26px; } .messageSelect input[type='checkbox'] { - float: right; + float: right; } .message .messageExcerpt { - font-size: 90%; + font-size: 90%; } .unread .messageDate, .unread .messageFrom, .unread .messageSubject { - font-weight: bold; + font-weight: bold; } .messageDate, .messageFrom, .messageSubject { - font-size: 13px; - padding: 2px 0; + font-size: 13px; + padding: 2px 0; } #messagingTabs .yui-content { - padding: 0; + padding: 0; } #messagingCreator { - border-top-color: #52acff; + border-top-color: #52acff; } #messagingCreator div.messagingCreatorC { - background-color: #d2d2d2; + background-color: #d2d2d2; } #messagingCreateToTbl { - background-color: #fff; + background-color: #fff; } #messagingCreateToTbl, #messagingCreateSubject { - width: 450px; + width: 450px; } #messagingCreateTo { - width: 100px; + width: 100px; } #messagingCreateBody { - height: 260px; + height: 260px; } #messagingCreateText { - width: 100%; - height: 100%; - border: 0; + width: 100%; + height: 100%; + border: 0; } #messagingCreateResponse { - color: red; + color: red; } #messagingArchiver { - background-color: #52acff; + background-color: #52acff; } /*#messagingPaginator, #statsEmpirePaginator*/ body.yui-skin-sam .yui-pg-container { - background-color: white; - margin: 0px; - border: 1px solid #52acff; + background-color: white; + margin: 0px; + border: 1px solid #52acff; } /*#messagingPaginator .yui-pg-current-page, #statsEmpirePaginator .yui-pg-current-page*/ body.yui-skin-sam .yui-pg-container .yui-pg-current-page { - color: #000; + color: #000; } #messagingDisplay { - padding-top: 5px; - margin-left: 1%; - /*overflow: auto; + padding-top: 5px; + margin-left: 1%; + /*overflow: auto; height:384px;*/ } #messagingDisplay label, #messagingCreator label { - background-color: #d2d2d2; - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - font-weight: bold; - width: 75px; - color: #000; + background-color: #d2d2d2; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + font-weight: bold; + width: 75px; + color: #000; } #messagingDisplay div, #messagingCreator div.messagingCreatorC { - border-width: 1px 0 0 0; - border-style: solid; - border-color: #d2d2d2; + border-width: 1px 0 0 0; + border-style: solid; + border-color: #d2d2d2; } #messagingDisplay span { - padding-left: 2px; + padding-left: 2px; } #messagingDisplay #messagingBody { - border-top: 1px solid #d2d2d2; - padding: 2px 5px; + border-top: 1px solid #d2d2d2; + padding: 2px 5px; } #messagingFrom a, #messagingTo a { - text-decoration: underline; - cursor: pointer; + text-decoration: underline; + cursor: pointer; } #messagingBody #attachmentImage { - border-color: transparent; - border-style: none; - border-width: 0; + border-color: transparent; + border-style: none; + border-width: 0; } #attachmentTable th { - font-weight: bold; - border: 1px solid #52acff; - padding: 1px 2px; + font-weight: bold; + border: 1px solid #52acff; + padding: 1px 2px; } #attachmentTable td { - border: 1px solid #52acff; - padding: 1px 2px; + border: 1px solid #52acff; + padding: 1px 2px; } #attachmentMap { - border-collapse: collapse; - border: 0; - width: 550px; - height: 550px; + border-collapse: collapse; + border: 0; + width: 550px; + height: 550px; } #attachmentMap .attachmentMapTile { - float: left; - width: 50px; - height: 50px; - overflow: hidden; + float: left; + width: 50px; + height: 50px; + overflow: hidden; } /* * Species creator */ .speciesSlider_bg { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - position: relative; - background: url('/Lacuna-Assets/ui/tickbar.png') -11px 5px no-repeat; - height: 28px; - width: 198px; - top: 5px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + position: relative; + background: url('/Lacuna-Assets/ui/tickbar.png') -11px 5px no-repeat; + height: 28px; + width: 198px; + top: 5px; } .speciesHO_min, .speciesHO_max { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - position: absolute; - top: 0px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + position: absolute; + top: 0px; } .speciesHO_min { - left: -7px; + left: -7px; } .speciesHO_max { - left: 7px; + left: 7px; } .thumbDisplay { - position: absolute; - display: block; - text-align: center; - width: 100%; - color: black; - bottom: 2px; + position: absolute; + display: block; + text-align: center; + width: 100%; + color: black; + bottom: 2px; } .speciesButtons { - margin-bottom: 5px; - padding-bottom: 5px; - border-bottom: 1px solid #52acff; + margin-bottom: 5px; + padding-bottom: 5px; + border-bottom: 1px solid #52acff; } .speciesHO_highlight { - position: absolute; - background: #103060; - _font-size: 5px; /* prevent IE6 expanding the box height to font-size */ - top: 10px; - left: 12px; - height: 13px; - width: 188px; - opacity: 0.7; - -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=70)'; - filter: alpha(opacity=70); + position: absolute; + background: #103060; + _font-size: 5px; /* prevent IE6 expanding the box height to font-size */ + top: 10px; + left: 12px; + height: 13px; + width: 188px; + opacity: 0.7; + -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=70)'; + filter: alpha(opacity=70); } .speciesHO .speciesSlider_lock { - border-left: 1px solid red; + border-left: 1px solid red; } .speciesSlider_lock { - position: absolute; - border-right: 1px solid red; - _font-size: 5px; /* prevent IE6 expanding the box height to font-size */ - top: 8px; - left: 12px; - height: 20px; - width: 0px; - display: none; + position: absolute; + border-right: 1px solid red; + _font-size: 5px; /* prevent IE6 expanding the box height to font-size */ + top: 8px; + left: 12px; + height: 20px; + width: 0px; + display: none; } .speciesSlider_lock_bg { - position: relative; - background: #bfbfbf; - _font-size: 5px; /* prevent IE6 expanding the box height to font-size */ - top: 2px; - height: 13px; - width: 100%; - display: block; - opacity: 0.5; - -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)'; - filter: alpha(opacity=50); + position: relative; + background: #bfbfbf; + _font-size: 5px; /* prevent IE6 expanding the box height to font-size */ + top: 2px; + height: 13px; + width: 100%; + display: block; + opacity: 0.5; + -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)'; + filter: alpha(opacity=50); } .speciesSliderThumb { - position: absolute; - cursor: default; - top: 8px; + position: absolute; + cursor: default; + top: 8px; } .affinitiesLabel { - font-size: 150%; - padding: 0 80px; + font-size: 150%; + padding: 0 80px; } .speciesPointLine { - font-size: 150%; + font-size: 150%; } .speciesPointsValid { - color: #00e000; + color: #00e000; } .speciesPointsInvalid { - color: #f00; + color: #f00; } .speciesPointsLow { - color: #ff0; + color: #ff0; } /* @@ -697,11 +697,11 @@ Info dialogs for Empire and Alliance */ #infoEmpire label, #infoAlliance label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 100px; - font-weight: bold; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 100px; + font-weight: bold; } /* @@ -709,238 +709,238 @@ Info dialogs for Empire and Alliance */ #starMap, #planetMap { - border: 0 none; - clear: both; - cursor: move; - cursor: grab; - cursor: -moz-grab; - cursor: -webkit-grab; + border: 0 none; + clear: both; + cursor: move; + cursor: grab; + cursor: -moz-grab; + cursor: -webkit-grab; } #planetMap, #starMap { - position: absolute; - top: 0; - width: 100vw; - height: 100vh; + position: absolute; + top: 0; + width: 100vw; + height: 100vh; } #starMap:active, #planetMap:active { - cursor: grabbing; - cursor: -moz-grabbing; - cursor: -webkit-grabbing; + cursor: grabbing; + cursor: -moz-grabbing; + cursor: -webkit-grabbing; } #planetMap .tile:hover { - margin: -1px; - border: 1px dashed #fff; + margin: -1px; + border: 1px dashed #fff; } .tile { - word-wrap: break-word; + word-wrap: break-word; } .tile .self { - border: 1px solid green; + border: 1px solid green; } .tile .ally { - border: 1px solid purple; + border: 1px solid purple; } .tile .ally-isolationist { - border: 1px dashed purple; + border: 1px dashed purple; } .tile .hostile { - border: 1px solid orange; + border: 1px solid orange; } .tile .hostile-isolationist { - border: 1px dashed orange; + border: 1px dashed orange; } .tile .probed { - border: 1px dotted #555; + border: 1px dotted #555; } .tileContainer div.planetMapTileCounter { - z-index: 2; - text-align: right; - font-size: 140%; - font-family: impact, sans-serif; - position: absolute; - left: 0; - top: 0; + z-index: 2; + text-align: right; + font-size: 140%; + font-family: impact, sans-serif; + position: absolute; + left: 0; + top: 0; } .tileContainer div.planetMapTileCounterWork { - z-index: 2; - text-align: left; - vertical-align: middle; - color: orange; - font-size: 140%; - font-family: impact, sans-serif; - position: absolute; - left: 0; - bottom: 0; + z-index: 2; + text-align: left; + vertical-align: middle; + color: orange; + font-size: 140%; + font-family: impact, sans-serif; + position: absolute; + left: 0; + bottom: 0; } .tileContainer div { - color: white; + color: white; } .planetMapEfficiencyBarContainer { - z-index: 2; - text-align: center; - font-size: 100%; - font-family: impact, sans-serif; - line-height: 15px; - height: 15px; - position: absolute; - left: 0; - bottom: 5px; - border: 1px solid #999; - background-color: #444; + z-index: 2; + text-align: center; + font-size: 100%; + font-family: impact, sans-serif; + line-height: 15px; + height: 15px; + position: absolute; + left: 0; + bottom: 5px; + border: 1px solid #999; + background-color: #444; } .planetMapEfficiencyBar { - z-index: 2; - height: 100%; - margin-right: auto; - white-space: nowrap; + z-index: 2; + height: 100%; + margin-right: auto; + white-space: nowrap; } .planetMapTileActionContainer { - z-index: 3; - text-align: left; - font-size: 140%; - font-family: impact, sans-serif; - visibility: hidden; - position: absolute; - left: 0; - top: 0; - padding-top: 50%; + z-index: 3; + text-align: left; + font-size: 140%; + font-family: impact, sans-serif; + visibility: hidden; + position: absolute; + left: 0; + top: 0; + padding-top: 50%; } .planetMapTileActionLevel, .planetMapTileActionButton { - width: 58px; - height: 45px; - border: 0; - cursor: pointer; - margin: -22px auto 0; - text-align: center; + width: 58px; + height: 45px; + border: 0; + cursor: pointer; + margin: -22px auto 0; + text-align: center; } .planetMapTileActionLevel { - font-size: 190%; - font-weight: bold; - color: white; + font-size: 190%; + font-weight: bold; + color: white; } .planetMapTileActionButton { - background: transparent url('/Lacuna-Assets/ui/l/build.png'); + background: transparent url('/Lacuna-Assets/ui/l/build.png'); } .plots-full .planetMapTileActionButton { - background: transparent url('/Lacuna-Assets/ui/l/build-no.png'); + background: transparent url('/Lacuna-Assets/ui/l/build-no.png'); } .tileContainer .tile50 div.planetMapTileCounter { - font-family: Arial Narrow, Times New Roman, sans-serif; - font-size: 95%; + font-family: Arial Narrow, Times New Roman, sans-serif; + font-size: 95%; } .tileContainer .tile50 div.planetMapTileCounterWork { - font-family: Arial Narrow, Times New Roman, sans-serif; - font-size: 95%; + font-family: Arial Narrow, Times New Roman, sans-serif; + font-size: 95%; } .tile50 .planetMapTileActionContainer { - font-size: 100%; + font-size: 100%; } .tile50 .planetMapTileActionLevel, .tile50 .planetMapTileActionButton { - width: 29px; - height: 22px; - margin: -12px auto 0; + width: 29px; + height: 22px; + margin: -12px auto 0; } .tile50 .planetMapTileActionLevel { - font-size: 180%; + font-size: 180%; } .tile50 .planetMapTileActionButton { - background: transparent url('/Lacuna-Assets/ui/s/build.png'); + background: transparent url('/Lacuna-Assets/ui/s/build.png'); } .plots-full .tile50 .planetMapTileActionButton { - background: transparent url('/Lacuna-Assets/ui/s/build-no.png'); + background: transparent url('/Lacuna-Assets/ui/s/build-no.png'); } .mapiator_zoom { - background: url(/Lacuna-Assets/ui/zoom.png); - background-position: -20px -60px; - position: absolute; - z-index: 30; - width: 20px; - height: 255px; - left: 15px; - top: 100px; + background: url(/Lacuna-Assets/ui/zoom.png); + background-position: -20px -60px; + position: absolute; + z-index: 30; + width: 20px; + height: 255px; + left: 15px; + top: 100px; } .mapiator_zoom_slider { - position: absolute; - cursor: pointer; - top: 50px; - left: 0px; - width: 20px; - height: 150px; + position: absolute; + cursor: pointer; + top: 50px; + left: 0px; + width: 20px; + height: 150px; } .mapiator_zoom_slider_thumb { - cursor: row-resize; + cursor: row-resize; } .mapiator_zoom_in, .mapiator_zoom_out { - position: absolute; - cursor: pointer; - width: 18px; - left: 1px; - height: 19px; + position: absolute; + cursor: pointer; + width: 18px; + left: 1px; + height: 19px; } .mapiator_zoom_in { - top: 26px; + top: 26px; } .mapiator_zoom_out { - top: 209px; + top: 209px; } .tile .planetMapTileActionContainer { - visibility: hidden; + visibility: hidden; } .tile:hover .planetMapTileActionContainer { - visibility: visible; + visibility: visible; } body.yui-skin-sam .yui-navset .yui-nav, body.yui-skin-sam .yui-navset .yui-navset-top .yui-nav { - border-color: #52acff; + border-color: #52acff; } body.yui-skin-sam .yui-navset .yui-content, body.yui-skin-sam .yui-navset .yui-navset-top .yui-content { - border-color: #52acff; + border-color: #52acff; } body.yui-skin-sam .yui-navset .yui-content { - background-color: transparent; + background-color: transparent; } body.yui-skin-sam .yui-navset .yui-nav .selected a, body.yui-skin-sam .yui-navset .yui-nav .selected a em { - border-color: #52acff; + border-color: #52acff; } body.yui-skin-sam .yui-navset .yui-nav a, body.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a { - background: none repeat scroll 0 0 #d8d8d8; + background: none repeat scroll 0 0 #d8d8d8; } body.yui-skin-sam .yui-navset .yui-nav a:focus, body.yui-skin-sam .yui-navset .yui-nav a:hover { - background: none repeat scroll 0 0 #bfdaff; + background: none repeat scroll 0 0 #bfdaff; } body.yui-skin-sam .yui-navset .yui-nav .selected a, body.yui-skin-sam .yui-navset .yui-nav .selected a:focus, body.yui-skin-sam .yui-navset .yui-nav .selected a:hover { - background: none repeat scroll 0 0 #52acff; + background: none repeat scroll 0 0 #52acff; } body.yui-skin-sam .yui-pg-page { - background-color: transparent; - border: 0px; + background-color: transparent; + border: 0px; } .planet, .star { - cursor: pointer; - position: relative; - display: inline; - vertical-align: middle; + cursor: pointer; + position: relative; + display: inline; + vertical-align: middle; } /* @@ -948,161 +948,161 @@ planet details */ #planetDetailsName, #starDetailsName { - font-family: impact; - font-size: 120%; + font-family: impact; + font-size: 120%; } #planetDetailsInfo label, #planetDetailOre label, #starDetailsInfo label { - font-weight: bold; - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 100px; + font-weight: bold; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 100px; } #planetDetailRename label { - width: 150px; + width: 150px; } #planetDetailFetchSpies, #planetDetailSendSpies { } .planetDetailSpiesMessage, .planetDetailSpyShipMessage { - height: 25px; - float: left; + height: 25px; + float: left; } .planetDetailSelectSpies button, .planetDetailSpyShipHeader button { - float: right; + float: right; } .planetDetailSpiesList, .planetDetailSpyShipList { - overflow-y: auto; - clear: both; - border-top: 1px solid #52acff; - margin: 0 -6px -3px -7px; + overflow-y: auto; + clear: both; + border-top: 1px solid #52acff; + margin: 0 -6px -3px -7px; } .planetDetailSpiesList li, .planetDetailSpyShipList li { - border-bottom: 1px solid #52acff; - padding: 5px; + border-bottom: 1px solid #52acff; + padding: 5px; } /*.planetDetailSpiesList li { position:relative; }*/ .planetDetailSpyShipList li button { - float: right; + float: right; } .planetDetailSpiesList li .description { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } .planetDetailSpiesList li .attributes { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - vertical-align: top; - margin-left: 10px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + vertical-align: top; + margin-left: 10px; } .planetDetailSpiesList li .attributes .attribute { - white-space: nowrap; - margin: 0 5px; + white-space: nowrap; + margin: 0 5px; } .planetDetailSpiesList li input { - float: right; + float: right; } .planetDetailSpiesList strong, .planetDetailSpyShipList strong { - font-weight: bold; + font-weight: bold; } .smallImg { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 25px; /*30px;*/ - vertical-align: middle; - text-align: center; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 25px; /*30px;*/ + vertical-align: middle; + text-align: center; } .buildingDetailsNum { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - text-align: right; - width: 120px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + text-align: right; + width: 120px; } #buildingDetailsName, .buildingName, .shipName { - font-weight: bold; + font-weight: bold; } .shipName { - cursor: pointer; - text-decoration: underline; + cursor: pointer; + text-decoration: underline; } #buildingDetailsDesc { - border-top: 1px solid #52acff; - font-size: 85%; + border-top: 1px solid #52acff; + font-size: 85%; } .buildingStats { - width: 100%; + width: 100%; } .buildingStats th { - font-weight: bold; + font-weight: bold; } .buildingStats .low-resource, .buildingDetailsNum.low-resource { - color: #f00; + color: #f00; } .buildingDesc, .shipDesc, .missionDesc, .missionPosted, .missionUniversity { - font-size: 85%; + font-size: 85%; } .shipDesc { - border-bottom: 1px solid #52acff; + border-bottom: 1px solid #52acff; } .buildingDesc a { - display: block; - text-align: right; + display: block; + text-align: right; } .buildingReason { - color: #f66; - font-size: 85%; + color: #f66; + font-size: 85%; } /*#buildingBuilderUnavailable .buildingDesc { border-top:1px solid #52acff; }*/ #builderMenu, #builderListContainer .yui-content { - border: 1px solid #52acff; + border: 1px solid #52acff; } #builderMenu .builderMenuGroup { - display: block; - width: 500px; - margin: 5px auto 15px; - text-align: center; + display: block; + width: 500px; + margin: 5px auto 15px; + text-align: center; } #builderMenu .builderMenuGroup em, #builderMenu .builderMenuGroup li { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - margin-bottom: 1px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + margin-bottom: 1px; } #builderMenu .builderMenuGroup a { - width: 200px; - /*height: 20px;*/ + width: 200px; + /*height: 20px;*/ } #builderMenu .builderMenuGroup em { - font-weight: bold; - height: 20px; + font-weight: bold; + height: 20px; } /*#buildingDetailsExtra { padding: 5px 0; @@ -1115,113 +1115,113 @@ planet details }*/ #buildingDetailsExtra, .buildingDetailsExtra { - min-height: 200px; - max-height: 300px; - overflow: auto; + min-height: 200px; + max-height: 300px; + overflow: auto; } .buildingDetailsExtra label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 75px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 75px; } .buildingDetailsExtra .buildingDetailsPC li label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 125px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 125px; } .buildingDetailsDockedShips label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 185px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 185px; } .pcStored, .pcCapacity, .pcPerHour { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - text-align: right; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + text-align: right; } .pcStored { - width: 100px; + width: 100px; } .pcCapacity { - width: 100px; + width: 100px; } .pcPerHour { - width: 50px; + width: 50px; } .pcSlash { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - text-align: center; - width: 15px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + text-align: center; + width: 15px; } .smallFood { - width: 22px; /*38px;*/ - height: 22px; + width: 22px; /*38px;*/ + height: 22px; } .smallOre { - width: 19px; /*21px;*/ - height: 22px; + width: 19px; /*21px;*/ + height: 22px; } .smallWater { - width: 18px; /*15px;*/ - height: 22px; + width: 18px; /*15px;*/ + height: 22px; } .smallEnergy { - width: 10px; /*11px;*/ - height: 22px; + width: 10px; /*11px;*/ + height: 22px; } .smallWaste { - width: 15px; /*16px;*/ - height: 22px; + width: 15px; /*16px;*/ + height: 22px; } .smallHappy { - width: 19px; /*22px;*/ - height: 22px; + width: 19px; /*22px;*/ + height: 22px; } .smallEssentia { - width: 24px; /*28px;*/ - height: 22px; + width: 24px; /*28px;*/ + height: 22px; } .smallTime { - width: 21px; - height: 22px; + width: 21px; + height: 22px; } .smallStorage { - width: 22px; - height: 22px; + width: 22px; + height: 22px; } .newsFeedContainer { - height: 200px; - overflow-y: auto; - font-size: 90%; - margin: 5px 0; - padding: 1px; - border: 1px solid #52acff; + height: 200px; + overflow-y: auto; + font-size: 90%; + margin: 5px 0; + padding: 1px; + border: 1px solid #52acff; } .newsRssLinksContainer { } #newsRssLinks li { - float: left; - margin-right: 10px; + float: left; + margin-right: 10px; } .newsRssLink a { - vertical-align: middle; + vertical-align: middle; } #observatoryInfo, #platformShippingInfo { - margin-bottom: 2px; - padding-bottom: 2px; - border-bottom: 1px solid #52acff; + margin-bottom: 2px; + padding-bottom: 2px; + border-bottom: 1px solid #52acff; } /* shared display headers */ @@ -1237,8 +1237,8 @@ planet details .planHeader, .supplyChainHeader, .incomingSupplyChainHeader { - font-weight: bold; - border-bottom: 1px solid #52acff; + font-weight: bold; + border-bottom: 1px solid #52acff; } .buildQueue li, .embassyInfo li, @@ -1255,703 +1255,703 @@ planet details .plan li, .supplyChainInfo li, .incomingSupplyChainInfo li { - float: left; + float: left; } .spyInfo, .platformInfo, .excavatorInfo { - border: 1px solid #ddd; - padding: 2px; - margin: 0 2px 2px 0; + border: 1px solid #ddd; + padding: 2px; + margin: 0 2px 2px 0; } .spyInfo li, .platformInfo li, .excavatorInfo li { - font-size: 90%; + font-size: 90%; } .spyInfo li label, .platformInfo li label, .excavatorInfo li label { - font-weight: bold; - margin-right: 3px; + font-weight: bold; + margin-right: 3px; } div.archaeologySlots { - padding: 5px; + padding: 5px; } ul.archaeologyGlyphInfo { - position: relative; - width: 510px; - height: 175px; - border: 1px solid #ffd800; - margin: 0; - padding: 0; - overflow-y: auto; - overflow-x: hidden; + position: relative; + width: 510px; + height: 175px; + border: 1px solid #ffd800; + margin: 0; + padding: 0; + overflow-y: auto; + overflow-x: hidden; } ul.archaeologyGlyphInfo li { - margin: 1px; - cursor: move; - zoom: 1; + margin: 1px; + cursor: move; + zoom: 1; } div.archaeologyGlyphContainer { - border: 1px solid white; + border: 1px solid white; } div.archaeologyGlyphContainer div.archaeologyGlyphHeader { - background-color: white; - color: black; + background-color: white; + color: black; } .subspaceTransmit { - width: 200px; - margin: 10px 5px; + width: 200px; + margin: 10px 5px; } #subspaceCompleteBuildQueue { - width: 300px; + width: 300px; } #buildingDetailsExtra { - overflow: auto; + overflow: auto; } .buildQueue .buildQueueRank { - width: 30px; + width: 30px; } .buildQueue .buildQueueName { - width: 170px; + width: 170px; } .buildQueue .buildQueueLevel { - width: 50px; - text-align: right; + width: 50px; + text-align: right; } .buildQueue .buildQueueTime { - width: 100px; - text-align: right; + width: 100px; + text-align: right; } .buildQueue .buildQueueCoords { - width: 100px; - text-align: right; + width: 100px; + text-align: right; } .buildQueue .buildQueueSubsidy { - width: 100px; - text-align: right; + width: 100px; + text-align: right; } .buildQueue .buildQueueAction { - text-align: right; - width: 115px; + text-align: right; + width: 115px; } .buildQueueHeader .buildQueueLevel, .buildQueueHeader .buildQueueTime { - text-align: center; + text-align: center; } .embassyInfo .embassyAlliance { - width: 200px; + width: 200px; } .embassyInfo .embassyEmpire { - width: 200px; - text-decoration: underline; - cursor: pointer; + width: 200px; + text-decoration: underline; + cursor: pointer; } .embassyInfo .embassyMessage { - width: 250px; + width: 250px; } .embassyInfo .embassyAction { - width: 200px; + width: 200px; } .embassyStash legend, .tradeStash legend, .distribContainers legend { - color: #fff; - padding: 0 5px; - font-weight: bold; + color: #fff; + padding: 0 5px; + font-weight: bold; } .embassyContainers, .tradeContainers, .distribContainers { - height: 200px; - overflow-y: auto; - border: 1px solid #52acff; + height: 200px; + overflow-y: auto; + border: 1px solid #52acff; } .embassyContainers .stashName, .tradeContainers .tradeName, .tradeContainers .tradeResourceName, .distribContainers .reserveName { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 150px; - overflow: hidden; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 150px; + overflow: hidden; } .embassyContainers li, .tradeContainers li, .distribContainers li { - background-color: #52acff; - border: 1px solid black; - margin: 1px; - padding: 1px 2px; - font-size: 80%; + background-color: #52acff; + border: 1px solid black; + margin: 1px; + padding: 1px 2px; + font-size: 80%; } .embassyContainers li button, .tradeContainers li button, .distribContainers li button { - padding: 1px; + padding: 1px; } .stashItem, .tradeItem, .reserveItem { - position: relative; + position: relative; } .stashItem .stashDelete, .tradeItem .tradeDelete, .distribContainers .reserveDelete { - background: url('/Lacuna-Assets/ui/close.png') no-repeat scroll center center transparent; - height: 11px; - width: 11px; - position: absolute; - right: 0pt; - cursor: pointer; + background: url('/Lacuna-Assets/ui/close.png') no-repeat scroll center center transparent; + height: 11px; + width: 11px; + position: absolute; + right: 0pt; + cursor: pointer; } .tradeContainers .tradeName { - width: 319px; /* reduced from 320px to keep the + button from wrapping */ + width: 319px; /* reduced from 320px to keep the + button from wrapping */ } .tradeContainers .tradeResourceName, .distribContainers .reserveName { - width: 230px; + width: 230px; } .accordian { - cursor: pointer; - background-color: gray; - border-color: white; - border-style: solid; - border-width: 1px 1px 0; - font-weight: bold; - padding: 4px; + cursor: pointer; + background-color: gray; + border-color: white; + border-style: solid; + border-width: 1px 1px 0; + font-weight: bold; + padding: 4px; } .recycleTab fieldset, .capitolEmpireRenameTab fieldset, .speciesRenameTab fieldset { - border: 1px solid #52acff; - padding: 5px; - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - text-align: center; - margin: 10px; + border: 1px solid #52acff; + padding: 5px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + text-align: center; + margin: 10px; } .recycleTab fieldset, .capitolEmpireRenameTab fieldset { - width: 220px; + width: 220px; } .recycleTab fieldset legend, .capitolEmpireRenameTab fieldset legend, .speciesRenameTab fieldset legend { - color: #fff; - padding: 0 5px; + color: #fff; + padding: 0 5px; } .recycleTab fieldset label, .speciesRenameTab fieldset label { - display: block; + display: block; } .recycleTab fieldset label { - height: 22px; + height: 22px; } .plan li { - width: 100px; + width: 100px; } .plan li.planName { - width: 200px; + width: 200px; } .planetDisplay { - width: 350px; - border: 1px solid black; - background-color: #52acff; - margin: 2px; - padding: 5px; - cursor: pointer; + width: 350px; + border: 1px solid black; + background-color: #52acff; + margin: 2px; + padding: 5px; + cursor: pointer; } .probeInfo .probeStar { - width: 200px; - border: 1px solid black; - background-color: #52acff; - margin: 2px; - position: relative; + width: 200px; + border: 1px solid black; + background-color: #52acff; + margin: 2px; + position: relative; } .probeStar .probeAction { - cursor: pointer; + cursor: pointer; } .probeStar .probeDelete { - background: url('/Lacuna-Assets/ui/close.png') no-repeat scroll center center transparent; - height: 11px; - width: 11px; - position: absolute; - right: 0pt; - cursor: pointer; + background: url('/Lacuna-Assets/ui/close.png') no-repeat scroll center center transparent; + height: 11px; + width: 11px; + position: absolute; + right: 0pt; + cursor: pointer; } .securityInfo .securityName { - width: 100px; + width: 100px; } .securityInfo .securityLevel { - width: 80px; + width: 80px; } .securityInfo .securityNextMisson, .securityInfo .securitySentence { - width: 180px; + width: 180px; } .securityInfo .securityStatus { - width: 140px; + width: 140px; } .securityInfo .securityExecute { - width: 100px; + width: 100px; } .securityInfo .securityRelease { - width: 100px; + width: 100px; } .spyInfo .spyName { - width: 100px; - font-weight: bold; - font-size: 100%; - cursor: url(/Lacuna-Assets/ui/web/pen_m.cur), text; + width: 100px; + font-weight: bold; + font-size: 100%; + cursor: url(/Lacuna-Assets/ui/web/pen_m.cur), text; } .spyInfo .spyName input { - width: 95px; - font-size: 90%; + width: 95px; + font-size: 90%; } .spyInfo .spyAssignedTo { - width: 200px; + width: 200px; } .spyInfo .spyAvailableWhen { - width: 270px; + width: 270px; } .spyInfo .spyAssignment { - width: 440px; + width: 440px; } .spyInfo .spyAssignment select { - width: 325px; - margin-right: 5px; + width: 325px; + margin-right: 5px; } .spyInfo .spyAssignResult a { - margin-left: 1em; + margin-left: 1em; } .spyInfo .spyOffense { - width: 100px; + width: 100px; } .spyInfo .spyDefense { - width: 100px; + width: 100px; } .spyInfo .spyLevel { - width: 100px; + width: 100px; } .spyInfo .spyIntel { - width: 100px; + width: 100px; } .spyInfo .spyMayhem { - width: 100px; + width: 100px; } .spyInfo .spyPolitics { - width: 100px; + width: 100px; } .spyInfo .spyTheft { - width: 100px; + width: 100px; } .spyInfo .spyBurn { - width: 60px; - float: right; + width: 60px; + float: right; } .spyInfo .spyMissionCounts { - width: 100px; + width: 100px; } .spyInfo .spyOffensiveMissions { - width: 100px; + width: 100px; } .spyInfo .spyDefensiveMissions { - width: 100px; + width: 100px; } .spyInfo .spyTotalMissions { - width: 100px; + width: 100px; } .shipInfo .shipType { - width: 180px; + width: 180px; } .shipInfo .shipCost { - width: 310px; + width: 310px; } .shipInfo .shipAttributes { - width: 100px; + width: 100px; } .shipInfo .shipBuild { - width: 60px; + width: 60px; } .shipInfo .shipArrives { - width: 180px; + width: 180px; } .shipInfo .shipFrom { - width: 140px; + width: 140px; } .shipInfo .shipTo { - width: 140px; + width: 140px; } .shipInfo .shipTypeImage { - width: 54px; + width: 54px; } .shipInfo .shipName { - width: 165px; + width: 165px; } .shipInfo .shipTask { - width: 100px; + width: 100px; } .shipInfo .shipSpeed { - width: 75px; + width: 75px; } .shipInfo .shipHold { - width: 75px; + width: 75px; } .shipInfo .shipAction { - width: 100px; + width: 100px; } .shipInfo .shipReason { - width: 150px; + width: 150px; } .shipQueue .shipQueueType { - width: 180px; + width: 180px; } .shipQueue .shipQueueEach { - width: 150px; + width: 150px; } .supplyChainInfo .supplyChainBody { - width: 35%; + width: 35%; } .supplyChainInfo .supplyChainResource { - width: 20%; + width: 20%; } .supplyChainInfo .supplyChainHour { - width: 15%; + width: 15%; } .supplyChainInfo .supplyChainAction { - width: 30%; + width: 30%; } .supplyChainInfo .supplyChainStalled { - color: #f00; + color: #f00; } .supplyChainStalled { - color: #f00; - font-weight: bold; + color: #f00; + font-weight: bold; } .incomingSupplyChainInfo .incomingSupplyChainBody { - width: 55%; + width: 55%; } .incomingSupplyChainInfo .incomingSupplyChainResource { - width: 15%; + width: 15%; } .incomingSupplyChainInfo .incomingSupplyChainHour { - width: 15%; + width: 15%; } .incomingSupplyChainInfo .incomingSupplyChainEfficiency { - width: 15%; + width: 15%; } .incomingSupplyChainStalled { - color: #f00; - font-weight: bold; + color: #f00; + font-weight: bold; } .tradeInfo { - margin-bottom: 10px; + margin-bottom: 10px; } .tradeInfo .tradeEmpire { - width: 180px; - text-decoration: underline; - cursor: pointer; + width: 180px; + text-decoration: underline; + cursor: pointer; } .tradeInfo .tradeOfferedDate { - width: 115px; + width: 115px; } .myTrades .tradeInfo .tradeOfferedDate { - width: 185px; + width: 185px; } .tradeInfo .tradeAsking { - width: 55px; + width: 55px; } .tradeInfo .tradeAsking img { - vertical-align: top; + vertical-align: top; } .tradeInfo .tradeOffer { - width: 240px; + width: 240px; } .myTrades .tradeInfo .tradeOffer { - width: 400px; + width: 400px; } .tradeInfo .tradeAction { - width: 75px; + width: 75px; } #tradePushCargo { - margin: 0 4px; + margin: 0 4px; } .transporterOneForOne label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 75px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 75px; } .transporterOneForOne input, .transporterOneForOne select { - width: 200px; + width: 200px; } .transporterOneForOne button { - margin: 5px; + margin: 5px; } .excavatorInfo .excavatorLocation { - width: 250px; - text-decoration: underline; - cursor: pointer; + width: 250px; + text-decoration: underline; + cursor: pointer; } .excavatorInfo .excavatorLocation img { - width: 30px; - height: 30px; - float: left; + width: 30px; + height: 30px; + float: left; } .excavatorInfo .excavatorProduction { - width: 200px; + width: 200px; } .excavatorInfo .excavatorChances { - width: 630px; + width: 630px; } .excavatorInfo .excavatorChances ul li { - float: left; - margin: 0 4px; + float: left; + margin: 0 4px; } .platformInfo .platformLocation { - width: 250px; - text-decoration: underline; - cursor: pointer; + width: 250px; + text-decoration: underline; + cursor: pointer; } .platformInfo .platformLocation img { - width: 30px; - height: 30px; - float: left; + width: 30px; + height: 30px; + float: left; } .platformInfo .platformProduction { - width: 200px; + width: 200px; } .platformInfo .platformShipping { - width: 200px; + width: 200px; } .platformInfo .platformOre { - width: 630px; + width: 630px; } .platformInfo .platformOre ul li { - float: left; - margin: 0 4px; + float: left; + margin: 0 4px; } .platformInfo .platformAbandon { - width: 100px; - float: right; + width: 100px; + float: right; } #battleLogsDetails label { - font-weight: bold; + font-weight: bold; } #battleLogsDetails .attacker { - padding: 5px; - border-top: 1px solid #52acff; + padding: 5px; + border-top: 1px solid #52acff; } #battleLogsDetails .attacked { - padding: 5px; + padding: 5px; } #battleLogsDetails .defender { - padding: 5px; + padding: 5px; } #battleLogsDetails .first { - border-top: none; + border-top: none; } #propsDetails li, #lawsDetails li { - margin-top: 3px; - border: 1px solid #52acff; - padding: 5px; + margin-top: 3px; + border: 1px solid #52acff; + padding: 5px; } #propsDetails li label, #lawsDetails li label { - font-weight: bold; + font-weight: bold; } #propsDetails .propDesc, #lawsDetails .lawDesc { - padding: 5px; - font-size: 90%; + padding: 5px; + font-size: 90%; } #propsDetails .propMyVote { - padding: 5px; + padding: 5px; } #propsDetails th { - border-bottom: 1px solid #999; - font-weight: bold; + border-bottom: 1px solid #999; + font-weight: bold; } #proposeContainer label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 130px; - font-weight: bold; - vertical-align: top; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 130px; + font-weight: bold; + vertical-align: top; } #proposeContainer button { - margin-top: 10px; + margin-top: 10px; } #proposeContainer li { - margin-top: 2px; + margin-top: 2px; } #proposeSeizeStarFindTbl, #proposeInductMemberTbl { - width: 400px; + width: 400px; } body.yui-skin-sam .yui-tt .bd { - -moz-border-radius: 0 0 0 0; - -webkit-border-top-right-radius: 0; - -webkit-border-top-left-radius: 0; - border-radius: 0 0 0 0; - border-width: 0; - background: #52acff; - border-color: #429cef #328cdf #328cdf; + -moz-border-radius: 0 0 0 0; + -webkit-border-top-right-radius: 0; + -webkit-border-top-left-radius: 0; + border-radius: 0 0 0 0; + border-width: 0; + background: #52acff; + border-color: #429cef #328cdf #328cdf; } /* PROFILE */ #profileDetails { - margin-bottom: 5px; + margin-bottom: 5px; } #profileDetails label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 75px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 75px; } #profileDescription { - width: 428px; + width: 428px; } #profileStatus { - width: 424px; + width: 424px; } .medalContainer { - overflow: hidden; - font-size: 80%; - zoom: 1; - height: 50px; - width: 50px; + overflow: hidden; + font-size: 80%; + zoom: 1; + height: 50px; + width: 50px; } .medal { - margin: 3px 3px 0; - padding: 2px 2px 0; - position: relative; - float: left; + margin: 3px 3px 0; + padding: 2px 2px 0; + position: relative; + float: left; } .medal .medalPublic { - cursor: pointer; - position: absolute; - right: 1px; + cursor: pointer; + position: absolute; + right: 1px; } .medal .medalImg { - float: left; - margin-right: 10px; + float: left; + margin-right: 10px; } #geneticsLabSpies li.selected { - font-weight: bold; + font-weight: bold; } #geneticsLabSpies li { - cursor: pointer; - background-color: #52acff; - padding: 2px; - margin: 2px 0; + cursor: pointer; + background-color: #52acff; + padding: 2px; + margin: 2px 0; } #profileSpecies label, #geneticsLabDetails label, #profileAccountInfo label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 125px; - vertical-align: top; - font-weight: bold; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 125px; + vertical-align: top; + font-weight: bold; } #profileSpecies span, #geneticsLabDetails span, #profileAccountInfo span { - display: inline-block; - width: 250px; + display: inline-block; + width: 250px; } #detailsAccount, #detailsPlayer, #detailsNotes, #detailsBrowser, #pccNotes { - padding: 5px; + padding: 5px; } #profileNotes, #pccNotesText { - width: 100%; - height: 200px; + width: 100%; + height: 200px; } #detailsAccount label, #detailsPlayer label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 350px; - text-align: right; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 350px; + text-align: right; } #detailsAccount label input, #detailsPlayer label input { - margin-left: 5px; - width: 200px; + margin-left: 5px; + width: 200px; } ul.statsList label { - font-weight: bold; - padding-right: 5px; + font-weight: bold; + padding-right: 5px; } ul.statsSubList, ul.statsSubList ul { - padding-left: 40px; + padding-left: 40px; } .statsSubHeader { - cursor: pointer; - text-decoration: underline; + cursor: pointer; + text-decoration: underline; } #statsTabs .yui-dt { - color: black; + color: black; } /*#statsEmpireTable, #statsColonyTable, #statsSpyTable { color:black; @@ -1962,152 +1962,151 @@ ul.statsSubList ul { .missionList, .inlineList { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - vertical-align: top; - margin-left: 20px; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + vertical-align: top; + margin-left: 20px; } .missionList li, .inlineList li { - list-style: square outside none; - font-size: 85%; - float: none; + list-style: square outside none; + font-size: 85%; + float: none; } .mission { - border-bottom: 1px solid #52acff; - padding-bottom: 5px; - margin-bottom: 2px; + border-bottom: 1px solid #52acff; + padding-bottom: 5px; + margin-bottom: 2px; } .missionName { - font-weight: bold; - font-size: 115%; + font-weight: bold; + font-size: 115%; } .missionDesc { - padding: 5px; + padding: 5px; } #lojDetails li label { - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - width: 130px; - font-weight: bold; + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + width: 130px; + font-weight: bold; } /* TextboxList */ .TextboxList { - position: relative; - font-size: inherit; - font-family: inherit; - width: 100%; - display: -moz-inline-stack; /*mozilla 2.0*/ - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + position: relative; + font-size: inherit; + font-family: inherit; + width: 100%; + display: -moz-inline-stack; /*mozilla 2.0*/ + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } .TextboxListContainer { - border: 1px solid #999999; - cursor: text; - width: 100%; - display: -moz-inline-stack; /*mozilla 2.0*/ - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + border: 1px solid #999999; + cursor: text; + width: 100%; + display: -moz-inline-stack; /*mozilla 2.0*/ + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } .TextboxListDisabled { - background-color: #ddd; - cursor: default; + background-color: #ddd; + cursor: default; } .TextboxListDisabled .TextboxListBitBoxDelete { - cursor: default; + cursor: default; } .TextboxList .TextboxListBit { - cursor: default; - display: block; - float: left; - list-style-type: none; - line-height: 18px; - margin: 0 5px 0 0; - padding: 0 0 0 2px; - min-width: 5px; /* override any other min-width settings */ + cursor: default; + display: block; + float: left; + list-style-type: none; + line-height: 18px; + margin: 0 5px 0 0; + padding: 0 0 0 2px; + min-width: 5px; /* override any other min-width settings */ } .TextboxList .TextboxListBitBox { - background: #52acff none repeat scroll 0 0; - border: 1px solid #cad8f3; - position: relative; - font-size: 85%; - padding: 0 15px 0 2px; + background: #52acff none repeat scroll 0 0; + border: 1px solid #cad8f3; + position: relative; + font-size: 85%; + padding: 0 15px 0 2px; } .TextboxList .TextboxListBitBoxDelete { - background: transparent url(/Lacuna-Assets/ui/crosssmall.gif) repeat scroll 0 0; - display: block; - font-size: 1px; - height: 7px; - position: absolute; - right: 4px; - top: 6px; - width: 7px; + background: transparent url(/Lacuna-Assets/ui/crosssmall.gif) repeat scroll 0 0; + display: block; + font-size: 1px; + height: 7px; + position: absolute; + right: 4px; + top: 6px; + width: 7px; } .TextboxList .TextboxListContainer ul.TextboxListBits { - position: static; - vertical-align: top; + position: static; + vertical-align: top; } /* width:15em; */ .TextboxList .TextboxListIndicator img { - height: 14px; - width: 14px; + height: 14px; + width: 14px; } .TextboxList .TextboxListIndicatorSingle { - position: absolute; - top: 2px; - left: 2px; + position: absolute; + top: 2px; + left: 2px; } .yui-skin-sam .TextboxList .TextboxListInput { - border: 0 none; - position: static; - width: 1px; + border: 0 none; + position: static; + width: 1px; } .yui-skin-sam .TextboxList .TextboxListInputSingle { - position: static; /*width:10em;*/ + position: static; /*width:10em;*/ } /*.yui-skin-sam .TextboxList .TextboxListAutoComplete { width:10em; }*/ .yui-skin-sam .TextboxList .TextboxListAutoComplete .yui-ac-content { - overflow-y: scroll; - height: 100px; - text-align: left; - background-color: #52acff; + overflow-y: scroll; + height: 100px; + text-align: left; + background-color: #52acff; } .yui-skin-sam .yui-dt-editor .TextboxList .TextboxListAutoComplete { - width: 10em; + width: 10em; } .yui-skin-sam .yui-dt-editor .TextboxList .TextboxListAutoComplete .yui-ac-content { - text-align: left; + text-align: left; } .TextboxListIcon { - cursor: default; - height: 15px; - width: 17px; - right: 1px; - top: 1px; - #top: 2px; - position: absolute; - background: transparent url(/Lacuna-Assets/ui/dropdown.gif) repeat scroll 0 0; - z-index: 2; - display: -moz-inline-stack; /*mozilla 2.0*/ - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ + cursor: default; + height: 15px; + width: 17px; + right: 1px; + top: 1px; + position: absolute; + background: transparent url(/Lacuna-Assets/ui/dropdown.gif) repeat scroll 0 0; + z-index: 2; + display: -moz-inline-stack; /*mozilla 2.0*/ + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ } .TextboxListColumn { - display: -moz-inline-stack; /*mozilla 2.0*/ - display: inline-block; /*mozilla 3.0, ie 8*/ - zoom: 1; /*force ie layout so we can use the display:inline below*/ - *display: inline; /*ie hack to make it think this is an inline-block*/ - overflow: hidden; + display: -moz-inline-stack; /*mozilla 2.0*/ + display: inline-block; /*mozilla 3.0, ie 8*/ + zoom: 1; /*force ie layout so we can use the display:inline below*/ + *display: inline; /*ie hack to make it think this is an inline-block*/ + overflow: hidden; } diff --git a/app/game.tsx b/app/game.tsx index 5097bc36..901111fe 100644 --- a/app/game.tsx +++ b/app/game.tsx @@ -18,598 +18,592 @@ import server from 'app/server'; import resources from 'app/json/resources'; if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { - (function () { - let Util = YAHOO.util; - let Lang = YAHOO.lang; - let Cookie = Util.Cookie; - let Dom = Util.Dom; - let Event = Util.Event; - let Lacuna = YAHOO.lacuna; - let Lib = Lacuna.Library; - - let Game = { - Resources: resources, - Services: {}, - Timeout: 60000, - HourMS: 3600000, // (60min * 60sec * 1000ms), - onTick: new Util.CustomEvent('onTick'), - OverlayManager: new YAHOO.widget.OverlayManager(), - domain: window.location.hostname || 'kenoantigen.com', - _session: undefined, - _hasRun: false, - - Start: function (query: any = {}) { - let body = document.getElementById('body'); - if (!body) return; - - // Give the React stuff somewhere to go. - let container = document.createElement('div'); - container.id = 'mainGameContainer'; - body.appendChild(container); - - ReactDOM.render(, document.getElementById('mainGameContainer')); - - MenuStore.showLoader(); - - Game.escListener = new Util.KeyListener( - document, - { - keys: 27, - }, - { - fn: function () { - Game.OverlayManager.hideAll(); - WindowsStore.onEscKey(); - }, - scope: Game.OverlayManager, - correctScope: true, - } - ); - - Game.Services = Game.InitServices(YAHOO.lacuna.SMD.Services); - - // The tooltips can often disappear because their parent elements are removed from the - // DOM and then replaced later. For example, switching between tabs that each have - // tooltips in them. Calling this every tick ensures that the tooltips are rebuilt if - // they disappear. - // - // TODO fix this - // - // TickerActions.tickerTick.listen(function() { - // ReactTooltip.rebuild(); - // }); - - let session = Game.GetSession(); - if (query.referral) { - // if they came from somewhere else - let now = new Date(); - Cookie.set('lacunaReferral', query.referral, { - domain: Game.domain, - expires: new Date(now.setFullYear(now.getFullYear() + 1)), - }); - } - if (query.reset_password) { - Game.InitLogin(); - Game.LoginDialog.resetPassword(query.reset_password); - return; - } - if (query.facebook_uid) { - Game.InitLogin(); - Game.LoginDialog.initEmpireCreator(); - Game.EmpireCreator.facebookReturn( - query.facebook_uid, - query.facebook_token, - query.facebook_name - ); - return; - } else if (query.session_id) { - Game.SetSession(query.session_id); - SessionStore.update(query.session_id); - } else if (query.empire_id) { - Game.InitLogin(); - Game.LoginDialog.initEmpireCreator(); - Game.SpeciesCreator.show(query.empire_id); - return; - } else if (!session) { - Game.DoLogin(); - return; - } - - SessionStore.update(session); - - server.call({ - module: 'empire', - method: 'get_status', - success: () => { - Game.Run(); - }, - error: () => { - Game.Reset(); - Game.DoLogin(); - }, - }); - }, - Failure: function (o: any, retry: any, fail: any) { - // session expired - if (o.error.code === 1006) { - Game.Reset(); - Game.DoLogin(o.error); - } else if (o.error.code === 1200) { - // Game over - window.alert(o.error.message); - Game.Reset(); - window.location = o.error.data; - } else if (o.error.code === 1016) { - // Captcha - window.alert('Captcha not implemeneted'); - // WindowActions.windowAdd(Captcha, 'captcha', { - // success: retry, - // }); - } else if (o.error.code === -32603) { - // Internal error - Game.QuickDialog( - { - width: '500px', - text: [ - '

An internal error has occurred. Please report this on the support forums, and include the data below.

', - '', - ].join(''), - buttons: [ - { - text: 'Close', - handler: function () { - this.hide(); - }, - }, - ], - }, - function () { - Dom.get('internalErrorMessageText').value = o.error.data; - } - ); - } else { - fail(); - } - }, - InitLogin: function () { - if (!Lacuna.Game.LoginDialog) { - console.log('Creating login dialog'); - Lacuna.Game.LoginDialog = new Lacuna.Login(); - Lacuna.Game.LoginDialog.subscribe('onLoginSuccessful', function (oArgs: any) { - let result = oArgs.result; - // remember session - Game.SetSession(result.session_id); - - Game.RemoveCookie('locationId'); - Game.RemoveCookie('locationView'); - - Lacuna.Game.Run(); - - if (result.welcome_message_id) { - Game.QuickDialog({ - width: '400px', - text: [ - 'Welcome to the Lacuna Expanse. It is recommended that you play through the in game tutorial to familiarize yourself with the game, and to get some free resources to build up your empire.', - '

If you choose to skip the tutorial now you may find it by clicking at the top of the interface and find the message with the subject `Welcome`.

', - '

Thanks for playing!

', - ].join(''), - buttons: [ - { - text: 'View Tutorial', - handler: function () { - this.hide(); - Lacuna.Messaging.showMessage(result.welcome_message_id); - }, - isDefault: true, - }, - { - text: 'Skip Tutorial', - handler: function () { - this.hide(); - }, - }, - ], - }); - } - }); - } - }, - DoLogin: function (error?: any) { - Dom.setStyle( - document.body, - 'background', - 'url(' + Lib.AssetUrl + 'star_system/field.png) repeat scroll 0 0 black' - ); - this.InitLogin(); - Lacuna.Game.LoginDialog.show(error); - MenuStore.hideMenu(); - MenuStore.hideLoader(); - }, - Run: function () { - // init event subscribtions if we need to - Game.InitEvents(); - // enable esc handler - Game.escListener.enable(); - - document.title = 'KA - ' + EmpireRPCStore.name; - - SessionStore.update(Game.GetSession('')); - MenuStore.showMenu(); - - console.log('Starting the ticker'); - TickerStore.start(); - - console.log('Firing up the planet view'); - MenuStore.changePlanet(EmpireRPCStore.home_planet_id); - }, - InitEvents: function () { - // make sure we only subscribe once - if (!Lacuna.Game._hasRun) { - Game._hasRun = true; - - Event.on(window, 'resize', function () { - // taken from YUI Overlay - if (YAHOO.env.ua.ie) { - if (!window.resizeEnd) { - window.resizeEnd = -1; - } - - clearTimeout(window.resizeEnd); - - window.resizeEnd = setTimeout(function () { - Lacuna.Game.Resize(); - }, 100); - } else { - Lacuna.Game.Resize(); - } - }); - } - }, - InitServices: function (smd) { - let serviceOut = {}; - for (let sKey in smd) { - if (smd.hasOwnProperty(sKey)) { - let oSmd = smd[sKey]; - if (oSmd.services) { - serviceOut[sKey] = new YAHOO.rpc.Service( - oSmd, - { - success: function () { - for (let methodName in this) { - if ( - this.hasOwnProperty(methodName) && - Lang.isFunction(this[methodName]) - ) { - let method = this[methodName]; - this[methodName] = Game.WrappedService( - method, - sKey + '.' + methodName - ); - } - } - }, - }, - constants.RPC_BASE - ); - } else { - serviceOut[sKey] = Game.InitServices(oSmd); - } - } - } - return serviceOut; - }, - WrappedService: function (method: Function, name: string) { - let logNS = 'Game.RPC.' + name + '.failure'; - let func = function (params: any, origOpts: any) { - let retry = function () { - let opts = { retry: 0 }; - YAHOO.lang.augmentObject(opts, origOpts, true); - opts.retry++; - func(params, opts); - }; - let opts = { - failure: function (o) { - let self = this; - let failure = function (silent: boolean) { - if (Lang.isFunction(origOpts.failure)) { - if (origOpts.failure.call(self, o)) { - return; - } - } - if (!silent) { - window.alert(o.error.message); - } - }; - YAHOO.log(o, 'error', logNS); - MenuStore.hideLoader(); - Game.Failure(o, retry, failure); - }, - }; - YAHOO.lang.augmentObject(opts, origOpts); - if (!('timeout' in opts)) { - opts.timeout = Game.Timeout; - } - method(params, opts); - }; - return func; - }, - QuickDialog: function (config: any, afterRender?: Function, afterHide?: Function) { - let container = document.createElement('div'); - if (config.id) { - container.id = config.id; - delete config.id; - } - YAHOO.lang.augmentObject(config, { - fixedcenter: true, - visible: false, - draggable: false, - constraintoviewport: true, - modal: true, - close: false, - zindex: 20000, - }); - Dom.addClass(container, 'quick-dialog'); - document.body.insertBefore(container, document.body.firstChild); - let dialog = new YAHOO.widget.SimpleDialog(container, config); - dialog.renderEvent.subscribe(function () { - if (afterRender) { - afterRender.call(this); - } - this.show(); - }); - dialog.hideEvent.subscribe(function () { - if (afterHide) { - afterHide.call(this); - } - // let the current process complete before destroying - setTimeout(function () { - dialog.destroy(); - }, 1); - }); - dialog.render(); - Game.OverlayManager.register(dialog); - }, - - GetSession: function (replace: string = '') { - if (!this._session) { - this._session = Game.GetCookie('session'); - } - return this._session || replace; - }, - SetSession: function (session: string) { - if (session) { - Game.SetCookie('session', session); - Game._session = session; - } else { - Game.RemoveCookie('session'); - Game._session = undefined; - } + (function () { + let Util = YAHOO.util; + let Lang = YAHOO.lang; + let Cookie = Util.Cookie; + let Dom = Util.Dom; + let Event = Util.Event; + let Lacuna = YAHOO.lacuna; + let Lib = Lacuna.Library; + + let Game = { + Resources: resources, + Services: {}, + Timeout: 60000, + HourMS: 3600000, // (60min * 60sec * 1000ms), + onTick: new Util.CustomEvent('onTick'), + OverlayManager: new YAHOO.widget.OverlayManager(), + domain: window.location.hostname || 'kenoantigen.com', + _session: undefined, + _hasRun: false, + + Start: function (query: any = {}) { + let body = document.getElementById('body'); + if (!body) return; + + // Give the React stuff somewhere to go. + let container = document.createElement('div'); + container.id = 'mainGameContainer'; + body.appendChild(container); + + ReactDOM.render(, document.getElementById('mainGameContainer')); + + MenuStore.showLoader(); + + Game.escListener = new Util.KeyListener( + document, + { + keys: 27, + }, + { + fn: function () { + Game.OverlayManager.hideAll(); + WindowsStore.onEscKey(); }, - GetSize: function () { - let content = document.getElementById('content'); - let width = content.offsetWidth; - let height = document.documentElement.clientHeight; - - return { - w: width, - h: height, - }; - }, - Resize: function () { - if (Lacuna.MapStar.IsVisible()) { - Lacuna.MapStar.Resize(); - } else if (Lacuna.MapPlanet.IsVisible()) { - Lacuna.MapPlanet.Resize(); - } - }, - StarJump: function (star: any) { - YAHOO.log(star, 'debug', 'StarJump'); - Game.OverlayManager.hideAll(); - MenuStore.showStarMap(); - // Lacuna.MapPlanet.MapVisible(false); - // Lacuna.MapStar.MapVisible(true); - Lacuna.MapStar.Jump(star.x * 1, star.y * 1); - }, - GetBuildingDesc: function (url: string) { - if (Game.Resources && Game.Resources.buildings) { - let desc = Game.Resources.buildings[url]; - if (desc) { - return [ - desc.description, - ' More Information on Wiki', - ].join(''); - } else { - return ''; - } - } + scope: Game.OverlayManager, + correctScope: true, + } + ); + + Game.Services = Game.InitServices(YAHOO.lacuna.SMD.Services); + + // The tooltips can often disappear because their parent elements are removed from the + // DOM and then replaced later. For example, switching between tabs that each have + // tooltips in them. Calling this every tick ensures that the tooltips are rebuilt if + // they disappear. + // + // TODO fix this + // + // TickerActions.tickerTick.listen(function() { + // ReactTooltip.rebuild(); + // }); + + let session = Game.GetSession(); + if (query.referral) { + // if they came from somewhere else + let now = new Date(); + Cookie.set('lacunaReferral', query.referral, { + domain: Game.domain, + expires: new Date(now.setFullYear(now.getFullYear() + 1)), + }); + } + if (query.reset_password) { + Game.InitLogin(); + Game.LoginDialog.resetPassword(query.reset_password); + return; + } + if (query.facebook_uid) { + Game.InitLogin(); + Game.LoginDialog.initEmpireCreator(); + Game.EmpireCreator.facebookReturn( + query.facebook_uid, + query.facebook_token, + query.facebook_name + ); + return; + } else if (query.session_id) { + Game.SetSession(query.session_id); + SessionStore.update(query.session_id); + } else if (query.empire_id) { + Game.InitLogin(); + Game.LoginDialog.initEmpireCreator(); + Game.SpeciesCreator.show(query.empire_id); + return; + } else if (!session) { + Game.DoLogin(); + return; + } + + SessionStore.update(session); + + server.call({ + module: 'empire', + method: 'get_status', + success: () => { + Game.Run(); + }, + error: () => { + Game.Reset(); + Game.DoLogin(); + }, + }); + }, + Failure: function (o: any, retry: any, fail: any) { + // session expired + if (o.error.code === 1006) { + Game.Reset(); + Game.DoLogin(o.error); + } else if (o.error.code === 1200) { + // Game over + window.alert(o.error.message); + Game.Reset(); + window.location = o.error.data; + } else if (o.error.code === 1016) { + // Captcha + window.alert('Captcha not implemeneted'); + // WindowActions.windowAdd(Captcha, 'captcha', { + // success: retry, + // }); + } else if (o.error.code === -32603) { + // Internal error + Game.QuickDialog( + { + width: '500px', + text: [ + '

An internal error has occurred. Please report this on the support forums, and include the data below.

', + '', + ].join(''), + buttons: [ + { + text: 'Close', + handler: function () { + this.hide(); + }, + }, + ], }, - GetShipDesc: function (type: string) { - if (Game.Resources && Game.Resources.ships) { - let desc = Game.Resources.ships[type]; - if (desc) { - return [ - desc.description, - ' More Information on Wiki', - ].join(''); + function () { + Dom.get('internalErrorMessageText').value = o.error.data; + } + ); + } else { + fail(); + } + }, + InitLogin: function () { + if (!Lacuna.Game.LoginDialog) { + console.log('Creating login dialog'); + Lacuna.Game.LoginDialog = new Lacuna.Login(); + Lacuna.Game.LoginDialog.subscribe('onLoginSuccessful', function (oArgs: any) { + let result = oArgs.result; + // remember session + Game.SetSession(result.session_id); + + Game.RemoveCookie('locationId'); + Game.RemoveCookie('locationView'); + + Lacuna.Game.Run(); + + if (result.welcome_message_id) { + Game.QuickDialog({ + width: '400px', + text: [ + 'Welcome to the Lacuna Expanse. It is recommended that you play through the in game tutorial to familiarize yourself with the game, and to get some free resources to build up your empire.', + '

If you choose to skip the tutorial now you may find it by clicking at the top of the interface and find the message with the subject `Welcome`.

', + '

Thanks for playing!

', + ].join(''), + buttons: [ + { + text: 'View Tutorial', + handler: function () { + this.hide(); + Lacuna.Messaging.showMessage(result.welcome_message_id); + }, + isDefault: true, + }, + { + text: 'Skip Tutorial', + handler: function () { + this.hide(); + }, + }, + ], + }); + } + }); + } + }, + DoLogin: function (error?: any) { + Dom.setStyle( + document.body, + 'background', + 'url(' + Lib.AssetUrl + 'star_system/field.png) repeat scroll 0 0 black' + ); + this.InitLogin(); + Lacuna.Game.LoginDialog.show(error); + MenuStore.hideMenu(); + MenuStore.hideLoader(); + }, + Run: function () { + // init event subscribtions if we need to + Game.InitEvents(); + // enable esc handler + Game.escListener.enable(); + + document.title = 'KA - ' + EmpireRPCStore.name; + + SessionStore.update(Game.GetSession('')); + MenuStore.showMenu(); + + console.log('Starting the ticker'); + TickerStore.start(); + + console.log('Firing up the planet view'); + MenuStore.changePlanet(EmpireRPCStore.home_planet_id); + }, + InitEvents: function () { + // make sure we only subscribe once + if (!Lacuna.Game._hasRun) { + Game._hasRun = true; + + Event.on(window, 'resize', function () { + // taken from YUI Overlay + if (YAHOO.env.ua.ie) { + if (!window.resizeEnd) { + window.resizeEnd = -1; + } + + clearTimeout(window.resizeEnd); + + window.resizeEnd = setTimeout(function () { + Lacuna.Game.Resize(); + }, 100); + } else { + Lacuna.Game.Resize(); + } + }); + } + }, + InitServices: function (smd) { + let serviceOut = {}; + for (let sKey in smd) { + if (smd.hasOwnProperty(sKey)) { + let oSmd = smd[sKey]; + if (oSmd.services) { + serviceOut[sKey] = new YAHOO.rpc.Service( + oSmd, + { + success: function () { + for (let methodName in this) { + if (this.hasOwnProperty(methodName) && Lang.isFunction(this[methodName])) { + let method = this[methodName]; + this[methodName] = Game.WrappedService(method, sKey + '.' + methodName); + } } - } - }, - GetContainerEffect: function (effect: any) { - if (Game.GetCookieSettings('disableDialogAnim', '0') === '1') { + }, + }, + constants.RPC_BASE + ); + } else { + serviceOut[sKey] = Game.InitServices(oSmd); + } + } + } + return serviceOut; + }, + WrappedService: function (method: Function, name: string) { + let logNS = 'Game.RPC.' + name + '.failure'; + let func = function (params: any, origOpts: any) { + let retry = function () { + let opts = { retry: 0 }; + YAHOO.lang.augmentObject(opts, origOpts, true); + opts.retry++; + func(params, opts); + }; + let opts = { + failure: function (o) { + let self = this; + let failure = function (silent: boolean) { + if (Lang.isFunction(origOpts.failure)) { + if (origOpts.failure.call(self, o)) { return; - } else { - return ( - effect || { - effect: YAHOO.widget.ContainerEffect.FADE, - duration: 0.5, - } - ); + } } - }, - - Reset: function () { - // disable esc handler - Game.escListener.disable(); - - document.title = 'Kenó Antigen'; - Game.RemoveCookie('locationId'); - Game.RemoveCookie('locationView'); - - Game.SetSession(''); - Lacuna.MapStar.Reset(); - Lacuna.MapPlanet.Reset(); - Lacuna.Notify.Hide(); - Lacuna.Notify.Destroy(); - }, - - // Cookie helpers functions - GetCookie: function (key: string, defaultValue?: any) { - let chip = Cookie.getSub('lacuna', key); - return chip || defaultValue; - }, - SetCookie: function (key: string, value: any, expiresDate?: any) { - let opts = { - domain: Game.domain, - }; - - if (expiresDate) { - opts.expires = expiresDate; + if (!silent) { + window.alert(o.error.message); } - - Cookie.setSub('lacuna', key, value, opts); - }, - RemoveCookie: function (key: string) { - Cookie.removeSub('lacuna', key, { - domain: Game.domain, - }); - }, - RemoveAllCookies: function () { - Cookie.remove('lacuna', { - domain: Game.domain, - }); - }, - - // using a more permanent cookie - GetCookieSettings: function (key: string, defaultValue: any) { - let chip = Cookie.getSub('lacunaSettings', key); - return chip || defaultValue; - }, - SetCookieSettings: function (key: string, value: any) { - let now = new Date(); - let opts = { - domain: Game.domain, - expires: new Date(now.setFullYear(now.getFullYear() + 1)), - }; - - Cookie.setSub('lacunaSettings', key, value, opts); + }; + YAHOO.log(o, 'error', logNS); + MenuStore.hideLoader(); + Game.Failure(o, retry, failure); }, - RemoveCookieSettings: function (key: string) { - Cookie.removeSub('lacunaSettings', key, { - domain: Game.domain, - }); - }, - - onScroll: (function () { - let pixelsPerLine = 10; - let ua = navigator.userAgent; - let safari5 = ua.match(/\bSafari\//) && ua.match(/\bVersion\/5/); - let isEventSupported = (function () { - interface tagnames { - [index: string]: string; - } - let TAGNAMES: tagnames = { - select: 'input', - change: 'input', - submit: 'form', - reset: 'form', - error: 'img', - load: 'img', - abort: 'img', - }; - let cache = {}; - function isEventSupported(eventName: string) { - let el = document.createElement(TAGNAMES[eventName] || 'div'); - eventName = 'on' + eventName; - if (eventName in cache) { - return cache[eventName]; - } - let isSupported = eventName in el; - if (!isSupported) { - el.setAttribute(eventName, 'return;'); - isSupported = typeof el[eventName] === 'function'; - } - cache[eventName] = isSupported; - el = null; - return isSupported; - } - return isEventSupported; - })(); - - if (isEventSupported('mousewheel')) { - return function (el: any, fn: any, obj: any, context: any) { - Event.on( - el, - 'mousewheel', - function (e: any, o: any) { - let xDelta = 'wheelDeltaX' in e ? e.wheelDeltaX : 0; - let yDelta = 'wheelDeltaY' in e ? e.wheelDeltaY : e.wheelDelta; - // chrome/safari 4 give pixels - // safari 5 gives pixels * 120 - if (safari5) { - xDelta /= 120; - yDelta /= 120; - } - fn.call(this, e, xDelta, yDelta, o); - }, - obj, - context - ); - }; - } else if (YAHOO.env.ua.gecko >= 1.9 && !ua.match(/\brv:1\.9\.0/)) { - // not possible to feature detect this, have to just use the version number - return function (el: any, fn: any, obj: any, context: any) { - Event.on( - el, - 'MozMousePixelScroll', - function (e: any, o: any) { - let xAxis = e.axis === e.HORIZONTAL_AXIS; - let xDelta = xAxis ? -e.detail : 0; - let yDelta = xAxis ? 0 : -e.detail; - fn.call(this, e, xDelta, yDelta, o); - }, - obj, - context - ); - }; - } else { - return function (el: any, fn: any, obj: any, context: any) { - Event.on( - el, - 'DOMMouseScroll', - function (e: any, o: any) { - let xAxis = 'axis' in e && e.axis === e.HORIZONTAL_AXIS; - // this event gets 'lines' - let xDelta = xAxis ? -e.detail * pixelsPerLine : 0; - let yDelta = xAxis ? 0 : -e.detail * pixelsPerLine; - fn.call(this, e, xDelta, yDelta, o); - }, - obj, - context - ); - }; - } - })(), + }; + YAHOO.lang.augmentObject(opts, origOpts); + if (!('timeout' in opts)) { + opts.timeout = Game.Timeout; + } + method(params, opts); + }; + return func; + }, + QuickDialog: function (config: any, afterRender?: Function, afterHide?: Function) { + let container = document.createElement('div'); + if (config.id) { + container.id = config.id; + delete config.id; + } + YAHOO.lang.augmentObject(config, { + fixedcenter: true, + visible: false, + draggable: false, + constraintoviewport: true, + modal: true, + close: false, + zindex: 20000, + }); + Dom.addClass(container, 'quick-dialog'); + document.body.insertBefore(container, document.body.firstChild); + let dialog = new YAHOO.widget.SimpleDialog(container, config); + dialog.renderEvent.subscribe(function () { + if (afterRender) { + afterRender.call(this); + } + this.show(); + }); + dialog.hideEvent.subscribe(function () { + if (afterHide) { + afterHide.call(this); + } + // let the current process complete before destroying + setTimeout(function () { + dialog.destroy(); + }, 1); + }); + dialog.render(); + Game.OverlayManager.register(dialog); + }, + + GetSession: function (replace: string = '') { + if (!this._session) { + this._session = Game.GetCookie('session'); + } + return this._session || replace; + }, + SetSession: function (session: string) { + if (session) { + Game.SetCookie('session', session); + Game._session = session; + } else { + Game.RemoveCookie('session'); + Game._session = undefined; + } + }, + GetSize: function () { + let content = document.getElementById('content'); + let width = content.offsetWidth; + let height = document.documentElement.clientHeight; + + return { + w: width, + h: height, + }; + }, + Resize: function () { + if (Lacuna.MapStar.IsVisible()) { + Lacuna.MapStar.Resize(); + } else if (Lacuna.MapPlanet.IsVisible()) { + Lacuna.MapPlanet.Resize(); + } + }, + StarJump: function (star: any) { + YAHOO.log(star, 'debug', 'StarJump'); + Game.OverlayManager.hideAll(); + MenuStore.showStarMap(); + // Lacuna.MapPlanet.MapVisible(false); + // Lacuna.MapStar.MapVisible(true); + Lacuna.MapStar.Jump(star.x * 1, star.y * 1); + }, + GetBuildingDesc: function (url: string) { + if (Game.Resources && Game.Resources.buildings) { + let desc = Game.Resources.buildings[url]; + if (desc) { + return [ + desc.description, + ' More Information on Wiki', + ].join(''); + } else { + return ''; + } + } + }, + GetShipDesc: function (type: string) { + if (Game.Resources && Game.Resources.ships) { + let desc = Game.Resources.ships[type]; + if (desc) { + return [ + desc.description, + ' More Information on Wiki', + ].join(''); + } + } + }, + GetContainerEffect: function (effect: any) { + if (Game.GetCookieSettings('disableDialogAnim', '0') === '1') { + return; + } else { + return ( + effect || { + effect: YAHOO.widget.ContainerEffect.FADE, + duration: 0.5, + } + ); + } + }, + + Reset: function () { + // disable esc handler + Game.escListener.disable(); + + document.title = 'Kenó Antigen'; + Game.RemoveCookie('locationId'); + Game.RemoveCookie('locationView'); + + Game.SetSession(''); + Lacuna.MapStar.Reset(); + Lacuna.MapPlanet.Reset(); + Lacuna.Notify.Hide(); + Lacuna.Notify.Destroy(); + }, + + // Cookie helpers functions + GetCookie: function (key: string, defaultValue?: any) { + let chip = Cookie.getSub('lacuna', key); + return chip || defaultValue; + }, + SetCookie: function (key: string, value: any, expiresDate?: any) { + let opts = { + domain: Game.domain, }; - YAHOO.lacuna.Game = Game; - })(); + if (expiresDate) { + opts.expires = expiresDate; + } + + Cookie.setSub('lacuna', key, value, opts); + }, + RemoveCookie: function (key: string) { + Cookie.removeSub('lacuna', key, { + domain: Game.domain, + }); + }, + RemoveAllCookies: function () { + Cookie.remove('lacuna', { + domain: Game.domain, + }); + }, + + // using a more permanent cookie + GetCookieSettings: function (key: string, defaultValue: any) { + let chip = Cookie.getSub('lacunaSettings', key); + return chip || defaultValue; + }, + SetCookieSettings: function (key: string, value: any) { + let now = new Date(); + let opts = { + domain: Game.domain, + expires: new Date(now.setFullYear(now.getFullYear() + 1)), + }; - YAHOO.register('game', YAHOO.lacuna.Game, { - version: '1', - build: '0', - }); + Cookie.setSub('lacunaSettings', key, value, opts); + }, + RemoveCookieSettings: function (key: string) { + Cookie.removeSub('lacunaSettings', key, { + domain: Game.domain, + }); + }, + + onScroll: (function () { + let pixelsPerLine = 10; + let ua = navigator.userAgent; + let safari5 = ua.match(/\bSafari\//) && ua.match(/\bVersion\/5/); + let isEventSupported = (function () { + interface tagnames { + [index: string]: string; + } + let TAGNAMES: tagnames = { + select: 'input', + change: 'input', + submit: 'form', + reset: 'form', + error: 'img', + load: 'img', + abort: 'img', + }; + let cache = {}; + function isEventSupported(eventName: string) { + let el = document.createElement(TAGNAMES[eventName] || 'div'); + eventName = 'on' + eventName; + if (eventName in cache) { + return cache[eventName]; + } + let isSupported = eventName in el; + if (!isSupported) { + el.setAttribute(eventName, 'return;'); + isSupported = typeof el[eventName] === 'function'; + } + cache[eventName] = isSupported; + el = null; + return isSupported; + } + return isEventSupported; + })(); + + if (isEventSupported('mousewheel')) { + return function (el: any, fn: any, obj: any, context: any) { + Event.on( + el, + 'mousewheel', + function (e: any, o: any) { + let xDelta = 'wheelDeltaX' in e ? e.wheelDeltaX : 0; + let yDelta = 'wheelDeltaY' in e ? e.wheelDeltaY : e.wheelDelta; + // chrome/safari 4 give pixels + // safari 5 gives pixels * 120 + if (safari5) { + xDelta /= 120; + yDelta /= 120; + } + fn.call(this, e, xDelta, yDelta, o); + }, + obj, + context + ); + }; + } else if (YAHOO.env.ua.gecko >= 1.9 && !ua.match(/\brv:1\.9\.0/)) { + // not possible to feature detect this, have to just use the version number + return function (el: any, fn: any, obj: any, context: any) { + Event.on( + el, + 'MozMousePixelScroll', + function (e: any, o: any) { + let xAxis = e.axis === e.HORIZONTAL_AXIS; + let xDelta = xAxis ? -e.detail : 0; + let yDelta = xAxis ? 0 : -e.detail; + fn.call(this, e, xDelta, yDelta, o); + }, + obj, + context + ); + }; + } else { + return function (el: any, fn: any, obj: any, context: any) { + Event.on( + el, + 'DOMMouseScroll', + function (e: any, o: any) { + let xAxis = 'axis' in e && e.axis === e.HORIZONTAL_AXIS; + // this event gets 'lines' + let xDelta = xAxis ? -e.detail * pixelsPerLine : 0; + let yDelta = xAxis ? 0 : -e.detail * pixelsPerLine; + fn.call(this, e, xDelta, yDelta, o); + }, + obj, + context + ); + }; + } + })(), + }; + + YAHOO.lacuna.Game = Game; + })(); + + YAHOO.register('game', YAHOO.lacuna.Game, { + version: '1', + build: '0', + }); } diff --git a/app/interfaces.ts b/app/interfaces.ts index 1850d9c7..f6b405d4 100644 --- a/app/interfaces.ts +++ b/app/interfaces.ts @@ -1,33 +1,34 @@ import React from 'react'; export interface Window { - type: WindowType; - index: number, - zIndex: number, - options: WindowOptions, + type: WindowType; + index: number; + zIndex: number; + options: WindowOptions; } export interface WindowOptions { - id?: number | string; - url?: string; + id?: number | string; + url?: string; } export interface WindowConfig { - title: string; - width: number; - height: number | 'auto'; + title: string; + width: number; + height: number | 'auto'; } export interface WindowDefinition { - component: React.ReactNode, - config: WindowConfig, + component: React.ReactNode; + config: WindowConfig; } -export type WindowType = 'about' | - 'captcha' | - 'essentia' | - 'genericBuilding' | - 'invite' | - 'planetPanel' | - 'serverClock' | - 'starPanel'; +export type WindowType = + | 'about' + | 'captcha' + | 'essentia' + | 'genericBuilding' + | 'invite' + | 'planetPanel' + | 'serverClock' + | 'starPanel'; diff --git a/app/json/resources.json b/app/json/resources.json index 57684a0c..489c39d7 100644 --- a/app/json/resources.json +++ b/app/json/resources.json @@ -1,914 +1,914 @@ { - "buildings": { - "/operahouse": { - "description": "A source of cultural influence for your space station.", - "wiki": "http://community.lacunaexpanse.com/wiki/opera-house" - }, - "/artmuseum": { - "description": "A source of cultural influence for your space station.", - "wiki": "http://community.lacunaexpanse.com/wiki/art-museum" - }, - "/culinaryinstitute": { - "description": "A source of cultural influence for your space station.", - "wiki": "http://community.lacunaexpanse.com/wiki/culinary-institute" - }, - "/stationcommand": { - "description": "The internal operations of a space station. Controls how big the station can be expanded.", - "wiki": "http://community.lacunaexpanse.com/wiki/station-command-center" - }, - "/parliament": { - "description": "The central government for the star systems that are controlled by a space station. Laws for the jurisdiction are made here.", - "wiki": "http://community.lacunaexpanse.com/wiki/parliament" - }, - "/policestation": { - "description": "The police station manages security on a Space Station. It can help defend the Station against spies as well as detect incoming ships.", - "wiki": "http://community.lacunaexpanse.com/wiki/police-station" - }, - "/warehouse": { - "description": "Resource storage for a space station.", - "wiki": "http://community.lacunaexpanse.com/wiki/warehouse" - }, - "/ibs": { - "description": "A means of spreading the culture and influence of a space station's government.", - "wiki": "http://community.lacunaexpanse.com/wiki/interstellar-broadcast-system" - }, - "/ssla": { - "description": "Allows the construction of Space Station Lab modules. Requires four plots, and this is the top left corner of the building.", - "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" - }, - "/sslb": { - "description": "Infrastructure required to support Space Station Lab (A).", - "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" - }, - "/sslc": { - "description": "Infrastructure required to support Space Station Lab (A).", - "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" - }, - "/ssld": { - "description": "Infrastructure required to support Space Station Lab (A).", - "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" - }, - "/distributioncenter": { - "description": "A tier two resource storage building. Allows keeping specific resources in reserve.", - "wiki": "http://community.lacunaexpanse.com/wiki/distribution-center" - }, - "/saw": { - "description": "A railgun system used to protect your planet from enemy ships.", - "wiki": "http://community.lacunaexpanse.com/wiki/shield-against-weapons" - }, - "/atmosphericevaporator": { - "description": "Produces water by condensing it from the air and soil.", - "wiki": "http://community.lacunaexpanse.com/wiki/atmospheric-evaporator" - }, - "/greatballofjunk": { - "description": "Eliminate waste and give your citizens something to be proud of at the same time.", - "wiki": "http://community.lacunaexpanse.com/wiki/great-ball-of-junk" - }, - "/pyramidjunksculpture": { - "description": "Eliminate waste and give your citizens something to be proud of at the same time.", - "wiki": "http://community.lacunaexpanse.com/wiki/pyramid-junk-sculpture" - }, - "/spacejunkpark": { - "description": "Eliminate waste and give your citizens something to be proud of at the same time.", - "wiki": "http://community.lacunaexpanse.com/wiki/space-junk-park" - }, - "/junkhengesculpture": { - "description": "Eliminate waste and give your citizens something to be proud of at the same time.", - "wiki": "http://community.lacunaexpanse.com/wiki/junk-henge-sculpture" - }, - "/metaljunkarches": { - "description": "Eliminate waste and give your citizens something to be proud of at the same time.", - "wiki": "http://community.lacunaexpanse.com/wiki/metal-junk-arches" - }, - "/deployedbleeder": { - "description": "Converts planet's resources directly into waste.", - "wiki": "http://community.lacunaexpanse.com/wiki/bleeder" - }, - "/oracleofanid": { - "description": "The all seeing Oracle can help detect enemy threats.", - "wiki": "http://community.lacunaexpanse.com/wiki/oracle-of-anid" - }, - "/themepark": { - "description": "Produces happiness for your citizens through food and entertainment.", - "wiki": "http://community.lacunaexpanse.com/wiki/theme-park" - }, - "/geneticslab": { - "description": "Allows genetic experiments on captured spies to improve your species.", - "wiki": "http://community.lacunaexpanse.com/wiki/genetics-lab" - }, - "/massadshenge": { - "description": "An ancient observatory.", - "wiki": "http://community.lacunaexpanse.com/wiki/massad-s-henge" - }, - "/gratchsgauntlet": { - "description": "The anti-espionage system of the Great Race.", - "wiki": "http://community.lacunaexpanse.com/wiki/gratch-s-gauntlet" - }, - "/kasternskeep": { - "description": "The place from which the Great Race commanded their armies.", - "wiki": "http://community.lacunaexpanse.com/wiki/kastern-s-keep" - }, - "/hallsofvrbansk": { - "description": "The source of ancient wisdom.", - "wiki": "http://community.lacunaexpanse.com/wiki/halls-of-vrbansk" - }, - "/libraryofjith": { - "description": "Where the Great Race kept records of their experiments.", - "wiki": "http://community.lacunaexpanse.com/wiki/library-of-jith" - }, - "/thedillonforge": { - "description": "Where raw ore formed into glyphs and the glyph buildings were born.", - "wiki": "http://community.lacunaexpanse.com/wiki/the-dillon-forge" - }, - "/blackholegenerator": { - "description": "An experimental singularity lab engineered by the Great Race.", - "wiki": "http://community.lacunaexpanse.com/wiki/black-hole-generator" - }, - "/supplypod": { - "description": "Used to hold emergency supplies on a damaged colony or on a fledgling colony.", - "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" - }, - "/subspacesupplydepot": { - "description": "Helps give a fledgling colony a kickstart.", - "wiki": "http://community.lacunaexpanse.com/wiki/subspace-supply-depot" - }, - "/pantheonofhagness": { - "description": "Increases the number of available plots on your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/pantheon-of-hagness" - }, - "/crashedshipsite": { - "description": "Harvest technology from a crashed ship to make your own ships better.", - "wiki": "http://community.lacunaexpanse.com/wiki/crashed-ship-site" - }, - "/citadelofknope": { - "description": "Enhances defensive value of your colony against hostile ships and reduces damage taken from fissure debris.", - "wiki": "http://community.lacunaexpanse.com/wiki/citadel-of-knope" - }, - "/ravine": { - "description": "A natural place to store waste.", - "wiki": "http://community.lacunaexpanse.com/wiki/ravine" - }, - "/fissure": { - "description": "The first sign of a dying planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/fissure" - }, - "/amalgusmeadow": { - "description": "A wild meadow filled with wild amalgus beans.", - "wiki": "http://community.lacunaexpanse.com/wiki/amalgus-meadow" - }, - "/dentonbrambles": { - "description": "A thorny patch of brambles, who's roots happen to be the delicious denton roots.", - "wiki": "http://community.lacunaexpanse.com/wiki/denton-brambles" - }, - "/malcudfield": { - "description": "A natural source of food.", - "wiki": "http://community.lacunaexpanse.com/wiki/malcud-field" - }, - "/lapisforest": { - "description": "A natural source of food.", - "wiki": "http://community.lacunaexpanse.com/wiki/lapis-forest" - }, - "/algaepond": { - "description": "A natural source of food.", - "wiki": "http://community.lacunaexpanse.com/wiki/algae-pond" - }, - "/beeldebannest": { - "description": "A natural source of food.", - "wiki": "http://community.lacunaexpanse.com/wiki/beeldeban-nest" - }, - "/geothermalvent": { - "description": "A natural source of energy from the planet's core.", - "wiki": "http://community.lacunaexpanse.com/wiki/geo-thermal-vent" - }, - "/naturalspring": { - "description": "A natural source of water from the planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/natural-spring" - }, - "/interdimensionalrift": { - "description": "The Great Race somehow learned a technique to create a pocket of subspace with a door into our world. This allowed them to store lots of resources, without taking up much space.", - "wiki": "http://community.lacunaexpanse.com/wiki/interdimensional-rift" - }, - "/templeofthedrajilites": { - "description": "The Temple of a group of star gazers from the Great Race. It was their belief that through ritual they could see other worlds.", - "wiki": "http://community.lacunaexpanse.com/wiki/temple-of-the-drajilites" - }, - "/sand": { - "description": "Decoration for your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/patch-of-sand" - }, - "/grove": { - "description": "Decoration for your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/grove-of-trees" - }, - "/lagoon": { - "description": "Decoration for your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/lagoon" - }, - "/kalavianruins": { - "description": "Attracts tourists and creates a sense of wonder for locals, increasing the happiness of your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/kalavian-ruins" - }, - "/essentiavein": { - "description": "Produces trace amounts of Essentia.", - "wiki": "http://community.lacunaexpanse.com/wiki/essentia-vein" - }, - "/volcano": { - "description": "A natural source of ore.", - "wiki": "http://community.lacunaexpanse.com/wiki/volcano" - }, - "/luxuryhousing": { - "description": "Produces more happiness than the Entertainment District, but costs more too.", - "wiki": "http://community.lacunaexpanse.com/wiki/luxury-housing" - }, - "/pilottraining": { - "description": "Increases speed and stealth of new piloted ships, and enables building Fighters.", - "wiki": "http://community.lacunaexpanse.com/wiki/pilot-training-facility" - }, - "/missioncommand": { - "description": "Lists available missions in your zone. You can view one mission per level of the Mission Command.", - "wiki": "http://community.lacunaexpanse.com/wiki/mission-command" - }, - "/cloakinglab": { - "description": "Increases the stealth of new ships.", - "wiki": "http://community.lacunaexpanse.com/wiki/cloaking-lab" - }, - "/munitionslab": { - "description": "Enables you to build the Detonator, Snark, and Seeker robotic war ships.", - "wiki": "http://community.lacunaexpanse.com/wiki/munitions-lab" - }, - "/crater": { - "description": "Decoration for your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/crater" - }, - "/rockyoutcrop": { - "description": "Decoration for your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/rocky-outcropping" - }, - "/lake": { - "description": "Decoration for your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/lake" - }, - "/beach1": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-1" - }, - "/beach2": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-2" - }, - "/beach3": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-3" - }, - "/beach4": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-4" - }, - "/beach5": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-5" - }, - "/beach6": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-6" - }, - "/beach7": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-7" - }, - "/beach8": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-8" - }, - "/beach9": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-9" - }, - "/beach10": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-10" - }, - "/beach11": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-11" - }, - "/beach12": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-12" - }, - "/beach13": { - "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", - "wiki": "http://community.lacunaexpanse.com/wiki/beach-13" - }, - "/algae": { - "description": "Produces algae to be used as food by your empire. It also produces a small amount of energy and can be built in any orbit. The higher the level of the cropper the more food and energy it produces.", - "wiki": "http://community.lacunaexpanse.com/wiki/algae-cropper" - }, - "/apple": { - "description": "Allows you to grow apples to feed your empire. You can only grow apples in orbit 3 (its goldilox zone). Food production increases for every level of the orchard. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/apple-orchard" - }, - "/archaeology": { - "description": "Allows you to search through specific types of ore to find Glyphs.", - "wiki": "http://community.lacunaexpanse.com/wiki/archaeology-ministry" - }, - "/bean": { - "description": "Allows you to grow beans to be used as food by your empire. You can only grow beans in orbit 4 (its goldilox zone). The higher the level of the plantation the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/amalgus-bean-plantation" - }, - "/beeldeban": { - "description": "Allows the raising of beeldeban to be used as food for your empire. The higher the building level the more food is produced.", - "wiki": "http://community.lacunaexpanse.com/wiki/beeldeban-herder" - }, - "/bread": { - "description": "Converts wheat from the Wheat Farm at a minimal loss into bread to be used as food by your empire. The conversion rate increases with every level of the Bakery.", - "wiki": "http://community.lacunaexpanse.com/wiki/bakery" - }, - "/burger": { - "description": "Converts fungus from the Malcud Fungus Farm and produces burgers, at a small loss, to food. The higher the building level the more food is converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/burger-packer" - }, - "/capitol": { - "description": "Provides protection from Insurrection, and produces happiness.", - "wiki": "http://community.lacunaexpanse.com/wiki/capitol" - }, - "/cheese": { - "description": "Converts milk from the Dairy Farm into cheese at a small loss to be used as food. The higher the building level the more food is converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/cheese-maker" - }, - "/chip": { - "description": "Converts roots from the Denton Root Farm and turns it into root chips as food for your empire at a minimal loss. The higher the level of the Chip Frier the more food it converts.", - "wiki": "http://community.lacunaexpanse.com/wiki/denton-root-chip-frier" - }, - "/cider": { - "description": "Allows you to convert apples from the Apple Orchard into cider with a small amount of loss. The amount of apples converted into cider increases with the level of the building.", - "wiki": "http://community.lacunaexpanse.com/wiki/apple-cider-bottler" - }, - "/corn": { - "description": "Produces corn to be used as food by your empire. The corn plantation can only be used in orbits 2 and 3. The higher the level of the plantation the more food is produced. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/corn-plantation" - }, - "/cornmeal": { - "description": "Converts corn from the Corn Plantation into corn meal at a small loss to be used as food. The higher the building level the more food is converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/corn-meal-grinder" - }, - "/dairy": { - "description": "Allows you to produce food via dairy cattle. It can only be used in orbit 3 (its goldilox zone). The higher the level of farm the more food it produces. Cows require certain minerals in their diet in order to produce lots of high quality milk. Therefore in order to have a dairy farm you're going to need a good supply of trona.", - "wiki": "http://community.lacunaexpanse.com/wiki/dairy-farm" - }, - "/denton": { - "description": "Produces roots to be used as food by your empire. The roots only grow in orbits 5 and 6 (its goldilox zone). The higher the level of the patch the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/denton-root-patch" - }, - "/development": { - "description": "Allows you to monitor your build queue and subsidize the construction of buildings through the use of Essentia. The higher the level of the building the more buildings you can have in your queue, however the queue still builds in series not in parallel. The number of projects that can be placed in the queue is the level of the ministry plus 1. ", - "wiki": "http://community.lacunaexpanse.com/wiki/development-ministry" - }, - "/embassy": { - "description": "Allows the formation of alliances. It is also a prerequisite to building the Space Station. Each level of the Embassy allows 2 more members to join the alliance. Each level of the embassy allows 1 stash exchange per day, and 10,000 more resources per exchange.", - "wiki": "http://community.lacunaexpanse.com/wiki/embassy" - }, - "/energyreserve": { - "description": "Stores your energy with a minimal amount of loss. Increasing the level of the building raises the amount of energy stored.", - "wiki": "http://community.lacunaexpanse.com/wiki/energy-reserve" - }, - "/entertainment": { - "description": "Increases your empire's happiness by providing a place for your citizens to unwind through activities such as casinos, restaurants, clubs and other amusements. The higher the building level the more happiness is produced. It can also be a source of essentia through its lottery system.", - "wiki": "http://community.lacunaexpanse.com/wiki/entertainment-district" - }, - "/espionage": { - "description": "Allows the construction of spy pods and spy shuttles at the shipyard. It also allows better training of your spies. The higher the building level, the more effective your spies will be applying their trade. ", - "wiki": "http://community.lacunaexpanse.com/wiki/espionage-ministry" - }, - "/foodreserve": { - "description": "Stores your food with a minimal amount of spoilage. It also gives you a report of the types of food you have stored. Increasing the level of this building increases the amount of food that can be stored.", - "wiki": "http://community.lacunaexpanse.com/wiki/food-reserve" - }, - "/fission": { - "description": "Produces energy by splitting atoms. This way of producing energy is very efficient on an waste per energy produced ratio. The higher the building level the more energy is produced. Splitting the atoms non-energenic particles doesn't produce much power, so you'll need radioactive ore to power your fission plant, such as uraninite or monazite.", - "wiki": "http://community.lacunaexpanse.com/wiki/fission-energy-plant" - }, - "/fusion": { - "description": "Produces energy by fusing atoms together. This type of energy is even more efficient than the Fission Energy Plant on a waste per energy produced ratio. Requires a high level University to construct. The higher the building level the more energy is produced. Unfortunately the fusion plant produces enormous amounts of heat as well which requires coolants such as molten lead or salt. Therefore you'll need a good supply of galena or halite to build one.", - "wiki": "http://community.lacunaexpanse.com/wiki/fusion-energy-plant" - }, - "/gasgiantlab": { - "description": "Does research on the gas giant ship which deploys into a gas giant platform. The gas giant platform allows settlement of a gas giant. The higher the building level the higher the level of the platform deployed from the gas giant ship.", - "wiki": "http://community.lacunaexpanse.com/wiki/gas-giant-lab" - }, - "/gasgiantplatform": { - "description": "Increases the available plots on a gas giant.", - "wiki": "http://community.lacunaexpanse.com/wiki/gas-giant-settlement-platform" - }, - "/geo": { - "description": "Produces energy with a minimal amount of waste by using the planets own processes such as wind, waves, solar and geo thermal. The higher the level of the building the more energy is produced.", - "wiki": "http://community.lacunaexpanse.com/wiki/geo-energy-plant" - }, - "/hydrocarbon": { - "description": "Produces large amounts of energy at the cost of producing large amounts of waste by burning hydrocarbons. It also uses significant amounts of ore in the production of this energy. The higher the building level the more energy is produced. Hydrocarbon energy is derived from burning hydrocarbons, so you'll need a good supply of kerogen, methane, or anthracite in order to power it.", - "wiki": "http://community.lacunaexpanse.com/wiki/hydrocarbon-energy-plant" - }, - "/intelligence": { - "description": "Trains spies. You may train 3 spies per level of this building. You may only construct 1 Intelligence Ministry on a planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/intelligence-ministry" - }, - "/inteltraining": { - "description": "Trains spies in the ways of intelligence gathering. You may only construct 1 Intel Training Facility on a planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/intel-training-facility" - }, - "/lapis": { - "description": "Produces lapis to be used as food by your empire. Lapis can only be grown in orbit 2 (its goldilox zone). The higher the level of the orchard the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/lapis-orchard" - }, - "/malcud": { - "description": "Produces fungus to be used as food by your empire. The Farm also consumes a small amount of waste and can be built in any orbit. The higher the level of the farm the more food is produced and waste consumed.", - "wiki": "http://community.lacunaexpanse.com/wiki/malcud-fungus-farm" - }, - "/mayhemtraining": { - "description": "Trains spies in the art of destruction. You may only construct 1 Mayhem Training Facility on a planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/mayhem-training-facility" - }, - "/mercenariesguild": { - "description": "A black market for buying and selling well trained spies.", - "wiki": "http://community.lacunaexpanse.com/wiki/mercenaries-guild" - }, - "/mine": { - "description": "Extracts mineral from your planet in the form of ore. The amounts of each mineral extracted depends on the concentration and composition of the planet. The higher the level of the mine the more ore is extracted.", - "wiki": "http://community.lacunaexpanse.com/wiki/mine" - }, - "/miningministry": { - "description": "Allows you to harvest resources from asteroids. Allows the construction of Mining Platform Ships. Every two levels allows an additional Mining Platform. Each level increases the output of all Mining Platforms controlled by the Ministry.", - "wiki": "http://community.lacunaexpanse.com/wiki/mining-ministry" - }, - "/network19": { - "description": "Your empire's source for up to the minute news in your region of the Expanse. Get updates on what other empire's are doing and what you'd prefer they weren't doing. The Network 19 feed can be manipulated through the use of of espionage and political policy. Well informed people are happy people so the network also produces happiness. The higher the building level the more of the expanse you can get news from and the more happiness is produced. ", - "wiki": "http://community.lacunaexpanse.com/wiki/network-19-affiliate" - }, - "/observatory": { - "description": "Allows the construction of probes and colony ships at the shipyard. It also provides a list of all your active probes and the stars they are observing. A higher building level allows more probes to be constructed.", - "wiki": "http://community.lacunaexpanse.com/wiki/observatory" - }, - "/orerefinery": { - "description": "Increases the amount of ore extracted from each terrestrial ore producing structure by purifying the ore and producing less waste. The higher the refinery level the higher the purification process and even greater amounts of ore are extracted. The ore refinery requires sufficient amounts of either sulfur or fluorite being produced in order to process ore.", - "wiki": "http://community.lacunaexpanse.com/wiki/ore-refinery" - }, - "/orestorage": { - "description": "Store the ore that is pulled from the Mine. The higher the level of the building the more ore can be stored.", - "wiki": "http://community.lacunaexpanse.com/wiki/ore-storage-tanks" - }, - "/oversight": { - "description": "Reduces the amount of time buildings take to upgrade through better project management. All buildings will be produced 3% faster per level of the Oversight Ministry.", - "wiki": "http://community.lacunaexpanse.com/wiki/oversight-ministry" - }, - "/pancake": { - "description": "Converts potatoes from the Potato Plantation into pancakes at a minimal loss to be used as food by your empire. The higher the level of the factory, the more food is converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/pancake-factory" - }, - "/park": { - "description": "A place for your people to gather and enjoy nature or hold large scale public events. The Park allows you to throw parties for your citizens to increase their happiness. The more varieties of foods you bring to the party the more happiness is produced.", - "wiki": "http://community.lacunaexpanse.com/wiki/park" - }, - "/pie": { - "description": "Converts lapis from the Lapis Orchard into pies at minimal loss to be used as food by your empire. The higher the level of the bakery, the more food is converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/pie-bakery" - }, - "/planetarycommand": { - "description": "Houses the central government for your empire. This is your \"flag in the ground\" that lets everyone know you've staked your claim to a planet. It provides some basic resources and and storage for those resources both of which increase with the level of this building. The planetary command also provides some critical reports on your planetary activities such as total resource production and total resource storage for the planet it's constructed on.", - "wiki": "http://community.lacunaexpanse.com/wiki/planetary-command-center" - }, - "/politicstraining": { - "description": "Trains spies in the dark art of social engineering. You may only construct 1 Politics Training Facility on a planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/politics-training-facility" - }, - "/potato": { - "description": "Allows you to grow potatoes to be used as food for you empire. The patch can only be used in orbits 3 and 4 (its goldilox zone). The higher the level of the patch the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/potato-patch" - }, - "/propulsion": { - "description": "Allows your ships to move faster through space by way of upgraded engines. The higher the building level the faster your ships move. All ships originating from this planet are affected. In order to produce high performance engines you'll need a good supply of structural minerals such as rutile, chromite, bauxite, magnetite, beryl, or goethite.", - "wiki": "http://community.lacunaexpanse.com/wiki/propulsion-system-factory" - }, - "/security": { - "description": "Increases the effectiveness of your counter-spies and allows you to detect foreign spies. The higher the building level the more training your counter-spies receive. The building will be able to detect foreign spies with a level equal to or lower than the building. It will also help detect incoming ships containing spies.", - "wiki": "http://community.lacunaexpanse.com/wiki/security-ministry" - }, - "/shake": { - "description": "Converts the beeldeban that are harvested in the Beeldeban Herder into protein shakes, at a small loss, to be used as food. The higher the level of the factory the more food is converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/beeldeban-protein-shake-factory" - }, - "/shipyard": { - "description": "Constructs ships. The types of ships that can be built in the Shipyard are dependent on some of the other buildings on your planet. The higher the building level the faster ships are produced. In addition, you may queue one ship per level of shipyard.", - "wiki": "http://community.lacunaexpanse.com/wiki/shipyard" - }, - "/singularity": { - "description": "Produces energy by pulling it from subspace. This is the cleanest and most powerful form of energy in the universe. This is extremely expensive to build and requires a very high level University to construct. The higher the building level the more energy is produced.", - "wiki": "http://community.lacunaexpanse.com/wiki/singularity-energy-plant" - }, - "/soup": { - "description": "Converts beans from the Amalgus Bean Plantation at a minimal loss into soup to be used as food for your empire. The higher the level of the cannery the more soup is produced.", - "wiki": "http://community.lacunaexpanse.com/wiki/soup-cannery" - }, - "/spaceport": { - "description": "Acts as the hangar and control tower for your ships. Here is where you can monitor your ships that are in transit. Be careful as the Space Port can only hold a limited number of ships, if there is no more room in the Space Port when a ship arrives or is built, it will be destroyed. The Space Port can hold double its level in ships and queue its level in ships. ", - "wiki": "http://community.lacunaexpanse.com/wiki/space-port" - }, - "/stockpile": { - "description": "Allows resource buildings to go above level 20. Provides storage.", - "wiki": "http://community.lacunaexpanse.com/wiki/stockpile" - }, - "/syrup": { - "description": "Takes algae from the Algae Cropper and converts it in to Syrup with a small loss to be used as food. The higher the level of the bottler the more food is produced.", - "wiki": "http://community.lacunaexpanse.com/wiki/syrup-bottler" - }, - "/thefttraining": { - "description": "Trains spies in the art of appropriation. You may only construct 1 Theft Training Facility on a planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/theft-training-facility" - }, - "/terraforminglab": { - "description": "The Terraforming Lab is where research is done on the production of terraforming platform ships. Terraforming platform ships deploy into terraforming platforms which allows you to colonize planets your species wouldn't normally be capable of colonizing. The level of the building determines the level of the platform that is deployed from the ship.", - "wiki": "http://community.lacunaexpanse.com/wiki/terraforming-lab" - }, - "/terraformingplatform": { - "description": "Increases the available build space on a planet that is not naturally inhabitable by your species.", - "wiki": "http://community.lacunaexpanse.com/wiki/terraforming-platform" - }, - "/trade": { - "description": "Allows access to the interstellar market. Through it you can set up trades for resources with other empires. This building is a prerequisite to building cargo ships, which carry your trade goods, in the shipyard. The higher the building level the more resources your cargo ships can carry.", - "wiki": "http://community.lacunaexpanse.com/wiki/trade-ministry" - }, - "/transporter": { - "description": "Allows the instant transport of resources to a destination, but requires Essentia. The transporter also allows conversion of resources through trading with the Lacunans. The higher the building level the more goods can be transported.", - "wiki": "http://community.lacunaexpanse.com/wiki/subspace-transporter" - }, - "/university": { - "description": "Is the key to growth for your empire. Other buildings can not be upgraded higher than the university building level plus 1. Your university's level is empire wide where construction level of buildings on other planets is concerned. Many of the more powerful buildings that can be constructed require a very high level University. The University is also a source of happiness for your empire. ", - "wiki": "http://community.lacunaexpanse.com/wiki/university" - }, - "/wastedigester": { - "description": "Converts waste into ore. The higher the building level the more ore is produced and waste consumed.", - "wiki": "http://community.lacunaexpanse.com/wiki/waste-digester" - }, - "/wasteenergy": { - "description": "Produces energy by burning your empire's waste. Producing energy this way is far less efficient than other types of energy production, but the benefit is that waste is reduced. The higher the building level the more energy is produced and waste consumed. In order to build and maintain the blast furnace you need a good supply of insulating ores such as zircon, beryl, and gypsum.", - "wiki": "http://community.lacunaexpanse.com/wiki/waste-energy-plant" - }, - "/wasterecycling": { - "description": "Allows you to manually convert large batches of waste into energy, ore and water. The more waste you convert, the longer it will take to make the resources you want. The higher the level of the building the faster the conversion will take place. You can also spend a small amount of Essentia to convert the waste instantly.", - "wiki": "http://community.lacunaexpanse.com/wiki/waste-recycling-center" - }, - "/wasteexchanger": { - "description": "The Waste Exchanger is a combination of a waste recycling center, waste sequestration well, and a waste treatment center. It tears apart waste at a molecular level and recombines it into useful resources.", - "wiki": "http://community.lacunaexpanse.com/wiki/waste-exchanger" - }, - "/wastesequestration": { - "description": "Stores waste. Waste that is not stored turns into pollution and lowers your empire's happiness. The higher the building level the more waste can be stored.", - "wiki": "http://community.lacunaexpanse.com/wiki/waste-sequestration-well" - }, - "/wastetreatment": { - "description": "Converts waste into water, ore, and energy. Waste treatment requires special chemical compounds derived from halite, sulfur, and trona.", - "wiki": "http://community.lacunaexpanse.com/wiki/waste-treatment-center" - }, - "/waterproduction": { - "description": "Converts energy and ore into water. This is especially useful on planets with low concentrations of water. A higher building level means more resources are converted.", - "wiki": "http://community.lacunaexpanse.com/wiki/water-production-plant" - }, - "/waterpurification": { - "description": "Produces water from the planet's sources. The higher the building level the more water it can purify.", - "wiki": "http://community.lacunaexpanse.com/wiki/water-purification-plant" - }, - "/waterreclamation": { - "description": "Converts waste into water. A higher building level means more resources are converted. If you don't have a good supply of halite or sulfur you cannot treat waste water.", - "wiki": "http://community.lacunaexpanse.com/wiki/water-reclamation-facility" - }, - "/waterstorage": { - "description": "Stores the water you've collected. A higher building level allows more water to be stored.", - "wiki": "http://community.lacunaexpanse.com/wiki/water-storage-tank" - }, - "/wheat": { - "description": "Allows you to grow wheat on your planet. You can only grow wheat on planets that are in orbits 2, 3 or 4 (the goldilox zone). The Farm will produce more wheat for each level it is increased. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", - "wiki": "http://community.lacunaexpanse.com/wiki/wheat-farm" - }, - "/lcota": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure. Be sure to place it where all the plots around it are unoccupied, and on a planet where you have 9 available plots.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcotb": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcotc": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcotd": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcote": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcotf": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcotg": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcoth": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - }, - "/lcoti": { - "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", - "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" - } - }, - "ships": { - "stake": { - "description": "Allows you to claim a planet prior to your colony ship arriving.", - "wiki": "http://community.lacunaexpanse.com/wiki/stake" - }, - "thud": { - "description": "Temporarily destroys plots on a planet's surface.", - "wiki": "http://community.lacunaexpanse.com/wiki/thud" - }, - "sweeper": { - "description": "An upgraded Fighter whose primary role is offense rather than defense.", - "wiki": "http://community.lacunaexpanse.com/wiki/sweeper" - }, - "supply_pod": { - "description": "Can deliver resources and creates temporary storage for 24 hours on a remote planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" - }, - "supply_pod2": { - "description": "A larger version of the Supply Pod.", - "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" - }, - "supply_pod3": { - "description": "A very large version of the Supply Pod.", - "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" - }, - "supply_pod4": { - "description": "A huge version of the Supply Pod.", - "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" - }, - "placebo": { - "description": "Use to fake an attack on another player.", - "wiki": "http://community.lacunaexpanse.com/wiki/placebo" - }, - "placebo2": { - "description": "A faster and more stealthed version of the Placebo.", - "wiki": "http://community.lacunaexpanse.com/wiki/placebo" - }, - "placebo3": { - "description": "A faster and more stealthed version of the Placebo II.", - "wiki": "http://community.lacunaexpanse.com/wiki/placebo" - }, - "placebo4": { - "description": "A faster and more stealthed version of the Placebo III.", - "wiki": "http://community.lacunaexpanse.com/wiki/placebo" - }, - "placebo5": { - "description": "A faster and more stealthed version of the Placebo IV.", - "wiki": "http://community.lacunaexpanse.com/wiki/placebo" - }, - "placebo6": { - "description": "A faster and more stealthed version of the Placebo V.", - "wiki": "http://community.lacunaexpanse.com/wiki/placebo" - }, - "probe": { - "description": "Allows you to view the bodies of a system if sent to a star. Probes are shared among members of the same alliance.", - "wiki": "http://community.lacunaexpanse.com/wiki/probe" - }, - "colony_ship": { - "description": "Use to create a new colony for your empire.", - "wiki": "http://community.lacunaexpanse.com/wiki/colony-ship" - }, - "short_range_colony_ship": { - "description": "Use to create a new colony for your empire. Very fast, but with a limited range. Useful within your own, or very close, star systems.", - "wiki": "http://community.lacunaexpanse.com/wiki/short-range-colony-ship" - }, - "spy_pod": { - "description": "Stealthy one way transport for a spy.", - "wiki": "http://community.lacunaexpanse.com/wiki/spy-pod" - }, - "cargo_ship": { - "description": "Medium transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/cargo-ship" - }, - "space_station": { - "description": "The base hull upon which you can build space station modules to build a complete space station.", - "wiki": "http://community.lacunaexpanse.com/wiki/space-station" - }, - "smuggler_ship": { - "description": "Stealthy transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/smuggler-ship" - }, - "mining_platform_ship": { - "description": "Allows the gathering of resources from asteroids.", - "wiki": "http://community.lacunaexpanse.com/wiki/mining-platform-ship" - }, - "terraforming_platform_ship": { - "description": "Allows you to settle planets your species could not normally colonize.", - "wiki": "http://community.lacunaexpanse.com/wiki/terraforming-platform-ship" - }, - "gas_giant_settlement_ship": { - "description": "Allows you to settle gas giants.", - "wiki": "http://community.lacunaexpanse.com/wiki/gas-giant-settlement-ship" - }, - "scow": { - "description": "Robotic waste transport ship. Can be used to dispose of waste in space.", - "wiki": "http://community.lacunaexpanse.com/wiki/scow" - }, - "scow_fast": { - "description": "Much faster than a normal scow. Robotic waste transport ship. Can be used to dispose of waste in space.", - "wiki": "http://community.lacunaexpanse.com/wiki/scow" - }, - "scow_large": { - "description": "Much larger and a bit slower than a normal scow. Robotic waste transport ship. Can be used to dispose of waste in space.", - "wiki": "http://community.lacunaexpanse.com/wiki/scow" - }, - "scow_mega": { - "description": "Incredibly larger and slower than a normal scow. Almost useless as an attack. Robotic waste transport ship. Can be used to dispose of waste in space.", - "wiki": "http://community.lacunaexpanse.com/wiki/scow" - }, - "bleeder": { - "description": "Robotic war ship. Once deployed on enemy planet, starts stealing resources and converting them into waste.", - "wiki": "http://community.lacunaexpanse.com/wiki/bleeder" - }, - "dory": { - "description": "Small transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/dory" - }, - "barge": { - "description": "Versatile transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/barge" - }, - "galleon": { - "description": "Fast medium transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/galleon" - }, - "hulk": { - "description": "Extra large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/hulk" - }, - "hulk_fast": { - "description": "Extra large transport ship slightly bigger and much faster than a Hulk. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/hulk" - }, - "hulk_huge": { - "description": "Incredibly large and very slow transport ship, useful for supply chains. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/hulk" - }, - "fissure_sealer": { - "description": "Large slow ship, used to attempt sealing fissures on uninhabited planets.", - "wiki": "http://community.lacunaexpanse.com/wiki/fissure-sealer" - }, - "freighter": { - "description": "Large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", - "wiki": "http://community.lacunaexpanse.com/wiki/freighter" - }, - "snark": { - "description": "Single-use robotic bombardment weapon, that can be used to damage buildings on remote planets.", - "wiki": "http://community.lacunaexpanse.com/wiki/snark" - }, - "snark2": { - "description": "An improved version of the Snark, which has four warheads", - "wiki": "http://community.lacunaexpanse.com/wiki/snark" - }, - "snark3": { - "description": "An improved version of the Snark, which has nine warheads", - "wiki": "http://community.lacunaexpanse.com/wiki/snark" - }, - "drone": { - "description": "Single use robotic defense weapon, that can stop enemy attacks before they reach your planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/drone" - }, - "fighter": { - "description": "Piloted defense ship that can stop enemy attacks before they reach your planet. Can also be sent to defend other bodies.", - "wiki": "http://community.lacunaexpanse.com/wiki/fighter" - }, - "spy_shuttle": { - "description": "Stealthy transport for up to four spies, that can orbit the target body waiting to pick the spies back up.", - "wiki": "http://community.lacunaexpanse.com/wiki/spy-shuttle" - }, - "observatory_seeker": { - "description": "Variant of the Snark that attacks an Observatory.", - "wiki": "http://community.lacunaexpanse.com/wiki/observatory-seeker" - }, - "security_ministry_seeker": { - "description": "Variant of the Snark that attacks a Security Ministry.", - "wiki": "http://community.lacunaexpanse.com/wiki/security-ministry-seeker" - }, - "spaceport_seeker": { - "description": "Variant of the Snark that attacks a SpacePort.", - "wiki": "http://community.lacunaexpanse.com/wiki/spaceport-seeker" - }, - "excavator": { - "description": "Robotic explorer that searches remote bodies looking for artifacts.", - "wiki": "http://community.lacunaexpanse.com/wiki/excavator" - }, - "detonator": { - "description": "Variant of the Snark that detonates in an electromagnetic pulse, which can be used to destroy probes, mining platforms, or excavators.", - "wiki": "http://community.lacunaexpanse.com/wiki/detonator" - }, - "surveyor": { - "description": "Robotic explorer that snaps a photograph of the surface of a remote planet, and also identifies the buildings in the photograph.", - "wiki": "http://community.lacunaexpanse.com/wiki/surveyor" - }, - "scanner": { - "description": "Robotic explorer that snaps a photograph of the surface of a remote planet.", - "wiki": "http://community.lacunaexpanse.com/wiki/scanner" - } - }, - "tips": [ - "Water Purification Plants are cheap, but slow. If you can afford them, Water Production Plants produce more water.", - "You need at least 3 food types to keep your people happy.", - "Building a Development Ministry will let you queue multiple buildings at once.", - "Buildings are built in series. So if you already have a building upgrading that will take 20 minutes, and you add a building that takes 15 seconds, the second building will take 20:15.", - "Buildings have both a cost and an upkeep. Cost is what it costs to build/upgrade the building. Upkeep is what it costs per hour to run the building.", - "If you have at least 4 food types, every time you build something you'll gain happiness.", - "You can use Essentia in the Development Ministry to auto-complete your entire build queue.", - "If your waste overflows it will create pollution, and that will make your people unhappy.", - "A good build strategy is to upgrade your storage first, then your resource generators, then your University.", - "Try to make sure your resource production will completely fill your available storage at least once per day.", - "If you run out of resources, your people will not be happy.", - "Construction and upgrades produce bulk waste all at once. Be sure you can store it, or the pollution it generates will make your citizens unhappy.", - "Though the planet map shows 121 spaces for buildings, each planet is limited to a certain number of plots. You can see how many plots are remaining in the Planetary Command Center.", - "In order to manage waste or recycle it, you must first store it. Build a Waste Sequestration Well to store waste.", - "Waste can be a very valuable resource. Build waste management buildings like Waste Reclamation, Waste Treatement, or Waste Digesters to turn it into useful resources.", - "You can use Essentia in the Waste Recycling Plant to instantly complete the recycling process.", - "We recommend at least 2 of each type of storage on every planet.", - "If you invite your friends to the game, and a few of them sign up, you'll start getting special buildings as rewards.", - "You can use Essentia in the Shipyard to auto-complete your entire build queue.", - "Knowledge gained from the University is permanent. Even if you demolish the University you still have the knowledge.", - "While you are waiting for your building upgrades to complete, build and send out probes to see what's around you.", - "Building an Oversight Ministry will speed up all of your building build/upgrade times.", - "You can win free Essentia in the Lottery at the Entertainment District.", - "Both the cost and production of buildings rise expontentially. Production rises slightly slower than cost however.", - "As an isolationist you are immune to attack. You are no longer an isolationist if you colonize a second planet, or build an Espionage Ministry or Munitions Lab.", - "Most ships are one use only, meaning once you send them you cannot get them back. Exceptions to this are trade ships like Dories and Cargo Ships.", - "Looking to the future you may want to upgrade your existing energy plants with newer technology as it becomes available.", - "You can use Essentia in the Intelligence Ministry to train spies instantly.", - "It costs 100,000 happiness to colonize your second planet, but it gets much more difficult for each subsequent colony.", - "You can use Essentia in the Park to speed along parties.", - "The University is global. The level of University you built on one planet affects all your planets. The University is the only building that has this ability.", - "As soon as a colony ship arrives at a new planet it begins functioning. Be prepared to deal with it when the ship arrives.", - "When choosing a planet to colonize things to consider are its size, distance from your other colonies, distance from asteroids, ore composition, and water composition.", - "Make sure you have some dories available when you colonize a planet so you can ship resources to the new colony to give it a head start.", - "You can use Essentia in the Subspace Transporter to do instant 1:1 trades of any resource.", - "Spies are the primary form of combat in the game. Send spies to other people's planets and you'll be able to gather information, sabotage infastructure, and steal resources from them.", - "Though you can lose colonies to spies, you cannot ever lose your home planet.", - "Some ores are only found in abundance on asteroids.", - "Resource buildings can only go to level 20, while all other buildings can go to level 30.", - "Glyphs enable you to build incredibly powerful buildings that aren't part of the normal technology tree.", - "You can use Essentia in the Archaeology Ministry to search for glyphs instantly.", - "Drones, Fighters, and Sweepers defend your planet from other players ships.", - "Spies defend your planet from other players spies.", - "Glyph buildings take up no plots.", - "Higher level Spaceports can tell you more information about ships that are coming in from other players.", - "A higher level Security Ministry increases the chance of catching enemy spies as they come and go from your planet.", - "A higher level Security Ministry allows you to see more detail about the enemy spies that are on your planet.", - "You can make a new planet your home planet by building a Capitol building." - ], - "writ_templates": [ - { - "title": "Non-Agression Mandate", - "description": "Planets in this jurisdiction may not attack anyone inside the jurisdiction." - }, - { - "title": "No Munitions", - "description": "Planets in this jurisdiction, except for members of ______ alliance are not allowed to build a Munitions Lab. If you are found with one the penalty shall be _______." - }, - { - "title": "No Operatives", - "description": "Planets in this jurisdiction, except for members of ______ alliance are not allowed to build an Espionage Ministry. If you are found with one the penalty shall be _______." - }, - { - "title": "Defense Mandate", - "description": "Planets in this jurisdiction are required to come to the aid of the other planets in this jurisdiction when under attack from both foreign and domestic enemies." - }, - { - "title": "Confederacy with ______", - "description": "_______ alliance declares a mutual confederation with _______ alliance." - }, - { - "title": "NAP with ______", - "description": "_______ alliance declares a non-aggression pact with _______ alliance." - }, - { - "title": "Declaration of War", - "description": "_______ alliance declares war on ______ alliance. All citizens in this jurisdiction are required to supply the war effort with all available ships, operatives, and aid packages." - }, - { - "title": "Censure of ______", - "description": "We, the members of _______ alliance, hereby declare a formal reprimand of _______ for __________________." - }, - { - "title": "Glyph Heresy", - "description": "_______ alliance hereby denounces the existence of the Great Race. Anyone in our jurisdiction found using glyph technology shall be treated cruelly and without mercy." - } - ] + "buildings": { + "/operahouse": { + "description": "A source of cultural influence for your space station.", + "wiki": "http://community.lacunaexpanse.com/wiki/opera-house" + }, + "/artmuseum": { + "description": "A source of cultural influence for your space station.", + "wiki": "http://community.lacunaexpanse.com/wiki/art-museum" + }, + "/culinaryinstitute": { + "description": "A source of cultural influence for your space station.", + "wiki": "http://community.lacunaexpanse.com/wiki/culinary-institute" + }, + "/stationcommand": { + "description": "The internal operations of a space station. Controls how big the station can be expanded.", + "wiki": "http://community.lacunaexpanse.com/wiki/station-command-center" + }, + "/parliament": { + "description": "The central government for the star systems that are controlled by a space station. Laws for the jurisdiction are made here.", + "wiki": "http://community.lacunaexpanse.com/wiki/parliament" + }, + "/policestation": { + "description": "The police station manages security on a Space Station. It can help defend the Station against spies as well as detect incoming ships.", + "wiki": "http://community.lacunaexpanse.com/wiki/police-station" + }, + "/warehouse": { + "description": "Resource storage for a space station.", + "wiki": "http://community.lacunaexpanse.com/wiki/warehouse" + }, + "/ibs": { + "description": "A means of spreading the culture and influence of a space station's government.", + "wiki": "http://community.lacunaexpanse.com/wiki/interstellar-broadcast-system" + }, + "/ssla": { + "description": "Allows the construction of Space Station Lab modules. Requires four plots, and this is the top left corner of the building.", + "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" + }, + "/sslb": { + "description": "Infrastructure required to support Space Station Lab (A).", + "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" + }, + "/sslc": { + "description": "Infrastructure required to support Space Station Lab (A).", + "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" + }, + "/ssld": { + "description": "Infrastructure required to support Space Station Lab (A).", + "wiki": "http://community.lacunaexpanse.com/wiki/space-station-lab" + }, + "/distributioncenter": { + "description": "A tier two resource storage building. Allows keeping specific resources in reserve.", + "wiki": "http://community.lacunaexpanse.com/wiki/distribution-center" + }, + "/saw": { + "description": "A railgun system used to protect your planet from enemy ships.", + "wiki": "http://community.lacunaexpanse.com/wiki/shield-against-weapons" + }, + "/atmosphericevaporator": { + "description": "Produces water by condensing it from the air and soil.", + "wiki": "http://community.lacunaexpanse.com/wiki/atmospheric-evaporator" + }, + "/greatballofjunk": { + "description": "Eliminate waste and give your citizens something to be proud of at the same time.", + "wiki": "http://community.lacunaexpanse.com/wiki/great-ball-of-junk" + }, + "/pyramidjunksculpture": { + "description": "Eliminate waste and give your citizens something to be proud of at the same time.", + "wiki": "http://community.lacunaexpanse.com/wiki/pyramid-junk-sculpture" + }, + "/spacejunkpark": { + "description": "Eliminate waste and give your citizens something to be proud of at the same time.", + "wiki": "http://community.lacunaexpanse.com/wiki/space-junk-park" + }, + "/junkhengesculpture": { + "description": "Eliminate waste and give your citizens something to be proud of at the same time.", + "wiki": "http://community.lacunaexpanse.com/wiki/junk-henge-sculpture" + }, + "/metaljunkarches": { + "description": "Eliminate waste and give your citizens something to be proud of at the same time.", + "wiki": "http://community.lacunaexpanse.com/wiki/metal-junk-arches" + }, + "/deployedbleeder": { + "description": "Converts planet's resources directly into waste.", + "wiki": "http://community.lacunaexpanse.com/wiki/bleeder" + }, + "/oracleofanid": { + "description": "The all seeing Oracle can help detect enemy threats.", + "wiki": "http://community.lacunaexpanse.com/wiki/oracle-of-anid" + }, + "/themepark": { + "description": "Produces happiness for your citizens through food and entertainment.", + "wiki": "http://community.lacunaexpanse.com/wiki/theme-park" + }, + "/geneticslab": { + "description": "Allows genetic experiments on captured spies to improve your species.", + "wiki": "http://community.lacunaexpanse.com/wiki/genetics-lab" + }, + "/massadshenge": { + "description": "An ancient observatory.", + "wiki": "http://community.lacunaexpanse.com/wiki/massad-s-henge" + }, + "/gratchsgauntlet": { + "description": "The anti-espionage system of the Great Race.", + "wiki": "http://community.lacunaexpanse.com/wiki/gratch-s-gauntlet" + }, + "/kasternskeep": { + "description": "The place from which the Great Race commanded their armies.", + "wiki": "http://community.lacunaexpanse.com/wiki/kastern-s-keep" + }, + "/hallsofvrbansk": { + "description": "The source of ancient wisdom.", + "wiki": "http://community.lacunaexpanse.com/wiki/halls-of-vrbansk" + }, + "/libraryofjith": { + "description": "Where the Great Race kept records of their experiments.", + "wiki": "http://community.lacunaexpanse.com/wiki/library-of-jith" + }, + "/thedillonforge": { + "description": "Where raw ore formed into glyphs and the glyph buildings were born.", + "wiki": "http://community.lacunaexpanse.com/wiki/the-dillon-forge" + }, + "/blackholegenerator": { + "description": "An experimental singularity lab engineered by the Great Race.", + "wiki": "http://community.lacunaexpanse.com/wiki/black-hole-generator" + }, + "/supplypod": { + "description": "Used to hold emergency supplies on a damaged colony or on a fledgling colony.", + "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" + }, + "/subspacesupplydepot": { + "description": "Helps give a fledgling colony a kickstart.", + "wiki": "http://community.lacunaexpanse.com/wiki/subspace-supply-depot" + }, + "/pantheonofhagness": { + "description": "Increases the number of available plots on your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/pantheon-of-hagness" + }, + "/crashedshipsite": { + "description": "Harvest technology from a crashed ship to make your own ships better.", + "wiki": "http://community.lacunaexpanse.com/wiki/crashed-ship-site" + }, + "/citadelofknope": { + "description": "Enhances defensive value of your colony against hostile ships and reduces damage taken from fissure debris.", + "wiki": "http://community.lacunaexpanse.com/wiki/citadel-of-knope" + }, + "/ravine": { + "description": "A natural place to store waste.", + "wiki": "http://community.lacunaexpanse.com/wiki/ravine" + }, + "/fissure": { + "description": "The first sign of a dying planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/fissure" + }, + "/amalgusmeadow": { + "description": "A wild meadow filled with wild amalgus beans.", + "wiki": "http://community.lacunaexpanse.com/wiki/amalgus-meadow" + }, + "/dentonbrambles": { + "description": "A thorny patch of brambles, who's roots happen to be the delicious denton roots.", + "wiki": "http://community.lacunaexpanse.com/wiki/denton-brambles" + }, + "/malcudfield": { + "description": "A natural source of food.", + "wiki": "http://community.lacunaexpanse.com/wiki/malcud-field" + }, + "/lapisforest": { + "description": "A natural source of food.", + "wiki": "http://community.lacunaexpanse.com/wiki/lapis-forest" + }, + "/algaepond": { + "description": "A natural source of food.", + "wiki": "http://community.lacunaexpanse.com/wiki/algae-pond" + }, + "/beeldebannest": { + "description": "A natural source of food.", + "wiki": "http://community.lacunaexpanse.com/wiki/beeldeban-nest" + }, + "/geothermalvent": { + "description": "A natural source of energy from the planet's core.", + "wiki": "http://community.lacunaexpanse.com/wiki/geo-thermal-vent" + }, + "/naturalspring": { + "description": "A natural source of water from the planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/natural-spring" + }, + "/interdimensionalrift": { + "description": "The Great Race somehow learned a technique to create a pocket of subspace with a door into our world. This allowed them to store lots of resources, without taking up much space.", + "wiki": "http://community.lacunaexpanse.com/wiki/interdimensional-rift" + }, + "/templeofthedrajilites": { + "description": "The Temple of a group of star gazers from the Great Race. It was their belief that through ritual they could see other worlds.", + "wiki": "http://community.lacunaexpanse.com/wiki/temple-of-the-drajilites" + }, + "/sand": { + "description": "Decoration for your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/patch-of-sand" + }, + "/grove": { + "description": "Decoration for your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/grove-of-trees" + }, + "/lagoon": { + "description": "Decoration for your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/lagoon" + }, + "/kalavianruins": { + "description": "Attracts tourists and creates a sense of wonder for locals, increasing the happiness of your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/kalavian-ruins" + }, + "/essentiavein": { + "description": "Produces trace amounts of Essentia.", + "wiki": "http://community.lacunaexpanse.com/wiki/essentia-vein" + }, + "/volcano": { + "description": "A natural source of ore.", + "wiki": "http://community.lacunaexpanse.com/wiki/volcano" + }, + "/luxuryhousing": { + "description": "Produces more happiness than the Entertainment District, but costs more too.", + "wiki": "http://community.lacunaexpanse.com/wiki/luxury-housing" + }, + "/pilottraining": { + "description": "Increases speed and stealth of new piloted ships, and enables building Fighters.", + "wiki": "http://community.lacunaexpanse.com/wiki/pilot-training-facility" + }, + "/missioncommand": { + "description": "Lists available missions in your zone. You can view one mission per level of the Mission Command.", + "wiki": "http://community.lacunaexpanse.com/wiki/mission-command" + }, + "/cloakinglab": { + "description": "Increases the stealth of new ships.", + "wiki": "http://community.lacunaexpanse.com/wiki/cloaking-lab" + }, + "/munitionslab": { + "description": "Enables you to build the Detonator, Snark, and Seeker robotic war ships.", + "wiki": "http://community.lacunaexpanse.com/wiki/munitions-lab" + }, + "/crater": { + "description": "Decoration for your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/crater" + }, + "/rockyoutcrop": { + "description": "Decoration for your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/rocky-outcropping" + }, + "/lake": { + "description": "Decoration for your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/lake" + }, + "/beach1": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-1" + }, + "/beach2": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-2" + }, + "/beach3": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-3" + }, + "/beach4": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-4" + }, + "/beach5": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-5" + }, + "/beach6": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-6" + }, + "/beach7": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-7" + }, + "/beach8": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-8" + }, + "/beach9": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-9" + }, + "/beach10": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-10" + }, + "/beach11": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-11" + }, + "/beach12": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-12" + }, + "/beach13": { + "description": "Decoration for your planet. Use with other beach tiles to create a beach front.", + "wiki": "http://community.lacunaexpanse.com/wiki/beach-13" + }, + "/algae": { + "description": "Produces algae to be used as food by your empire. It also produces a small amount of energy and can be built in any orbit. The higher the level of the cropper the more food and energy it produces.", + "wiki": "http://community.lacunaexpanse.com/wiki/algae-cropper" + }, + "/apple": { + "description": "Allows you to grow apples to feed your empire. You can only grow apples in orbit 3 (its goldilox zone). Food production increases for every level of the orchard. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/apple-orchard" + }, + "/archaeology": { + "description": "Allows you to search through specific types of ore to find Glyphs.", + "wiki": "http://community.lacunaexpanse.com/wiki/archaeology-ministry" + }, + "/bean": { + "description": "Allows you to grow beans to be used as food by your empire. You can only grow beans in orbit 4 (its goldilox zone). The higher the level of the plantation the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/amalgus-bean-plantation" + }, + "/beeldeban": { + "description": "Allows the raising of beeldeban to be used as food for your empire. The higher the building level the more food is produced.", + "wiki": "http://community.lacunaexpanse.com/wiki/beeldeban-herder" + }, + "/bread": { + "description": "Converts wheat from the Wheat Farm at a minimal loss into bread to be used as food by your empire. The conversion rate increases with every level of the Bakery.", + "wiki": "http://community.lacunaexpanse.com/wiki/bakery" + }, + "/burger": { + "description": "Converts fungus from the Malcud Fungus Farm and produces burgers, at a small loss, to food. The higher the building level the more food is converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/burger-packer" + }, + "/capitol": { + "description": "Provides protection from Insurrection, and produces happiness.", + "wiki": "http://community.lacunaexpanse.com/wiki/capitol" + }, + "/cheese": { + "description": "Converts milk from the Dairy Farm into cheese at a small loss to be used as food. The higher the building level the more food is converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/cheese-maker" + }, + "/chip": { + "description": "Converts roots from the Denton Root Farm and turns it into root chips as food for your empire at a minimal loss. The higher the level of the Chip Frier the more food it converts.", + "wiki": "http://community.lacunaexpanse.com/wiki/denton-root-chip-frier" + }, + "/cider": { + "description": "Allows you to convert apples from the Apple Orchard into cider with a small amount of loss. The amount of apples converted into cider increases with the level of the building.", + "wiki": "http://community.lacunaexpanse.com/wiki/apple-cider-bottler" + }, + "/corn": { + "description": "Produces corn to be used as food by your empire. The corn plantation can only be used in orbits 2 and 3. The higher the level of the plantation the more food is produced. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/corn-plantation" + }, + "/cornmeal": { + "description": "Converts corn from the Corn Plantation into corn meal at a small loss to be used as food. The higher the building level the more food is converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/corn-meal-grinder" + }, + "/dairy": { + "description": "Allows you to produce food via dairy cattle. It can only be used in orbit 3 (its goldilox zone). The higher the level of farm the more food it produces. Cows require certain minerals in their diet in order to produce lots of high quality milk. Therefore in order to have a dairy farm you're going to need a good supply of trona.", + "wiki": "http://community.lacunaexpanse.com/wiki/dairy-farm" + }, + "/denton": { + "description": "Produces roots to be used as food by your empire. The roots only grow in orbits 5 and 6 (its goldilox zone). The higher the level of the patch the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/denton-root-patch" + }, + "/development": { + "description": "Allows you to monitor your build queue and subsidize the construction of buildings through the use of Essentia. The higher the level of the building the more buildings you can have in your queue, however the queue still builds in series not in parallel. The number of projects that can be placed in the queue is the level of the ministry plus 1. ", + "wiki": "http://community.lacunaexpanse.com/wiki/development-ministry" + }, + "/embassy": { + "description": "Allows the formation of alliances. It is also a prerequisite to building the Space Station. Each level of the Embassy allows 2 more members to join the alliance. Each level of the embassy allows 1 stash exchange per day, and 10,000 more resources per exchange.", + "wiki": "http://community.lacunaexpanse.com/wiki/embassy" + }, + "/energyreserve": { + "description": "Stores your energy with a minimal amount of loss. Increasing the level of the building raises the amount of energy stored.", + "wiki": "http://community.lacunaexpanse.com/wiki/energy-reserve" + }, + "/entertainment": { + "description": "Increases your empire's happiness by providing a place for your citizens to unwind through activities such as casinos, restaurants, clubs and other amusements. The higher the building level the more happiness is produced. It can also be a source of essentia through its lottery system.", + "wiki": "http://community.lacunaexpanse.com/wiki/entertainment-district" + }, + "/espionage": { + "description": "Allows the construction of spy pods and spy shuttles at the shipyard. It also allows better training of your spies. The higher the building level, the more effective your spies will be applying their trade. ", + "wiki": "http://community.lacunaexpanse.com/wiki/espionage-ministry" + }, + "/foodreserve": { + "description": "Stores your food with a minimal amount of spoilage. It also gives you a report of the types of food you have stored. Increasing the level of this building increases the amount of food that can be stored.", + "wiki": "http://community.lacunaexpanse.com/wiki/food-reserve" + }, + "/fission": { + "description": "Produces energy by splitting atoms. This way of producing energy is very efficient on an waste per energy produced ratio. The higher the building level the more energy is produced. Splitting the atoms non-energenic particles doesn't produce much power, so you'll need radioactive ore to power your fission plant, such as uraninite or monazite.", + "wiki": "http://community.lacunaexpanse.com/wiki/fission-energy-plant" + }, + "/fusion": { + "description": "Produces energy by fusing atoms together. This type of energy is even more efficient than the Fission Energy Plant on a waste per energy produced ratio. Requires a high level University to construct. The higher the building level the more energy is produced. Unfortunately the fusion plant produces enormous amounts of heat as well which requires coolants such as molten lead or salt. Therefore you'll need a good supply of galena or halite to build one.", + "wiki": "http://community.lacunaexpanse.com/wiki/fusion-energy-plant" + }, + "/gasgiantlab": { + "description": "Does research on the gas giant ship which deploys into a gas giant platform. The gas giant platform allows settlement of a gas giant. The higher the building level the higher the level of the platform deployed from the gas giant ship.", + "wiki": "http://community.lacunaexpanse.com/wiki/gas-giant-lab" + }, + "/gasgiantplatform": { + "description": "Increases the available plots on a gas giant.", + "wiki": "http://community.lacunaexpanse.com/wiki/gas-giant-settlement-platform" + }, + "/geo": { + "description": "Produces energy with a minimal amount of waste by using the planets own processes such as wind, waves, solar and geo thermal. The higher the level of the building the more energy is produced.", + "wiki": "http://community.lacunaexpanse.com/wiki/geo-energy-plant" + }, + "/hydrocarbon": { + "description": "Produces large amounts of energy at the cost of producing large amounts of waste by burning hydrocarbons. It also uses significant amounts of ore in the production of this energy. The higher the building level the more energy is produced. Hydrocarbon energy is derived from burning hydrocarbons, so you'll need a good supply of kerogen, methane, or anthracite in order to power it.", + "wiki": "http://community.lacunaexpanse.com/wiki/hydrocarbon-energy-plant" + }, + "/intelligence": { + "description": "Trains spies. You may train 3 spies per level of this building. You may only construct 1 Intelligence Ministry on a planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/intelligence-ministry" + }, + "/inteltraining": { + "description": "Trains spies in the ways of intelligence gathering. You may only construct 1 Intel Training Facility on a planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/intel-training-facility" + }, + "/lapis": { + "description": "Produces lapis to be used as food by your empire. Lapis can only be grown in orbit 2 (its goldilox zone). The higher the level of the orchard the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/lapis-orchard" + }, + "/malcud": { + "description": "Produces fungus to be used as food by your empire. The Farm also consumes a small amount of waste and can be built in any orbit. The higher the level of the farm the more food is produced and waste consumed.", + "wiki": "http://community.lacunaexpanse.com/wiki/malcud-fungus-farm" + }, + "/mayhemtraining": { + "description": "Trains spies in the art of destruction. You may only construct 1 Mayhem Training Facility on a planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/mayhem-training-facility" + }, + "/mercenariesguild": { + "description": "A black market for buying and selling well trained spies.", + "wiki": "http://community.lacunaexpanse.com/wiki/mercenaries-guild" + }, + "/mine": { + "description": "Extracts mineral from your planet in the form of ore. The amounts of each mineral extracted depends on the concentration and composition of the planet. The higher the level of the mine the more ore is extracted.", + "wiki": "http://community.lacunaexpanse.com/wiki/mine" + }, + "/miningministry": { + "description": "Allows you to harvest resources from asteroids. Allows the construction of Mining Platform Ships. Every two levels allows an additional Mining Platform. Each level increases the output of all Mining Platforms controlled by the Ministry.", + "wiki": "http://community.lacunaexpanse.com/wiki/mining-ministry" + }, + "/network19": { + "description": "Your empire's source for up to the minute news in your region of the Expanse. Get updates on what other empire's are doing and what you'd prefer they weren't doing. The Network 19 feed can be manipulated through the use of of espionage and political policy. Well informed people are happy people so the network also produces happiness. The higher the building level the more of the expanse you can get news from and the more happiness is produced. ", + "wiki": "http://community.lacunaexpanse.com/wiki/network-19-affiliate" + }, + "/observatory": { + "description": "Allows the construction of probes and colony ships at the shipyard. It also provides a list of all your active probes and the stars they are observing. A higher building level allows more probes to be constructed.", + "wiki": "http://community.lacunaexpanse.com/wiki/observatory" + }, + "/orerefinery": { + "description": "Increases the amount of ore extracted from each terrestrial ore producing structure by purifying the ore and producing less waste. The higher the refinery level the higher the purification process and even greater amounts of ore are extracted. The ore refinery requires sufficient amounts of either sulfur or fluorite being produced in order to process ore.", + "wiki": "http://community.lacunaexpanse.com/wiki/ore-refinery" + }, + "/orestorage": { + "description": "Store the ore that is pulled from the Mine. The higher the level of the building the more ore can be stored.", + "wiki": "http://community.lacunaexpanse.com/wiki/ore-storage-tanks" + }, + "/oversight": { + "description": "Reduces the amount of time buildings take to upgrade through better project management. All buildings will be produced 3% faster per level of the Oversight Ministry.", + "wiki": "http://community.lacunaexpanse.com/wiki/oversight-ministry" + }, + "/pancake": { + "description": "Converts potatoes from the Potato Plantation into pancakes at a minimal loss to be used as food by your empire. The higher the level of the factory, the more food is converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/pancake-factory" + }, + "/park": { + "description": "A place for your people to gather and enjoy nature or hold large scale public events. The Park allows you to throw parties for your citizens to increase their happiness. The more varieties of foods you bring to the party the more happiness is produced.", + "wiki": "http://community.lacunaexpanse.com/wiki/park" + }, + "/pie": { + "description": "Converts lapis from the Lapis Orchard into pies at minimal loss to be used as food by your empire. The higher the level of the bakery, the more food is converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/pie-bakery" + }, + "/planetarycommand": { + "description": "Houses the central government for your empire. This is your \"flag in the ground\" that lets everyone know you've staked your claim to a planet. It provides some basic resources and and storage for those resources both of which increase with the level of this building. The planetary command also provides some critical reports on your planetary activities such as total resource production and total resource storage for the planet it's constructed on.", + "wiki": "http://community.lacunaexpanse.com/wiki/planetary-command-center" + }, + "/politicstraining": { + "description": "Trains spies in the dark art of social engineering. You may only construct 1 Politics Training Facility on a planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/politics-training-facility" + }, + "/potato": { + "description": "Allows you to grow potatoes to be used as food for you empire. The patch can only be used in orbits 3 and 4 (its goldilox zone). The higher the level of the patch the more food it produces. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/potato-patch" + }, + "/propulsion": { + "description": "Allows your ships to move faster through space by way of upgraded engines. The higher the building level the faster your ships move. All ships originating from this planet are affected. In order to produce high performance engines you'll need a good supply of structural minerals such as rutile, chromite, bauxite, magnetite, beryl, or goethite.", + "wiki": "http://community.lacunaexpanse.com/wiki/propulsion-system-factory" + }, + "/security": { + "description": "Increases the effectiveness of your counter-spies and allows you to detect foreign spies. The higher the building level the more training your counter-spies receive. The building will be able to detect foreign spies with a level equal to or lower than the building. It will also help detect incoming ships containing spies.", + "wiki": "http://community.lacunaexpanse.com/wiki/security-ministry" + }, + "/shake": { + "description": "Converts the beeldeban that are harvested in the Beeldeban Herder into protein shakes, at a small loss, to be used as food. The higher the level of the factory the more food is converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/beeldeban-protein-shake-factory" + }, + "/shipyard": { + "description": "Constructs ships. The types of ships that can be built in the Shipyard are dependent on some of the other buildings on your planet. The higher the building level the faster ships are produced. In addition, you may queue one ship per level of shipyard.", + "wiki": "http://community.lacunaexpanse.com/wiki/shipyard" + }, + "/singularity": { + "description": "Produces energy by pulling it from subspace. This is the cleanest and most powerful form of energy in the universe. This is extremely expensive to build and requires a very high level University to construct. The higher the building level the more energy is produced.", + "wiki": "http://community.lacunaexpanse.com/wiki/singularity-energy-plant" + }, + "/soup": { + "description": "Converts beans from the Amalgus Bean Plantation at a minimal loss into soup to be used as food for your empire. The higher the level of the cannery the more soup is produced.", + "wiki": "http://community.lacunaexpanse.com/wiki/soup-cannery" + }, + "/spaceport": { + "description": "Acts as the hangar and control tower for your ships. Here is where you can monitor your ships that are in transit. Be careful as the Space Port can only hold a limited number of ships, if there is no more room in the Space Port when a ship arrives or is built, it will be destroyed. The Space Port can hold double its level in ships and queue its level in ships. ", + "wiki": "http://community.lacunaexpanse.com/wiki/space-port" + }, + "/stockpile": { + "description": "Allows resource buildings to go above level 20. Provides storage.", + "wiki": "http://community.lacunaexpanse.com/wiki/stockpile" + }, + "/syrup": { + "description": "Takes algae from the Algae Cropper and converts it in to Syrup with a small loss to be used as food. The higher the level of the bottler the more food is produced.", + "wiki": "http://community.lacunaexpanse.com/wiki/syrup-bottler" + }, + "/thefttraining": { + "description": "Trains spies in the art of appropriation. You may only construct 1 Theft Training Facility on a planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/theft-training-facility" + }, + "/terraforminglab": { + "description": "The Terraforming Lab is where research is done on the production of terraforming platform ships. Terraforming platform ships deploy into terraforming platforms which allows you to colonize planets your species wouldn't normally be capable of colonizing. The level of the building determines the level of the platform that is deployed from the ship.", + "wiki": "http://community.lacunaexpanse.com/wiki/terraforming-lab" + }, + "/terraformingplatform": { + "description": "Increases the available build space on a planet that is not naturally inhabitable by your species.", + "wiki": "http://community.lacunaexpanse.com/wiki/terraforming-platform" + }, + "/trade": { + "description": "Allows access to the interstellar market. Through it you can set up trades for resources with other empires. This building is a prerequisite to building cargo ships, which carry your trade goods, in the shipyard. The higher the building level the more resources your cargo ships can carry.", + "wiki": "http://community.lacunaexpanse.com/wiki/trade-ministry" + }, + "/transporter": { + "description": "Allows the instant transport of resources to a destination, but requires Essentia. The transporter also allows conversion of resources through trading with the Lacunans. The higher the building level the more goods can be transported.", + "wiki": "http://community.lacunaexpanse.com/wiki/subspace-transporter" + }, + "/university": { + "description": "Is the key to growth for your empire. Other buildings can not be upgraded higher than the university building level plus 1. Your university's level is empire wide where construction level of buildings on other planets is concerned. Many of the more powerful buildings that can be constructed require a very high level University. The University is also a source of happiness for your empire. ", + "wiki": "http://community.lacunaexpanse.com/wiki/university" + }, + "/wastedigester": { + "description": "Converts waste into ore. The higher the building level the more ore is produced and waste consumed.", + "wiki": "http://community.lacunaexpanse.com/wiki/waste-digester" + }, + "/wasteenergy": { + "description": "Produces energy by burning your empire's waste. Producing energy this way is far less efficient than other types of energy production, but the benefit is that waste is reduced. The higher the building level the more energy is produced and waste consumed. In order to build and maintain the blast furnace you need a good supply of insulating ores such as zircon, beryl, and gypsum.", + "wiki": "http://community.lacunaexpanse.com/wiki/waste-energy-plant" + }, + "/wasterecycling": { + "description": "Allows you to manually convert large batches of waste into energy, ore and water. The more waste you convert, the longer it will take to make the resources you want. The higher the level of the building the faster the conversion will take place. You can also spend a small amount of Essentia to convert the waste instantly.", + "wiki": "http://community.lacunaexpanse.com/wiki/waste-recycling-center" + }, + "/wasteexchanger": { + "description": "The Waste Exchanger is a combination of a waste recycling center, waste sequestration well, and a waste treatment center. It tears apart waste at a molecular level and recombines it into useful resources.", + "wiki": "http://community.lacunaexpanse.com/wiki/waste-exchanger" + }, + "/wastesequestration": { + "description": "Stores waste. Waste that is not stored turns into pollution and lowers your empire's happiness. The higher the building level the more waste can be stored.", + "wiki": "http://community.lacunaexpanse.com/wiki/waste-sequestration-well" + }, + "/wastetreatment": { + "description": "Converts waste into water, ore, and energy. Waste treatment requires special chemical compounds derived from halite, sulfur, and trona.", + "wiki": "http://community.lacunaexpanse.com/wiki/waste-treatment-center" + }, + "/waterproduction": { + "description": "Converts energy and ore into water. This is especially useful on planets with low concentrations of water. A higher building level means more resources are converted.", + "wiki": "http://community.lacunaexpanse.com/wiki/water-production-plant" + }, + "/waterpurification": { + "description": "Produces water from the planet's sources. The higher the building level the more water it can purify.", + "wiki": "http://community.lacunaexpanse.com/wiki/water-purification-plant" + }, + "/waterreclamation": { + "description": "Converts waste into water. A higher building level means more resources are converted. If you don't have a good supply of halite or sulfur you cannot treat waste water.", + "wiki": "http://community.lacunaexpanse.com/wiki/water-reclamation-facility" + }, + "/waterstorage": { + "description": "Stores the water you've collected. A higher building level allows more water to be stored.", + "wiki": "http://community.lacunaexpanse.com/wiki/water-storage-tank" + }, + "/wheat": { + "description": "Allows you to grow wheat on your planet. You can only grow wheat on planets that are in orbits 2, 3 or 4 (the goldilox zone). The Farm will produce more wheat for each level it is increased. All plants need a source of phosphorus to photosynthesize their food. Therefore you need a good source of gypsum, sulfur, or monazite for plants to thrive.", + "wiki": "http://community.lacunaexpanse.com/wiki/wheat-farm" + }, + "/lcota": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure. Be sure to place it where all the plots around it are unoccupied, and on a planet where you have 9 available plots.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcotb": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcotc": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcotd": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcote": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcotf": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcotg": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcoth": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + }, + "/lcoti": { + "description": "A self contained city that produces all it's own resources and waste management. It also produces a lot extra for you to use to support your other infrastructure.", + "wiki": "http://community.lacunaexpanse.com/wiki/lost-city-of-tyleon" + } + }, + "ships": { + "stake": { + "description": "Allows you to claim a planet prior to your colony ship arriving.", + "wiki": "http://community.lacunaexpanse.com/wiki/stake" + }, + "thud": { + "description": "Temporarily destroys plots on a planet's surface.", + "wiki": "http://community.lacunaexpanse.com/wiki/thud" + }, + "sweeper": { + "description": "An upgraded Fighter whose primary role is offense rather than defense.", + "wiki": "http://community.lacunaexpanse.com/wiki/sweeper" + }, + "supply_pod": { + "description": "Can deliver resources and creates temporary storage for 24 hours on a remote planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" + }, + "supply_pod2": { + "description": "A larger version of the Supply Pod.", + "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" + }, + "supply_pod3": { + "description": "A very large version of the Supply Pod.", + "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" + }, + "supply_pod4": { + "description": "A huge version of the Supply Pod.", + "wiki": "http://community.lacunaexpanse.com/wiki/supply-pod" + }, + "placebo": { + "description": "Use to fake an attack on another player.", + "wiki": "http://community.lacunaexpanse.com/wiki/placebo" + }, + "placebo2": { + "description": "A faster and more stealthed version of the Placebo.", + "wiki": "http://community.lacunaexpanse.com/wiki/placebo" + }, + "placebo3": { + "description": "A faster and more stealthed version of the Placebo II.", + "wiki": "http://community.lacunaexpanse.com/wiki/placebo" + }, + "placebo4": { + "description": "A faster and more stealthed version of the Placebo III.", + "wiki": "http://community.lacunaexpanse.com/wiki/placebo" + }, + "placebo5": { + "description": "A faster and more stealthed version of the Placebo IV.", + "wiki": "http://community.lacunaexpanse.com/wiki/placebo" + }, + "placebo6": { + "description": "A faster and more stealthed version of the Placebo V.", + "wiki": "http://community.lacunaexpanse.com/wiki/placebo" + }, + "probe": { + "description": "Allows you to view the bodies of a system if sent to a star. Probes are shared among members of the same alliance.", + "wiki": "http://community.lacunaexpanse.com/wiki/probe" + }, + "colony_ship": { + "description": "Use to create a new colony for your empire.", + "wiki": "http://community.lacunaexpanse.com/wiki/colony-ship" + }, + "short_range_colony_ship": { + "description": "Use to create a new colony for your empire. Very fast, but with a limited range. Useful within your own, or very close, star systems.", + "wiki": "http://community.lacunaexpanse.com/wiki/short-range-colony-ship" + }, + "spy_pod": { + "description": "Stealthy one way transport for a spy.", + "wiki": "http://community.lacunaexpanse.com/wiki/spy-pod" + }, + "cargo_ship": { + "description": "Medium transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/cargo-ship" + }, + "space_station": { + "description": "The base hull upon which you can build space station modules to build a complete space station.", + "wiki": "http://community.lacunaexpanse.com/wiki/space-station" + }, + "smuggler_ship": { + "description": "Stealthy transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/smuggler-ship" + }, + "mining_platform_ship": { + "description": "Allows the gathering of resources from asteroids.", + "wiki": "http://community.lacunaexpanse.com/wiki/mining-platform-ship" + }, + "terraforming_platform_ship": { + "description": "Allows you to settle planets your species could not normally colonize.", + "wiki": "http://community.lacunaexpanse.com/wiki/terraforming-platform-ship" + }, + "gas_giant_settlement_ship": { + "description": "Allows you to settle gas giants.", + "wiki": "http://community.lacunaexpanse.com/wiki/gas-giant-settlement-ship" + }, + "scow": { + "description": "Robotic waste transport ship. Can be used to dispose of waste in space.", + "wiki": "http://community.lacunaexpanse.com/wiki/scow" + }, + "scow_fast": { + "description": "Much faster than a normal scow. Robotic waste transport ship. Can be used to dispose of waste in space.", + "wiki": "http://community.lacunaexpanse.com/wiki/scow" + }, + "scow_large": { + "description": "Much larger and a bit slower than a normal scow. Robotic waste transport ship. Can be used to dispose of waste in space.", + "wiki": "http://community.lacunaexpanse.com/wiki/scow" + }, + "scow_mega": { + "description": "Incredibly larger and slower than a normal scow. Almost useless as an attack. Robotic waste transport ship. Can be used to dispose of waste in space.", + "wiki": "http://community.lacunaexpanse.com/wiki/scow" + }, + "bleeder": { + "description": "Robotic war ship. Once deployed on enemy planet, starts stealing resources and converting them into waste.", + "wiki": "http://community.lacunaexpanse.com/wiki/bleeder" + }, + "dory": { + "description": "Small transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/dory" + }, + "barge": { + "description": "Versatile transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/barge" + }, + "galleon": { + "description": "Fast medium transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/galleon" + }, + "hulk": { + "description": "Extra large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/hulk" + }, + "hulk_fast": { + "description": "Extra large transport ship slightly bigger and much faster than a Hulk. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/hulk" + }, + "hulk_huge": { + "description": "Incredibly large and very slow transport ship, useful for supply chains. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/hulk" + }, + "fissure_sealer": { + "description": "Large slow ship, used to attempt sealing fissures on uninhabited planets.", + "wiki": "http://community.lacunaexpanse.com/wiki/fissure-sealer" + }, + "freighter": { + "description": "Large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", + "wiki": "http://community.lacunaexpanse.com/wiki/freighter" + }, + "snark": { + "description": "Single-use robotic bombardment weapon, that can be used to damage buildings on remote planets.", + "wiki": "http://community.lacunaexpanse.com/wiki/snark" + }, + "snark2": { + "description": "An improved version of the Snark, which has four warheads", + "wiki": "http://community.lacunaexpanse.com/wiki/snark" + }, + "snark3": { + "description": "An improved version of the Snark, which has nine warheads", + "wiki": "http://community.lacunaexpanse.com/wiki/snark" + }, + "drone": { + "description": "Single use robotic defense weapon, that can stop enemy attacks before they reach your planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/drone" + }, + "fighter": { + "description": "Piloted defense ship that can stop enemy attacks before they reach your planet. Can also be sent to defend other bodies.", + "wiki": "http://community.lacunaexpanse.com/wiki/fighter" + }, + "spy_shuttle": { + "description": "Stealthy transport for up to four spies, that can orbit the target body waiting to pick the spies back up.", + "wiki": "http://community.lacunaexpanse.com/wiki/spy-shuttle" + }, + "observatory_seeker": { + "description": "Variant of the Snark that attacks an Observatory.", + "wiki": "http://community.lacunaexpanse.com/wiki/observatory-seeker" + }, + "security_ministry_seeker": { + "description": "Variant of the Snark that attacks a Security Ministry.", + "wiki": "http://community.lacunaexpanse.com/wiki/security-ministry-seeker" + }, + "spaceport_seeker": { + "description": "Variant of the Snark that attacks a SpacePort.", + "wiki": "http://community.lacunaexpanse.com/wiki/spaceport-seeker" + }, + "excavator": { + "description": "Robotic explorer that searches remote bodies looking for artifacts.", + "wiki": "http://community.lacunaexpanse.com/wiki/excavator" + }, + "detonator": { + "description": "Variant of the Snark that detonates in an electromagnetic pulse, which can be used to destroy probes, mining platforms, or excavators.", + "wiki": "http://community.lacunaexpanse.com/wiki/detonator" + }, + "surveyor": { + "description": "Robotic explorer that snaps a photograph of the surface of a remote planet, and also identifies the buildings in the photograph.", + "wiki": "http://community.lacunaexpanse.com/wiki/surveyor" + }, + "scanner": { + "description": "Robotic explorer that snaps a photograph of the surface of a remote planet.", + "wiki": "http://community.lacunaexpanse.com/wiki/scanner" + } + }, + "tips": [ + "Water Purification Plants are cheap, but slow. If you can afford them, Water Production Plants produce more water.", + "You need at least 3 food types to keep your people happy.", + "Building a Development Ministry will let you queue multiple buildings at once.", + "Buildings are built in series. So if you already have a building upgrading that will take 20 minutes, and you add a building that takes 15 seconds, the second building will take 20:15.", + "Buildings have both a cost and an upkeep. Cost is what it costs to build/upgrade the building. Upkeep is what it costs per hour to run the building.", + "If you have at least 4 food types, every time you build something you'll gain happiness.", + "You can use Essentia in the Development Ministry to auto-complete your entire build queue.", + "If your waste overflows it will create pollution, and that will make your people unhappy.", + "A good build strategy is to upgrade your storage first, then your resource generators, then your University.", + "Try to make sure your resource production will completely fill your available storage at least once per day.", + "If you run out of resources, your people will not be happy.", + "Construction and upgrades produce bulk waste all at once. Be sure you can store it, or the pollution it generates will make your citizens unhappy.", + "Though the planet map shows 121 spaces for buildings, each planet is limited to a certain number of plots. You can see how many plots are remaining in the Planetary Command Center.", + "In order to manage waste or recycle it, you must first store it. Build a Waste Sequestration Well to store waste.", + "Waste can be a very valuable resource. Build waste management buildings like Waste Reclamation, Waste Treatement, or Waste Digesters to turn it into useful resources.", + "You can use Essentia in the Waste Recycling Plant to instantly complete the recycling process.", + "We recommend at least 2 of each type of storage on every planet.", + "If you invite your friends to the game, and a few of them sign up, you'll start getting special buildings as rewards.", + "You can use Essentia in the Shipyard to auto-complete your entire build queue.", + "Knowledge gained from the University is permanent. Even if you demolish the University you still have the knowledge.", + "While you are waiting for your building upgrades to complete, build and send out probes to see what's around you.", + "Building an Oversight Ministry will speed up all of your building build/upgrade times.", + "You can win free Essentia in the Lottery at the Entertainment District.", + "Both the cost and production of buildings rise expontentially. Production rises slightly slower than cost however.", + "As an isolationist you are immune to attack. You are no longer an isolationist if you colonize a second planet, or build an Espionage Ministry or Munitions Lab.", + "Most ships are one use only, meaning once you send them you cannot get them back. Exceptions to this are trade ships like Dories and Cargo Ships.", + "Looking to the future you may want to upgrade your existing energy plants with newer technology as it becomes available.", + "You can use Essentia in the Intelligence Ministry to train spies instantly.", + "It costs 100,000 happiness to colonize your second planet, but it gets much more difficult for each subsequent colony.", + "You can use Essentia in the Park to speed along parties.", + "The University is global. The level of University you built on one planet affects all your planets. The University is the only building that has this ability.", + "As soon as a colony ship arrives at a new planet it begins functioning. Be prepared to deal with it when the ship arrives.", + "When choosing a planet to colonize things to consider are its size, distance from your other colonies, distance from asteroids, ore composition, and water composition.", + "Make sure you have some dories available when you colonize a planet so you can ship resources to the new colony to give it a head start.", + "You can use Essentia in the Subspace Transporter to do instant 1:1 trades of any resource.", + "Spies are the primary form of combat in the game. Send spies to other people's planets and you'll be able to gather information, sabotage infastructure, and steal resources from them.", + "Though you can lose colonies to spies, you cannot ever lose your home planet.", + "Some ores are only found in abundance on asteroids.", + "Resource buildings can only go to level 20, while all other buildings can go to level 30.", + "Glyphs enable you to build incredibly powerful buildings that aren't part of the normal technology tree.", + "You can use Essentia in the Archaeology Ministry to search for glyphs instantly.", + "Drones, Fighters, and Sweepers defend your planet from other players ships.", + "Spies defend your planet from other players spies.", + "Glyph buildings take up no plots.", + "Higher level Spaceports can tell you more information about ships that are coming in from other players.", + "A higher level Security Ministry increases the chance of catching enemy spies as they come and go from your planet.", + "A higher level Security Ministry allows you to see more detail about the enemy spies that are on your planet.", + "You can make a new planet your home planet by building a Capitol building." + ], + "writ_templates": [ + { + "title": "Non-Agression Mandate", + "description": "Planets in this jurisdiction may not attack anyone inside the jurisdiction." + }, + { + "title": "No Munitions", + "description": "Planets in this jurisdiction, except for members of ______ alliance are not allowed to build a Munitions Lab. If you are found with one the penalty shall be _______." + }, + { + "title": "No Operatives", + "description": "Planets in this jurisdiction, except for members of ______ alliance are not allowed to build an Espionage Ministry. If you are found with one the penalty shall be _______." + }, + { + "title": "Defense Mandate", + "description": "Planets in this jurisdiction are required to come to the aid of the other planets in this jurisdiction when under attack from both foreign and domestic enemies." + }, + { + "title": "Confederacy with ______", + "description": "_______ alliance declares a mutual confederation with _______ alliance." + }, + { + "title": "NAP with ______", + "description": "_______ alliance declares a non-aggression pact with _______ alliance." + }, + { + "title": "Declaration of War", + "description": "_______ alliance declares war on ______ alliance. All citizens in this jurisdiction are required to supply the war effort with all available ships, operatives, and aid packages." + }, + { + "title": "Censure of ______", + "description": "We, the members of _______ alliance, hereby declare a formal reprimand of _______ for __________________." + }, + { + "title": "Glyph Heresy", + "description": "_______ alliance hereby denounces the existence of the Great Race. Anyone in our jurisdiction found using glyph technology shall be treated cruelly and without mercy." + } + ] } diff --git a/app/load.ts b/app/load.ts index a71aa9e7..0cae3391 100644 --- a/app/load.ts +++ b/app/load.ts @@ -28,30 +28,30 @@ import 'app/yui/notify'; declare const YAHOO: any; const init = () => { - // TODO this code can be improved. - let l = window.location; - let query = {}; - let vars = l.hash.substring(1).split('&'); - if (vars.length > 0) { - for (let i = 0; i < vars.length; i++) { - let pair = vars[i].split('='); - query[pair[0]] = decodeURIComponent(pair[1]); - } - } - if (window.history.replaceState) { - window.history.replaceState( - {}, - document.title, - l.protocol + '//' + l.host + l.pathname + l.search - ); - } else if (l.hash !== '') { - l.hash = ''; + // TODO this code can be improved. + let l = window.location; + let query = {}; + let vars = l.hash.substring(1).split('&'); + if (vars.length > 0) { + for (let i = 0; i < vars.length; i++) { + let pair = vars[i].split('='); + query[pair[0]] = decodeURIComponent(pair[1]); } + } + if (window.history.replaceState) { + window.history.replaceState( + {}, + document.title, + l.protocol + '//' + l.host + l.pathname + l.search + ); + } else if (l.hash !== '') { + l.hash = ''; + } - // Start everything! - YAHOO.util.Event.throwErrors = true; - YAHOO.widget.Logger.enableBrowserConsole(); - YAHOO.lacuna.Game.Start(query); + // Start everything! + YAHOO.util.Event.throwErrors = true; + YAHOO.widget.Logger.enableBrowserConsole(); + YAHOO.lacuna.Game.Start(query); }; $(init); diff --git a/app/server.ts b/app/server.ts index a25f002c..271ec446 100644 --- a/app/server.ts +++ b/app/server.ts @@ -11,143 +11,143 @@ import SessionStore from 'app/stores/session'; import WindowsStore from 'app/stores/windows'; interface ServerRequest { - module: string; - method: string; - params?: object; - success?: Function; - error?: Function; - addSession?: boolean; + module: string; + method: string; + params?: object; + success?: Function; + error?: Function; + addSession?: boolean; } const addSession = function (options: ServerRequest): ServerRequest { - let sessionId = SessionStore.session; - - if (options.addSession === true && sessionId) { - if (_.isArray(options.params)) { - options.params = [sessionId].concat(options.params); - } else { - options.params.session_id = sessionId; - } + let sessionId = SessionStore.session; + + if (options.addSession === true && sessionId) { + if (_.isArray(options.params)) { + options.params = [sessionId].concat(options.params); + } else { + options.params.session_id = sessionId; } + } - return options; + return options; }; let handleParams = function (options: ServerRequest) { - options = _.merge({ addSession: true, params: [] }, options); - if (typeof options.addSession === 'undefined') { - options.addSession = true; - } - - if (typeof options.params === 'undefined') { - options.params = []; - } - - // If there was only one parameter passed and it's an object, it's fine. Otherwise make it into - // an array to be sent off. - if (!_.isObject(options.params) && !_.isArray(options.params)) { - options.params = [options.params]; - } - - return addSession(options); + options = _.merge({ addSession: true, params: [] }, options); + if (typeof options.addSession === 'undefined') { + options.addSession = true; + } + + if (typeof options.params === 'undefined') { + options.params = []; + } + + // If there was only one parameter passed and it's an object, it's fine. Otherwise make it into + // an array to be sent off. + if (!_.isObject(options.params) && !_.isArray(options.params)) { + options.params = [options.params]; + } + + return addSession(options); }; let createData = function (options: ServerRequest) { - return JSON.stringify({ - jsonrpc: '2.0', - id: 1, - method: options.method, - params: options.params, - }); + return JSON.stringify({ + jsonrpc: '2.0', + id: 1, + method: options.method, + params: options.params, + }); }; let createUrl = function (options: ServerRequest) { - return constants.RPC_BASE + options.module; + return constants.RPC_BASE + options.module; }; let handleSuccess = function (options: ServerRequest, result: any) { - if (result) { - if (result.status) { - splitStatus(result.status); - } else if (options.method === 'get_status') { - splitStatus(result); - } + if (result) { + if (result.status) { + splitStatus(result.status); + } else if (options.method === 'get_status') { + splitStatus(result); } + } - if (typeof options.success === 'function') { - options.success(result); - } + if (typeof options.success === 'function') { + options.success(result); + } }; let handleError = function (options: ServerRequest, error: any) { - window.alert(error.message + ' (' + error.code + ')'); - console.error('Request error: ', error); + window.alert(error.message + ' (' + error.code + ')'); + console.error('Request error: ', error); - if (typeof options.error === 'function') { - options.error(error); - } + if (typeof options.error === 'function') { + options.error(error); + } }; let sendRequest = function (url: string, data: any, options: ServerRequest, retry: Function) { - console.log('Calling', options.module + '/' + options.method, options.params); - - $.ajax({ - data: data, - dataType: 'json', - type: 'POST', - contentType: 'application/json', - url: url, - - success: function (data, textStatus, jqXHR) { - MenuStore.showLoader(); - - let dataToEmit = util.fixNumbers(data.result); - - if (textStatus === 'success' && jqXHR.status === 200) { - handleSuccess(options, dataToEmit); - } - }, - - error: function (jqXHR) { - MenuStore.hideLoader(); - let error = {}; - - if (typeof jqXHR.responseJSON === 'undefined') { - error = { - code: -1, - message: jqXHR.responseText, - }; - } else { - error = jqXHR.responseJSON.error; - } - - let fail = function () { - handleError(options, error); - }; - - if (error.code === 1016) { - WindowsStore.add('captcha', { - success: retry, - }); - } else { - fail(); - } - }, - }); + console.log('Calling', options.module + '/' + options.method, options.params); + + $.ajax({ + data: data, + dataType: 'json', + type: 'POST', + contentType: 'application/json', + url: url, + + success: function (data, textStatus, jqXHR) { + MenuStore.showLoader(); + + let dataToEmit = util.fixNumbers(data.result); + + if (textStatus === 'success' && jqXHR.status === 200) { + handleSuccess(options, dataToEmit); + } + }, + + error: function (jqXHR) { + MenuStore.hideLoader(); + let error = {}; + + if (typeof jqXHR.responseJSON === 'undefined') { + error = { + code: -1, + message: jqXHR.responseText, + }; + } else { + error = jqXHR.responseJSON.error; + } + + let fail = function () { + handleError(options, error); + }; + + if (error.code === 1016) { + WindowsStore.add('captcha', { + success: retry, + }); + } else { + fail(); + } + }, + }); }; export const call = function (obj: ServerRequest) { - MenuStore.showLoader(); + MenuStore.showLoader(); - const options = handleParams(obj); - const data = createData(options); - const url = createUrl(options); + const options = handleParams(obj); + const data = createData(options); + const url = createUrl(options); - const retry = function () { - call(obj); - }; + const retry = function () { + call(obj); + }; - sendRequest(url, data, options, retry); + sendRequest(url, data, options, retry); }; // @@ -155,18 +155,18 @@ export const call = function (obj: ServerRequest) { // and call the corresponding actions // export const splitStatus = function (status: any) { - if (status.server) { - let serverStatus = util.fixNumbers(_.cloneDeep(status.server)); - ServerRPCStore.update(serverStatus); - } - if (status.empire) { - let empireStatus = util.fixNumbers(_.cloneDeep(status.empire)); - EmpireRPCStore.update(empireStatus); - } - if (status.body) { - let bodyStatus = util.fixNumbers(_.cloneDeep(status.body)); - BodyRPCStore.update(bodyStatus); - } + if (status.server) { + let serverStatus = util.fixNumbers(_.cloneDeep(status.server)); + ServerRPCStore.update(serverStatus); + } + if (status.empire) { + let empireStatus = util.fixNumbers(_.cloneDeep(status.empire)); + EmpireRPCStore.update(empireStatus); + } + if (status.body) { + let bodyStatus = util.fixNumbers(_.cloneDeep(status.body)); + BodyRPCStore.update(bodyStatus); + } }; export default { call, splitStatus }; diff --git a/app/services/empire.ts b/app/services/empire.ts index c29a7bd8..11ba6a94 100644 --- a/app/services/empire.ts +++ b/app/services/empire.ts @@ -7,60 +7,60 @@ import * as vex from 'app/vex'; declare const YAHOO: any; class EmpireService { - getBoosts() { - server.call({ - module: 'empire', - method: 'get_boosts', - params: [], - success: (result: any) => { - BoostsRPCStore.update(result); - }, - }); - } + getBoosts() { + server.call({ + module: 'empire', + method: 'get_boosts', + params: [], + success: (result: any) => { + BoostsRPCStore.update(result); + }, + }); + } - getInviteFriendUrl() { - server.call({ - module: 'empire', - method: 'invite_friend', - params: [], - success: (result: any) => { - InviteRPCStore.update(result); - }, - }); - } + getInviteFriendUrl() { + server.call({ + module: 'empire', + method: 'invite_friend', + params: [], + success: (result: any) => { + InviteRPCStore.update(result); + }, + }); + } - inviteFriend(email: string, message: string) { - server.call({ - module: 'empire', - method: 'get_invite_friend_url', - params: { - email: email, - custom_message: message, - }, - success: () => { - vex.alert('Invite email sent!'); - }, - }); - } + inviteFriend(email: string, message: string) { + server.call({ + module: 'empire', + method: 'get_invite_friend_url', + params: { + email: email, + custom_message: message, + }, + success: () => { + vex.alert('Invite email sent!'); + }, + }); + } - login() { - // - } + login() { + // + } - logout() { - server.call({ - module: 'empire', - method: 'logout', - success: () => { - YAHOO.lacuna.Game.Reset(); - YAHOO.lacuna.MapPlanet.Reset(); - YAHOO.lacuna.Game.DoLogin(); + logout() { + server.call({ + module: 'empire', + method: 'logout', + success: () => { + YAHOO.lacuna.Game.Reset(); + YAHOO.lacuna.MapPlanet.Reset(); + YAHOO.lacuna.Game.DoLogin(); - // Hide all our tooltips - ReactTooltip.hide(); - }, - }); - } + // Hide all our tooltips + ReactTooltip.hide(); + }, + }); + } } export default new EmpireService(); diff --git a/app/services/genericBuilding.ts b/app/services/genericBuilding.ts index 10bc8478..15a56a21 100644 --- a/app/services/genericBuilding.ts +++ b/app/services/genericBuilding.ts @@ -2,17 +2,17 @@ import server from 'app/server'; import GenericBuildingRPCStore from 'app/stores/rpc/genericBuilding'; class GenericBuildingService { - view(url: string, id: string) { - GenericBuildingRPCStore.clear(); - server.call({ - module: url.replace(/^\//, ''), - method: 'view', - params: [id], - success: (result: any) => { - GenericBuildingRPCStore.update(result); - }, - }); - } + view(url: string, id: string) { + GenericBuildingRPCStore.clear(); + server.call({ + module: url.replace(/^\//, ''), + method: 'view', + params: [id], + success: (result: any) => { + GenericBuildingRPCStore.update(result); + }, + }); + } } export default new GenericBuildingService(); diff --git a/app/services/stats.ts b/app/services/stats.ts index 6c45210f..22cf1bdf 100644 --- a/app/services/stats.ts +++ b/app/services/stats.ts @@ -2,16 +2,16 @@ import CreditsRPCStore from 'app/stores/rpc/stats/credits'; import server from 'app/server'; class StatsService { - getCredits() { - server.call({ - module: 'stats', - method: 'credits', - params: [], - success: (result: any) => { - CreditsRPCStore.update(result); - }, - }); - } + getCredits() { + server.call({ + module: 'stats', + method: 'credits', + params: [], + success: (result: any) => { + CreditsRPCStore.update(result); + }, + }); + } } export default new StatsService(); diff --git a/app/stores/menu.ts b/app/stores/menu.ts index f9a32151..7660998c 100644 --- a/app/stores/menu.ts +++ b/app/stores/menu.ts @@ -6,66 +6,66 @@ export const PLANET_MAP_MODE = 'planetMap'; export const STAR_MAP_MODE = 'starMap'; class MenuStore { - menuShown: boolean = false; - leftSidebarShown: boolean = false; - rightSidebarShown: boolean = false; - loaderShwon: boolean = false; - mapMode: MapMode = PLANET_MAP_MODE; - planetId: number = 0; - - constructor() { - makeAutoObservable(this); - } - - showMenu() { - this.menuShown = true; - } - - hideMenu() { - this.menuShown = false; - } - - showPlanetMap() { - this.mapMode = PLANET_MAP_MODE; - } - - showStarMap() { - this.mapMode = STAR_MAP_MODE; - } - - toggleMapMode() { - this.mapMode = this.mapMode == PLANET_MAP_MODE ? STAR_MAP_MODE : PLANET_MAP_MODE; - } - - changePlanet(id: number) { - console.log('Changing to planet (#' + id + ').'); - this.mapMode = PLANET_MAP_MODE; - this.planetId = id; - } - - showLeftSidebar() { - this.leftSidebarShown = true; - } - - hideLeftSidebar() { - this.leftSidebarShown = false; - } - - showRightSidebar() { - this.rightSidebarShown = true; - } - - hideRightSidebar() { - this.rightSidebarShown = false; - } - - showLoader() { - this.loaderShwon = true; - } - - hideLoader() { - this.loaderShwon = false; - } + menuShown: boolean = false; + leftSidebarShown: boolean = false; + rightSidebarShown: boolean = false; + loaderShwon: boolean = false; + mapMode: MapMode = PLANET_MAP_MODE; + planetId: number = 0; + + constructor() { + makeAutoObservable(this); + } + + showMenu() { + this.menuShown = true; + } + + hideMenu() { + this.menuShown = false; + } + + showPlanetMap() { + this.mapMode = PLANET_MAP_MODE; + } + + showStarMap() { + this.mapMode = STAR_MAP_MODE; + } + + toggleMapMode() { + this.mapMode = this.mapMode == PLANET_MAP_MODE ? STAR_MAP_MODE : PLANET_MAP_MODE; + } + + changePlanet(id: number) { + console.log('Changing to planet (#' + id + ').'); + this.mapMode = PLANET_MAP_MODE; + this.planetId = id; + } + + showLeftSidebar() { + this.leftSidebarShown = true; + } + + hideLeftSidebar() { + this.leftSidebarShown = false; + } + + showRightSidebar() { + this.rightSidebarShown = true; + } + + hideRightSidebar() { + this.rightSidebarShown = false; + } + + showLoader() { + this.loaderShwon = true; + } + + hideLoader() { + this.loaderShwon = false; + } } export default new MenuStore(); diff --git a/app/stores/rpc/body.ts b/app/stores/rpc/body.ts index 4aa613f8..c7ea5439 100644 --- a/app/stores/rpc/body.ts +++ b/app/stores/rpc/body.ts @@ -5,255 +5,245 @@ import * as util from 'app/util'; let int = util.int; class BodyRPCStore { - id = 0; - x = 0; - y = 0; - star_id = ''; - star_name = ''; - orbit = 0; - type = ''; - name = ''; - image = ''; - size = 0; - water = 0; - ore = { - anthracite: 0, - bauxite: 0, - beryl: 0, - chromite: 0, - chalcopyrite: 0, - fluorite: 0, - galena: 0, - goethite: 0, - gold: 0, - gypsum: 0, - halite: 0, - kerogen: 0, - magnetite: 0, - methane: 0, - monazite: 0, - rutile: 0, - sulfur: 0, - trona: 0, - uraninite: 0, - zircon: 0, + id = 0; + x = 0; + y = 0; + star_id = ''; + star_name = ''; + orbit = 0; + type = ''; + name = ''; + image = ''; + size = 0; + water = 0; + ore = { + anthracite: 0, + bauxite: 0, + beryl: 0, + chromite: 0, + chalcopyrite: 0, + fluorite: 0, + galena: 0, + goethite: 0, + gold: 0, + gypsum: 0, + halite: 0, + kerogen: 0, + magnetite: 0, + methane: 0, + monazite: 0, + rutile: 0, + sulfur: 0, + trona: 0, + uraninite: 0, + zircon: 0, + }; + empire = { + id: '', + name: '', + alignment: '', + is_isolationist: 0, + }; + station = { + id: 0, + x: 0, + y: 0, + name: '', + }; + needs_surface_refresh = 0; + building_count = 0; + build_queue_size = 0; + build_queue_len = 0; + plots_available = 0; + happiness = 0; + happiness_hour = 0; + unhappy_date = '01 13 2014 16:11:21 +0600'; + neutral_entry = '01 13 2014 16:11:21 +0600'; + propaganda_boost = 0; + food_stored = 0; + food_capacity = 0; + food_hour = 0; + energy_stored = 0; + energy_capacity = 0; + energy_hour = 0; + ore_hour = 0; + ore_capacity = 0; + ore_stored = 0; + waste_hour = 0; + waste_stored = 0; + waste_capacity = 0; + water_stored = 0; + water_hour = 0; + water_capacity = 0; + skip_incoming_ships = 0; + num_incoming_enemy = 0; + num_incoming_ally = 0; + num_incoming_own = 0; + incoming_enemy_ships = []; + incoming_ally_ships = []; + incoming_own_ships = []; + alliance = { + id: '', + name: '', + }; + influence = { + total: 0, + spent: 0, + }; + + constructor() { + makeAutoObservable(this); + } + + clear() {} + + update(body: any) { + this.id = body.id; + this.x = int(body.x); + this.y = int(body.y); + this.star_id = body.star_id; + this.star_name = body.star_name; + this.orbit = int(body.orbit); + this.type = body.type; + this.name = body.name; + this.image = body.image; + this.size = body.size; + this.water = body.water; + + this.ore.anthracite = body.ore.anthracite; + this.ore.bauxite = body.ore.bauxite; + this.ore.beryl = body.ore.beryl; + this.ore.chromite = body.ore.chromite; + this.ore.chalcopyrite = body.ore.chalcopyrite; + this.ore.fluorite = body.ore.fluorite; + this.ore.galena = body.ore.galena; + this.ore.goethite = body.ore.goethite; + this.ore.gold = body.ore.gold; + this.ore.gypsum = body.ore.gypsum; + this.ore.halite = body.ore.halite; + this.ore.kerogen = body.ore.kerogen; + this.ore.magnetite = body.ore.magnetite; + this.ore.methane = body.ore.methane; + this.ore.monazite = body.ore.monazite; + this.ore.rutile = body.ore.rutile; + this.ore.sulfur = body.ore.sulfur; + this.ore.trona = body.ore.trona; + this.ore.uraninite = body.ore.uraninite; + this.ore.zircon = body.ore.zircon; + + this.empire.id = body.empire.id; + this.empire.name = body.empire.name; + this.empire.alignment = body.empire.alignment; + this.empire.is_isolationist = body.empire.is_isolationist; + this.station.id = body.station.id; + this.station.x = body.station.x; + this.station.y = body.station.y; + this.station.name = body.station.name; + this.needs_surface_refresh = body.needs_surface_refresh; + this.building_count = int(body.building_count); + this.build_queue_size = body.build_queue_size; + this.build_queue_len = body.build_queue_len; + this.plots_available = int(body.plots_available); + this.happiness = body.happiness; + this.happiness_hour = body.happiness_hour; + this.unhappy_date = body.unhappy_date; + this.neutral_entry = body.neutral_entry; + this.propaganda_boost = body.propaganda_boost; + this.food_stored = body.food_stored; + this.food_capacity = body.food_capacity; + this.food_hour = body.food_hour; + this.energy_stored = body.energy_stored; + this.energy_capacity = body.energy_capacity; + this.energy_hour = body.energy_hour; + this.ore_hour = body.ore_hour; + this.ore_capacity = body.ore_capacity; + this.ore_stored = body.ore_stored; + this.waste_hour = body.waste_hour; + this.waste_stored = body.waste_stored; + this.waste_capacity = body.waste_capacity; + this.water_stored = body.water_stored; + this.water_hour = body.water_hour; + this.water_capacity = body.water_capacity; + this.skip_incoming_ships = body.skip_incoming_ships; + this.num_incoming_own = int(body.num_incoming_own); + this.num_incoming_ally = int(body.num_incoming_ally); + this.num_incoming_enemy = int(body.num_incoming_enemy); + this.incoming_enemy_ships = body.incoming_enemy_ships; + this.incoming_ally_ships = body.incoming_ally_ships; + this.incoming_own_ships = body.incoming_own_ships; + this.alliance = body.alliance; + this.influence = body.influence; + + let updateShip = function (ship: any) { + ship.arrival_ms = util.serverDateToMs(ship.date_arrives) - ServerRPCStore.serverTimeMs; + return ship; }; - empire = { - id: '', - name: '', - alignment: '', - is_isolationist: 0, - }; - station = { - id: 0, - x: 0, - y: 0, - name: '', - }; - needs_surface_refresh = 0; - building_count = 0; - build_queue_size = 0; - build_queue_len = 0; - plots_available = 0; - happiness = 0; - happiness_hour = 0; - unhappy_date = '01 13 2014 16:11:21 +0600'; - neutral_entry = '01 13 2014 16:11:21 +0600'; - propaganda_boost = 0; - food_stored = 0; - food_capacity = 0; - food_hour = 0; - energy_stored = 0; - energy_capacity = 0; - energy_hour = 0; - ore_hour = 0; - ore_capacity = 0; - ore_stored = 0; - waste_hour = 0; - waste_stored = 0; - waste_capacity = 0; - water_stored = 0; - water_hour = 0; - water_capacity = 0; - skip_incoming_ships = 0; - num_incoming_enemy = 0; - num_incoming_ally = 0; - num_incoming_own = 0; - incoming_enemy_ships = []; - incoming_ally_ships = []; - incoming_own_ships = []; - alliance = { - id: '', - name: '', - }; - influence = { - total: 0, - spent: 0, - }; - - constructor() { - makeAutoObservable(this); - } - - clear() {} - - update(body: any) { - this.id = body.id; - this.x = int(body.x); - this.y = int(body.y); - this.star_id = body.star_id; - this.star_name = body.star_name; - this.orbit = int(body.orbit); - this.type = body.type; - this.name = body.name; - this.image = body.image; - this.size = body.size; - this.water = body.water; - - this.ore.anthracite = body.ore.anthracite; - this.ore.bauxite = body.ore.bauxite; - this.ore.beryl = body.ore.beryl; - this.ore.chromite = body.ore.chromite; - this.ore.chalcopyrite = body.ore.chalcopyrite; - this.ore.fluorite = body.ore.fluorite; - this.ore.galena = body.ore.galena; - this.ore.goethite = body.ore.goethite; - this.ore.gold = body.ore.gold; - this.ore.gypsum = body.ore.gypsum; - this.ore.halite = body.ore.halite; - this.ore.kerogen = body.ore.kerogen; - this.ore.magnetite = body.ore.magnetite; - this.ore.methane = body.ore.methane; - this.ore.monazite = body.ore.monazite; - this.ore.rutile = body.ore.rutile; - this.ore.sulfur = body.ore.sulfur; - this.ore.trona = body.ore.trona; - this.ore.uraninite = body.ore.uraninite; - this.ore.zircon = body.ore.zircon; - - this.empire.id = body.empire.id; - this.empire.name = body.empire.name; - this.empire.alignment = body.empire.alignment; - this.empire.is_isolationist = body.empire.is_isolationist; - this.station.id = body.station.id; - this.station.x = body.station.x; - this.station.y = body.station.y; - this.station.name = body.station.name; - this.needs_surface_refresh = body.needs_surface_refresh; - this.building_count = int(body.building_count); - this.build_queue_size = body.build_queue_size; - this.build_queue_len = body.build_queue_len; - this.plots_available = int(body.plots_available); - this.happiness = body.happiness; - this.happiness_hour = body.happiness_hour; - this.unhappy_date = body.unhappy_date; - this.neutral_entry = body.neutral_entry; - this.propaganda_boost = body.propaganda_boost; - this.food_stored = body.food_stored; - this.food_capacity = body.food_capacity; - this.food_hour = body.food_hour; - this.energy_stored = body.energy_stored; - this.energy_capacity = body.energy_capacity; - this.energy_hour = body.energy_hour; - this.ore_hour = body.ore_hour; - this.ore_capacity = body.ore_capacity; - this.ore_stored = body.ore_stored; - this.waste_hour = body.waste_hour; - this.waste_stored = body.waste_stored; - this.waste_capacity = body.waste_capacity; - this.water_stored = body.water_stored; - this.water_hour = body.water_hour; - this.water_capacity = body.water_capacity; - this.skip_incoming_ships = body.skip_incoming_ships; - this.num_incoming_own = int(body.num_incoming_own); - this.num_incoming_ally = int(body.num_incoming_ally); - this.num_incoming_enemy = int(body.num_incoming_enemy); - this.incoming_enemy_ships = body.incoming_enemy_ships; - this.incoming_ally_ships = body.incoming_ally_ships; - this.incoming_own_ships = body.incoming_own_ships; - this.alliance = body.alliance; - this.influence = body.influence; - - let updateShip = function (ship: any) { - ship.arrival_ms = util.serverDateToMs(ship.date_arrives) - ServerRPCStore.serverTimeMs; - return ship; - }; - _.map(this.incoming_own_ships, updateShip); - _.map(this.incoming_ally_ships, updateShip); - _.map(this.incoming_enemy_ships, updateShip); - } + _.map(this.incoming_own_ships, updateShip); + _.map(this.incoming_ally_ships, updateShip); + _.map(this.incoming_enemy_ships, updateShip); + } - tick() { - let tickIncoming = function (ship: any) { - ship.arrival_ms -= 1000; - return ship; - }; - - _.map(this.incoming_own_ships, tickIncoming); - _.map(this.incoming_ally_ships, tickIncoming); - _.map(this.incoming_enemy_ships, tickIncoming); - - let tickResource = function ( - production: number, - capacity: number | undefined, - stored: number, - stopAtZero: boolean - ) { - let amount = production / 60 / 60; - let rv = stored + amount; - - if (typeof capacity !== 'undefined' && rv > capacity) { - return Math.floor(capacity); - } else if (rv < 0 && stopAtZero) { - return 0; - } else { - return Math.floor(rv); - } - }; - - this.food_stored = tickResource(this.food_hour, this.food_capacity, this.food_stored, true); - this.ore_stored = tickResource(this.ore_hour, this.ore_capacity, this.ore_stored, true); - this.water_stored = tickResource( - this.water_hour, - this.water_capacity, - this.water_stored, - true - ); - this.energy_stored = tickResource( - this.energy_hour, - this.energy_capacity, - this.energy_stored, - true - ); - this.waste_stored = tickResource( - this.waste_hour, - this.waste_capacity, - this.waste_stored, - true - ); - this.happiness = tickResource(this.happiness_hour, undefined, this.happiness, false); - } - - get food_percent_full() { - return Math.floor((this.food_stored / this.food_capacity) * 100); - } - - get ore_percent_full() { - return Math.floor((this.ore_stored / this.ore_capacity) * 100); - } - - get water_percent_full() { - return Math.floor((this.water_stored / this.water_capacity) * 100); - } + tick() { + let tickIncoming = function (ship: any) { + ship.arrival_ms -= 1000; + return ship; + }; - get energy_percent_full() { - return Math.floor((this.energy_stored / this.energy_capacity) * 100); - } + _.map(this.incoming_own_ships, tickIncoming); + _.map(this.incoming_ally_ships, tickIncoming); + _.map(this.incoming_enemy_ships, tickIncoming); + + let tickResource = function ( + production: number, + capacity: number | undefined, + stored: number, + stopAtZero: boolean + ) { + let amount = production / 60 / 60; + let rv = stored + amount; + + if (typeof capacity !== 'undefined' && rv > capacity) { + return Math.floor(capacity); + } else if (rv < 0 && stopAtZero) { + return 0; + } else { + return Math.floor(rv); + } + }; - get waste_percent_full() { - return Math.floor((this.waste_stored / this.waste_capacity) * 100); - } + this.food_stored = tickResource(this.food_hour, this.food_capacity, this.food_stored, true); + this.ore_stored = tickResource(this.ore_hour, this.ore_capacity, this.ore_stored, true); + this.water_stored = tickResource(this.water_hour, this.water_capacity, this.water_stored, true); + this.energy_stored = tickResource( + this.energy_hour, + this.energy_capacity, + this.energy_stored, + true + ); + this.waste_stored = tickResource(this.waste_hour, this.waste_capacity, this.waste_stored, true); + this.happiness = tickResource(this.happiness_hour, undefined, this.happiness, false); + } + + get food_percent_full() { + return Math.floor((this.food_stored / this.food_capacity) * 100); + } + + get ore_percent_full() { + return Math.floor((this.ore_stored / this.ore_capacity) * 100); + } + + get water_percent_full() { + return Math.floor((this.water_stored / this.water_capacity) * 100); + } + + get energy_percent_full() { + return Math.floor((this.energy_stored / this.energy_capacity) * 100); + } + + get waste_percent_full() { + return Math.floor((this.waste_stored / this.waste_capacity) * 100); + } } export default new BodyRPCStore(); diff --git a/app/stores/rpc/captcha.ts b/app/stores/rpc/captcha.ts index aa8e1c21..f9abf1d7 100644 --- a/app/stores/rpc/captcha.ts +++ b/app/stores/rpc/captcha.ts @@ -1,21 +1,21 @@ import { makeAutoObservable } from 'mobx'; class CaptchaRPCStore { - guid = ''; - url = ''; - solved = ''; - window = ''; + guid = ''; + url = ''; + solved = ''; + window = ''; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - clear() { - this.guid = ''; - this.url = ''; - this.solved = ''; - this.window = ''; - } + clear() { + this.guid = ''; + this.url = ''; + this.solved = ''; + this.window = ''; + } } export default new CaptchaRPCStore(); diff --git a/app/stores/rpc/empire.ts b/app/stores/rpc/empire.ts index a2d74725..8b31b487 100644 --- a/app/stores/rpc/empire.ts +++ b/app/stores/rpc/empire.ts @@ -4,120 +4,120 @@ import { int, serverDateToMs } from 'app/util'; import ServerRPCStore from 'app/stores/rpc/server'; function bodyObjectToArray(bodyObj) { - let arr = []; - _.each(bodyObj, function (value, key) { - arr.push({ - id: key, - name: value, - }); + let arr = []; + _.each(bodyObj, function (value, key) { + arr.push({ + id: key, + name: value, }); + }); - // Sort by name. - return _.sortBy(arr, 'name'); + // Sort by name. + return _.sortBy(arr, 'name'); } class EmpireRPCStore { - bodies = { - colonies: [], - mystations: [], - ourstations: [], - babies: [], - }; - colonies = []; - essentia = 0; - exactEssentia = 0; - has_new_messages = 0; - home_planet_id = ''; - id = ''; - insurrect_value = 0; - is_isolationist = 0; - latest_message_id = 0; - name = ''; - next_colony_cost = 0; - next_colony_srcs = 0; - next_station_cost = 0; - planets = []; - primary_embassy_id = 0; - rpc_count = 0; - self_destruct_active = 0; - self_destruct_date = ''; - self_destruct_ms = 0; - stations = []; - status_message = ''; - tech_level = 0; + bodies = { + colonies: [], + mystations: [], + ourstations: [], + babies: [], + }; + colonies = []; + essentia = 0; + exactEssentia = 0; + has_new_messages = 0; + home_planet_id = ''; + id = ''; + insurrect_value = 0; + is_isolationist = 0; + latest_message_id = 0; + name = ''; + next_colony_cost = 0; + next_colony_srcs = 0; + next_station_cost = 0; + planets = []; + primary_embassy_id = 0; + rpc_count = 0; + self_destruct_active = 0; + self_destruct_date = ''; + self_destruct_ms = 0; + stations = []; + status_message = ''; + tech_level = 0; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - tick() { - if (this.self_destruct_active && this.self_destruct_ms > 0) { - this.self_destruct_ms -= 1000; - } + tick() { + if (this.self_destruct_active && this.self_destruct_ms > 0) { + this.self_destruct_ms -= 1000; } + } - update(empire: any) { - this.has_new_messages = empire.has_new_messages; - this.home_planet_id = empire.home_planet_id; - this.id = empire.id; - this.insurrect_value = empire.insurrect_value; - this.is_isolationist = empire.is_isolationist; - this.latest_message_id = empire.latest_message_id; - this.name = empire.name; - this.next_colony_cost = empire.next_colony_cost; - this.next_colony_srcs = empire.next_colony_srcs; - this.next_station_cost = empire.next_station_cost; - this.primary_embassy_id = empire.primary_embassy_id; - this.rpc_count = empire.rpc_count; - this.self_destruct_active = empire.self_destruct_active; - this.self_destruct_date = empire.self_destruct_date; - this.status_message = empire.status_message; - this.tech_level = empire.tech_level; - - // Possible things to do here: - // ~ Turn self_destruct_date into a Date object. - this.self_destruct_active = int(empire.self_destruct_active); - this.exactEssentia = parseFloat(empire.essentia, 10); - this.essentia = int(empire.essentia); - if (empire.self_destruct_active) { - this.self_destruct_ms = - serverDateToMs(empire.self_destruct_date) - ServerRPCStore.serverTimeMoment; - } + update(empire: any) { + this.has_new_messages = empire.has_new_messages; + this.home_planet_id = empire.home_planet_id; + this.id = empire.id; + this.insurrect_value = empire.insurrect_value; + this.is_isolationist = empire.is_isolationist; + this.latest_message_id = empire.latest_message_id; + this.name = empire.name; + this.next_colony_cost = empire.next_colony_cost; + this.next_colony_srcs = empire.next_colony_srcs; + this.next_station_cost = empire.next_station_cost; + this.primary_embassy_id = empire.primary_embassy_id; + this.rpc_count = empire.rpc_count; + this.self_destruct_active = empire.self_destruct_active; + this.self_destruct_date = empire.self_destruct_date; + this.status_message = empire.status_message; + this.tech_level = empire.tech_level; - // Fix up all the planet lists. - empire.colonies = bodyObjectToArray(empire.colonies); - empire.planets = bodyObjectToArray(empire.planets); - empire.stations = bodyObjectToArray(empire.stations); + // Possible things to do here: + // ~ Turn self_destruct_date into a Date object. + this.self_destruct_active = int(empire.self_destruct_active); + this.exactEssentia = parseFloat(empire.essentia, 10); + this.essentia = int(empire.essentia); + if (empire.self_destruct_active) { + this.self_destruct_ms = + serverDateToMs(empire.self_destruct_date) - ServerRPCStore.serverTimeMoment; } - clear() { - this.bodies.colonies = []; - this.bodies.mystations = []; - this.bodies.ourstations = []; - this.bodies.babies = []; - this.colonies = []; - this.essentia = 0; - this.exactEssentia = 0; - this.has_new_messages = 0; - this.home_planet_id = ''; - this.id = ''; - this.insurrect_value = 0; - this.is_isolationist = 0; - this.latest_message_id = 0; - this.name = ''; - this.next_colony_cost = 0; - this.next_colony_srcs = 0; - this.next_station_cost = 0; - this.planets = []; - this.primary_embassy_id = 0; - this.rpc_count = 0; - this.self_destruct_active = 0; - this.self_destruct_date = ''; - this.self_destruct_ms = 0; - this.stations = []; - this.status_message = ''; - this.tech_level = 0; - } + // Fix up all the planet lists. + empire.colonies = bodyObjectToArray(empire.colonies); + empire.planets = bodyObjectToArray(empire.planets); + empire.stations = bodyObjectToArray(empire.stations); + } + + clear() { + this.bodies.colonies = []; + this.bodies.mystations = []; + this.bodies.ourstations = []; + this.bodies.babies = []; + this.colonies = []; + this.essentia = 0; + this.exactEssentia = 0; + this.has_new_messages = 0; + this.home_planet_id = ''; + this.id = ''; + this.insurrect_value = 0; + this.is_isolationist = 0; + this.latest_message_id = 0; + this.name = ''; + this.next_colony_cost = 0; + this.next_colony_srcs = 0; + this.next_station_cost = 0; + this.planets = []; + this.primary_embassy_id = 0; + this.rpc_count = 0; + this.self_destruct_active = 0; + this.self_destruct_date = ''; + this.self_destruct_ms = 0; + this.stations = []; + this.status_message = ''; + this.tech_level = 0; + } } export default new EmpireRPCStore(); diff --git a/app/stores/rpc/empire/boosts.ts b/app/stores/rpc/empire/boosts.ts index 625f18bd..86b545b2 100644 --- a/app/stores/rpc/empire/boosts.ts +++ b/app/stores/rpc/empire/boosts.ts @@ -3,41 +3,41 @@ import { serverDateToMoment } from 'app/util'; import ServerRPCStore from 'app/stores/rpc/server'; class BoostsEmpireRPCStore { - foodMsRemaining = 0; - oreMsRemaining = 0; - waterMsRemaining = 0; - energyMsRemaining = 0; - happinessMsRemaining = 0; - storageMsRemaining = 0; - buildingMsRemaining = 0; - spyTrainingMsRemaining = 0; + foodMsRemaining = 0; + oreMsRemaining = 0; + waterMsRemaining = 0; + energyMsRemaining = 0; + happinessMsRemaining = 0; + storageMsRemaining = 0; + buildingMsRemaining = 0; + spyTrainingMsRemaining = 0; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - update(result: any) { - const now = ServerRPCStore.serverTimeMoment; - this.buildingMsRemaining = serverDateToMoment(result.boosts.building).diff(now); - this.energyMsRemaining = serverDateToMoment(result.boosts.energy).diff(now); - this.foodMsRemaining = serverDateToMoment(result.boosts.food).diff(now); - this.happinessMsRemaining = serverDateToMoment(result.boosts.happiness).diff(now); - this.oreMsRemaining = serverDateToMoment(result.boosts.ore).diff(now); - this.spyTrainingMsRemaining = serverDateToMoment(result.boosts.spy_training).diff(now); - this.storageMsRemaining = serverDateToMoment(result.boosts.storage).diff(now); - this.waterMsRemaining = serverDateToMoment(result.boosts.water).diff(now); - } + update(result: any) { + const now = ServerRPCStore.serverTimeMoment; + this.buildingMsRemaining = serverDateToMoment(result.boosts.building).diff(now); + this.energyMsRemaining = serverDateToMoment(result.boosts.energy).diff(now); + this.foodMsRemaining = serverDateToMoment(result.boosts.food).diff(now); + this.happinessMsRemaining = serverDateToMoment(result.boosts.happiness).diff(now); + this.oreMsRemaining = serverDateToMoment(result.boosts.ore).diff(now); + this.spyTrainingMsRemaining = serverDateToMoment(result.boosts.spy_training).diff(now); + this.storageMsRemaining = serverDateToMoment(result.boosts.storage).diff(now); + this.waterMsRemaining = serverDateToMoment(result.boosts.water).diff(now); + } - tick() { - if (this.buildingMsRemaining > 0) this.buildingMsRemaining -= 1000; - if (this.energyMsRemaining > 0) this.energyMsRemaining -= 1000; - if (this.foodMsRemaining > 0) this.foodMsRemaining -= 1000; - if (this.happinessMsRemaining > 0) this.happinessMsRemaining -= 1000; - if (this.oreMsRemaining > 0) this.oreMsRemaining -= 1000; - if (this.spyTrainingMsRemaining > 0) this.spyTrainingMsRemaining -= 1000; - if (this.storageMsRemaining > 0) this.storageMsRemaining -= 1000; - if (this.waterMsRemaining > 0) this.waterMsRemaining -= 1000; - } + tick() { + if (this.buildingMsRemaining > 0) this.buildingMsRemaining -= 1000; + if (this.energyMsRemaining > 0) this.energyMsRemaining -= 1000; + if (this.foodMsRemaining > 0) this.foodMsRemaining -= 1000; + if (this.happinessMsRemaining > 0) this.happinessMsRemaining -= 1000; + if (this.oreMsRemaining > 0) this.oreMsRemaining -= 1000; + if (this.spyTrainingMsRemaining > 0) this.spyTrainingMsRemaining -= 1000; + if (this.storageMsRemaining > 0) this.storageMsRemaining -= 1000; + if (this.waterMsRemaining > 0) this.waterMsRemaining -= 1000; + } } export default new BoostsEmpireRPCStore(); diff --git a/app/stores/rpc/empire/invite.ts b/app/stores/rpc/empire/invite.ts index 2e0d946d..261b0e8a 100644 --- a/app/stores/rpc/empire/invite.ts +++ b/app/stores/rpc/empire/invite.ts @@ -1,15 +1,15 @@ import { makeAutoObservable } from 'mobx'; class InviteRPCStore { - referral_url = ''; + referral_url = ''; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - update(result: any) { - this.referral_url = result.referral_url; - } + update(result: any) { + this.referral_url = result.referral_url; + } } export default new InviteRPCStore(); diff --git a/app/stores/rpc/genericBuilding.ts b/app/stores/rpc/genericBuilding.ts index 969ed830..a6c62259 100644 --- a/app/stores/rpc/genericBuilding.ts +++ b/app/stores/rpc/genericBuilding.ts @@ -2,204 +2,203 @@ import { makeAutoObservable } from 'mobx'; import _ from 'lodash'; class GenericBuildingRPCStore { - id = ''; - name = ''; - image = ''; - level = 0; - x = 0; - y = 0; - food_hour = 0; - food_capacity = 0; - energy_hour = 0; - energy_capacity = 0; - ore_hour = 0; - ore_capacity = 0; - water_hour = 0; - water_capacity = 0; - waste_hour = 0; - waste_capacity = 0; - happiness_hour = 0; - efficiency = 0; - extraViewData = {}; - - repair_costs = { - food: 0, - water: 0, - energy: 0, - ore: 0, + id = ''; + name = ''; + image = ''; + level = 0; + x = 0; + y = 0; + food_hour = 0; + food_capacity = 0; + energy_hour = 0; + energy_capacity = 0; + ore_hour = 0; + ore_capacity = 0; + water_hour = 0; + water_capacity = 0; + waste_hour = 0; + waste_capacity = 0; + happiness_hour = 0; + efficiency = 0; + extraViewData = {}; + + repair_costs = { + food: 0, + water: 0, + energy: 0, + ore: 0, + }; + + downgrade = { + can: 1, + reason: '', + image: '', + }; + + upgrade = { + can: 1, + reason: '', + + cost: { + food: 0, + water: 0, + energy: 0, + waste: 0, + ore: 0, + time: 0, + halls: 0, + }, + production: { + food_hour: 0, + food_capacity: 0, + energy_hour: 0, + energy_capacity: 0, + ore_hour: 0, + ore_capacity: 0, + water_hour: 0, + water_capacity: 0, + waste_hour: 0, + waste_capacity: 0, + happiness_hour: 0, + }, + image: '', + }; + + constructor() { + makeAutoObservable(this); + } + + update(result: any) { + this.id = result.building.id; + this.name = result.building.name; + this.image = result.building.image; + this.level = result.building.level; + this.x = result.building.x; + this.y = result.building.y; + this.food_hour = result.building.food_hour; + this.food_capacity = result.building.food_capacity; + this.energy_hour = result.building.energy_hour; + this.energy_capacity = result.building.energy_capacity; + this.ore_hour = result.building.ore_hour; + this.ore_capacity = result.building.ore_capacity; + this.water_hour = result.building.water_hour; + this.water_capacity = result.building.water_capacity; + this.waste_hour = result.building.waste_hour; + this.waste_capacity = result.building.waste_capacity; + this.happiness_hour = result.building.happiness_hour; + this.efficiency = result.building.efficiency; + + this.repair_costs.food = result.building.repair_costs.food; + this.repair_costs.water = result.building.repair_costs.water; + this.repair_costs.energy = result.building.repair_costs.energy; + this.repair_costs.ore = result.building.repair_costs.ore; + + this.downgrade.can = result.building.downgrade.can; + this.downgrade.reason = result.building.downgrade.reason; + this.downgrade.image = result.building.downgrade.image; + + this.upgrade.can = result.building.upgrade.can; + this.upgrade.reason = result.building.upgrade.reason; + + this.upgrade.cost.food = result.building.upgrade.cost.food || 0; + this.upgrade.cost.water = result.building.upgrade.cost.water || 0; + this.upgrade.cost.energy = result.building.upgrade.cost.energy || 0; + this.upgrade.cost.waste = result.building.upgrade.cost.waste || 0; + this.upgrade.cost.ore = result.building.upgrade.cost.ore || 0; + this.upgrade.cost.time = result.building.upgrade.cost.time || 0; + this.upgrade.cost.halls = result.building.upgrade.cost.halls || 0; + + this.upgrade.production.food_hour = result.building.upgrade.production.food_hour; + this.upgrade.production.food_capacity = result.building.upgrade.production.food_capacity; + this.upgrade.production.energy_hour = result.building.upgrade.production.energy_hour; + this.upgrade.production.energy_capacity = result.building.upgrade.production.energy_capacity; + this.upgrade.production.ore_hour = result.building.upgrade.production.ore_hour; + this.upgrade.production.ore_capacity = result.building.upgrade.production.ore_capacity; + this.upgrade.production.water_hour = result.building.upgrade.production.water_hour; + this.upgrade.production.water_capacity = result.building.upgrade.production.water_capacity; + this.upgrade.production.waste_hour = result.building.upgrade.production.waste_hour; + this.upgrade.production.waste_capacity = result.building.upgrade.production.waste_capacity; + this.upgrade.production.happiness_hour = result.building.upgrade.production.happiness_hour; + + this.upgrade.image = result.building.upgrade.image; + + // // Any 'view' call that returns extra data (say, the Planetary Command Center) has that + // // data put into 'building.extraViewData' so that it is accessible from the store. + // let extraViewData = {}; + // _.each(result, function(value, key) { + // if (key === 'status' || key === 'building') { + // return; + // } + // extraViewData[key] = _.cloneDeep(value); + // }); + // building.extraViewData = extraViewData; + // // Manually update the old planet map with the new data we got. + // YAHOO.lacuna.MapPlanet.ReloadBuilding(_.cloneDeep(building)); + } + + clear() { + this.id = ''; + this.name = ''; + this.image = ''; + this.level = 0; + this.x = 0; + this.y = 0; + this.food_hour = 0; + this.food_capacity = 0; + this.energy_hour = 0; + this.energy_capacity = 0; + this.ore_hour = 0; + this.ore_capacity = 0; + this.water_hour = 0; + this.water_capacity = 0; + this.waste_hour = 0; + this.waste_capacity = 0; + this.happiness_hour = 0; + this.efficiency = 0; + this.extraViewData = {}; + + this.repair_costs = { + food: 0, + water: 0, + energy: 0, + ore: 0, }; - downgrade = { - can: 1, - reason: '', - image: '', + this.downgrade = { + can: 1, + reason: '', + image: '', }; - upgrade = { - can: 1, - reason: '', - - cost: { - food: 0, - water: 0, - energy: 0, - waste: 0, - ore: 0, - time: 0, - halls: 0, - }, - production: { - food_hour: 0, - food_capacity: 0, - energy_hour: 0, - energy_capacity: 0, - ore_hour: 0, - ore_capacity: 0, - water_hour: 0, - water_capacity: 0, - waste_hour: 0, - waste_capacity: 0, - happiness_hour: 0, - }, - image: '', - }; + this.upgrade = { + can: 1, + reason: '', - constructor() { - makeAutoObservable(this); - } - - update(result: any) { - this.id = result.building.id; - this.name = result.building.name; - this.image = result.building.image; - this.level = result.building.level; - this.x = result.building.x; - this.y = result.building.y; - this.food_hour = result.building.food_hour; - this.food_capacity = result.building.food_capacity; - this.energy_hour = result.building.energy_hour; - this.energy_capacity = result.building.energy_capacity; - this.ore_hour = result.building.ore_hour; - this.ore_capacity = result.building.ore_capacity; - this.water_hour = result.building.water_hour; - this.water_capacity = result.building.water_capacity; - this.waste_hour = result.building.waste_hour; - this.waste_capacity = result.building.waste_capacity; - this.happiness_hour = result.building.happiness_hour; - this.efficiency = result.building.efficiency; - - this.repair_costs.food = result.building.repair_costs.food; - this.repair_costs.water = result.building.repair_costs.water; - this.repair_costs.energy = result.building.repair_costs.energy; - this.repair_costs.ore = result.building.repair_costs.ore; - - this.downgrade.can = result.building.downgrade.can; - this.downgrade.reason = result.building.downgrade.reason; - this.downgrade.image = result.building.downgrade.image; - - this.upgrade.can = result.building.upgrade.can; - this.upgrade.reason = result.building.upgrade.reason; - - this.upgrade.cost.food = result.building.upgrade.cost.food || 0; - this.upgrade.cost.water = result.building.upgrade.cost.water || 0; - this.upgrade.cost.energy = result.building.upgrade.cost.energy || 0; - this.upgrade.cost.waste = result.building.upgrade.cost.waste || 0; - this.upgrade.cost.ore = result.building.upgrade.cost.ore || 0; - this.upgrade.cost.time = result.building.upgrade.cost.time || 0; - this.upgrade.cost.halls = result.building.upgrade.cost.halls || 0; - - this.upgrade.production.food_hour = result.building.upgrade.production.food_hour; - this.upgrade.production.food_capacity = result.building.upgrade.production.food_capacity; - this.upgrade.production.energy_hour = result.building.upgrade.production.energy_hour; - this.upgrade.production.energy_capacity = - result.building.upgrade.production.energy_capacity; - this.upgrade.production.ore_hour = result.building.upgrade.production.ore_hour; - this.upgrade.production.ore_capacity = result.building.upgrade.production.ore_capacity; - this.upgrade.production.water_hour = result.building.upgrade.production.water_hour; - this.upgrade.production.water_capacity = result.building.upgrade.production.water_capacity; - this.upgrade.production.waste_hour = result.building.upgrade.production.waste_hour; - this.upgrade.production.waste_capacity = result.building.upgrade.production.waste_capacity; - this.upgrade.production.happiness_hour = result.building.upgrade.production.happiness_hour; - - this.upgrade.image = result.building.upgrade.image; - - // // Any 'view' call that returns extra data (say, the Planetary Command Center) has that - // // data put into 'building.extraViewData' so that it is accessible from the store. - // let extraViewData = {}; - // _.each(result, function(value, key) { - // if (key === 'status' || key === 'building') { - // return; - // } - // extraViewData[key] = _.cloneDeep(value); - // }); - // building.extraViewData = extraViewData; - // // Manually update the old planet map with the new data we got. - // YAHOO.lacuna.MapPlanet.ReloadBuilding(_.cloneDeep(building)); - } - - clear() { - this.id = ''; - this.name = ''; - this.image = ''; - this.level = 0; - this.x = 0; - this.y = 0; - this.food_hour = 0; - this.food_capacity = 0; - this.energy_hour = 0; - this.energy_capacity = 0; - this.ore_hour = 0; - this.ore_capacity = 0; - this.water_hour = 0; - this.water_capacity = 0; - this.waste_hour = 0; - this.waste_capacity = 0; - this.happiness_hour = 0; - this.efficiency = 0; - this.extraViewData = {}; - - this.repair_costs = { - food: 0, - water: 0, - energy: 0, - ore: 0, - }; - - this.downgrade = { - can: 1, - reason: '', - image: '', - }; - - this.upgrade = { - can: 1, - reason: '', - - cost: { - food: 0, - water: 0, - energy: 0, - waste: 0, - ore: 0, - time: 0, - halls: 0, - }, - production: { - food_hour: 0, - food_capacity: 0, - energy_hour: 0, - energy_capacity: 0, - ore_hour: 0, - ore_capacity: 0, - water_hour: 0, - water_capacity: 0, - waste_hour: 0, - waste_capacity: 0, - happiness_hour: 0, - }, - image: '', - }; - } + cost: { + food: 0, + water: 0, + energy: 0, + waste: 0, + ore: 0, + time: 0, + halls: 0, + }, + production: { + food_hour: 0, + food_capacity: 0, + energy_hour: 0, + energy_capacity: 0, + ore_hour: 0, + ore_capacity: 0, + water_hour: 0, + water_capacity: 0, + waste_hour: 0, + waste_capacity: 0, + happiness_hour: 0, + }, + image: '', + }; + } } export default new GenericBuildingRPCStore(); diff --git a/app/stores/rpc/server.ts b/app/stores/rpc/server.ts index 5b1897f6..2adc108f 100644 --- a/app/stores/rpc/server.ts +++ b/app/stores/rpc/server.ts @@ -5,79 +5,79 @@ import { serverDateToMoment, formatMomentLong, serverDateToDateObj } from 'app/u import constants from 'app/constants'; class ServerRPCStore { - time = '01 31 2010 13:09:05 +0600'; - version = '1.0'; - announcement = 0; - promotions = []; - rpc_limit = 10000; - star_map_size = { - x: [-15, 15], - y: [-15, 15], - z: [-15, 15], - }; - - constructor() { - makeAutoObservable(this); - } - - update(server: any) { - // TODO: show announcement window if needed. - - this.time = server.time; - this.rpc_limit = server.rpc_limit; - this.star_map_size = server.star_map_size; - this.version = server.version; - - // The server won't return the promotions block if there aren't any but components - // will expect it to exist. - if (!this.promotions) { - this.promotions = []; - } - } - - tick() { - let now = Date.now(); - - this.time = this.serverTimeMoment.add(1, 'second').format(constants.NEW_SERVER_DATE_FORMAT); - - this.promotions = _.chain(this.promotions) - .filter(function (promotion) { - // Note: date objects can be compared numerically, - // see: http://stackoverflow.com/a/493018/1978973 - return now < serverDateToDateObj(promotion.end_date); - }) - .map(function (promotion) { - promotion.header = promotion.title; - promotion.ends = moment().to(serverDateToMoment(promotion.end_date)); - - return promotion; - }) - .value(); - } - - get serverTimeMoment() { - return serverDateToMoment(this.time).utcOffset(0); - } - - get clientTimeMoment() { - return serverDateToMoment(this.time); - } - - get serverTimeFormatted() { - return formatMomentLong(this.serverTimeMoment); - } - - get clientTimeFormatted() { - return formatMomentLong(this.clientTimeMoment); - } - - get serverTimeMs() { - return this.serverTimeMoment.valueOf(); - } - - get clientTimeMs() { - return this.clientTimeMoment.valueOf(); + time = '01 31 2010 13:09:05 +0600'; + version = '1.0'; + announcement = 0; + promotions = []; + rpc_limit = 10000; + star_map_size = { + x: [-15, 15], + y: [-15, 15], + z: [-15, 15], + }; + + constructor() { + makeAutoObservable(this); + } + + update(server: any) { + // TODO: show announcement window if needed. + + this.time = server.time; + this.rpc_limit = server.rpc_limit; + this.star_map_size = server.star_map_size; + this.version = server.version; + + // The server won't return the promotions block if there aren't any but components + // will expect it to exist. + if (!this.promotions) { + this.promotions = []; } + } + + tick() { + let now = Date.now(); + + this.time = this.serverTimeMoment.add(1, 'second').format(constants.NEW_SERVER_DATE_FORMAT); + + this.promotions = _.chain(this.promotions) + .filter(function (promotion) { + // Note: date objects can be compared numerically, + // see: http://stackoverflow.com/a/493018/1978973 + return now < serverDateToDateObj(promotion.end_date); + }) + .map(function (promotion) { + promotion.header = promotion.title; + promotion.ends = moment().to(serverDateToMoment(promotion.end_date)); + + return promotion; + }) + .value(); + } + + get serverTimeMoment() { + return serverDateToMoment(this.time).utcOffset(0); + } + + get clientTimeMoment() { + return serverDateToMoment(this.time); + } + + get serverTimeFormatted() { + return formatMomentLong(this.serverTimeMoment); + } + + get clientTimeFormatted() { + return formatMomentLong(this.clientTimeMoment); + } + + get serverTimeMs() { + return this.serverTimeMoment.valueOf(); + } + + get clientTimeMs() { + return this.clientTimeMoment.valueOf(); + } } export default new ServerRPCStore(); diff --git a/app/stores/rpc/stats/credits.ts b/app/stores/rpc/stats/credits.ts index 0546709c..fd90c1c8 100644 --- a/app/stores/rpc/stats/credits.ts +++ b/app/stores/rpc/stats/credits.ts @@ -2,44 +2,44 @@ import { makeAutoObservable } from 'mobx'; import _ from 'lodash'; interface Credits { - [index: string]: string[]; + [index: string]: string[]; } class CreditsRPCStore { - credits: Credits = {}; - - constructor() { - makeAutoObservable(this); - } - - // INPUT: - // - // [ - // { 'Game Server' : ['JT Smith']}, - // { 'iPhone Client' : ['Kevin Runde']}, - // { 'Web Client' : ['John Rozeske']}, - // { 'Play Testers' : ['John Ottinger', 'Jamie Vrbsky']} - // ] - // - // OUTPUT - // { - // 'Game Server': ['JT Smith'], - // 'iPhone Client': ['Kevin Runde'], - // 'Web Client' : ['John Rozeske'], - // 'Play Testers' : ['John Ottinger', 'Jamie Vrbsky'] - // } - - update(result: any) { - const credits: Credits = {}; - - _.each(result, function (foo) { - _.each(foo, function (names, header) { - credits[header] = names; - }); - }); - - this.credits = credits; - } + credits: Credits = {}; + + constructor() { + makeAutoObservable(this); + } + + // INPUT: + // + // [ + // { 'Game Server' : ['JT Smith']}, + // { 'iPhone Client' : ['Kevin Runde']}, + // { 'Web Client' : ['John Rozeske']}, + // { 'Play Testers' : ['John Ottinger', 'Jamie Vrbsky']} + // ] + // + // OUTPUT + // { + // 'Game Server': ['JT Smith'], + // 'iPhone Client': ['Kevin Runde'], + // 'Web Client' : ['John Rozeske'], + // 'Play Testers' : ['John Ottinger', 'Jamie Vrbsky'] + // } + + update(result: any) { + const credits: Credits = {}; + + _.each(result, function (foo) { + _.each(foo, function (names, header) { + credits[header] = names; + }); + }); + + this.credits = credits; + } } export default new CreditsRPCStore(); diff --git a/app/stores/session.ts b/app/stores/session.ts index 67188d7c..a8ca270c 100644 --- a/app/stores/session.ts +++ b/app/stores/session.ts @@ -1,15 +1,15 @@ import { makeAutoObservable } from 'mobx'; class SessionStore { - session: string = ''; + session: string = ''; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - update(session: string) { - this.session = session; - } + update(session: string) { + this.session = session; + } } export default new SessionStore(); diff --git a/app/stores/ticker.ts b/app/stores/ticker.ts index 2e0bdac5..d204ca1e 100644 --- a/app/stores/ticker.ts +++ b/app/stores/ticker.ts @@ -14,35 +14,35 @@ import BodyRPCStore from 'app/stores/rpc/body'; const INTERVAL_TIME = 1000; class TickerStore { - ticking: boolean = false; - interval: number = 0; - clockTicks: number = 0; - - constructor() { - makeAutoObservable(this); - } - - tick() { - this.clockTicks += 1; - BoostsRPCStore.tick(); - BodyRPCStore.tick(); - EmpireRPCStore.tick(); - ServerRPCStore.tick(); - } - - start() { - if (!this.ticking) { - this.interval = window.setInterval(() => this.tick(), INTERVAL_TIME); - this.ticking = true; - } + ticking: boolean = false; + interval: number = 0; + clockTicks: number = 0; + + constructor() { + makeAutoObservable(this); + } + + tick() { + this.clockTicks += 1; + BoostsRPCStore.tick(); + BodyRPCStore.tick(); + EmpireRPCStore.tick(); + ServerRPCStore.tick(); + } + + start() { + if (!this.ticking) { + this.interval = window.setInterval(() => this.tick(), INTERVAL_TIME); + this.ticking = true; } + } - stop() { - if (this.ticking) { - window.clearInterval(this.interval); - this.ticking = false; - } + stop() { + if (this.ticking) { + window.clearInterval(this.interval); + this.ticking = false; } + } } export default new TickerStore(); diff --git a/app/stores/window/mail.ts b/app/stores/window/mail.ts index 27a6988d..61b462ae 100644 --- a/app/stores/window/mail.ts +++ b/app/stores/window/mail.ts @@ -1,19 +1,19 @@ import { makeAutoObservable } from 'mobx'; class MailWindowStore { - shown = false; + shown = false; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - show() { - this.shown = true; - } + show() { + this.shown = true; + } - hide() { - this.shown = false; - } + hide() { + this.shown = false; + } } export default new MailWindowStore(); diff --git a/app/stores/window/options.ts b/app/stores/window/options.ts index d7d400db..a8030ca1 100644 --- a/app/stores/window/options.ts +++ b/app/stores/window/options.ts @@ -1,19 +1,19 @@ import { makeAutoObservable } from 'mobx'; class OptionsWindowStore { - shown = false; + shown = false; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - show() { - this.shown = true; - } + show() { + this.shown = true; + } - hide() { - this.shown = false; - } + hide() { + this.shown = false; + } } export default new OptionsWindowStore(); diff --git a/app/stores/window/stats.ts b/app/stores/window/stats.ts index 6c9161fa..af914f36 100644 --- a/app/stores/window/stats.ts +++ b/app/stores/window/stats.ts @@ -1,20 +1,20 @@ import { makeAutoObservable } from 'mobx'; class StatsWindowStore { - shown = false; + shown = false; - constructor() { - makeAutoObservable(this); - } + constructor() { + makeAutoObservable(this); + } - show() { - console.log('shown got called'); - this.shown = true; - } + show() { + console.log('shown got called'); + this.shown = true; + } - hide() { - this.shown = false; - } + hide() { + this.shown = false; + } } export default new StatsWindowStore(); diff --git a/app/stores/windows.ts b/app/stores/windows.ts index 7454cea2..f7f0737f 100644 --- a/app/stores/windows.ts +++ b/app/stores/windows.ts @@ -3,97 +3,97 @@ import { makeAutoObservable } from 'mobx'; import { Window, WindowType, WindowOptions } from 'app/interfaces'; let findWindowByType = function (windows: Window[], type: WindowType) { - let index = _.findIndex(windows, function (o) { - if (o) { - return o.type === type; - } + let index = _.findIndex(windows, function (o) { + if (o) { + return o.type === type; + } - return false; - }); + return false; + }); - if (index > -1) { - let obj = windows[index]; + if (index > -1) { + let obj = windows[index]; - // Add the index we found this at for convenience. - obj.index = index; + // Add the index we found this at for convenience. + obj.index = index; - return obj; - } else { - return undefined; - } + return obj; + } else { + return undefined; + } }; class WindowsStore { - windows: Window[] = []; - zIndex = 2000000; - - constructor() { - makeAutoObservable(this); + windows: Window[] = []; + zIndex = 2000000; + + constructor() { + makeAutoObservable(this); + } + + // + // We only allow one window of each type (e.g. 'about' or 'building') + // + add(type: WindowType, options: WindowOptions = {}) { + let index = this.windows.length; + + // However, if there is an existing window type, we replace it because we only want + // one of each type of window on screen at a given time. + let existingWindow = findWindowByType(this.windows, type); + if (existingWindow) { + index = existingWindow.index; } - // - // We only allow one window of each type (e.g. 'about' or 'building') - // - add(type: WindowType, options: WindowOptions = {}) { - let index = this.windows.length; - - // However, if there is an existing window type, we replace it because we only want - // one of each type of window on screen at a given time. - let existingWindow = findWindowByType(this.windows, type); - if (existingWindow) { - index = existingWindow.index; - } - - this.windows[index] = { - type: type, - zIndex: this.zIndex, - options: options, - index: index, - }; - - this.zIndex += 1; - } - - // - // Close window by type, e.g. 'captcha' - // - close(type: WindowType) { - let existingWindow = findWindowByType(this.windows, type); - if (!existingWindow) return; - this.windows.splice(existingWindow.index, 1); - } - - // - // Close all windows (i.e., where we log out). - // - closeAll() { - this.windows = []; - this.zIndex = 2000000; - } - - // - // Close the window on top when user hits the escape key. - // - onEscKey() { - let toClose = _.chain(this.windows).sortBy('zIndex').reverse().first().value(); - if (!toClose) return; - this.close(toClose.type); - } - - // - // Bring a window to the top of the stack by type. - // - bringToTop(type: WindowType) { - let toBringToTop = findWindowByType(this.windows, type); - if (!toBringToTop) return; - - if (this.windows[toBringToTop.index].zIndex === this.zIndex - 1) { - // We're already the top window and there's therefore nothing to do... - } else { - this.windows[toBringToTop.index].zIndex = this.zIndex; - this.zIndex += 1; - } + this.windows[index] = { + type: type, + zIndex: this.zIndex, + options: options, + index: index, + }; + + this.zIndex += 1; + } + + // + // Close window by type, e.g. 'captcha' + // + close(type: WindowType) { + let existingWindow = findWindowByType(this.windows, type); + if (!existingWindow) return; + this.windows.splice(existingWindow.index, 1); + } + + // + // Close all windows (i.e., where we log out). + // + closeAll() { + this.windows = []; + this.zIndex = 2000000; + } + + // + // Close the window on top when user hits the escape key. + // + onEscKey() { + let toClose = _.chain(this.windows).sortBy('zIndex').reverse().first().value(); + if (!toClose) return; + this.close(toClose.type); + } + + // + // Bring a window to the top of the stack by type. + // + bringToTop(type: WindowType) { + let toBringToTop = findWindowByType(this.windows, type); + if (!toBringToTop) return; + + if (this.windows[toBringToTop.index].zIndex === this.zIndex - 1) { + // We're already the top window and there's therefore nothing to do... + } else { + this.windows[toBringToTop.index].zIndex = this.zIndex; + this.zIndex += 1; } + } } export default new WindowsStore(); diff --git a/app/util.ts b/app/util.ts index 3b666b46..48863d7c 100644 --- a/app/util.ts +++ b/app/util.ts @@ -3,155 +3,155 @@ import _ from 'lodash'; import constants from 'app/constants'; let xPad = function (x: any, pad: string, r: any) { - if (typeof r === 'undefined') { - r = 10; - } - for (; parseInt(x, 10) < r && r > 1; r /= 10) { - x = pad.toString() + x; - } - return x.toString(); + if (typeof r === 'undefined') { + r = 10; + } + for (; parseInt(x, 10) < r && r > 1; r /= 10) { + x = pad.toString() + x; + } + return x.toString(); }; export const reduceNumber = function (number: number) { - if (number >= 100000000000000000 || number <= -100000000000000000) { - // 101Q - return Math.floor(number / 1000000000000000) + 'Q'; - } else if (number >= 1000000000000000 || number <= -1000000000000000) { - // 75.3Q - return Math.floor(number / 100000000000000) / 10 + 'Q'; - } else if (number >= 100000000000000 || number <= -100000000000000) { - // 101T - return Math.floor(number / 1000000000000) + 'T'; - } else if (number >= 1000000000000 || number <= -1000000000000) { - // 75.3T - return Math.floor(number / 100000000000) / 10 + 'T'; - } else if (number >= 100000000000 || number <= -100000000000) { - // 101B - return Math.floor(number / 1000000000) + 'B'; - } else if (number >= 1000000000 || number <= -1000000000) { - // 75.3B - return Math.floor(number / 100000000) / 10 + 'B'; - } else if (number >= 100000000 || number <= -100000000) { - // 101M - return Math.floor(number / 1000000) + 'M'; - } else if (number >= 1000000 || number <= -1000000) { - // 75.3M - return Math.floor(number / 100000) / 10 + 'M'; - } else if (number >= 10000 || number <= -10000) { - // 123k - return Math.floor(number / 1000) + 'k'; - } else { - // 8765 - return Math.floor(number).toString() || '0'; - } + if (number >= 100000000000000000 || number <= -100000000000000000) { + // 101Q + return Math.floor(number / 1000000000000000) + 'Q'; + } else if (number >= 1000000000000000 || number <= -1000000000000000) { + // 75.3Q + return Math.floor(number / 100000000000000) / 10 + 'Q'; + } else if (number >= 100000000000000 || number <= -100000000000000) { + // 101T + return Math.floor(number / 1000000000000) + 'T'; + } else if (number >= 1000000000000 || number <= -1000000000000) { + // 75.3T + return Math.floor(number / 100000000000) / 10 + 'T'; + } else if (number >= 100000000000 || number <= -100000000000) { + // 101B + return Math.floor(number / 1000000000) + 'B'; + } else if (number >= 1000000000 || number <= -1000000000) { + // 75.3B + return Math.floor(number / 100000000) / 10 + 'B'; + } else if (number >= 100000000 || number <= -100000000) { + // 101M + return Math.floor(number / 1000000) + 'M'; + } else if (number >= 1000000 || number <= -1000000) { + // 75.3M + return Math.floor(number / 100000) / 10 + 'M'; + } else if (number >= 10000 || number <= -10000) { + // 123k + return Math.floor(number / 1000) + 'k'; + } else { + // 8765 + return Math.floor(number).toString() || '0'; + } }; export const serverDateToDateObj = function (serverDate: string) { - // "23 03 2010 01:20:11 +0000" - let pieces = serverDate.split(' '); // [day month year hr:min:sec timez - let time = pieces[3].split(':'); - let dt = new Date(); - - dt.setUTCFullYear(int(pieces[2])); - dt.setUTCMonth(int(pieces[1]) - 1, int(pieces[0])); - dt.setUTCHours(int(time[0])); - dt.setUTCMinutes(int(time[1])); - dt.setUTCSeconds(int(time[2])); - - return dt; + // "23 03 2010 01:20:11 +0000" + let pieces = serverDate.split(' '); // [day month year hr:min:sec timez + let time = pieces[3].split(':'); + let dt = new Date(); + + dt.setUTCFullYear(int(pieces[2])); + dt.setUTCMonth(int(pieces[1]) - 1, int(pieces[0])); + dt.setUTCHours(int(time[0])); + dt.setUTCMinutes(int(time[1])); + dt.setUTCSeconds(int(time[2])); + + return dt; }; export const serverDateToMs = function (serverDate: string) { - return serverDateToDateObj(serverDate).getTime(); + return serverDateToDateObj(serverDate).getTime(); }; export const int = function (number: string) { - return parseInt(number, 10); + return parseInt(number, 10); }; export const formatTime = function (totalSeconds: number) { - if (totalSeconds < 0) { - return ''; - } - - let secondsInDay = 60 * 60 * 24; - let secondsInHour = 60 * 60; - let day = Math.floor(totalSeconds / secondsInDay); - let hleft = totalSeconds % secondsInDay; - let hour = Math.floor(hleft / secondsInHour); - let sleft = hleft % secondsInHour; - let min = Math.floor(sleft / 60); - let seconds = Math.floor(sleft % 60); - - if (day > 0) { - return [day, xPad(hour, '0'), xPad(min, '0'), xPad(seconds, '0')].join(':'); - } else if (hour > 0) { - return [hour, xPad(min, '0'), xPad(seconds, '0')].join(':'); - } else { - return [min, xPad(seconds, '0')].join(':'); - } + if (totalSeconds < 0) { + return ''; + } + + let secondsInDay = 60 * 60 * 24; + let secondsInHour = 60 * 60; + let day = Math.floor(totalSeconds / secondsInDay); + let hleft = totalSeconds % secondsInDay; + let hour = Math.floor(hleft / secondsInHour); + let sleft = hleft % secondsInHour; + let min = Math.floor(sleft / 60); + let seconds = Math.floor(sleft % 60); + + if (day > 0) { + return [day, xPad(hour, '0'), xPad(min, '0'), xPad(seconds, '0')].join(':'); + } else if (hour > 0) { + return [hour, xPad(min, '0'), xPad(seconds, '0')].join(':'); + } else { + return [min, xPad(seconds, '0')].join(':'); + } }; export const formatMillisecondTime = function (ms: number) { - return formatTime(ms / 1000); + return formatTime(ms / 1000); }; export const serverDateToMoment = function (str: string) { - // There are currently two date formats being used by the server. - // This is to handle that. - - let usingOldFormat = moment(str, constants.OLD_SERVER_DATE_FORMAT); - let usingNewFormat = moment(str, constants.NEW_SERVER_DATE_FORMAT); - - if (usingNewFormat.isValid()) { - return usingNewFormat; - } else if (usingOldFormat.isValid()) { - return usingOldFormat; - } else { - console.error('Cannot parse server date: ' + str); - return moment(); - } + // There are currently two date formats being used by the server. + // This is to handle that. + + let usingOldFormat = moment(str, constants.OLD_SERVER_DATE_FORMAT); + let usingNewFormat = moment(str, constants.NEW_SERVER_DATE_FORMAT); + + if (usingNewFormat.isValid()) { + return usingNewFormat; + } else if (usingOldFormat.isValid()) { + return usingOldFormat; + } else { + console.error('Cannot parse server date: ' + str); + return moment(); + } }; export const formatMomentLong = function (theMoment: moment.Moment) { - return theMoment.format('dddd, Do MMMM HH:mm:ss ZZ'); + return theMoment.format('dddd, Do MMMM HH:mm:ss ZZ'); }; export const clone = function (obj: object) { - return $.extend(true, {}, obj); + return $.extend(true, {}, obj); }; export const commify = function (num: number) { - if (num === undefined) { - return ''; - } + if (num === undefined) { + return ''; + } - return Number(num).toLocaleString(); + return Number(num).toLocaleString(); }; let handleString = function (string: any) { - if (window.isNaN(string)) { - return string; - } else { - return string * 1; - } + if (window.isNaN(string)) { + return string; + } else { + return string * 1; + } }; let handleObj = function (obj: any): any { - if (_.isString(obj)) { - return handleString(obj); - } else if (_.isObject(obj)) { - // NOTE: isObject returns true for arrays. - if (Array.isArray(obj)) { - return _.forEach(obj, handleObj); - } else { - return _.mapValues(obj, handleObj); - } + if (_.isString(obj)) { + return handleString(obj); + } else if (_.isObject(obj)) { + // NOTE: isObject returns true for arrays. + if (Array.isArray(obj)) { + return _.forEach(obj, handleObj); } else { - return obj; + return _.mapValues(obj, handleObj); } + } else { + return obj; + } }; export const fixNumbers = function (data: any) { - return _.mapValues(data, handleObj); + return _.mapValues(data, handleObj); }; diff --git a/app/vex.ts b/app/vex.ts index cb00a3f6..112abd1c 100644 --- a/app/vex.ts +++ b/app/vex.ts @@ -8,26 +8,26 @@ vex.registerPlugin(vexDialog); vex.defaultOptions.className = 'vex-theme-default'; export const alert = function (message: string) { - vex.dialog.alert(message); + vex.dialog.alert(message); }; export const confirm = function (message: string, yesCallback?: Function, noCallback?: Function) { - vex.dialog.confirm({ - message: message, - callback: function (value) { - if (value && typeof yesCallback === 'function') { - yesCallback(); - } else if (!value && typeof noCallback === 'function') { - noCallback(); - } - }, - }); + vex.dialog.confirm({ + message: message, + callback: function (value) { + if (value && typeof yesCallback === 'function') { + yesCallback(); + } else if (!value && typeof noCallback === 'function') { + noCallback(); + } + }, + }); }; export const prompt = function (message: string, placeholder: string, callback: Function) { - vex.dialog.prompt({ - message: message, - placeholder: placeholder, - callback: callback, - }); + vex.dialog.prompt({ + message: message, + placeholder: placeholder, + callback: callback, + }); }; diff --git a/app/yui/announce.js b/app/yui/announce.js index e89f10ad..4c61f2c1 100644 --- a/app/yui/announce.js +++ b/app/yui/announce.js @@ -1,94 +1,85 @@ YAHOO.namespace('lacuna'); if (typeof YAHOO.lacuna.Announce == 'undefined' || !YAHOO.lacuna.Announce) { - (function() { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; - var Announce = function() {}; - Announce.prototype = { - build: function() { - this.id = 'Announce'; + var Announce = function () {}; + Announce.prototype = { + build: function () { + this.id = 'Announce'; - var container = document.createElement('div'); - container.id = this.id; - Dom.addClass(container, 'nofooter'); - Dom.addClass(container, Lib.Styles.HIDDEN); - container.innerHTML = this._getHtml(); - var yuicontainer = document.getElementById( - 'oldYUIPanelContainer' - ); + var container = document.createElement('div'); + container.id = this.id; + Dom.addClass(container, 'nofooter'); + Dom.addClass(container, Lib.Styles.HIDDEN); + container.innerHTML = this._getHtml(); + var yuicontainer = document.getElementById('oldYUIPanelContainer'); - // if we haven't been fully initialised yet, - // the container doesn't exist, so defer until later. - if (!yuicontainer) { - return; - } + // if we haven't been fully initialised yet, + // the container doesn't exist, so defer until later. + if (!yuicontainer) { + return; + } - yuicontainer.appendChild(container); + yuicontainer.appendChild(container); - this.Panel = new YAHOO.widget.Panel(this.id, { - constraintoviewport: true, - fixedcenter: false, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - underlay: false, - modal: false, - close: true, - width: '350px', - zIndex: 19999, - context: [ - 'header', - 'tr', - 'br', - ['beforeShow', 'windowResize'], - [0, 20], - ], - }); - this.Panel.renderEvent.subscribe( - function() { - this.iFrame = Dom.get('announceFrame'); - Dom.removeClass(this.id, Lib.Styles.HIDDEN); - }, - this, - true - ); - this.Panel.render(); - return 1; - }, - _getHtml: function() { - return [ - '
Announcements
', - '
', - ' ', - '
', - ].join(''); - }, - show: function() { - if (!this.build()) { - return; - } + this.Panel = new YAHOO.widget.Panel(this.id, { + constraintoviewport: true, + fixedcenter: false, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + underlay: false, + modal: false, + close: true, + width: '350px', + zIndex: 19999, + context: ['header', 'tr', 'br', ['beforeShow', 'windowResize'], [0, 20]], + }); + this.Panel.renderEvent.subscribe( + function () { + this.iFrame = Dom.get('announceFrame'); + Dom.removeClass(this.id, Lib.Styles.HIDDEN); + }, + this, + true + ); + this.Panel.render(); + return 1; + }, + _getHtml: function () { + return [ + '
Announcements
', + '
', + ' ', + '
', + ].join(''); + }, + show: function () { + if (!this.build()) { + return; + } - this.iFrame.src = - '/announcement?session_id=' + Game.GetSession(); + this.iFrame.src = '/announcement?session_id=' + Game.GetSession(); - this.Panel.show(); - }, - hide: function() { - this.Panel.hide(); - }, - }; - Lang.augmentProto(Announce, Util.EventProvider); + this.Panel.show(); + }, + hide: function () { + this.Panel.hide(); + }, + }; + Lang.augmentProto(Announce, Util.EventProvider); - Lacuna.Announce = new Announce(); - })(); - YAHOO.register('Announce', YAHOO.lacuna.Announce, { - version: '1', - build: '0', - }); + Lacuna.Announce = new Announce(); + })(); + YAHOO.register('Announce', YAHOO.lacuna.Announce, { + version: '1', + build: '0', + }); } diff --git a/app/yui/createEmpire.js b/app/yui/createEmpire.js index 8b17ac21..f6d69cc5 100644 --- a/app/yui/createEmpire.js +++ b/app/yui/createEmpire.js @@ -3,270 +3,270 @@ YAHOO.namespace('lacuna'); import MenuStore from 'app/stores/menu'; if (typeof YAHOO.lacuna.CreateEmpire == 'undefined' || !YAHOO.lacuna.CreateEmpire) { - (function () { - var Util = YAHOO.util, - Cookie = Util.Cookie, - Dom = Util.Dom, - Event = Util.Event, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; + (function () { + var Util = YAHOO.util, + Cookie = Util.Cookie, + Dom = Util.Dom, + Event = Util.Event, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; - var CreateEmpire = function (Login) { - this.id = 'createEmpire'; - this._login = Login; - this.createEvent('onCreateSuccessful'); + var CreateEmpire = function (Login) { + this.id = 'createEmpire'; + this._login = Login; + this.createEvent('onCreateSuccessful'); - var container = document.createElement('div'); - container.id = this.id; - Dom.addClass(container, 'hidden'); - container.innerHTML = [ - '
Create Empire
', - '
', - '
', - '
', - '
    ', - '
  • ', - '
  • ', - '
  • ', - '
  • ', - '
  • ', - '
  • ', - '
', - '
    ', - '
  • ', - '
  • *
  • ', - '
  • *
  • ', - '
  • *
  • ', - '
  • * Required field
  • ', - '
', - '
', - ' ', - '
', - '
', - '
', - ].join(''); - document.body.insertBefore(container, document.body.firstChild); + var container = document.createElement('div'); + container.id = this.id; + Dom.addClass(container, 'hidden'); + container.innerHTML = [ + '
Create Empire
', + '
', + '
', + '
', + '
    ', + '
  • ', + '
  • ', + '
  • ', + '
  • ', + '
  • ', + '
  • ', + '
', + '
    ', + '
  • ', + '
  • *
  • ', + '
  • *
  • ', + '
  • *
  • ', + '
  • * Required field
  • ', + '
', + '
', + ' ', + '
', + '
', + '
', + ].join(''); + document.body.insertBefore(container, document.body.firstChild); - this.Dialog = new YAHOO.widget.Dialog(this.id, { - constraintoviewport: true, - fixedcenter: true, - postmethod: 'none', - visible: false, - buttons: [ - { - text: 'Create', - handler: { fn: this.handleCreate, scope: this }, - isDefault: true, - }, - { - text: 'Cancel', - handler: { fn: this.handleCancel, scope: this }, - }, - ], - draggable: false, - effect: Game.GetContainerEffect(), - modal: false, - close: false, - width: '750px', - underlay: false, - zIndex: 9999, - }); - this.Dialog.renderEvent.subscribe( - function () { - //get el's after rendered - this.elName = Dom.get('empireName'); - this.elDesc = Dom.get('empireDesc'); - this.elEmail = Dom.get('empireEmail'); - this.elFriendCode = Dom.get('empireFriendCode'); - this.elPass = Dom.get('empirePass'); - this.elPassConfirm = Dom.get('empirePassConfirm'); - this.elAgreeTOS = Dom.get('empireAgreeTOS'); - this.elAgreeRules = Dom.get('empireAgreeRules'); - this.elMessage = Dom.get('empireMessage'); - this.elCaptchaImage = Dom.get('empireCaptchaImage'); - this.elCaptcha = Dom.get('empireCaptcha'); - Event.on(this.elCaptchaImage, 'load', function () { - Dom.setStyle(this, 'visibility', 'inherit'); - }); - Event.on( - 'empireRefreshCaptcha', - 'click', - function (e) { - Event.stopEvent(e); - this.refreshCaptcha(); - }, - this, - true - ); + this.Dialog = new YAHOO.widget.Dialog(this.id, { + constraintoviewport: true, + fixedcenter: true, + postmethod: 'none', + visible: false, + buttons: [ + { + text: 'Create', + handler: { fn: this.handleCreate, scope: this }, + isDefault: true, + }, + { + text: 'Cancel', + handler: { fn: this.handleCancel, scope: this }, + }, + ], + draggable: false, + effect: Game.GetContainerEffect(), + modal: false, + close: false, + width: '750px', + underlay: false, + zIndex: 9999, + }); + this.Dialog.renderEvent.subscribe( + function () { + //get el's after rendered + this.elName = Dom.get('empireName'); + this.elDesc = Dom.get('empireDesc'); + this.elEmail = Dom.get('empireEmail'); + this.elFriendCode = Dom.get('empireFriendCode'); + this.elPass = Dom.get('empirePass'); + this.elPassConfirm = Dom.get('empirePassConfirm'); + this.elAgreeTOS = Dom.get('empireAgreeTOS'); + this.elAgreeRules = Dom.get('empireAgreeRules'); + this.elMessage = Dom.get('empireMessage'); + this.elCaptchaImage = Dom.get('empireCaptchaImage'); + this.elCaptcha = Dom.get('empireCaptcha'); + Event.on(this.elCaptchaImage, 'load', function () { + Dom.setStyle(this, 'visibility', 'inherit'); + }); + Event.on( + 'empireRefreshCaptcha', + 'click', + function (e) { + Event.stopEvent(e); + this.refreshCaptcha(); + }, + this, + true + ); - Dom.removeClass(this.id, Lib.Styles.HIDDEN); - }, - this, - true - ); - this.Dialog.cfg.queueProperty( - 'keylisteners', - new YAHOO.util.KeyListener( - 'empirePassConfirm', - { keys: 13 }, - { fn: this.handleCreate, scope: this, correctScope: true } - ) - ); - this.Dialog.render(); - Game.OverlayManager.register(this.Dialog); + Dom.removeClass(this.id, Lib.Styles.HIDDEN); + }, + this, + true + ); + this.Dialog.cfg.queueProperty( + 'keylisteners', + new YAHOO.util.KeyListener( + 'empirePassConfirm', + { keys: 13 }, + { fn: this.handleCreate, scope: this, correctScope: true } + ) + ); + this.Dialog.render(); + Game.OverlayManager.register(this.Dialog); - this.initSpecies(); - }; - CreateEmpire.prototype = { - refreshCaptcha: function () { - Dom.setStyle(this.elCaptchaImage, 'visibility', 'hidden'); - Game.Services.Empire.fetch_captcha( - {}, - { - success: function (o) { - YAHOO.log(o, 'info', 'RefreshCaptcha'); - this.captchaGUID = o.result.guid; - this.elCaptchaImage.src = o.result.url; - }, - failure: function (o) { - this.setMessage(o.error.message); - return true; - }, - scope: this, - } - ); + this.initSpecies(); + }; + CreateEmpire.prototype = { + refreshCaptcha: function () { + Dom.setStyle(this.elCaptchaImage, 'visibility', 'hidden'); + Game.Services.Empire.fetch_captcha( + {}, + { + success: function (o) { + YAHOO.log(o, 'info', 'RefreshCaptcha'); + this.captchaGUID = o.result.guid; + this.elCaptchaImage.src = o.result.url; }, - - handleCreate: function () { - if (!this.elAgreeTOS.checked || !this.elAgreeRules.checked) { - this.setMessage( - 'You must agree to the Terms of Service and the rules before registering.' - ); - return; - } - this.setMessage(''); - if (this.savedEmpire && this.savedEmpire.name == this.elName.value) { - Game.SpeciesCreator.show(this.savedEmpire.id); - this.hide(); //hide empire - } else { - MenuStore.showLoader(); - var EmpireServ = Game.Services.Empire, - data = { - name: this.elName.value, - description: this.elDesc.value, - email: this.elEmail.value, - }; - if (this.facebook) { - data.facebook_uid = this.facebook.uid; - data.facebook_token = this.facebook.token; - } else { - data.captcha_guid = this.captchaGUID; - data.captcha_solution = this.elCaptcha.value; - } - if (this.elPass.value.length > 0) { - data.password = this.elPass.value; - data.password1 = this.elPassConfirm.value; - } - if (this.elFriendCode.value.length > 0) { - data.invite_code = this.elFriendCode.value; - } - EmpireServ.create(data, { - success: function (o) { - YAHOO.log(o, 'info', 'CreateEmpire'); - this.savedEmpire = data; - this.savedEmpire.id = o.result; - Game.SpeciesCreator.show(o.result); - MenuStore.hideLoader(); - this.hide(); //hide empire - }, - failure: function (o) { - this.setMessage(o.error.message); - if (o.error.code == 1014) { - this.captchaGUID = o.error.data.guid; - this.elCaptchaImage.src = o.error.data.url; - this.elCaptcha.value = ''; - this.elCaptcha.focus(); - } else if (o.error.code == 1100) { - this.savedEmpire = data; - this.savedEmpire.id = o.error.data; - Game.SpeciesCreator.show(o.error.data.empire_id); - this.hide(); //hide empire - } - return true; - }, - scope: this, - }); - } + failure: function (o) { + this.setMessage(o.error.message); + return true; }, - handleCancel: function () { - this.hide(); - this._login.show(); + scope: this, + } + ); + }, + + handleCreate: function () { + if (!this.elAgreeTOS.checked || !this.elAgreeRules.checked) { + this.setMessage( + 'You must agree to the Terms of Service and the rules before registering.' + ); + return; + } + this.setMessage(''); + if (this.savedEmpire && this.savedEmpire.name == this.elName.value) { + Game.SpeciesCreator.show(this.savedEmpire.id); + this.hide(); //hide empire + } else { + MenuStore.showLoader(); + var EmpireServ = Game.Services.Empire, + data = { + name: this.elName.value, + description: this.elDesc.value, + email: this.elEmail.value, + }; + if (this.facebook) { + data.facebook_uid = this.facebook.uid; + data.facebook_token = this.facebook.token; + } else { + data.captcha_guid = this.captchaGUID; + data.captcha_solution = this.elCaptcha.value; + } + if (this.elPass.value.length > 0) { + data.password = this.elPass.value; + data.password1 = this.elPassConfirm.value; + } + if (this.elFriendCode.value.length > 0) { + data.invite_code = this.elFriendCode.value; + } + EmpireServ.create(data, { + success: function (o) { + YAHOO.log(o, 'info', 'CreateEmpire'); + this.savedEmpire = data; + this.savedEmpire.id = o.result; + Game.SpeciesCreator.show(o.result); + MenuStore.hideLoader(); + this.hide(); //hide empire }, - setMessage: function (str) { - Dom.replaceClass(this.elMessage, Lib.Styles.HIDDEN, Lib.Styles.ALERT); - this.elMessage.innerHTML = str; + failure: function (o) { + this.setMessage(o.error.message); + if (o.error.code == 1014) { + this.captchaGUID = o.error.data.guid; + this.elCaptchaImage.src = o.error.data.url; + this.elCaptcha.value = ''; + this.elCaptcha.focus(); + } else if (o.error.code == 1100) { + this.savedEmpire = data; + this.savedEmpire.id = o.error.data; + Game.SpeciesCreator.show(o.error.data.empire_id); + this.hide(); //hide empire + } + return true; }, - facebookReturn: function (uid, token, name) { - this.savedEmpire = undefined; - this.elName.value = name + "'s Empire"; - this.elAgreeTOS.checked = false; - this.elAgreeRules.checked = false; + scope: this, + }); + } + }, + handleCancel: function () { + this.hide(); + this._login.show(); + }, + setMessage: function (str) { + Dom.replaceClass(this.elMessage, Lib.Styles.HIDDEN, Lib.Styles.ALERT); + this.elMessage.innerHTML = str; + }, + facebookReturn: function (uid, token, name) { + this.savedEmpire = undefined; + this.elName.value = name + "'s Empire"; + this.elAgreeTOS.checked = false; + this.elAgreeRules.checked = false; - this.facebook = { - uid: uid, - token: token, - }; + this.facebook = { + uid: uid, + token: token, + }; - Dom.addClass(this.id, 'facebookLogin'); - Game.OverlayManager.hideAll(); - this.Dialog.show(); + Dom.addClass(this.id, 'facebookLogin'); + Game.OverlayManager.hideAll(); + this.Dialog.show(); + }, + show: function (doNotClear) { + Game.OverlayManager.hideAll(); + Dom.removeClass(this.id, 'facebookLogin'); + delete this.facebook; + if (!doNotClear) { + this.savedEmpire = undefined; + this.elName.value = ''; + this.elDesc.value = ''; + this.elEmail.value = ''; + this.elFriendCode.value = Cookie.get('lacunaReferral') || ''; + this.elPass.value = ''; + this.elPassConfirm.value = ''; + this.elAgreeTOS.checked = false; + this.elAgreeRules.checked = false; + this.elCaptcha.value = ''; + } + this.refreshCaptcha(); + this.Dialog.show(); + }, + hide: function () { + Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); + this.Dialog.hide(); + }, + initSpecies: function () { + if (!Game.SpeciesCreator) { + Game.SpeciesCreator = new Lacuna.CreateSpecies(this); + Game.SpeciesCreator.subscribe( + 'onCreateSuccessful', + function (oArgs) { + this.fireEvent('onCreateSuccessful', oArgs); }, - show: function (doNotClear) { - Game.OverlayManager.hideAll(); - Dom.removeClass(this.id, 'facebookLogin'); - delete this.facebook; - if (!doNotClear) { - this.savedEmpire = undefined; - this.elName.value = ''; - this.elDesc.value = ''; - this.elEmail.value = ''; - this.elFriendCode.value = Cookie.get('lacunaReferral') || ''; - this.elPass.value = ''; - this.elPassConfirm.value = ''; - this.elAgreeTOS.checked = false; - this.elAgreeRules.checked = false; - this.elCaptcha.value = ''; - } - this.refreshCaptcha(); - this.Dialog.show(); - }, - hide: function () { - Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); - this.Dialog.hide(); - }, - initSpecies: function () { - if (!Game.SpeciesCreator) { - Game.SpeciesCreator = new Lacuna.CreateSpecies(this); - Game.SpeciesCreator.subscribe( - 'onCreateSuccessful', - function (oArgs) { - this.fireEvent('onCreateSuccessful', oArgs); - }, - this, - true - ); - } - }, - }; - YAHOO.lang.augmentProto(CreateEmpire, Util.EventProvider); + this, + true + ); + } + }, + }; + YAHOO.lang.augmentProto(CreateEmpire, Util.EventProvider); - Lacuna.CreateEmpire = CreateEmpire; - })(); - YAHOO.register('createEmpire', YAHOO.lacuna.CreateEmpire, { - version: '1', - build: '0', - }); + Lacuna.CreateEmpire = CreateEmpire; + })(); + YAHOO.register('createEmpire', YAHOO.lacuna.CreateEmpire, { + version: '1', + build: '0', + }); } diff --git a/app/yui/createSpecies.js b/app/yui/createSpecies.js index 4a7d52e5..5ce08848 100644 --- a/app/yui/createSpecies.js +++ b/app/yui/createSpecies.js @@ -3,148 +3,148 @@ YAHOO.namespace('lacuna'); import MenuStore from 'app/stores/menu'; if (typeof YAHOO.lacuna.CreateSpecies == 'undefined' || !YAHOO.lacuna.CreateSpecies) { - (function () { - var Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; + (function () { + var Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; - var CreateSpecies = function (Empire) { - this.id = 'createSpecies'; - this._empire = Empire; - this.createEvent('onCreateSuccessful'); + var CreateSpecies = function (Empire) { + this.id = 'createSpecies'; + this._empire = Empire; + this.createEvent('onCreateSuccessful'); - var container = document.createElement('div'); - container.id = this.id; - Dom.addClass(container, Lib.Styles.HIDDEN); - container.innerHTML = this._getHtml(); - document.body.insertBefore(container, document.body.firstChild); + var container = document.createElement('div'); + container.id = this.id; + Dom.addClass(container, Lib.Styles.HIDDEN); + container.innerHTML = this._getHtml(); + document.body.insertBefore(container, document.body.firstChild); - this.Dialog = new YAHOO.widget.Dialog(this.id, { - constraintoviewport: false, - //fixedcenter:true, - postmethod: 'none', - visible: false, - buttons: [ - { - text: 'Found Empire', - handler: { fn: this.handleCreate, scope: this }, - isDefault: true, - }, - { - text: 'Cancel', - handler: { fn: this.handleCancel, scope: this }, - }, - ], - draggable: true, - effect: Game.GetContainerEffect(), - modal: false, - close: false, - width: '735px', - underlay: false, - zIndex: 9999, - }); - this.Dialog.renderEvent.subscribe( - function () { - this.elMessage = Dom.get('speciesMessage'); - this.designer = new Lacuna.SpeciesDesigner(); - this.designer.render('speciesCreateDesign'); - Dom.removeClass(this.id, Lib.Styles.HIDDEN); - }, - this, - true - ); - this.Dialog.render(); - Game.OverlayManager.register(this.Dialog); - }; - CreateSpecies.prototype = { - handleCreate: function () { - this.setMessage(''); - var EmpireServ = Game.Services.Empire, - data = this.designer.getSpeciesData(); - try { - if (!this.designer.validateSpecies(data)) { - return; - } - } catch (e) { - this.setMessage(e); - return; - } - delete data.affinity_total; - data.empire_id = this.empireId; - EmpireServ.update_species(data, { - success: function (o) { - YAHOO.log(o, 'info', 'CreateSpecies'); - this._found(); - }, - failure: function (o) { - this.setMessage(o.error.message); - return true; - }, - scope: this, - }); - }, - handleCancel: function () { - this.hide(); - this._empire.handleCancel(); - }, + this.Dialog = new YAHOO.widget.Dialog(this.id, { + constraintoviewport: false, + //fixedcenter:true, + postmethod: 'none', + visible: false, + buttons: [ + { + text: 'Found Empire', + handler: { fn: this.handleCreate, scope: this }, + isDefault: true, + }, + { + text: 'Cancel', + handler: { fn: this.handleCancel, scope: this }, + }, + ], + draggable: true, + effect: Game.GetContainerEffect(), + modal: false, + close: false, + width: '735px', + underlay: false, + zIndex: 9999, + }); + this.Dialog.renderEvent.subscribe( + function () { + this.elMessage = Dom.get('speciesMessage'); + this.designer = new Lacuna.SpeciesDesigner(); + this.designer.render('speciesCreateDesign'); + Dom.removeClass(this.id, Lib.Styles.HIDDEN); + }, + this, + true + ); + this.Dialog.render(); + Game.OverlayManager.register(this.Dialog); + }; + CreateSpecies.prototype = { + handleCreate: function () { + this.setMessage(''); + var EmpireServ = Game.Services.Empire, + data = this.designer.getSpeciesData(); + try { + if (!this.designer.validateSpecies(data)) { + return; + } + } catch (e) { + this.setMessage(e); + return; + } + delete data.affinity_total; + data.empire_id = this.empireId; + EmpireServ.update_species(data, { + success: function (o) { + YAHOO.log(o, 'info', 'CreateSpecies'); + this._found(); + }, + failure: function (o) { + this.setMessage(o.error.message); + return true; + }, + scope: this, + }); + }, + handleCancel: function () { + this.hide(); + this._empire.handleCancel(); + }, - _found: function () { - MenuStore.showLoader(); - var EmpireServ = Game.Services.Empire; - EmpireServ.found( - { empire_id: this.empireId, api_key: Lib.ApiKey }, - { - success: function (o) { - YAHOO.log(o, 'info', 'CreateSpecies._found.success'); - MenuStore.hideLoader(); - this.hide(); //hide species - this.fireEvent('onCreateSuccessful', o); - }, - failure: function (o) { - this.setMessage(o.error.message); - return true; - }, - scope: this, - } - ); - }, - _getHtml: function () { - return [ - '
Create Species
', - '
', - '
', - '
', - ' ', - '
', - '
', - '
', - ].join(''); - }, - setMessage: function (str) { - Dom.replaceClass(this.elMessage, Lib.Styles.HIDDEN, Lib.Styles.ALERT); - this.elMessage.innerHTML = str; - }, - show: function (empire_id) { - this.empireId = empire_id; - Game.OverlayManager.hideAll(); - this.Dialog.show(); - this.Dialog.center(); + _found: function () { + MenuStore.showLoader(); + var EmpireServ = Game.Services.Empire; + EmpireServ.found( + { empire_id: this.empireId, api_key: Lib.ApiKey }, + { + success: function (o) { + YAHOO.log(o, 'info', 'CreateSpecies._found.success'); + MenuStore.hideLoader(); + this.hide(); //hide species + this.fireEvent('onCreateSuccessful', o); }, - hide: function () { - Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); - this.Dialog.hide(); + failure: function (o) { + this.setMessage(o.error.message); + return true; }, - }; - YAHOO.lang.augmentProto(CreateSpecies, Util.EventProvider); + scope: this, + } + ); + }, + _getHtml: function () { + return [ + '
Create Species
', + '
', + '
', + '
', + ' ', + '
', + '
', + '
', + ].join(''); + }, + setMessage: function (str) { + Dom.replaceClass(this.elMessage, Lib.Styles.HIDDEN, Lib.Styles.ALERT); + this.elMessage.innerHTML = str; + }, + show: function (empire_id) { + this.empireId = empire_id; + Game.OverlayManager.hideAll(); + this.Dialog.show(); + this.Dialog.center(); + }, + hide: function () { + Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); + this.Dialog.hide(); + }, + }; + YAHOO.lang.augmentProto(CreateSpecies, Util.EventProvider); - Lacuna.CreateSpecies = CreateSpecies; - })(); - YAHOO.register('createSpecies', YAHOO.lacuna.CreateSpecies, { - version: '1', - build: '0', - }); + Lacuna.CreateSpecies = CreateSpecies; + })(); + YAHOO.register('createSpecies', YAHOO.lacuna.CreateSpecies, { + version: '1', + build: '0', + }); } diff --git a/app/yui/library.js b/app/yui/library.js index 8db83309..2446ba89 100644 --- a/app/yui/library.js +++ b/app/yui/library.js @@ -14,373 +14,373 @@ following code at the beginning of your scripts, allowing use of indexOf in impl exactly the one used in Firefox and SpiderMonkey. */ if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function (elt /*, from*/) { - var len = this.length >>> 0; + Array.prototype.indexOf = function (elt /*, from*/) { + var len = this.length >>> 0; - var from = Number(arguments[1]) || 0; - from = from < 0 ? Math.ceil(from) : Math.floor(from); - if (from < 0) { - from += len; - } + var from = Number(arguments[1]) || 0; + from = from < 0 ? Math.ceil(from) : Math.floor(from); + if (from < 0) { + from += len; + } - for (; from < len; from++) { - if (from in this && this[from] === elt) { - return from; - } - } - return -1; - }; + for (; from < len; from++) { + if (from in this && this[from] === elt) { + return from; + } + } + return -1; + }; } if (!String.prototype.titleCaps) { - String.small = '(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)'; - String.punct = '([!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)'; + String.small = '(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)'; + String.punct = '([!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)'; - String.prototype.titleCaps = function (replaceVal, withVal) { - var parts = [], - split = /[:.;?!] |(?: |^)["�]/g, - index = 0, - processVal = this; - var fnUpper = function (all) { - return /[A-Za-z]\.[A-Za-z]/.test(all) ? all : String.upper(all); - }, - fnPuntUpper = function (all, punct, word) { - return punct + String.upper(word); - }; + String.prototype.titleCaps = function (replaceVal, withVal) { + var parts = [], + split = /[:.;?!] |(?: |^)["�]/g, + index = 0, + processVal = this; + var fnUpper = function (all) { + return /[A-Za-z]\.[A-Za-z]/.test(all) ? all : String.upper(all); + }, + fnPuntUpper = function (all, punct, word) { + return punct + String.upper(word); + }; - if (replaceVal) { - var rg = new RegExp(replaceVal, 'g'); - processVal = processVal.replace(rg, withVal || ''); - } + if (replaceVal) { + var rg = new RegExp(replaceVal, 'g'); + processVal = processVal.replace(rg, withVal || ''); + } - while (true) { - var m = split.exec(processVal); + while (true) { + var m = split.exec(processVal); - parts.push( - processVal - .substring(index, m ? m.index : processVal.length) - .replace(/\b([A-Za-z][a-z.'�]*)\b/g, fnUpper) - .replace(RegExp('\\b' + String.small + '\\b', 'ig'), String.lower) - .replace(RegExp('^' + String.punct + String.small + '\\b', 'ig'), fnPuntUpper) - .replace(RegExp('\\b' + String.small + String.punct + '$', 'ig'), String.upper) - ); + parts.push( + processVal + .substring(index, m ? m.index : processVal.length) + .replace(/\b([A-Za-z][a-z.'�]*)\b/g, fnUpper) + .replace(RegExp('\\b' + String.small + '\\b', 'ig'), String.lower) + .replace(RegExp('^' + String.punct + String.small + '\\b', 'ig'), fnPuntUpper) + .replace(RegExp('\\b' + String.small + String.punct + '$', 'ig'), String.upper) + ); - index = split.lastIndex; + index = split.lastIndex; - if (m) { - parts.push(m[0]); - } else { - break; - } - } + if (m) { + parts.push(m[0]); + } else { + break; + } + } - return parts - .join('') - .replace(/ V(s?)\. /gi, ' v$1. ') - .replace(/(['�])S\b/gi, '$1s') - .replace(/\b(AT&T|Q&A)\b/gi, function (all) { - return all.toUpperCase(); - }); - }; - String.lower = function (word) { - return word.toLowerCase(); - }; - String.upper = function (word) { - return word.substr(0, 1).toUpperCase() + word.substr(1); - }; + return parts + .join('') + .replace(/ V(s?)\. /gi, ' v$1. ') + .replace(/(['�])S\b/gi, '$1s') + .replace(/\b(AT&T|Q&A)\b/gi, function (all) { + return all.toUpperCase(); + }); + }; + String.lower = function (word) { + return word.toLowerCase(); + }; + String.upper = function (word) { + return word.substr(0, 1).toUpperCase() + word.substr(1); + }; } if (typeof YAHOO.lacuna.Library == 'undefined' || !YAHOO.lacuna.Library) { - (function () { - var Util = YAHOO.util, - Lang = YAHOO.lang, - Dom = Util.Dom, - assetUrl = process.env.KA_ASSETS_URL; + (function () { + var Util = YAHOO.util, + Lang = YAHOO.lang, + Dom = Util.Dom, + assetUrl = process.env.KA_ASSETS_URL; - var Library = { - ApiKey: '53137d8f-3544-4118-9001-b0acbec70b3d', - AssetUrl: assetUrl, - Styles: { - HIDDEN: 'hidden', - ALERT: 'alert', - }, - ErrorCodes: { - 1000: 'Name not available', - 1001: 'Invalid password', - 1002: 'Object does not exist', - 1003: 'Too much information', - 1004: 'Password incorrect', - 1005: 'Contains invalid characters', - 1006: 'Session expired', - 1007: 'Overspend', - 1008: 'Underspend', - 1009: 'Invalid range', - 1010: 'Insufficient privileges', - 1011: 'Not enough resources in storage', - 1012: 'Not enough resources in production', - 1013: 'Missing prerequisites', - 1014: 'Captcha not valid', - 1015: 'Restricted for sitter logins', - 1100: 'Empire not founded', - 1101: 'Empire not founded, and you tried to create it, but had the wrong password', - 1200: 'Game Over', - }, - View: { - STAR: 'star', - SYSTEM: 'system', - PLANET: 'planet', - }, - QueueTypes: { - PLANET: '1', - STAR: '2', - SYSTEM: '3', - }, + var Library = { + ApiKey: '53137d8f-3544-4118-9001-b0acbec70b3d', + AssetUrl: assetUrl, + Styles: { + HIDDEN: 'hidden', + ALERT: 'alert', + }, + ErrorCodes: { + 1000: 'Name not available', + 1001: 'Invalid password', + 1002: 'Object does not exist', + 1003: 'Too much information', + 1004: 'Password incorrect', + 1005: 'Contains invalid characters', + 1006: 'Session expired', + 1007: 'Overspend', + 1008: 'Underspend', + 1009: 'Invalid range', + 1010: 'Insufficient privileges', + 1011: 'Not enough resources in storage', + 1012: 'Not enough resources in production', + 1013: 'Missing prerequisites', + 1014: 'Captcha not valid', + 1015: 'Restricted for sitter logins', + 1100: 'Empire not founded', + 1101: 'Empire not founded, and you tried to create it, but had the wrong password', + 1200: 'Game Over', + }, + View: { + STAR: 'star', + SYSTEM: 'system', + PLANET: 'planet', + }, + QueueTypes: { + PLANET: '1', + STAR: '2', + SYSTEM: '3', + }, - formatInlineList: function (stringArray, start, end) { - if (Lang.isArray(stringArray)) { - var offering = ['
    ']; + formatInlineList: function (stringArray, start, end) { + if (Lang.isArray(stringArray)) { + var offering = ['
      ']; - var len = stringArray.length, - begin = 0; - if (start) { - begin = start; + var len = stringArray.length, + begin = 0; + if (start) { + begin = start; - if (end) { - end += 1; //add one so we include the end index - len = end > len ? len : end; - } - } + if (end) { + end += 1; //add one so we include the end index + len = end > len ? len : end; + } + } - for (var n = begin; n < len; n++) { - offering[offering.length] = '
    • '; - offering[offering.length] = stringArray[n]; - offering[offering.length] = '
    • '; - } + for (var n = begin; n < len; n++) { + offering[offering.length] = '
    • '; + offering[offering.length] = stringArray[n]; + offering[offering.length] = '
    • '; + } - offering[offering.length] = '
    '; - return offering.join(''); - } else if (Lang.isString(stringArray)) { - return stringArray; - } else { - return 'Unrecognized stringArray in formatInlineList'; - } - }, - formatMillisecondTime: function (totalMs) { - return Library.formatTime(totalMs / 1000); - }, - padit: function (x, pad, r) { - if (typeof r === 'undefined') { - r = 10; - } - for (; parseInt(x, 10) < r && r > 1; r /= 10) { - x = pad.toString() + x; - } - return x.toString(); - }, - formatTime: function (totalSeconds) { - return util.formatTime(totalSeconds); - }, - formatNumber: function (num) { - return Util.Number.format(num, { thousandsSeparator: ',' }); - }, - getTime: function (dt) { - if (dt instanceof Date) { - return dt.getTime(); + offering[offering.length] = '
'; + return offering.join(''); + } else if (Lang.isString(stringArray)) { + return stringArray; + } else { + return 'Unrecognized stringArray in formatInlineList'; + } + }, + formatMillisecondTime: function (totalMs) { + return Library.formatTime(totalMs / 1000); + }, + padit: function (x, pad, r) { + if (typeof r === 'undefined') { + r = 10; + } + for (; parseInt(x, 10) < r && r > 1; r /= 10) { + x = pad.toString() + x; + } + return x.toString(); + }, + formatTime: function (totalSeconds) { + return util.formatTime(totalSeconds); + }, + formatNumber: function (num) { + return Util.Number.format(num, { thousandsSeparator: ',' }); + }, + getTime: function (dt) { + if (dt instanceof Date) { + return dt.getTime(); + } else { + return Library.parseServerDate(dt).getTime(); + } + }, + parseServerDate: function (strDate) { + if (strDate instanceof Date) { + return strDate; + } + //"23 03 2010 01:20:11 +0000" + var pieces = strDate.split(' '), //[day month year hr:min:sec timez] + time = pieces[3].split(':'); + var dt = new Date(); + dt.setUTCFullYear(pieces[2] * 1); + dt.setUTCMonth(pieces[1] * 1 - 1, pieces[0] * 1); + dt.setUTCHours(time[0] * 1); + dt.setUTCMinutes(time[1] * 1); + dt.setUTCSeconds(time[2] * 1); + return dt; + }, + parseReason: function (reason, defReason) { + var output = ''; + if (reason) { + if (Lang.isArray(reason)) { + switch (reason[0]) { + case 1011: + output = [ + reason[1], + ' Requires more ', + Lang.isArray(reason[2]) ? reason[2].join(', ') : reason[2], + ].join(''); + break; + case 1012: + if (reason[2]) { + output = [ + reason[1], + ' Requires higher production of ', + Lang.isArray(reason[2]) ? reason[2].join(', ') : reason[2], + ].join(''); } else { - return Library.parseServerDate(dt).getTime(); - } - }, - parseServerDate: function (strDate) { - if (strDate instanceof Date) { - return strDate; + output = reason[1]; } - //"23 03 2010 01:20:11 +0000" - var pieces = strDate.split(' '), //[day month year hr:min:sec timez] - time = pieces[3].split(':'); - var dt = new Date(); - dt.setUTCFullYear(pieces[2] * 1); - dt.setUTCMonth(pieces[1] * 1 - 1, pieces[0] * 1); - dt.setUTCHours(time[0] * 1); - dt.setUTCMinutes(time[1] * 1); - dt.setUTCSeconds(time[2] * 1); - return dt; - }, - parseReason: function (reason, defReason) { - var output = ''; - if (reason) { - if (Lang.isArray(reason)) { - switch (reason[0]) { - case 1011: - output = [ - reason[1], - ' Requires more ', - Lang.isArray(reason[2]) ? reason[2].join(', ') : reason[2], - ].join(''); - break; - case 1012: - if (reason[2]) { - output = [ - reason[1], - ' Requires higher production of ', - Lang.isArray(reason[2]) ? reason[2].join(', ') : reason[2], - ].join(''); - } else { - output = reason[1]; - } - break; - case 1013: - output = reason[1]; - break; - default: - output = defReason || reason[1]; - break; - } - } else { - output = defReason || reason; - } - } - return output; - }, - formatServerDate: function (oDate) { - var dt = oDate instanceof Date ? oDate : Library.parseServerDate(oDate); - return Util.Date.format(dt, { format: '%m/%d/%Y %r' }, 'en'); - }, - formatServerDateShort: function (oDate) { - var dt = oDate instanceof Date ? oDate : Library.parseServerDate(oDate); - return Util.Date.format(dt, { format: '%m/%d %r' }, 'en'); - }, - formatServerDateTimeShort: function (oDate) { - var dt = oDate instanceof Date ? oDate : Library.parseServerDate(oDate); - return Util.Date.format(dt, { format: '%m/%d %I:%M%p' }, 'en'); - }, - formatUTC: function (oDate) { - var dt = new Date( - oDate.getUTCFullYear(), - oDate.getUTCMonth(), - oDate.getUTCDate(), - oDate.getUTCHours(), - oDate.getUTCMinutes(), - oDate.getUTCSeconds(), - 0 - ); - return Util.Date.format(dt, { format: '%m/%d/%Y %r' }, 'en'); - }, + break; + case 1013: + output = reason[1]; + break; + default: + output = defReason || reason[1]; + break; + } + } else { + output = defReason || reason; + } + } + return output; + }, + formatServerDate: function (oDate) { + var dt = oDate instanceof Date ? oDate : Library.parseServerDate(oDate); + return Util.Date.format(dt, { format: '%m/%d/%Y %r' }, 'en'); + }, + formatServerDateShort: function (oDate) { + var dt = oDate instanceof Date ? oDate : Library.parseServerDate(oDate); + return Util.Date.format(dt, { format: '%m/%d %r' }, 'en'); + }, + formatServerDateTimeShort: function (oDate) { + var dt = oDate instanceof Date ? oDate : Library.parseServerDate(oDate); + return Util.Date.format(dt, { format: '%m/%d %I:%M%p' }, 'en'); + }, + formatUTC: function (oDate) { + var dt = new Date( + oDate.getUTCFullYear(), + oDate.getUTCMonth(), + oDate.getUTCDate(), + oDate.getUTCHours(), + oDate.getUTCMinutes(), + oDate.getUTCSeconds(), + 0 + ); + return Util.Date.format(dt, { format: '%m/%d/%Y %r' }, 'en'); + }, - capitalizeFirstLetter: function (string) { - return string.charAt(0).toUpperCase() + string.slice(1); - }, + capitalizeFirstLetter: function (string) { + return string.charAt(0).toUpperCase() + string.slice(1); + }, - getSelectedOption: function (select) { - //just making sure - select = Dom.get(select); + getSelectedOption: function (select) { + //just making sure + select = Dom.get(select); - return Library.getSelectedOptionFromSelectElement(select); - }, - getSelectedOptionFromSelectElement: function (select) { - var opts = select.options, - ind = select.selectedIndex; - return ind >= 0 && opts.length > ind ? opts[ind] : null; - }, - getSelectedOptionValue: function (select) { - var opt = Library.getSelectedOption(select); - return opt ? opt.value : null; - }, - getSelectedOptionValueFromSelectElement: function (select) { - var opt = Library.getSelectedOptionFromSelectElement(select); - return opt ? opt.value : null; - }, + return Library.getSelectedOptionFromSelectElement(select); + }, + getSelectedOptionFromSelectElement: function (select) { + var opts = select.options, + ind = select.selectedIndex; + return ind >= 0 && opts.length > ind ? opts[ind] : null; + }, + getSelectedOptionValue: function (select) { + var opt = Library.getSelectedOption(select); + return opt ? opt.value : null; + }, + getSelectedOptionValueFromSelectElement: function (select) { + var opt = Library.getSelectedOptionFromSelectElement(select); + return opt ? opt.value : null; + }, - fadeOutElm: function (id) { - var a = new Util.Anim(id, { opacity: { from: 1, to: 0 } }, 4); - a.onComplete.subscribe(function (e, dur, arg) { - Dom.get(arg).innerHTML = ''; - Dom.setStyle(arg, 'opacity', 1); - }, id); - a.animate(); - }, + fadeOutElm: function (id) { + var a = new Util.Anim(id, { opacity: { from: 1, to: 0 } }, 4); + a.onComplete.subscribe(function (e, dur, arg) { + Dom.get(arg).innerHTML = ''; + Dom.setStyle(arg, 'opacity', 1); + }, id); + a.animate(); + }, - ResourceTypes: { - energy: 1, - essentia: 0, - food: [ - 'algae', - 'apple', - 'bean', - 'beetle', - 'burger', - 'bread', - 'cheese', - 'chip', - 'cider', - 'corn', - 'fungus', - 'lapis', - 'meal', - 'milk', - 'pancake', - 'pie', - 'potato', - 'root', - 'shake', - 'soup', - 'syrup', - 'wheat', - ], - ore: [ - 'anthracite', - 'bauxite', - 'beryl', - 'chromite', - 'chalcopyrite', - 'fluorite', - 'galena', - 'goethite', - 'gold', - 'gypsum', - 'halite', - 'kerogen', - 'magnetite', - 'methane', - 'monazite', - 'rutile', - 'sulfur', - 'trona', - 'uraninite', - 'zircon', - ], - waste: 1, - water: 1, - }, - Ships: { - bomber: 'Bomber', - cargo_ship: 'Cargo Ship', - colony_ship: 'Colony Ship', - detonator: 'Detonator', - dory: 'Dory', - drone: 'Drone', - excavator: 'Excavator', - fighter: 'Fighter', - freighter: 'Freighter', - gas_giant_settlement_platform_ship: 'Gas Giant Settlement Platform Ship', - mining_platform_ship: 'Mining Platform Ship', - observatory_seeker: 'Observatory Seeker', - probe: 'Probe', - scanner: 'Scanner', - scow: 'Scow', - security_ministry_seeker: 'Security Ministry Seeker', - smuggler_ship: 'Smuggler Ship', - snark: 'Snark', - space_station: 'Space Station', - spaceport_seeker: 'Spaceport Seeker', - spy_pod: 'Spy Pod', - spy_shuttle: 'Spy Shuttle', - terraforming_platform_ship: 'Terraforming Platform Ship', - }, - }; + ResourceTypes: { + energy: 1, + essentia: 0, + food: [ + 'algae', + 'apple', + 'bean', + 'beetle', + 'burger', + 'bread', + 'cheese', + 'chip', + 'cider', + 'corn', + 'fungus', + 'lapis', + 'meal', + 'milk', + 'pancake', + 'pie', + 'potato', + 'root', + 'shake', + 'soup', + 'syrup', + 'wheat', + ], + ore: [ + 'anthracite', + 'bauxite', + 'beryl', + 'chromite', + 'chalcopyrite', + 'fluorite', + 'galena', + 'goethite', + 'gold', + 'gypsum', + 'halite', + 'kerogen', + 'magnetite', + 'methane', + 'monazite', + 'rutile', + 'sulfur', + 'trona', + 'uraninite', + 'zircon', + ], + waste: 1, + water: 1, + }, + Ships: { + bomber: 'Bomber', + cargo_ship: 'Cargo Ship', + colony_ship: 'Colony Ship', + detonator: 'Detonator', + dory: 'Dory', + drone: 'Drone', + excavator: 'Excavator', + fighter: 'Fighter', + freighter: 'Freighter', + gas_giant_settlement_platform_ship: 'Gas Giant Settlement Platform Ship', + mining_platform_ship: 'Mining Platform Ship', + observatory_seeker: 'Observatory Seeker', + probe: 'Probe', + scanner: 'Scanner', + scow: 'Scow', + security_ministry_seeker: 'Security Ministry Seeker', + smuggler_ship: 'Smuggler Ship', + snark: 'Snark', + space_station: 'Space Station', + spaceport_seeker: 'Spaceport Seeker', + spy_pod: 'Spy Pod', + spy_shuttle: 'Spy Shuttle', + terraforming_platform_ship: 'Terraforming Platform Ship', + }, + }; - YAHOO.lacuna.Library = Library; - })(); - YAHOO.register('library', YAHOO.lacuna.Library, { - version: '1', - build: '0', - }); + YAHOO.lacuna.Library = Library; + })(); + YAHOO.register('library', YAHOO.lacuna.Library, { + version: '1', + build: '0', + }); } diff --git a/app/yui/login.js b/app/yui/login.js index 419f48d9..b40f2c93 100644 --- a/app/yui/login.js +++ b/app/yui/login.js @@ -6,493 +6,490 @@ import MenuStore from 'app/stores/menu'; YAHOO.namespace('lacuna'); if (typeof YAHOO.lacuna.Login == 'undefined' || !YAHOO.lacuna.Login) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Cookie = Util.Cookie, - Dom = Util.Dom, - Event = Util.Event, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Cookie = Util.Cookie, + Dom = Util.Dom, + Event = Util.Event, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; - var Login = function () { - this.id = 'login'; - this.createEvent('onLoginSuccessful'); + var Login = function () { + this.id = 'login'; + this.createEvent('onLoginSuccessful'); - var container = document.createElement('div'); - container.id = this.id; - Dom.addClass(container, 'hidden'); + var container = document.createElement('div'); + container.id = this.id; + Dom.addClass(container, 'hidden'); - // currently have to turn off autocomplete. Firefox asks to - // remember login but is unable to fill in the saved values later. - container.innerHTML = [ - '
Login
', - '
', - '
', - '
', - '
', - '
    ', - '
  • ', - '
  • ', - '
  • ', - '
', - ' ', - '
', - '
', - '
', - //'
    ', - //'
  • Have a Facebook account?
  • ', - //'
  • Log in or Create Empire
  • ', - //'
  • ', - //'
', - //'
', - '
    ', - "
  • Don't have an account?
  • ", - '
  • ', - '
', - '
', - '
', - //'
', - //' New to the Lacuna Expanse? Want to find out more before signing up? Click here.', - //'
', - '
', - ].join(''); - document.body.insertBefore(container, document.body.firstChild); - Dom.addClass(container, 'nofooter'); + // currently have to turn off autocomplete. Firefox asks to + // remember login but is unable to fill in the saved values later. + container.innerHTML = [ + '
Login
', + '
', + '
', + '
', + '
', + '
    ', + '
  • ', + '
  • ', + '
  • ', + '
', + ' ', + '
', + '
', + '
', + //'
    ', + //'
  • Have a Facebook account?
  • ', + //'
  • Log in or Create Empire
  • ', + //'
  • ', + //'
', + //'
', + '
    ', + "
  • Don't have an account?
  • ", + '
  • ', + '
', + '
', + '
', + //'
', + //' New to the Lacuna Expanse? Want to find out more before signing up? Click here.', + //'
', + '
', + ].join(''); + document.body.insertBefore(container, document.body.firstChild); + Dom.addClass(container, 'nofooter'); - this.Dialog = new YAHOO.widget.Panel(this.id, { - constraintoviewport: true, - fixedcenter: true, - visible: false, - draggable: false, - effect: Game.GetContainerEffect(), - modal: false, - close: false, - width: '650px', - underlay: false, - zIndex: 9999, - }); - this.Dialog.renderEvent.subscribe( - function () { - //get el's after rendered - this.elName = Dom.get('loginName'); - this.elPass = Dom.get('loginPass'); - this.elCreate = Dom.get('loginCreate'); - this.elRemember = Dom.get('loginRemember'); - this.elForm = Dom.get('loginForm'); - this.elCreate = Dom.get('loginCreate'); - this.elReset = Dom.get('loginReset'); + this.Dialog = new YAHOO.widget.Panel(this.id, { + constraintoviewport: true, + fixedcenter: true, + visible: false, + draggable: false, + effect: Game.GetContainerEffect(), + modal: false, + close: false, + width: '650px', + underlay: false, + zIndex: 9999, + }); + this.Dialog.renderEvent.subscribe( + function () { + //get el's after rendered + this.elName = Dom.get('loginName'); + this.elPass = Dom.get('loginPass'); + this.elCreate = Dom.get('loginCreate'); + this.elRemember = Dom.get('loginRemember'); + this.elForm = Dom.get('loginForm'); + this.elCreate = Dom.get('loginCreate'); + this.elReset = Dom.get('loginReset'); - Event.addListener( - this.elCreate, - 'click', - function (e) { - Event.stopEvent(e); - this.createEmpire(); - }, - this, - true - ); - Event.addListener( - this.elReset, - 'click', - function (e) { - Event.stopEvent(e); - this.resetPassword(); - }, - this, - true - ); - Event.addListener( - this.elForm, - 'submit', - function (e) { - Event.stopEvent(e); - this.handleLogin(); - }, - this, - true - ); - Dom.removeClass(this.id, Lib.Styles.HIDDEN); - }, - this, - true - ); - - this.Dialog.render(); - Game.OverlayManager.register(this.Dialog); - }; - Login.prototype = { - handleLogin: function () { - MenuStore.showLoader(); - this.setMessage(''); - var EmpireServ = Game.Services.Empire; - Fingerprint2.get( - _.bind(function (result) { - console.log('browser: ' + result); - EmpireServ.login( - { - name: this.elName.value, - password: this.elPass.value, - api_key: Lib.ApiKey, - browser: result, - }, - { - success: function (o) { - YAHOO.log(o, 'info', 'Login.handleLogin.success'); - //clear the session just in case - Game.RemoveCookie('session'); - - if (this.elRemember.checked) { - var now = new Date(); - Cookie.set('lacunaEmpireName', this.elName.value, { - domain: Game.domain, - expires: new Date( - now.setFullYear(now.getFullYear() + 1) - ), - }); - } else { - Cookie.remove('lacunaEmpireName'); - } - - this.fireEvent('onLoginSuccessful', o); - - this.elForm.reset(); - this.hide(); - }, - failure: function (o) { - if (o.error.code == 1100) { - //haven't founded empire yet so take them to species - this.hide(); - this.initEmpireCreator(); - Game.OverlayManager.hideAll(); - Game.SpeciesCreator.show(o.error.data.empire_id); - } else if (o.error.code == 1200) { - alert(o.error.message); - window.location = o.error.data; - } else { - this.setMessage( - o.error.message || - 'There was a problem logging in. Please try again.' - ); - } - return true; - }, - scope: this, - } - ); - }, this) - ); - }, - show: function (error) { - if (!this.Dialog.cfg.getProperty('visible')) { - Game.OverlayManager.hideAll(); - this.elForm.reset(); - this.Dialog.show(); - var str = Cookie.get('lacunaEmpireName'); - if (str) { - this.elName.value = str; - this.elRemember.checked = true; - this.elPass.focus(); - } else { - this.elName.focus(); - } - if (error) { - this.setMessage(error.message); - } - } - }, - hide: function () { - if (this.elMessage) { - Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); - } - this.Dialog.hide(); - }, - setMessage: function (str) { - if (!this.elMessage) { - var d = document.createElement('div'); - d.id = 'loginMessage'; - var eUl = this.elName.parentNode.parentNode; - eUl.parentNode.insertBefore(d, eUl.nextSibling); - this.elMessage = d; - } - if (str && str.length > 0) { - Dom.replaceClass(this.elMessage, Lib.Styles.HIDDEN, Lib.Styles.ALERT); - this.elMessage.innerHTML = str; - } else { - Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); - } - }, - initEmpireCreator: function () { - if (!Game.EmpireCreator) { - Game.EmpireCreator = new Lacuna.CreateEmpire(this); - Game.EmpireCreator.subscribe( - 'onCreateSuccessful', - function (oArgs) { - this.fireEvent('onLoginSuccessful', oArgs); - }, - this, - true - ); - } + Event.addListener( + this.elCreate, + 'click', + function (e) { + Event.stopEvent(e); + this.createEmpire(); }, - createEmpire: function () { - this.hide(); //hide login - this.initEmpireCreator(); - Game.OverlayManager.hideAll(); - Game.EmpireCreator.show(); + this, + true + ); + Event.addListener( + this.elReset, + 'click', + function (e) { + Event.stopEvent(e); + this.resetPassword(); }, - resetPassword: function (reset_key) { - this.hide(); //hide login - if (!this.ResetPassword) { - this.ResetPassword = new ResetPassword(this); - this.ResetPassword.subscribe( - 'onResetSuccessful', - function (oArgs) { - this.fireEvent('onLoginSuccessful', oArgs); - }, - this, - true - ); - } - Game.OverlayManager.hideAll(); - if (reset_key) { - this.ResetPassword.showReset(reset_key); - } else { - this.ResetPassword.show(this.elName.value); - } + this, + true + ); + Event.addListener( + this.elForm, + 'submit', + function (e) { + Event.stopEvent(e); + this.handleLogin(); }, - }; - Lang.augmentProto(Login, Util.EventProvider); - - var ResetPassword = function (Login) { - this.createEvent('onResetSuccessful'); - this._login = Login; + this, + true + ); + Dom.removeClass(this.id, Lib.Styles.HIDDEN); + }, + this, + true + ); - this.emailId = 'resetPasswordEmail'; + this.Dialog.render(); + Game.OverlayManager.register(this.Dialog); + }; + Login.prototype = { + handleLogin: function () { + MenuStore.showLoader(); + this.setMessage(''); + var EmpireServ = Game.Services.Empire; + Fingerprint2.get( + _.bind(function (result) { + console.log('browser: ' + result); + EmpireServ.login( + { + name: this.elName.value, + password: this.elPass.value, + api_key: Lib.ApiKey, + browser: result, + }, + { + success: function (o) { + YAHOO.log(o, 'info', 'Login.handleLogin.success'); + //clear the session just in case + Game.RemoveCookie('session'); - var emailContainer = document.createElement('div'); - emailContainer.id = this.emailId; - Dom.addClass(emailContainer, 'hidden'); - emailContainer.innerHTML = [ - '
Reset Password
', - '
', - '
', - '

', - ' Enter either your empire name, or the email address used on the account. You will be sent an email with instructions for resetting your password.', - '

', - ' ', - '
', - '
', - '
', - ].join(''); - document.body.insertBefore(emailContainer, document.body.firstChild); + if (this.elRemember.checked) { + var now = new Date(); + Cookie.set('lacunaEmpireName', this.elName.value, { + domain: Game.domain, + expires: new Date(now.setFullYear(now.getFullYear() + 1)), + }); + } else { + Cookie.remove('lacunaEmpireName'); + } - this.EmailDialog = new YAHOO.widget.Dialog(this.emailId, { - constraintoviewport: true, - fixedcenter: true, - visible: false, - draggable: false, - effect: Game.GetContainerEffect(), - modal: true, - close: true, - width: '400px', - underlay: false, - zIndex: 9999, - buttons: [ - { - text: 'Send Reset Email', - handler: function () { - this.submit(); - }, - isDefault: true, - }, - { - text: 'Cancel', - handler: function () { - this.cancel(); - }, - }, - ], - hideaftersubmit: false, - postmethod: 'manual', - }); - this.EmailDialog.renderEvent.subscribe( - function () { - this.elName = Dom.get('resetEmpireName'); - this.elEmail = Dom.get('resetEmail'); + this.fireEvent('onLoginSuccessful', o); - Event.on( - 'resetShowKey', - 'click', - function (e) { - this.showReset(); - }, - this, - true + this.elForm.reset(); + this.hide(); + }, + failure: function (o) { + if (o.error.code == 1100) { + //haven't founded empire yet so take them to species + this.hide(); + this.initEmpireCreator(); + Game.OverlayManager.hideAll(); + Game.SpeciesCreator.show(o.error.data.empire_id); + } else if (o.error.code == 1200) { + alert(o.error.message); + window.location = o.error.data; + } else { + this.setMessage( + o.error.message || 'There was a problem logging in. Please try again.' ); - Dom.removeClass(this.emailId, Lib.Styles.HIDDEN); + } + return true; }, - this, - true + scope: this, + } ); - this.EmailDialog.submitEvent.subscribe(this.sendEmail, this, true); - this.EmailDialog.cancelEvent.subscribe(this.hide, this, true); - this.EmailDialog.render(); - Game.OverlayManager.register(this.EmailDialog); + }, this) + ); + }, + show: function (error) { + if (!this.Dialog.cfg.getProperty('visible')) { + Game.OverlayManager.hideAll(); + this.elForm.reset(); + this.Dialog.show(); + var str = Cookie.get('lacunaEmpireName'); + if (str) { + this.elName.value = str; + this.elRemember.checked = true; + this.elPass.focus(); + } else { + this.elName.focus(); + } + if (error) { + this.setMessage(error.message); + } + } + }, + hide: function () { + if (this.elMessage) { + Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); + } + this.Dialog.hide(); + }, + setMessage: function (str) { + if (!this.elMessage) { + var d = document.createElement('div'); + d.id = 'loginMessage'; + var eUl = this.elName.parentNode.parentNode; + eUl.parentNode.insertBefore(d, eUl.nextSibling); + this.elMessage = d; + } + if (str && str.length > 0) { + Dom.replaceClass(this.elMessage, Lib.Styles.HIDDEN, Lib.Styles.ALERT); + this.elMessage.innerHTML = str; + } else { + Dom.replaceClass(this.elMessage, Lib.Styles.ALERT, Lib.Styles.HIDDEN); + } + }, + initEmpireCreator: function () { + if (!Game.EmpireCreator) { + Game.EmpireCreator = new Lacuna.CreateEmpire(this); + Game.EmpireCreator.subscribe( + 'onCreateSuccessful', + function (oArgs) { + this.fireEvent('onLoginSuccessful', oArgs); + }, + this, + true + ); + } + }, + createEmpire: function () { + this.hide(); //hide login + this.initEmpireCreator(); + Game.OverlayManager.hideAll(); + Game.EmpireCreator.show(); + }, + resetPassword: function (reset_key) { + this.hide(); //hide login + if (!this.ResetPassword) { + this.ResetPassword = new ResetPassword(this); + this.ResetPassword.subscribe( + 'onResetSuccessful', + function (oArgs) { + this.fireEvent('onLoginSuccessful', oArgs); + }, + this, + true + ); + } + Game.OverlayManager.hideAll(); + if (reset_key) { + this.ResetPassword.showReset(reset_key); + } else { + this.ResetPassword.show(this.elName.value); + } + }, + }; + Lang.augmentProto(Login, Util.EventProvider); - this.resetId = 'resetPasswordKey'; + var ResetPassword = function (Login) { + this.createEvent('onResetSuccessful'); + this._login = Login; - var resetContainer = document.createElement('div'); - resetContainer.id = this.resetId; - Dom.addClass(resetContainer, 'hidden'); - resetContainer.innerHTML = [ - '
Reset Password
', - '
', - '
', - '

', - ' Enter the reset key you have received in your email, along with what you would like your password set to.', - '

', - '
    ', - '
  • ', - '
  • ', - '
  • ', - '
', - '
', - '
', - '
', - ].join(''); - document.body.insertBefore(resetContainer, document.body.firstChild); + this.emailId = 'resetPasswordEmail'; - this.ResetDialog = new YAHOO.widget.Dialog(this.resetId, { - constraintoviewport: true, - fixedcenter: true, - visible: false, - draggable: false, - modal: true, - close: true, - width: '450px', - underlay: false, - zIndex: 9999, - buttons: [ - { - text: 'Reset Password', - handler: function () { - this.submit(); - }, - isDefault: true, - }, - { - text: 'Cancel', - handler: function () { - this.cancel(); - }, - }, - ], - hideaftersubmit: false, - postmethod: 'manual', - }); - this.ResetDialog.renderEvent.subscribe( - function () { - this.elKey = Dom.get('resetKey'); - this.elPassword1 = Dom.get('resetPassword1'); - this.elPassword2 = Dom.get('resetPassword2'); + var emailContainer = document.createElement('div'); + emailContainer.id = this.emailId; + Dom.addClass(emailContainer, 'hidden'); + emailContainer.innerHTML = [ + '
Reset Password
', + '
', + '
', + '

', + ' Enter either your empire name, or the email address used on the account. You will be sent an email with instructions for resetting your password.', + '

', + ' ', + '
', + '
', + '
', + ].join(''); + document.body.insertBefore(emailContainer, document.body.firstChild); - Dom.removeClass(this.resetId, Lib.Styles.HIDDEN); - }, - this, - true - ); - this.ResetDialog.submitEvent.subscribe(this.resetPassword, this, true); - this.ResetDialog.cancelEvent.subscribe(this.hide, this, true); - this.ResetDialog.render(); - Game.OverlayManager.register(this.ResetDialog); - }; - ResetPassword.prototype = { - show: function (empire_name) { - this.elName.value = empire_name ? empire_name : ''; - this.elEmail.value = ''; - this.EmailDialog.getButtons()[0].disabled = false; - this.EmailDialog.show(); + this.EmailDialog = new YAHOO.widget.Dialog(this.emailId, { + constraintoviewport: true, + fixedcenter: true, + visible: false, + draggable: false, + effect: Game.GetContainerEffect(), + modal: true, + close: true, + width: '400px', + underlay: false, + zIndex: 9999, + buttons: [ + { + text: 'Send Reset Email', + handler: function () { + this.submit(); }, - hide: function () { - this.EmailDialog.hide(); - this.ResetDialog.hide(); - this._login.show(); + isDefault: true, + }, + { + text: 'Cancel', + handler: function () { + this.cancel(); }, - sendEmail: function () { - var empireName = this.elName.value; - var email = this.elEmail.value; - var data = {}; - if (empireName.length > 0) { - data.empire_name = empireName; - } - if (email.length > 0) { - data.email = email; - } - this.EmailDialog.getButtons()[0].disabled = true; - MenuStore.showLoader(); - Game.Services.Empire.send_password_reset_message(data, { - success: function (o) { - YAHOO.log(o, 'info', 'ResetPassword.sendEmail.success'); - MenuStore.hideLoader(); - this.showReset(); - }, - failure: function (o) { - this.EmailDialog.getButtons()[0].disabled = false; - }, - scope: this, - }); + }, + ], + hideaftersubmit: false, + postmethod: 'manual', + }); + this.EmailDialog.renderEvent.subscribe( + function () { + this.elName = Dom.get('resetEmpireName'); + this.elEmail = Dom.get('resetEmail'); + + Event.on( + 'resetShowKey', + 'click', + function (e) { + this.showReset(); }, - showReset: function (reset_key) { - if (reset_key) { - this.elKey.value = reset_key; - } else { - this.elKey.value = ''; - } - this.elPassword1.value = ''; - this.elPassword2.value = ''; - this.EmailDialog.hide(); - this.ResetDialog.show(); + this, + true + ); + Dom.removeClass(this.emailId, Lib.Styles.HIDDEN); + }, + this, + true + ); + this.EmailDialog.submitEvent.subscribe(this.sendEmail, this, true); + this.EmailDialog.cancelEvent.subscribe(this.hide, this, true); + this.EmailDialog.render(); + Game.OverlayManager.register(this.EmailDialog); + + this.resetId = 'resetPasswordKey'; + + var resetContainer = document.createElement('div'); + resetContainer.id = this.resetId; + Dom.addClass(resetContainer, 'hidden'); + resetContainer.innerHTML = [ + '
Reset Password
', + '
', + '
', + '

', + ' Enter the reset key you have received in your email, along with what you would like your password set to.', + '

', + '
    ', + '
  • ', + '
  • ', + '
  • ', + '
', + '
', + '
', + '
', + ].join(''); + document.body.insertBefore(resetContainer, document.body.firstChild); + + this.ResetDialog = new YAHOO.widget.Dialog(this.resetId, { + constraintoviewport: true, + fixedcenter: true, + visible: false, + draggable: false, + modal: true, + close: true, + width: '450px', + underlay: false, + zIndex: 9999, + buttons: [ + { + text: 'Reset Password', + handler: function () { + this.submit(); }, - resetPassword: function () { - var reset_key = this.elKey.value; - var password1 = this.elPassword1.value; - var password2 = this.elPassword2.value; - if (password1 != password2) { - alert('Passwords do not match!'); - } else { - MenuStore.showLoader(); - Game.Services.Empire.reset_password( - { - reset_key: reset_key, - password1: password1, - password2: password2, - api_key: Lib.ApiKey, - }, - { - success: function (o) { - YAHOO.log(o, 'info', 'ResetPassword.resetPassword.success'); - MenuStore.hideLoader(); - this.fireEvent('onResetSuccessful', o); - this.hide(); - }, - scope: this, - } - ); - } + isDefault: true, + }, + { + text: 'Cancel', + handler: function () { + this.cancel(); + }, + }, + ], + hideaftersubmit: false, + postmethod: 'manual', + }); + this.ResetDialog.renderEvent.subscribe( + function () { + this.elKey = Dom.get('resetKey'); + this.elPassword1 = Dom.get('resetPassword1'); + this.elPassword2 = Dom.get('resetPassword2'); + + Dom.removeClass(this.resetId, Lib.Styles.HIDDEN); + }, + this, + true + ); + this.ResetDialog.submitEvent.subscribe(this.resetPassword, this, true); + this.ResetDialog.cancelEvent.subscribe(this.hide, this, true); + this.ResetDialog.render(); + Game.OverlayManager.register(this.ResetDialog); + }; + ResetPassword.prototype = { + show: function (empire_name) { + this.elName.value = empire_name ? empire_name : ''; + this.elEmail.value = ''; + this.EmailDialog.getButtons()[0].disabled = false; + this.EmailDialog.show(); + }, + hide: function () { + this.EmailDialog.hide(); + this.ResetDialog.hide(); + this._login.show(); + }, + sendEmail: function () { + var empireName = this.elName.value; + var email = this.elEmail.value; + var data = {}; + if (empireName.length > 0) { + data.empire_name = empireName; + } + if (email.length > 0) { + data.email = email; + } + this.EmailDialog.getButtons()[0].disabled = true; + MenuStore.showLoader(); + Game.Services.Empire.send_password_reset_message(data, { + success: function (o) { + YAHOO.log(o, 'info', 'ResetPassword.sendEmail.success'); + MenuStore.hideLoader(); + this.showReset(); + }, + failure: function (o) { + this.EmailDialog.getButtons()[0].disabled = false; + }, + scope: this, + }); + }, + showReset: function (reset_key) { + if (reset_key) { + this.elKey.value = reset_key; + } else { + this.elKey.value = ''; + } + this.elPassword1.value = ''; + this.elPassword2.value = ''; + this.EmailDialog.hide(); + this.ResetDialog.show(); + }, + resetPassword: function () { + var reset_key = this.elKey.value; + var password1 = this.elPassword1.value; + var password2 = this.elPassword2.value; + if (password1 != password2) { + alert('Passwords do not match!'); + } else { + MenuStore.showLoader(); + Game.Services.Empire.reset_password( + { + reset_key: reset_key, + password1: password1, + password2: password2, + api_key: Lib.ApiKey, }, - }; - Lang.augmentProto(ResetPassword, Util.EventProvider); + { + success: function (o) { + YAHOO.log(o, 'info', 'ResetPassword.resetPassword.success'); + MenuStore.hideLoader(); + this.fireEvent('onResetSuccessful', o); + this.hide(); + }, + scope: this, + } + ); + } + }, + }; + Lang.augmentProto(ResetPassword, Util.EventProvider); - Lacuna.Login = Login; - })(); - YAHOO.register('login', YAHOO.lacuna.Login, { version: '1', build: '0' }); + Lacuna.Login = Login; + })(); + YAHOO.register('login', YAHOO.lacuna.Login, { version: '1', build: '0' }); } diff --git a/app/yui/mapPlanet.js b/app/yui/mapPlanet.js index 6b28ad98..0bd915ed 100644 --- a/app/yui/mapPlanet.js +++ b/app/yui/mapPlanet.js @@ -10,1170 +10,1132 @@ import MenuStore from 'app/stores/menu'; import { WindowMap } from 'app/components/menu/windowManager'; if (typeof YAHOO.lacuna.MapPlanet == 'undefined' || !YAHOO.lacuna.MapPlanet) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; - - var FactoryMap = {}; - - var MapPlanet = function () { - this.createEvent('onMapRpc'); + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; + + var FactoryMap = {}; + + var MapPlanet = function () { + this.createEvent('onMapRpc'); + }; + MapPlanet.prototype = { + _buildDetailsPanel: _.once(function () { + var panelId = 'buildingDetails'; + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
Details
', + '
', + '
', + '
', + ' ', + '
', + '
', + '
    ', + '
  • ', + '
  • ', + '
  • ', + '
', + '
', + '
', + '
', + '
    ', + '
', + '
', + '
', + '
', + '
', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); + + this.buildingDetails = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: false, + close: true, + width: '800px', + underlay: false, + zIndex: 9995, + context: ['header', 'tl', 'bl'], + }); + this.buildingDetails.addQueue = function (seconds, queueFn, elm, sc) { + this.queue = this.queue || []; + //check if the queue is empty and store + var notStarted = this.queue.length == 0; + //push new queue item so it's immediately available for the tick + this.queue.push({ + secondsRemaining: seconds * 1, + el: elm, + fn: queueFn, + scope: sc, + }); + //make sure we subscribe to the tick + if (notStarted) { + Game.onTick.subscribe(this.processQueue, this, true); + } + }; + this.buildingDetails.processQueue = function (e, oArgs) { + if (this.queue.length > 0) { + var queue = this.queue, + diff = oArgs[0] / 1000, + newq = []; + + while (queue.length > 0) { + var callback = queue.pop(); + callback.secondsRemaining -= diff; + if ( + !callback.fn.call(callback.scope || this, callback.secondsRemaining, callback.el) && + callback.secondsRemaining > 0 + ) { + newq.push(callback); + } + } + this.queue = newq; + } else { + Game.onTick.unsubscribe(this.processQueue); + } + }; + this.buildingDetails.resetQueue = function () { + Game.onTick.unsubscribe(this.processQueue); + this.queue = []; + }; + this.buildingDetails.isVisible = function () { + return this.cfg.getProperty('visible'); + }; + this.buildingDetails.resetDisplay = function (oSelf) { + this.resetQueue(); + this.dataStore = {}; + oSelf.currentBuilding = undefined; + if (oSelf.currentBuildingObj) { + oSelf.currentBuildingObj.destroy(); + oSelf.currentBuildingObj = undefined; + } + if (oSelf.currentViewConnection) { + MenuStore.hideLoader(); + Util.Connect.abort(oSelf.currentViewConnection); + } }; - MapPlanet.prototype = { - _buildDetailsPanel: _.once(function () { - var panelId = 'buildingDetails'; - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
Details
', - '
', - '
', - '
', - ' ', - '
', - '
', - '
    ', - '
  • ', - '
  • ', - '
  • ', - '
', - '
', - '
', - '
', - '
    ', - '
', - '
', - '
', - '
', - '
', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); - - this.buildingDetails = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: false, - close: true, - width: '800px', - underlay: false, - zIndex: 9995, - context: ['header', 'tl', 'bl'], - }); - this.buildingDetails.addQueue = function (seconds, queueFn, elm, sc) { - this.queue = this.queue || []; - //check if the queue is empty and store - var notStarted = this.queue.length == 0; - //push new queue item so it's immediately available for the tick - this.queue.push({ - secondsRemaining: seconds * 1, - el: elm, - fn: queueFn, - scope: sc, - }); - //make sure we subscribe to the tick - if (notStarted) { - Game.onTick.subscribe(this.processQueue, this, true); - } - }; - this.buildingDetails.processQueue = function (e, oArgs) { - if (this.queue.length > 0) { - var queue = this.queue, - diff = oArgs[0] / 1000, - newq = []; - - while (queue.length > 0) { - var callback = queue.pop(); - callback.secondsRemaining -= diff; - if ( - !callback.fn.call( - callback.scope || this, - callback.secondsRemaining, - callback.el - ) && - callback.secondsRemaining > 0 - ) { - newq.push(callback); - } - } - this.queue = newq; - } else { - Game.onTick.unsubscribe(this.processQueue); - } - }; - this.buildingDetails.resetQueue = function () { - Game.onTick.unsubscribe(this.processQueue); - this.queue = []; - }; - this.buildingDetails.isVisible = function () { - return this.cfg.getProperty('visible'); - }; - this.buildingDetails.resetDisplay = function (oSelf) { - this.resetQueue(); - this.dataStore = {}; - oSelf.currentBuilding = undefined; - if (oSelf.currentBuildingObj) { - oSelf.currentBuildingObj.destroy(); - oSelf.currentBuildingObj = undefined; - } - if (oSelf.currentViewConnection) { - MenuStore.hideLoader(); - Util.Connect.abort(oSelf.currentViewConnection); - } - }; - - this.buildingDetails.renderEvent.subscribe(function () { - this.img = Dom.get('buildingDetailsImg'); - this.name = Dom.get('buildingDetailsName'); - this.desc = Dom.get('buildingDetailsDesc'); - this.timeLeftLi = Dom.get('buildingDetailsTimeLeft'); - - this.tabView = new YAHOO.widget.TabView('buildingDetailTabs'); - this.tabView.getTabByLabel = function (label) { - var tabs = this.get('tabs'); - for (var t = 0; t < tabs.length; t++) { - var tab = tabs[t]; - if (tab.get('label') == label) { - return this.getTab(t); - } - } - }; - this.tabView.set('activeIndex', 0); - - this.queue = []; - this.dataStore = {}; - }); - this.buildingDetails.hideEvent.subscribe( - function () { - this.buildingDetails.resetDisplay(this); - }, - this, - true - ); - - this.buildingDetails.render(); - Game.OverlayManager.register(this.buildingDetails); - }), - _buildBuilderPanel: _.once(function () { - var panelId = 'buildingBuilder'; - - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
Builder
', - '
', - '
Building on X:Y
', - '
', - ' ', - '
', - '
', - '
', - '
', - ' Available: ', - ' ', - '
', - ' Build > Resources > Ore', - '
', - '
    ', - '
    ', - '
    ', - '
    ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); - - this.buildingBuilder = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: false, - close: true, - underlay: false, - width: '600px', - zIndex: 9996, - context: ['header', 'tr', 'br'], - }); - this.buildingBuilder.renderEvent.subscribe(function () { - this.X = Dom.get('builderX'); - this.Y = Dom.get('builderY'); - this.menuView = Dom.get('builderMenu'); - this.listView = Dom.get('builderListContainer'); - this.buildingList = Dom.get('builderList'); - this.timeFilter = Dom.get('builderTimeFilter'); - this.filterTrail = Dom.get('builderFilterTrail'); - - Event.on('builderTimeFilter', 'change', this.updateDisplay, this, true); - Event.on( - 'builderBuildLink', - 'click', - function (e) { - Event.preventDefault(e); - this.buildingList.innerHTML = ''; - Dom.setStyle(this.listView, 'display', 'none'); - Dom.setStyle(this.menuView, 'display', 'block'); - }, - this, - true - ); - Event.delegate(this.menuView, 'click', this.clickBuildMenu, 'a', this, true); - Event.delegate( - 'builderFilter', - 'click', - this.clickBuildMenu, - 'a.buildMenuLink', - this, - true - ); - Event.delegate(this.buildingList, 'click', this.build, 'button', this, true); - Event.delegate( - this.buildingList, - 'click', - this.build, - 'img.buildingImage', - this, - true - ); - }); - this.buildingBuilder.hideEvent.subscribe( - function () { - this.buildingBuilder.resetDisplay(this); - }, - this, - true - ); - this.buildingBuilder.clickBuildMenu = function (e, matchedEl, container) { - Event.preventDefault(e); - var frag = matchedEl.href.split('#')[1]; - var tags = frag.split('/'); - var mainTag = tags[0]; - var subTag = tags[1]; - this.viewBuildings(mainTag, subTag); - }; - this.buildingBuilder.viewBuildings = function (mainTag, subTag) { - this.mainTag = mainTag; - this.subTag = subTag; - Dom.setStyle(this.listView, 'display', 'block'); - Dom.setStyle(this.menuView, 'display', 'none'); - this.buildingList.innerHTML = ''; - var displayTag = mainTag ? mainTag : 'All'; - if (subTag) { - this.filterTrail.innerHTML = - ' > ' + - displayTag + - ' > ' + - subTag + - ''; - } else { - this.filterTrail.innerHTML = - ' > ' + displayTag + ''; - } - var filterTag = subTag ? subTag : mainTag; - if (!this.buildable[mainTag] && !this.buildable[filterTag]) { - Lacuna.MapPlanet.BuilderGet({ - session_id: Game.GetSession(''), - body_id: Lacuna.MapPlanet.locationId, - x: this.currentTile.x, - y: this.currentTile.y, - tag: filterTag, - }); - } else { - this.updateDisplay(); - } - }; - this.buildingBuilder.isVisible = function () { - return this.cfg.getProperty('visible'); - }; - this.buildingBuilder.setTile = function (tile) { - this.currentTile = tile; - this.X.innerHTML = tile.x; - this.Y.innerHTML = tile.y; - }; - this.buildingBuilder.load = function (b, q, request) { - this.buildable[request.tag] = b; //store - this.queue_status = q; - - this.updateDisplay(); - }; - this.buildingBuilder.build = function (e, matchedEl, container) { - Lacuna.MapPlanet.Build( - matchedEl.building, - this.currentTile.x, - this.currentTile.y - ); - }; - this.buildingBuilder.resetDisplay = function (oSelf) { - if (oSelf.currentBuildConnection) { - MenuStore.hideLoader(); - Util.Connect.abort(oSelf.currentBuildConnection); - } - delete this.currentTile; - this.buildable = {}; - Dom.setStyle(this.menuView, 'display', 'block'); - Dom.setStyle(this.listView, 'display', 'none'); - }; - this.buildingBuilder.resetFilter = function () { - this.timeFilter.options[1].selected = 1; - }; - this.buildingBuilder.updateDisplay = function () { - var mainTag = this.mainTag; - var subTag = this.subTag; - var b = this.buildable[mainTag] || this.buildable[subTag]; - var list = this.buildingList; - var filters = {}; - if (subTag) { - filters[subTag] = 1; - } - if (this.timeFilter.value.length) { - filters[this.timeFilter.value] = 1; - } - var isQueueFull = this.queue_status.max == this.queue_status.current; - - list.parentNode.scrollTop = 0; - list.innerHTML = ''; - - var frag = document.createDocumentFragment(), - li = document.createElement('li'), - filterCount = 0, - names = [], - reason, - br, - planet = BodyRPCStore, - isMaxPlots = planet.plots_available * 1 === 0; - - for (var key in filters) { - if (filters.hasOwnProperty(key)) { - filterCount++; - } - } - - for (var name in b) { - if (b.hasOwnProperty(name)) { - var tags = b[name].build.tags, - filterMatch = 0; - for (var t = 0; t < tags.length; t++) { - if (filters[tags[t]]) { - filterMatch++; - } - } - if (filterMatch == filterCount) { - names.push(name); - } - } - } - names.sort(); - - if (names.length == 0) { - var mLi = li.cloneNode(false); - mLi.innerHTML = 'No available buildings.'; - list.appendChild(mLi); - } - - for (var i = 0; i < names.length; i++) { - var bd = b[names[i]], - nLi = li.cloneNode(false), - costs = bd.build.cost, - prod = bd.production, - noPlots = isMaxPlots && !bd.build.no_plot_use, - isLater = bd.build.tags.indexOf('Later') > -1, - isPlan = bd.build.tags.indexOf('Plan') > -1, - isNotBuildable = isLater || isQueueFull || noPlots; - - bd.name = names[i]; - - if (bd.build.reason) { - reason = bd.build.reason[1]; - } else { - reason = undefined; - if (isQueueFull) { - reason = 'Build queue is full.'; - } else if (noPlots) { - reason = 'No plots available.'; - } else if (isPlan) { - var extra_level = bd.build.extra_level * 1; - if (extra_level) { - reason = - 'Will build to level ' + - (extra_level + 1) + - ' for free with plan.'; - } else { - reason = 'Will build for free with plan.'; - } - } - } - - nLi.innerHTML = [ - '
    ', - '
    ', - ' ', - '
    ', - '
    ', - '
    ', - bd.name, - ':
    ', - reason - ? '
    ' + reason + '
    ' - : '', - '
    ', - Game.GetBuildingDesc(bd.url), - '
    ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - '
    Cost:', - costs.food, - '', - costs.ore, - '', - costs.water, - '', - costs.energy, - '', - costs.waste, - '
    Prod:', - prod.food_hour, - '/hr', - prod.ore_hour, - '/hr', - prod.water_hour, - '/hr', - prod.energy_hour, - '/hr', - prod.waste_hour, - '/hr', - prod.happiness_hour, - '/hr
    ', - '
    ', - isNotBuildable - ? '' - : ' ', - ' ', - Lib.formatTime(costs.time), - ' sec', - '
    ', - '
    ', - '
    ', - ].join(''); - - if (!isNotBuildable) { - Sel.query('button', nLi, true).building = bd; - Sel.query('img.buildingImage', nLi, true).building = bd; - } - - frag.appendChild(nLi); - } - - list.appendChild(frag); - list.parentNode.scrollTop = 0; - }; - - this.buildingBuilder.render(); - Game.OverlayManager.register(this.buildingBuilder); - }), - - _fireRpcSuccess: function (result) { - this.fireEvent('onMapRpc', result); - }, - _fireQueueAdd: function (obj) { - if (this.buildingDetails.isVisible()) { - this.buildingDetails.addQueue(obj.seconds, obj.fn, obj.el, obj.scope); - } - }, - _fireBuildingReload: function (building) { - this.ReloadBuilding(building); - }, - _fireQueueReset: function () { - this.buildingDetails.resetQueue(); - }, - _fireAddTab: function (tab) { - if (this.buildingDetails.isVisible()) { - this.buildingDetails.tabView.addTab(tab); - } - }, - _fireRemoveTab: function (tab) { - if (this.buildingDetails.isVisible()) { - this.buildingDetails.tabView.selectTab(0); - this.buildingDetails.tabView.removeTab(tab); - } - }, - _fireSelectTab: function (tabIndex) { - if (this.buildingDetails.isVisible()) { - this.buildingDetails.tabView.selectTab(tabIndex); - } - }, - _fireReloadTabs: function () { - if (this.currentBuildingObj) { - var panel = this.buildingDetails; - //remove any tabs - while (panel.tabView.get('tabs').length > 0) { - var tab = panel.tabView.getTab(0); - Event.purgeElement(tab.get('contentEl')); - panel.tabView.removeTab(tab); - } - //add again - var tabs = this.currentBuildingObj.getTabs(); - for (var at = 0; at < tabs.length; at++) { - panel.tabView.addTab(tabs[at]); - } - //select first tab - panel.tabView.selectTab(0); - } - }, - _fireUpdateTile: function (building) { - if (building && building.id && building.name) { - this.ReloadBuilding(building); - } - }, - _fireUpdateMap: function () { - // this.Refresh(); - }, - _fireRemoveTile: function (building) { - if (building && building.id) { - delete this.buildings[building.id]; - this._map.removeTile(building.x, building.y); - } - }, - _fireHide: function () { - this.buildingDetails.hide(); - }, - IsVisible: function () { - return this._isVisible; + this.buildingDetails.renderEvent.subscribe(function () { + this.img = Dom.get('buildingDetailsImg'); + this.name = Dom.get('buildingDetailsName'); + this.desc = Dom.get('buildingDetailsDesc'); + this.timeLeftLi = Dom.get('buildingDetailsTimeLeft'); + + this.tabView = new YAHOO.widget.TabView('buildingDetailTabs'); + this.tabView.getTabByLabel = function (label) { + var tabs = this.get('tabs'); + for (var t = 0; t < tabs.length; t++) { + var tab = tabs[t]; + if (tab.get('label') == label) { + return this.getTab(t); + } + } + }; + this.tabView.set('activeIndex', 0); + + this.queue = []; + this.dataStore = {}; + }); + this.buildingDetails.hideEvent.subscribe( + function () { + this.buildingDetails.resetDisplay(this); + }, + this, + true + ); + + this.buildingDetails.render(); + Game.OverlayManager.register(this.buildingDetails); + }), + _buildBuilderPanel: _.once(function () { + var panelId = 'buildingBuilder'; + + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
    Builder
    ', + '
    ', + '
    Building on X:Y
    ', + '
    ', + ' ', + '
    ', + '
    ', + '
    ', + '
    ', + ' Available: ', + ' ', + '
    ', + ' Build > Resources > Ore', + '
    ', + '
      ', + '
      ', + '
      ', + '
      ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); + + this.buildingBuilder = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: false, + close: true, + underlay: false, + width: '600px', + zIndex: 9996, + context: ['header', 'tr', 'br'], + }); + this.buildingBuilder.renderEvent.subscribe(function () { + this.X = Dom.get('builderX'); + this.Y = Dom.get('builderY'); + this.menuView = Dom.get('builderMenu'); + this.listView = Dom.get('builderListContainer'); + this.buildingList = Dom.get('builderList'); + this.timeFilter = Dom.get('builderTimeFilter'); + this.filterTrail = Dom.get('builderFilterTrail'); + + Event.on('builderTimeFilter', 'change', this.updateDisplay, this, true); + Event.on( + 'builderBuildLink', + 'click', + function (e) { + Event.preventDefault(e); + this.buildingList.innerHTML = ''; + Dom.setStyle(this.listView, 'display', 'none'); + Dom.setStyle(this.menuView, 'display', 'block'); }, - MapVisible: function (visible) { - if (this._isVisible != visible) { - if (this._elGrid) { - this._isVisible = visible; - //YAHOO.log(visible, "info", "MapPlanet.MapVisible"); - if (visible) { - if (!Dom.inDocument(this._elGrid)) { - document.getElementById('content').appendChild(this._elGrid); - } - //Dom.setStyle(this._elGrid, "display", visible ? "" : "none"); - } else { - this._elGrid = this._elGrid.parentNode.removeChild(this._elGrid); - } - if (visible && this._map) { - this.Resize(); - } - } - if (!visible) { - // These can sometimes get called before they exist, so watch out for that. :/ - this.buildingDetails && this.buildingDetails.hide(); - this.buildingBuilder && this.buildingBuilder.hide(); - } - } - }, - Mapper: function (oArgs) { - //YAHOO.log(oArgs.buildings, "debug", "Mapper"); - this.buildings = oArgs.buildings; - this.surfaceUrl = [ - Lib.AssetUrl, - 'planet_side/', - oArgs.body.surface_image, - '.jpg', - ].join(''); - Dom.setStyle( - 'buildingDetailsImgBkgd', - 'background', - ['transparent url(', this.surfaceUrl, ') no-repeat left top'].join('') - ); - //clean up numbers in buidlings - for (var key in this.buildings) { - if (this.buildings.hasOwnProperty(key)) { - this.buildings[key] = this.CleanBuilding(this.buildings[key]); - } + this, + true + ); + Event.delegate(this.menuView, 'click', this.clickBuildMenu, 'a', this, true); + Event.delegate( + 'builderFilter', + 'click', + this.clickBuildMenu, + 'a.buildMenuLink', + this, + true + ); + Event.delegate(this.buildingList, 'click', this.build, 'button', this, true); + Event.delegate(this.buildingList, 'click', this.build, 'img.buildingImage', this, true); + }); + this.buildingBuilder.hideEvent.subscribe( + function () { + this.buildingBuilder.resetDisplay(this); + }, + this, + true + ); + this.buildingBuilder.clickBuildMenu = function (e, matchedEl, container) { + Event.preventDefault(e); + var frag = matchedEl.href.split('#')[1]; + var tags = frag.split('/'); + var mainTag = tags[0]; + var subTag = tags[1]; + this.viewBuildings(mainTag, subTag); + }; + this.buildingBuilder.viewBuildings = function (mainTag, subTag) { + this.mainTag = mainTag; + this.subTag = subTag; + Dom.setStyle(this.listView, 'display', 'block'); + Dom.setStyle(this.menuView, 'display', 'none'); + this.buildingList.innerHTML = ''; + var displayTag = mainTag ? mainTag : 'All'; + if (subTag) { + this.filterTrail.innerHTML = + ' > ' + + displayTag + + ' > ' + + subTag + + ''; + } else { + this.filterTrail.innerHTML = + ' > ' + displayTag + ''; + } + var filterTag = subTag ? subTag : mainTag; + if (!this.buildable[mainTag] && !this.buildable[filterTag]) { + Lacuna.MapPlanet.BuilderGet({ + session_id: Game.GetSession(''), + body_id: Lacuna.MapPlanet.locationId, + x: this.currentTile.x, + y: this.currentTile.y, + tag: filterTag, + }); + } else { + this.updateDisplay(); + } + }; + this.buildingBuilder.isVisible = function () { + return this.cfg.getProperty('visible'); + }; + this.buildingBuilder.setTile = function (tile) { + this.currentTile = tile; + this.X.innerHTML = tile.x; + this.Y.innerHTML = tile.y; + }; + this.buildingBuilder.load = function (b, q, request) { + this.buildable[request.tag] = b; //store + this.queue_status = q; + + this.updateDisplay(); + }; + this.buildingBuilder.build = function (e, matchedEl, container) { + Lacuna.MapPlanet.Build(matchedEl.building, this.currentTile.x, this.currentTile.y); + }; + this.buildingBuilder.resetDisplay = function (oSelf) { + if (oSelf.currentBuildConnection) { + MenuStore.hideLoader(); + Util.Connect.abort(oSelf.currentBuildConnection); + } + delete this.currentTile; + this.buildable = {}; + Dom.setStyle(this.menuView, 'display', 'block'); + Dom.setStyle(this.listView, 'display', 'none'); + }; + this.buildingBuilder.resetFilter = function () { + this.timeFilter.options[1].selected = 1; + }; + this.buildingBuilder.updateDisplay = function () { + var mainTag = this.mainTag; + var subTag = this.subTag; + var b = this.buildable[mainTag] || this.buildable[subTag]; + var list = this.buildingList; + var filters = {}; + if (subTag) { + filters[subTag] = 1; + } + if (this.timeFilter.value.length) { + filters[this.timeFilter.value] = 1; + } + var isQueueFull = this.queue_status.max == this.queue_status.current; + + list.parentNode.scrollTop = 0; + list.innerHTML = ''; + + var frag = document.createDocumentFragment(), + li = document.createElement('li'), + filterCount = 0, + names = [], + reason, + br, + planet = BodyRPCStore, + isMaxPlots = planet.plots_available * 1 === 0; + + for (var key in filters) { + if (filters.hasOwnProperty(key)) { + filterCount++; + } + } + + for (var name in b) { + if (b.hasOwnProperty(name)) { + var tags = b[name].build.tags, + filterMatch = 0; + for (var t = 0; t < tags.length; t++) { + if (filters[tags[t]]) { + filterMatch++; } - //create/update map - if (!this._gridCreated) { - var planetMap = document.createElement('div'); - planetMap.id = 'planetMap'; - this._elGrid = document.getElementById('content').appendChild(planetMap); - this.MapVisible(true); //needs to be visible before we set sizing and map - this.SetSize(); - - var map = new Lacuna.Mapper.PlanetMap('planetMap', { - surfaceUrl: this.surfaceUrl, - }); - map.addTileData(this.buildings); - map.setPlotsAvailable(oArgs.status.body.plots_available * 1); - //map.imgUrlLoc = Lib.AssetUrl + 'ui/mapiator/'; - map.subscribe('onReloadTile', this.ReLoadTile, this, true); - //draw what we got - map.redraw(); - //move to command - map.setCenterToCommand(); - - this._map = map; - this._gridCreated = true; - - Event.delegate( - this._map.mapDiv, - 'click', - function (e, matchedEl, container) { - if (!this._map.controller.isDragging()) { - var tile = this._map.tileLayer.findTileById( - matchedEl.parentNode.id - ); - if (tile && tile.data) { - this.DetailsView(tile); - } else { - //if(planet.size*1 > planet.building_count*1) { - this.BuilderView(tile); - } - /*else { - alert("You've already reached the maximum number of buildings for this planet"); - }*/ - } - }, - 'div.planetMapTileActionContainer', - this, - true - ); //"button.planetMapTileActionButton" + } + if (filterMatch == filterCount) { + names.push(name); + } + } + } + names.sort(); + + if (names.length == 0) { + var mLi = li.cloneNode(false); + mLi.innerHTML = 'No available buildings.'; + list.appendChild(mLi); + } + + for (var i = 0; i < names.length; i++) { + var bd = b[names[i]], + nLi = li.cloneNode(false), + costs = bd.build.cost, + prod = bd.production, + noPlots = isMaxPlots && !bd.build.no_plot_use, + isLater = bd.build.tags.indexOf('Later') > -1, + isPlan = bd.build.tags.indexOf('Plan') > -1, + isNotBuildable = isLater || isQueueFull || noPlots; + + bd.name = names[i]; + + if (bd.build.reason) { + reason = bd.build.reason[1]; + } else { + reason = undefined; + if (isQueueFull) { + reason = 'Build queue is full.'; + } else if (noPlots) { + reason = 'No plots available.'; + } else if (isPlan) { + var extra_level = bd.build.extra_level * 1; + if (extra_level) { + reason = 'Will build to level ' + (extra_level + 1) + ' for free with plan.'; } else { - this.MapVisible(true); //needs to be visible before we set sizing and map - if (!this._elGrid.parentNode) { - document.getElementById('content').appendChild(this._elGrid); - } - this._map.reset(); - this._map.setSurfaceUrl(this.surfaceUrl); - this._map.setPlotsAvailable(oArgs.status.body.plots_available * 1); - this._map.addTileData(this.buildings); - this._map.refresh(); + reason = 'Will build for free with plan.'; } + } + } + + nLi.innerHTML = [ + '
      ', + '
      ', + ' ', + '
      ', + '
      ', + '
      ', + bd.name, + ':
      ', + reason ? '
      ' + reason + '
      ' : '', + '
      ', + Game.GetBuildingDesc(bd.url), + '
      ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '
      Cost:', + costs.food, + '', + costs.ore, + '', + costs.water, + '', + costs.energy, + '', + costs.waste, + '
      Prod:', + prod.food_hour, + '/hr', + prod.ore_hour, + '/hr', + prod.water_hour, + '/hr', + prod.energy_hour, + '/hr', + prod.waste_hour, + '/hr', + prod.happiness_hour, + '/hr
      ', + '
      ', + isNotBuildable + ? '' + : ' ', + ' ', + Lib.formatTime(costs.time), + ' sec', + '
      ', + '
      ', + '
      ', + ].join(''); + + if (!isNotBuildable) { + Sel.query('button', nLi, true).building = bd; + Sel.query('img.buildingImage', nLi, true).building = bd; + } + + frag.appendChild(nLi); + } + + list.appendChild(frag); + list.parentNode.scrollTop = 0; + }; - MenuStore.hideLoader(); - }, - Load: function (planetId, showNotify, silent) { - MenuStore.showLoader(); - if (showNotify) { - Lacuna.Notify.Show(planetId); + this.buildingBuilder.render(); + Game.OverlayManager.register(this.buildingBuilder); + }), + + _fireRpcSuccess: function (result) { + this.fireEvent('onMapRpc', result); + }, + _fireQueueAdd: function (obj) { + if (this.buildingDetails.isVisible()) { + this.buildingDetails.addQueue(obj.seconds, obj.fn, obj.el, obj.scope); + } + }, + _fireBuildingReload: function (building) { + this.ReloadBuilding(building); + }, + _fireQueueReset: function () { + this.buildingDetails.resetQueue(); + }, + _fireAddTab: function (tab) { + if (this.buildingDetails.isVisible()) { + this.buildingDetails.tabView.addTab(tab); + } + }, + _fireRemoveTab: function (tab) { + if (this.buildingDetails.isVisible()) { + this.buildingDetails.tabView.selectTab(0); + this.buildingDetails.tabView.removeTab(tab); + } + }, + _fireSelectTab: function (tabIndex) { + if (this.buildingDetails.isVisible()) { + this.buildingDetails.tabView.selectTab(tabIndex); + } + }, + _fireReloadTabs: function () { + if (this.currentBuildingObj) { + var panel = this.buildingDetails; + //remove any tabs + while (panel.tabView.get('tabs').length > 0) { + var tab = panel.tabView.getTab(0); + Event.purgeElement(tab.get('contentEl')); + panel.tabView.removeTab(tab); + } + //add again + var tabs = this.currentBuildingObj.getTabs(); + for (var at = 0; at < tabs.length; at++) { + panel.tabView.addTab(tabs[at]); + } + //select first tab + panel.tabView.selectTab(0); + } + }, + _fireUpdateTile: function (building) { + if (building && building.id && building.name) { + this.ReloadBuilding(building); + } + }, + _fireUpdateMap: function () { + // this.Refresh(); + }, + _fireRemoveTile: function (building) { + if (building && building.id) { + delete this.buildings[building.id]; + this._map.removeTile(building.x, building.y); + } + }, + _fireHide: function () { + this.buildingDetails.hide(); + }, + + IsVisible: function () { + return this._isVisible; + }, + MapVisible: function (visible) { + if (this._isVisible != visible) { + if (this._elGrid) { + this._isVisible = visible; + //YAHOO.log(visible, "info", "MapPlanet.MapVisible"); + if (visible) { + if (!Dom.inDocument(this._elGrid)) { + document.getElementById('content').appendChild(this._elGrid); + } + //Dom.setStyle(this._elGrid, "display", visible ? "" : "none"); + } else { + this._elGrid = this._elGrid.parentNode.removeChild(this._elGrid); + } + if (visible && this._map) { + this.Resize(); + } + } + if (!visible) { + // These can sometimes get called before they exist, so watch out for that. :/ + this.buildingDetails && this.buildingDetails.hide(); + this.buildingBuilder && this.buildingBuilder.hide(); + } + } + }, + Mapper: function (oArgs) { + //YAHOO.log(oArgs.buildings, "debug", "Mapper"); + this.buildings = oArgs.buildings; + this.surfaceUrl = [Lib.AssetUrl, 'planet_side/', oArgs.body.surface_image, '.jpg'].join(''); + Dom.setStyle( + 'buildingDetailsImgBkgd', + 'background', + ['transparent url(', this.surfaceUrl, ') no-repeat left top'].join('') + ); + //clean up numbers in buidlings + for (var key in this.buildings) { + if (this.buildings.hasOwnProperty(key)) { + this.buildings[key] = this.CleanBuilding(this.buildings[key]); + } + } + //create/update map + if (!this._gridCreated) { + var planetMap = document.createElement('div'); + planetMap.id = 'planetMap'; + this._elGrid = document.getElementById('content').appendChild(planetMap); + this.MapVisible(true); //needs to be visible before we set sizing and map + this.SetSize(); + + var map = new Lacuna.Mapper.PlanetMap('planetMap', { + surfaceUrl: this.surfaceUrl, + }); + map.addTileData(this.buildings); + map.setPlotsAvailable(oArgs.status.body.plots_available * 1); + //map.imgUrlLoc = Lib.AssetUrl + 'ui/mapiator/'; + map.subscribe('onReloadTile', this.ReLoadTile, this, true); + //draw what we got + map.redraw(); + //move to command + map.setCenterToCommand(); + + this._map = map; + this._gridCreated = true; + + Event.delegate( + this._map.mapDiv, + 'click', + function (e, matchedEl, container) { + if (!this._map.controller.isDragging()) { + var tile = this._map.tileLayer.findTileById(matchedEl.parentNode.id); + if (tile && tile.data) { + this.DetailsView(tile); } else { - Lacuna.Notify.Hide(); + //if(planet.size*1 > planet.building_count*1) { + this.BuilderView(tile); } - this.locationId = planetId; - this.ReLoad(silent); - }, - RefreshWithData: function (o) { - this.fireEvent('onMapRpc', o.result); - this._map.setPlotsAvailable(BodyRPCStore.plots_available * 1); - this._map.addTileData(o.result.buildings, true); - this._map.refresh(); - }, - Refresh: function () { - if (this.locationId) { - var BodyServ = Game.Services.Body, - data = { - session_id: Game.GetSession(''), - body_id: this.locationId, - }; - - BodyServ.get_buildings(data, { - success: function (o) { - //YAHOO.log(o, "info", "MapPlanet.Refresh"); - this.RefreshWithData(o); - }, - scope: this, - }); - } - }, - ReLoad: function (silent) { - if (this.locationId) { - var BodyServ = Game.Services.Body, - data = { - session_id: Game.GetSession(''), - body_id: this.locationId, - }; - - BodyServ.get_buildings(data, { - success: function (o) { - //YAHOO.log(o, "info", "MapPlanet.ReLoad"); - this.fireEvent('onMapRpc', o.result); - if (silent) { - MenuStore.hideLoader(); - } else { - this.Mapper(o.result); - } - }, - scope: this, - }); - } - }, - ReLoadTile: function (id) { - //YAHOO.log(this._isVisible, "info", "MapPlanet.ReLoadTile._isVisible"); - if (this._isVisible && id) { - //YAHOO.log(id, "info", "MapPlanet.ReLoadTile.id"); - var building = this.buildings[id]; - if (building) { - //YAHOO.log(building, "info", "MapPlanet.ReLoadTile.building"); - - this.ViewData( - id, - building.url, - { - url: building.url, - }, - building.x, - building.y - ); - } - } - }, - SetSize: function () { - var size = Game.GetSize(); - Dom.setStyle(this._elGrid, 'width', size.w + 'px'); - Dom.setStyle(this._elGrid, 'height', size.h + 'px'); - }, - Resize: function () { - this.SetSize(); - this._map.resize(); - }, - Reset: function () { - delete this.locationId; - if (this._map) { - this._map.reset(); - } - this.buildingDetails && this.buildingDetails.resetQueue(); - this.buildingBuilder && this.buildingBuilder.resetFilter(); - this.MapVisible(false); - }, - - BuilderView: function (tile) { - //YAHOO.log(tile, "info", "BuilderView"); - - this._buildBuilderPanel(); - - Game.OverlayManager.hideAllBut(this.buildingBuilder.id); - this.buildingBuilder.resetDisplay(this); - this.buildingBuilder.setTile(tile); - this.buildingBuilder.show(); - - var Ht = Game.GetSize().h - 75; - if (Ht > 420) { - Ht = 420; - } - Dom.setStyle(Dom.get('builderMenu'), 'height', Ht + 'px'); - Dom.setStyle(Dom.get('builderList').parentNode, 'height', Ht + 'px'); + /*else { + alert("You've already reached the maximum number of buildings for this planet"); + }*/ + } }, - BuilderGet: function (data) { - MenuStore.showLoader(); - this.currentBuildConnection = Game.Services.Body.get_buildable(data, { - success: function (o) { - delete this.currentBuildConnection; - //YAHOO.log(o, "info", "MapPlanet.BuilderGet.success"); - this.fireEvent('onMapRpc', o.result); - - this.BuilderProcess(o.result, data); - }, - failure: function (o) { - delete this.currentBuildConnection; - }, - scope: this, - }); + 'div.planetMapTileActionContainer', + this, + true + ); //"button.planetMapTileActionButton" + } else { + this.MapVisible(true); //needs to be visible before we set sizing and map + if (!this._elGrid.parentNode) { + document.getElementById('content').appendChild(this._elGrid); + } + this._map.reset(); + this._map.setSurfaceUrl(this.surfaceUrl); + this._map.setPlotsAvailable(oArgs.status.body.plots_available * 1); + this._map.addTileData(this.buildings); + this._map.refresh(); + } + + MenuStore.hideLoader(); + }, + Load: function (planetId, showNotify, silent) { + MenuStore.showLoader(); + if (showNotify) { + Lacuna.Notify.Show(planetId); + } else { + Lacuna.Notify.Hide(); + } + this.locationId = planetId; + this.ReLoad(silent); + }, + RefreshWithData: function (o) { + this.fireEvent('onMapRpc', o.result); + this._map.setPlotsAvailable(BodyRPCStore.plots_available * 1); + this._map.addTileData(o.result.buildings, true); + this._map.refresh(); + }, + Refresh: function () { + if (this.locationId) { + var BodyServ = Game.Services.Body, + data = { + session_id: Game.GetSession(''), + body_id: this.locationId, + }; + + BodyServ.get_buildings(data, { + success: function (o) { + //YAHOO.log(o, "info", "MapPlanet.Refresh"); + this.RefreshWithData(o); }, - BuilderProcess: function (oResults, request) { - if (this.buildingBuilder.isVisible() && oResults) { - var b = oResults.buildable; - var q = oResults.build_queue; - if (b) { - this.buildingBuilder.load(b, q, request); - } - } + scope: this, + }); + } + }, + ReLoad: function (silent) { + if (this.locationId) { + var BodyServ = Game.Services.Body, + data = { + session_id: Game.GetSession(''), + body_id: this.locationId, + }; + + BodyServ.get_buildings(data, { + success: function (o) { + //YAHOO.log(o, "info", "MapPlanet.ReLoad"); + this.fireEvent('onMapRpc', o.result); + if (silent) { MenuStore.hideLoader(); + } else { + this.Mapper(o.result); + } }, - NotIsolationist: function (building) { - if (EmpireRPCStore.is_isolationist) { - if ( - building.url == '/espionage' && - !confirm( - 'If you build an Espionage Ministry you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' - ) - ) { - return true; - } else if ( - building.url == '/munitionslab' && - !confirm( - 'If you build a Munitions Lab you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' - ) - ) { - return true; - } - } - }, - Build: function (building, x, y) { - if (this.NotIsolationist(building)) { - return; - } - - MenuStore.showLoader(); - var BuildingServ = Game.Services.Buildings.Generic, - data = { - session_id: Game.GetSession(''), - planet_id: this.locationId, - x: x, - y: y, - }; - - BuildingServ.build(data, { - success: function (o) { - //YAHOO.log(o, "info", "MapPlanet.Build.success"); - MenuStore.hideLoader(); - this.fireEvent('onMapRpc', o.result); - this.buildingBuilder.hide(); - - var b = building; //originally passed in building data from BuildProcess - b.id = o.result.building.id; - b.level = o.result.building.level; - b.pending_build = o.result.building.pending_build; - b.work = o.result.building.work; - b.x = x; - b.y = y; - //YAHOO.log(b, "info", "MapPlanet.Build.success.building"); - //this.UpdateCost(b.build.cost); - - this.ReloadBuilding(b); - }, - failure: function (o) { - this.buildingBuilder.hide(); - }, - scope: this, - target: building.url, - }); - }, - - ViewData: function (id, url, callback, x, y) { - var BuildingServ = Game.Services.Buildings.Generic, - data = { - session_id: Game.GetSession(''), - building_id: id, - }; - - return BuildingServ.view(data, { - success: function (o) { - //YAHOO.log(o, "info", "MapPlanet.ViewData.success"); - this.fireEvent('onMapRpc', o.result); - var newB = o.result.building; - newB.url = callback.url; - newB.x = x; - newB.y = y; - newB.updated = - !this.buildings[newB.id] || newB.level != this.buildings[newB.id].level; - this.ReloadBuilding(newB); - /*newB = this.CleanBuilding(newB); + scope: this, + }); + } + }, + ReLoadTile: function (id) { + //YAHOO.log(this._isVisible, "info", "MapPlanet.ReLoadTile._isVisible"); + if (this._isVisible && id) { + //YAHOO.log(id, "info", "MapPlanet.ReLoadTile.id"); + var building = this.buildings[id]; + if (building) { + //YAHOO.log(building, "info", "MapPlanet.ReLoadTile.building"); + + this.ViewData( + id, + building.url, + { + url: building.url, + }, + building.x, + building.y + ); + } + } + }, + SetSize: function () { + var size = Game.GetSize(); + Dom.setStyle(this._elGrid, 'width', size.w + 'px'); + Dom.setStyle(this._elGrid, 'height', size.h + 'px'); + }, + Resize: function () { + this.SetSize(); + this._map.resize(); + }, + Reset: function () { + delete this.locationId; + if (this._map) { + this._map.reset(); + } + this.buildingDetails && this.buildingDetails.resetQueue(); + this.buildingBuilder && this.buildingBuilder.resetFilter(); + this.MapVisible(false); + }, + + BuilderView: function (tile) { + //YAHOO.log(tile, "info", "BuilderView"); + + this._buildBuilderPanel(); + + Game.OverlayManager.hideAllBut(this.buildingBuilder.id); + this.buildingBuilder.resetDisplay(this); + this.buildingBuilder.setTile(tile); + this.buildingBuilder.show(); + + var Ht = Game.GetSize().h - 75; + if (Ht > 420) { + Ht = 420; + } + Dom.setStyle(Dom.get('builderMenu'), 'height', Ht + 'px'); + Dom.setStyle(Dom.get('builderList').parentNode, 'height', Ht + 'px'); + }, + BuilderGet: function (data) { + MenuStore.showLoader(); + this.currentBuildConnection = Game.Services.Body.get_buildable(data, { + success: function (o) { + delete this.currentBuildConnection; + //YAHOO.log(o, "info", "MapPlanet.BuilderGet.success"); + this.fireEvent('onMapRpc', o.result); + + this.BuilderProcess(o.result, data); + }, + failure: function (o) { + delete this.currentBuildConnection; + }, + scope: this, + }); + }, + BuilderProcess: function (oResults, request) { + if (this.buildingBuilder.isVisible() && oResults) { + var b = oResults.buildable; + var q = oResults.build_queue; + if (b) { + this.buildingBuilder.load(b, q, request); + } + } + MenuStore.hideLoader(); + }, + NotIsolationist: function (building) { + if (EmpireRPCStore.is_isolationist) { + if ( + building.url == '/espionage' && + !confirm( + 'If you build an Espionage Ministry you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' + ) + ) { + return true; + } else if ( + building.url == '/munitionslab' && + !confirm( + 'If you build a Munitions Lab you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' + ) + ) { + return true; + } + } + }, + Build: function (building, x, y) { + if (this.NotIsolationist(building)) { + return; + } + + MenuStore.showLoader(); + var BuildingServ = Game.Services.Buildings.Generic, + data = { + session_id: Game.GetSession(''), + planet_id: this.locationId, + x: x, + y: y, + }; + + BuildingServ.build(data, { + success: function (o) { + //YAHOO.log(o, "info", "MapPlanet.Build.success"); + MenuStore.hideLoader(); + this.fireEvent('onMapRpc', o.result); + this.buildingBuilder.hide(); + + var b = building; //originally passed in building data from BuildProcess + b.id = o.result.building.id; + b.level = o.result.building.level; + b.pending_build = o.result.building.pending_build; + b.work = o.result.building.work; + b.x = x; + b.y = y; + //YAHOO.log(b, "info", "MapPlanet.Build.success.building"); + //this.UpdateCost(b.build.cost); + + this.ReloadBuilding(b); + }, + failure: function (o) { + this.buildingBuilder.hide(); + }, + scope: this, + target: building.url, + }); + }, + + ViewData: function (id, url, callback, x, y) { + var BuildingServ = Game.Services.Buildings.Generic, + data = { + session_id: Game.GetSession(''), + building_id: id, + }; + + return BuildingServ.view(data, { + success: function (o) { + //YAHOO.log(o, "info", "MapPlanet.ViewData.success"); + this.fireEvent('onMapRpc', o.result); + var newB = o.result.building; + newB.url = callback.url; + newB.x = x; + newB.y = y; + newB.updated = !this.buildings[newB.id] || newB.level != this.buildings[newB.id].level; + this.ReloadBuilding(newB); + /*newB = this.CleanBuilding(newB); this.buildings[newB.id] = newB; this._map.refreshTile(newB); */ - if (callback && callback.success) { - callback.success.call(this, o.result, callback.url, x, y); - } - MenuStore.hideLoader(); - }, - failure: function (o) { - if (callback && callback.failure) { - callback.failure.call(this, o, callback.url, x, y); - return true; - } - }, - scope: this, - target: url, - }); - }, - DetailsView: function (tile) { - //YAHOO.log(tile, "info", "DetailsView"); - - if (!FactoryMap[tile.data.url]) { - // Pass this off to the new React stuff. - - if (WindowMap[tile.data.url.substring(1)]) { - WindowsStore.add(tile.data.url.substring(1), tile.data); - } else { - WindowsStore.add('genericBuilding', tile.data); - } - - return; - } - - MenuStore.showLoader(); - - this._buildDetailsPanel(); - - var panel = this.buildingDetails; - Game.OverlayManager.hideAllBut(panel.id); - panel.resetDisplay(this); - //clear values - panel.name.innerHTML = 'Loading'; - panel.img.src = this.surfaceUrl; - panel.desc.innerHTML = ''; - panel.timeLeftLi.innerHTML = ''; - - panel.tabView.set('activeTab', null); - while (panel.tabView.get('tabs').length > 0) { - var tab = panel.tabView.getTab(0); - Event.purgeElement(tab.get('contentEl'), true); - panel.tabView.removeTab(tab); - } - - this.buildingDetails.show(); //show before we get data so it looks like we're doing something - - this.currentViewConnection = this.ViewData( - tile.data.id, - tile.data.url, - { - success: function (oResults, url, x, y) { - delete this.currentViewConnection; - this.DetailsProcess(oResults, url, x, y); - }, - failure: function (o) { - delete this.currentViewConnection; - }, - url: tile.data.url, - }, - tile.x, - tile.y - ); + if (callback && callback.success) { + callback.success.call(this, o.result, callback.url, x, y); + } + MenuStore.hideLoader(); + }, + failure: function (o) { + if (callback && callback.failure) { + callback.failure.call(this, o, callback.url, x, y); + return true; + } + }, + scope: this, + target: url, + }); + }, + DetailsView: function (tile) { + //YAHOO.log(tile, "info", "DetailsView"); + + if (!FactoryMap[tile.data.url]) { + // Pass this off to the new React stuff. + + if (WindowMap[tile.data.url.substring(1)]) { + WindowsStore.add(tile.data.url.substring(1), tile.data); + } else { + WindowsStore.add('genericBuilding', tile.data); + } + + return; + } + + MenuStore.showLoader(); + + this._buildDetailsPanel(); + + var panel = this.buildingDetails; + Game.OverlayManager.hideAllBut(panel.id); + panel.resetDisplay(this); + //clear values + panel.name.innerHTML = 'Loading'; + panel.img.src = this.surfaceUrl; + panel.desc.innerHTML = ''; + panel.timeLeftLi.innerHTML = ''; + + panel.tabView.set('activeTab', null); + while (panel.tabView.get('tabs').length > 0) { + var tab = panel.tabView.getTab(0); + Event.purgeElement(tab.get('contentEl'), true); + panel.tabView.removeTab(tab); + } + + this.buildingDetails.show(); //show before we get data so it looks like we're doing something + + this.currentViewConnection = this.ViewData( + tile.data.id, + tile.data.url, + { + success: function (oResults, url, x, y) { + delete this.currentViewConnection; + this.DetailsProcess(oResults, url, x, y); }, - BuildingFactory: function (result) { - var classConstructor = FactoryMap[result.building.url] || Lacuna.buildings.Building, - classObj = new classConstructor(result, this.locationId); - if (classObj) { - classObj.subscribe('onMapRpc', this._fireRpcSuccess, this, true); - classObj.subscribe('onQueueAdd', this._fireQueueAdd, this, true); - classObj.subscribe('onQueueReset', this._fireQueueReset, this, true); - classObj.subscribe('onAddTab', this._fireAddTab, this, true); - classObj.subscribe('onRemoveTab', this._fireRemoveTab, this, true); - classObj.subscribe('onSelectTab', this._fireSelectTab, this, true); - classObj.subscribe('onReloadTabs', this._fireReloadTabs, this, true); - classObj.subscribe('onUpdateTile', this._fireUpdateTile, this, true); - classObj.subscribe('onUpdateMap', this._fireUpdateMap, this, true); - classObj.subscribe('onRemoveTile', this._fireRemoveTile, this, true); - classObj.subscribe('onHide', this._fireHide, this, true); - } - - return classObj; + failure: function (o) { + delete this.currentViewConnection; }, - DetailsProcess: function (oResults, url, x, y) { - var building = oResults.building, - panel = this.buildingDetails, - currBuildingId = this.currentBuilding - ? this.currentBuilding.building.id - : undefined; - if (panel.isVisible() && currBuildingId != oResults.building.id) { - building.url = url; - building.x = x; - building.y = y; - oResults.building = building; - - if (panel.pager) { - panel.pager.destroy(); - } - - this.currentBuilding = oResults; //assign new building - //fill production tab - panel.name.innerHTML = [ - building.name, - ' ', - building.level, - ' (ID: ', - building.id, - ')', - ].join(''); - panel.img.src = [Lib.AssetUrl, 'planet_side/100/', building.image, '.png'].join( - '' - ); - panel.desc.innerHTML = Game.GetBuildingDesc(building.url); - if (building.pending_build) { - panel.timeLeftLi.innerHTML = - ' ' + - Lib.formatTime(building.pending_build.seconds_remaining); - if (building.pending_build.seconds_remaining > 0) { - panel.addQueue( - building.pending_build.seconds_remaining, - function (remaining, elm) { - var rf = Math.round(remaining); - if (rf <= 0) { - elm.innerHTML = ''; - YAHOO.log( - 'Complete', - 'info', - 'buildingDetails.showEvent.BuildTimeRemaining' - ); - this.DetailsView({ - data: { - id: building.id, - url: building.url, - }, - x: building.x, - y: building.y, - }); - } else { - elm.innerHTML = - ' ' + - Lib.formatTime(rf); - } - }, - panel.timeLeftLi, - this - ); - } - } else { - panel.timeLeftLi.innerHTML = ''; - } - - var output, stored, bq, ul, li, div; - - //create building specific tabs and functionality - this.currentBuildingObj = this.BuildingFactory(oResults); - if (this.currentBuildingObj) { - //remove any tabs - while (panel.tabView.get('tabs').length > 0) { - var tab = panel.tabView.getTab(0); - Event.purgeElement(tab.get('contentEl')); - panel.tabView.removeTab(tab); - } - var tabs = this.currentBuildingObj.getTabs(); - for (var at = 0; at < tabs.length; at++) { - panel.tabView.addTab(tabs[at]); - } - this.currentBuildingObj.load(); - } - - Dom.setStyle('buildingDetailTabs', 'display', ''); - panel.tabView.selectTab(0); - panel.setFirstLastFocusable(); - panel.focusFirst(); - } - }, - - CleanBuilding: function (building) { - building.efficiency = building.efficiency * 1; - if (building.repair_costs && building.efficiency == 100) { - delete building.repair_costs; - } - if (building.pending_build) { - building.pending_build.seconds_remaining *= 1; - } - if (building.work) { - building.work.seconds_remaining *= 1; - } - return building; - }, - ReloadBuilding: function (building) { - //YAHOO.log(building, "debug", "ReloadBuilding"); - - building = this.CleanBuilding(building); - this.buildings[building.id] = building; - this._map.refreshTile(building); - }, - }; - Lang.augmentProto(MapPlanet, Util.EventProvider); - - Lacuna.MapPlanet = new MapPlanet(); - })(); - YAHOO.register('mapPlanet', YAHOO.lacuna.MapPlanet, { - version: '1', - build: '0', - }); + url: tile.data.url, + }, + tile.x, + tile.y + ); + }, + BuildingFactory: function (result) { + var classConstructor = FactoryMap[result.building.url] || Lacuna.buildings.Building, + classObj = new classConstructor(result, this.locationId); + if (classObj) { + classObj.subscribe('onMapRpc', this._fireRpcSuccess, this, true); + classObj.subscribe('onQueueAdd', this._fireQueueAdd, this, true); + classObj.subscribe('onQueueReset', this._fireQueueReset, this, true); + classObj.subscribe('onAddTab', this._fireAddTab, this, true); + classObj.subscribe('onRemoveTab', this._fireRemoveTab, this, true); + classObj.subscribe('onSelectTab', this._fireSelectTab, this, true); + classObj.subscribe('onReloadTabs', this._fireReloadTabs, this, true); + classObj.subscribe('onUpdateTile', this._fireUpdateTile, this, true); + classObj.subscribe('onUpdateMap', this._fireUpdateMap, this, true); + classObj.subscribe('onRemoveTile', this._fireRemoveTile, this, true); + classObj.subscribe('onHide', this._fireHide, this, true); + } + + return classObj; + }, + DetailsProcess: function (oResults, url, x, y) { + var building = oResults.building, + panel = this.buildingDetails, + currBuildingId = this.currentBuilding ? this.currentBuilding.building.id : undefined; + if (panel.isVisible() && currBuildingId != oResults.building.id) { + building.url = url; + building.x = x; + building.y = y; + oResults.building = building; + + if (panel.pager) { + panel.pager.destroy(); + } + + this.currentBuilding = oResults; //assign new building + //fill production tab + panel.name.innerHTML = [ + building.name, + ' ', + building.level, + ' (ID: ', + building.id, + ')', + ].join(''); + panel.img.src = [Lib.AssetUrl, 'planet_side/100/', building.image, '.png'].join(''); + panel.desc.innerHTML = Game.GetBuildingDesc(building.url); + if (building.pending_build) { + panel.timeLeftLi.innerHTML = + ' ' + + Lib.formatTime(building.pending_build.seconds_remaining); + if (building.pending_build.seconds_remaining > 0) { + panel.addQueue( + building.pending_build.seconds_remaining, + function (remaining, elm) { + var rf = Math.round(remaining); + if (rf <= 0) { + elm.innerHTML = ''; + YAHOO.log('Complete', 'info', 'buildingDetails.showEvent.BuildTimeRemaining'); + this.DetailsView({ + data: { + id: building.id, + url: building.url, + }, + x: building.x, + y: building.y, + }); + } else { + elm.innerHTML = ' ' + Lib.formatTime(rf); + } + }, + panel.timeLeftLi, + this + ); + } + } else { + panel.timeLeftLi.innerHTML = ''; + } + + var output, stored, bq, ul, li, div; + + //create building specific tabs and functionality + this.currentBuildingObj = this.BuildingFactory(oResults); + if (this.currentBuildingObj) { + //remove any tabs + while (panel.tabView.get('tabs').length > 0) { + var tab = panel.tabView.getTab(0); + Event.purgeElement(tab.get('contentEl')); + panel.tabView.removeTab(tab); + } + var tabs = this.currentBuildingObj.getTabs(); + for (var at = 0; at < tabs.length; at++) { + panel.tabView.addTab(tabs[at]); + } + this.currentBuildingObj.load(); + } + + Dom.setStyle('buildingDetailTabs', 'display', ''); + panel.tabView.selectTab(0); + panel.setFirstLastFocusable(); + panel.focusFirst(); + } + }, + + CleanBuilding: function (building) { + building.efficiency = building.efficiency * 1; + if (building.repair_costs && building.efficiency == 100) { + delete building.repair_costs; + } + if (building.pending_build) { + building.pending_build.seconds_remaining *= 1; + } + if (building.work) { + building.work.seconds_remaining *= 1; + } + return building; + }, + ReloadBuilding: function (building) { + //YAHOO.log(building, "debug", "ReloadBuilding"); + + building = this.CleanBuilding(building); + this.buildings[building.id] = building; + this._map.refreshTile(building); + }, + }; + Lang.augmentProto(MapPlanet, Util.EventProvider); + + Lacuna.MapPlanet = new MapPlanet(); + })(); + YAHOO.register('mapPlanet', YAHOO.lacuna.MapPlanet, { + version: '1', + build: '0', + }); } diff --git a/app/yui/mapStar.js b/app/yui/mapStar.js index 1d5951f7..6d582c68 100644 --- a/app/yui/mapStar.js +++ b/app/yui/mapStar.js @@ -10,144 +10,140 @@ import MenuStore from 'app/stores/menu'; import constants from 'app/constants'; if (typeof YAHOO.lacuna.MapStar == 'undefined' || !YAHOO.lacuna.MapStar) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; - - var MapStar = function () { - this.createEvent('onMapRpc'); - //this.createEvent("onChangeToSystemView"); - this.createEvent('onChangeToPlanetView'); - - this._renameLabel = 'Rename'; - this._sendSpiesLabel = 'Send Spy'; - this._fetchSpiesLabel = 'Fetch Spy'; - this._miningLabel = 'Mining'; - this._excavLabel = 'Excavators'; + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; + + var MapStar = function () { + this.createEvent('onMapRpc'); + //this.createEvent("onChangeToSystemView"); + this.createEvent('onChangeToPlanetView'); + + this._renameLabel = 'Rename'; + this._sendSpiesLabel = 'Send Spy'; + this._fetchSpiesLabel = 'Fetch Spy'; + this._miningLabel = 'Mining'; + this._excavLabel = 'Excavators'; + }; + MapStar.prototype = { + _buildDetailsPanel: _.once(function () { + var panelId = 'starDetails'; + + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
      Details
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + ' ', + '
      ', + '
        ', + '
        Set speed:
          ', + '
            ', + '
              ', + '
              ', + '
              ', + '
              ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); + + this.starDetails = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: false, + close: true, + underlay: false, + width: '500px', + zIndex: 9997, + context: ['header', 'tl', 'bl'], + }); + this.starDetails.addQueue = function (seconds, queueFn, elm, sc) { + this.queue = this.queue || []; + //check if the queue is empty and store + var notStarted = this.queue.length == 0; + //push new queue item so it's immediately available for the tick + this.queue.push({ + secondsRemaining: seconds * 1, + el: elm, + fn: queueFn, + scope: sc, + }); + //make sure we subscribe to the tick + if (notStarted) { + Game.onTick.subscribe(this.processQueue, this, true); + } }; - MapStar.prototype = { - _buildDetailsPanel: _.once(function () { - var panelId = 'starDetails'; - - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
              Details
              ', - '
              ', - '
              ', - '
              ', - '
              ', - '
              ', - '
              ', - '
              ', - '
              ', - ' ', - '
              ', - '
                ', - '
                Set speed:
                  ', - '
                    ', - '
                      ', - '
                      ', - '
                      ', - '
                      ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); - - this.starDetails = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: false, - close: true, - underlay: false, - width: '500px', - zIndex: 9997, - context: ['header', 'tl', 'bl'], - }); - this.starDetails.addQueue = function (seconds, queueFn, elm, sc) { - this.queue = this.queue || []; - //check if the queue is empty and store - var notStarted = this.queue.length == 0; - //push new queue item so it's immediately available for the tick - this.queue.push({ - secondsRemaining: seconds * 1, - el: elm, - fn: queueFn, - scope: sc, - }); - //make sure we subscribe to the tick - if (notStarted) { - Game.onTick.subscribe(this.processQueue, this, true); - } - }; - this.starDetails.processQueue = function (e, oArgs) { - if (this.queue.length > 0) { - var queue = this.queue, - diff = oArgs[0] / 1000, - newq = []; - - while (queue.length > 0) { - var callback = queue.pop(); - callback.secondsRemaining -= diff; - if (callback.secondsRemaining > 0) { - newq.push(callback); - } - callback.fn.call( - callback.scope || this, - callback.secondsRemaining, - callback.el - ); - } - this.queue = newq; - } else { - Game.onTick.unsubscribe(this.processQueue); - } - }; - this.starDetails.resetQueue = function () { - Game.onTick.unsubscribe(this.processQueue); - this.queue = []; - }; - this.starDetails.addTab = function (tab) { - this.removeableTabs = this.removeableTabs || []; - this.removeableTabs.push(tab); - this.tabView.addTab(tab); - }; - this.starDetails.removeTabs = function () { - var rt = this.removeableTabs; - if (rt && rt.length > 0) { - for (var n = 0; n < rt.length; n++) { - Event.purgeElement(rt[n].get('contentEl'), true); - this.tabView.removeTab(rt[n]); - } - delete this.removeableTabs; - } - this.tabView.selectTab(0); - }; - this.starDetails.resetDisplay = function (oSelf) { - delete oSelf.currentShips; - delete oSelf.selectedStar; - this.resetQueue(); - this.removeTabs(); - }; - - this.starDetails.renderEvent.subscribe( - function () { - this.starDetails.tabView = new YAHOO.widget.TabView('starDetailTabs'); - - /*Event.delegate("starDetailsInfo", "click", function(e, matchedEl, container){ + this.starDetails.processQueue = function (e, oArgs) { + if (this.queue.length > 0) { + var queue = this.queue, + diff = oArgs[0] / 1000, + newq = []; + + while (queue.length > 0) { + var callback = queue.pop(); + callback.secondsRemaining -= diff; + if (callback.secondsRemaining > 0) { + newq.push(callback); + } + callback.fn.call(callback.scope || this, callback.secondsRemaining, callback.el); + } + this.queue = newq; + } else { + Game.onTick.unsubscribe(this.processQueue); + } + }; + this.starDetails.resetQueue = function () { + Game.onTick.unsubscribe(this.processQueue); + this.queue = []; + }; + this.starDetails.addTab = function (tab) { + this.removeableTabs = this.removeableTabs || []; + this.removeableTabs.push(tab); + this.tabView.addTab(tab); + }; + this.starDetails.removeTabs = function () { + var rt = this.removeableTabs; + if (rt && rt.length > 0) { + for (var n = 0; n < rt.length; n++) { + Event.purgeElement(rt[n].get('contentEl'), true); + this.tabView.removeTab(rt[n]); + } + delete this.removeableTabs; + } + this.tabView.selectTab(0); + }; + this.starDetails.resetDisplay = function (oSelf) { + delete oSelf.currentShips; + delete oSelf.selectedStar; + this.resetQueue(); + this.removeTabs(); + }; + + this.starDetails.renderEvent.subscribe( + function () { + this.starDetails.tabView = new YAHOO.widget.TabView('starDetailTabs'); + + /*Event.delegate("starDetailsInfo", "click", function(e, matchedEl, container){ var data = this.selectedStar; if(data) { if(matchedEl.innerHTML == "Send Probe") { @@ -155,1968 +151,1886 @@ if (typeof YAHOO.lacuna.MapStar == 'undefined' || !YAHOO.lacuna.MapStar) { } } }, "button", this, true);*/ - }, - this, - true - ); - this.starDetails.hideEvent.subscribe( - function () { - this.starDetails.resetDisplay(this); - }, - this, - true - ); - this.starDetails.showEvent.subscribe(function () { - this.bringToTop(); - }); + }, + this, + true + ); + this.starDetails.hideEvent.subscribe( + function () { + this.starDetails.resetDisplay(this); + }, + this, + true + ); + this.starDetails.showEvent.subscribe(function () { + this.bringToTop(); + }); + + this.starDetails.isStarPanel = true; + + this.starDetails.render(); + Game.OverlayManager.register(this.starDetails); + }), + _buildPlanetDetailsPanel: _.once(function () { + var panelId = 'planetDetails'; + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
                      Details
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + ' ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                        ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      ', + '
                      ', + '
                      ', + '
                        ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      • ', + '
                      ', + '
                      ', + '
                      ', + '
                      ', + '
                        ', + '
                        Set speed:
                          ', + '
                            ', + '
                              ', + '
                                ', + '
                                ', + '
                                  ', + '
                                • From Empire
                                • ', + '
                                ', + '
                                  ', + '
                                  ', + '
                                  ', + '
                                    ', + '
                                  • From Empire
                                  • ', + '
                                  ', + '
                                    ', + '
                                    ', + '
                                      ', + '
                                    • ', + '
                                    • ', + '
                                    • ', + '
                                    ', + '
                                    ', + '
                                    ', + '
                                    ', + '
                                      ', + '
                                    ', + '
                                    ', + '
                                    ', + '
                                    ', + '
                                    Sending spies. Select Ship:
                                    ', + '
                                    ', + '
                                      ', + '
                                      ', + '
                                      ', + '
                                      ', + '
                                      ', + '
                                      ', + '
                                        ', + '
                                        ', + '
                                        ', + '
                                        ', + '
                                        Fetching spies. Select Ship:
                                        ', + '
                                        ', + '
                                          ', + '
                                        ', + '
                                        ', + '
                                        ', + '
                                        ', + '
                                        ', + '
                                        ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); + + this.planetDetails = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: false, + close: true, + underlay: false, + width: '710px', + zIndex: 9997, + context: ['header', 'tr', 'br', ['beforeShow', 'windowResize'], [-200, 40]], + }); + this.planetDetails.addQueue = function (seconds, queueFn, elm, sc) { + this.queue = this.queue || []; + //check if the queue is empty and store + var notStarted = this.queue.length == 0; + //push new queue item so it's immediately available for the tick + this.queue.push({ + secondsRemaining: seconds * 1, + el: elm, + fn: queueFn, + scope: sc, + }); + //make sure we subscribe to the tick + if (notStarted) { + Game.onTick.subscribe(this.processQueue, this, true); + } + }; + this.planetDetails.processQueue = function (e, oArgs) { + if (this.queue.length > 0) { + var queue = this.queue, + diff = oArgs[0] / 1000, + newq = []; + + while (queue.length > 0) { + var callback = queue.pop(); + callback.secondsRemaining -= diff; + if (callback.secondsRemaining > 0) { + newq.push(callback); + } + callback.fn.call(callback.scope || this, callback.secondsRemaining, callback.el); + } + this.queue = newq; + } else { + Game.onTick.unsubscribe(this.processQueue); + } + }; + this.planetDetails.resetQueue = function () { + Game.onTick.unsubscribe(this.processQueue); + this.queue = []; + }; + this.planetDetails.addTab = function (tab) { + this.removeableTabs = this.removeableTabs || []; + this.removeableTabs.push(tab); + this.tabView.addTab(tab); + }; + this.planetDetails.removeTabs = function () { + var rt = this.removeableTabs; + if (rt && rt.length > 0) { + for (var n = 0; n < rt.length; n++) { + this.tabView.removeTab(rt[n]); + } + delete this.removeableTabs; + } + //this.tabView.selectTab(0); + }; + this.planetDetails.resetDisplay = function (oSelf) { + delete oSelf.currentShips; + delete oSelf.selectedBody; + delete oSelf.selectedTile; + this.resetQueue(); + this.removeTabs(); + + var send = Dom.get('planetDetailSendShips'), + fleet = Dom.get('planetDetailSendFleet'), + unavail = Dom.get('planetDetailUnavailShips'), + mining = Dom.get('planetDetailMiningShips'), + excav = Dom.get('planetDetailExcavators'), + incoming = Dom.get('planetDetailIncomingShips'), + orbiting = Dom.get('planetDetailOrbitingShips'); + + if (send) { + Event.purgeElement(send, true); + send.innerHTML = ''; + } + if (fleet) { + Event.purgeElement(fleet, true); + fleet.innerHTML = ''; + } + if (unavail) { + Event.purgeElement(unavail, true); + unavail.innerHTML = ''; + } + if (mining) { + Event.purgeElement(mining, true); + mining.innerHTML = ''; + } + if (excav) { + Event.purgeElement(excav, true); + excav.innerHTML = ''; + } + if (incoming) { + Event.purgeElement(incoming, true); + incoming.innerHTML = ''; + } + if (orbiting) { + Event.purgeElement(orbiting, true); + orbiting.innerHTML = ''; + } + }; - this.starDetails.isStarPanel = true; - - this.starDetails.render(); - Game.OverlayManager.register(this.starDetails); - }), - _buildPlanetDetailsPanel: _.once(function () { - var panelId = 'planetDetails'; - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
                                        Details
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - ' ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                          ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                          ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        • ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                        ', - '
                                          ', - '
                                          Set speed:
                                            ', - '
                                              ', - '
                                                ', - '
                                                  ', - '
                                                  ', - '
                                                    ', - '
                                                  • From Empire
                                                  • ', - '
                                                  ', - '
                                                    ', - '
                                                    ', - '
                                                    ', - '
                                                      ', - '
                                                    • From Empire
                                                    • ', - '
                                                    ', - '
                                                      ', - '
                                                      ', - '
                                                        ', - '
                                                      • ', - '
                                                      • ', - '
                                                      • ', - '
                                                      ', - '
                                                      ', - '
                                                      ', - '
                                                      ', - '
                                                        ', - '
                                                      ', - '
                                                      ', - '
                                                      ', - '
                                                      ', - '
                                                      Sending spies. Select Ship:
                                                      ', - '
                                                      ', - '
                                                        ', - '
                                                        ', - '
                                                        ', - '
                                                        ', - '
                                                        ', - '
                                                        ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          Fetching spies. Select Ship:
                                                          ', - '
                                                          ', - '
                                                            ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); - - this.planetDetails = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: false, - close: true, - underlay: false, - width: '710px', - zIndex: 9997, - context: ['header', 'tr', 'br', ['beforeShow', 'windowResize'], [-200, 40]], + this.planetDetails.renderEvent.subscribe( + function () { + Event.delegate('planetDetailsInfo', 'click', this.DetailsClick, 'button', this, true); + var tv = (this.planetDetails.tabView = new YAHOO.widget.TabView('planetDetailTabs')); + + var getShips = function (e) { + if (e.newValue) { + this.GetShips(this.planetDetails, { + body_id: this.selectedBody.id, }); - this.planetDetails.addQueue = function (seconds, queueFn, elm, sc) { - this.queue = this.queue || []; - //check if the queue is empty and store - var notStarted = this.queue.length == 0; - //push new queue item so it's immediately available for the tick - this.queue.push({ - secondsRemaining: seconds * 1, - el: elm, - fn: queueFn, - scope: sc, - }); - //make sure we subscribe to the tick - if (notStarted) { - Game.onTick.subscribe(this.processQueue, this, true); - } - }; - this.planetDetails.processQueue = function (e, oArgs) { - if (this.queue.length > 0) { - var queue = this.queue, - diff = oArgs[0] / 1000, - newq = []; - - while (queue.length > 0) { - var callback = queue.pop(); - callback.secondsRemaining -= diff; - if (callback.secondsRemaining > 0) { - newq.push(callback); - } - callback.fn.call( - callback.scope || this, - callback.secondsRemaining, - callback.el - ); - } - this.queue = newq; - } else { - Game.onTick.unsubscribe(this.processQueue); - } - }; - this.planetDetails.resetQueue = function () { - Game.onTick.unsubscribe(this.processQueue); - this.queue = []; - }; - this.planetDetails.addTab = function (tab) { - this.removeableTabs = this.removeableTabs || []; - this.removeableTabs.push(tab); - this.tabView.addTab(tab); - }; - this.planetDetails.removeTabs = function () { - var rt = this.removeableTabs; - if (rt && rt.length > 0) { - for (var n = 0; n < rt.length; n++) { - this.tabView.removeTab(rt[n]); - } - delete this.removeableTabs; - } - //this.tabView.selectTab(0); - }; - this.planetDetails.resetDisplay = function (oSelf) { - delete oSelf.currentShips; - delete oSelf.selectedBody; - delete oSelf.selectedTile; - this.resetQueue(); - this.removeTabs(); - - var send = Dom.get('planetDetailSendShips'), - fleet = Dom.get('planetDetailSendFleet'), - unavail = Dom.get('planetDetailUnavailShips'), - mining = Dom.get('planetDetailMiningShips'), - excav = Dom.get('planetDetailExcavators'), - incoming = Dom.get('planetDetailIncomingShips'), - orbiting = Dom.get('planetDetailOrbitingShips'); - - if (send) { - Event.purgeElement(send, true); - send.innerHTML = ''; - } - if (fleet) { - Event.purgeElement(fleet, true); - fleet.innerHTML = ''; - } - if (unavail) { - Event.purgeElement(unavail, true); - unavail.innerHTML = ''; - } - if (mining) { - Event.purgeElement(mining, true); - mining.innerHTML = ''; - } - if (excav) { - Event.purgeElement(excav, true); - excav.innerHTML = ''; - } - if (incoming) { - Event.purgeElement(incoming, true); - incoming.innerHTML = ''; - } - if (orbiting) { - Event.purgeElement(orbiting, true); - orbiting.innerHTML = ''; - } - }; - - this.planetDetails.renderEvent.subscribe( - function () { - Event.delegate( - 'planetDetailsInfo', - 'click', - this.DetailsClick, - 'button', - this, - true - ); - var tv = (this.planetDetails.tabView = new YAHOO.widget.TabView( - 'planetDetailTabs' - )); - - var getShips = function (e) { - if (e.newValue) { - this.GetShips(this.planetDetails, { - body_id: this.selectedBody.id, - }); - } - }; - //Send Tab - tv.getTab(1).subscribe('beforeActiveChange', getShips, this, true); - //Send Fleet Tab - tv.getTab(2).subscribe('beforeActiveChange', getShips, this, true); - //Unavailable Tab - tv.getTab(3).subscribe('beforeActiveChange', getShips, this, true); - //Incoming Tab - tv.getTab(4).subscribe('beforeActiveChange', getShips, this, true); - //Orbiting Tab - tv.getTab(5).subscribe('beforeActiveChange', getShips, this, true); - //Mining Tab - tv.getTab(6).subscribe('beforeActiveChange', getShips, this, true); - //Excavator Tab - tv.getTab(7).subscribe('beforeActiveChange', getShips, this, true); - - Event.on( - 'planetDetailSendFleetSubmit', - 'click', - this.FleetSend, - this, - true - ); - Event.on('starDetailSendFleetSubmit', 'click', this.FleetSend, this, true); - - var spyTabs = { - planetDetailSendSpies: 9, - planetDetailFetchSpies: 10, - }; - var tabChange = function (e, tabEl) { - if (e.newValue) { - this.ShowSpies(tabEl); - } - }, - hideEventFn = function () { - delete this.avail?.spyShips; - delete this.avail?.spies; - }; - for (var tabId in spyTabs) { - if (spyTabs.hasOwnProperty(tabId)) { - var tab = tv.getTab(spyTabs[tabId]); - var tabEl = Dom.get(tabId); - tab.subscribe('beforeActiveChange', tabChange, tabEl, this); - tabEl.elSpiesPane = Sel.query( - '.planetDetailSelectSpies', - tabEl, - true - ); - tabEl.elSpyShipsPane = Sel.query( - '.planetDetailSelectSpyShip', - tabEl, - true - ); - tabEl.elSendButton = Sel.query( - '.planetDetailSelectSpies button', - tabEl, - true - ); - tabEl.elSpiesList = Sel.query( - '.planetDetailSpiesList', - tabEl, - true - ); - tabEl.elSpyShipsList = Sel.query( - '.planetDetailSpyShipList', - tabEl, - true - ); - tabEl.elMessage = Sel.query( - '.planetDetailSpiesMessage', - tabEl, - true - ); - tabEl.elShipMessageCount = Sel.query( - '.planetDetailSpyShipMessage span.count', - tabEl, - true - ); - Event.on(tabEl.elSendButton, 'click', this.MoveSpies, tabEl, this); - Event.on( - Sel.query('.planetDetailSelectSpyShip button', tabEl, true), - 'click', - this.MoveSpiesCancel, - tabEl, - this - ); - Event.delegate( - tabEl, - 'click', - this.MoveSpyShip, - '.planetDetailSelectSpyShip ul button', - this, - true - ); - this.planetDetails.hideEvent.subscribe(hideEventFn, tabEl, true); - } - } - Event.on('planetDetailRenameSubmit', 'click', this.Rename, this, true); - }, - this, - true + } + }; + //Send Tab + tv.getTab(1).subscribe('beforeActiveChange', getShips, this, true); + //Send Fleet Tab + tv.getTab(2).subscribe('beforeActiveChange', getShips, this, true); + //Unavailable Tab + tv.getTab(3).subscribe('beforeActiveChange', getShips, this, true); + //Incoming Tab + tv.getTab(4).subscribe('beforeActiveChange', getShips, this, true); + //Orbiting Tab + tv.getTab(5).subscribe('beforeActiveChange', getShips, this, true); + //Mining Tab + tv.getTab(6).subscribe('beforeActiveChange', getShips, this, true); + //Excavator Tab + tv.getTab(7).subscribe('beforeActiveChange', getShips, this, true); + + Event.on('planetDetailSendFleetSubmit', 'click', this.FleetSend, this, true); + Event.on('starDetailSendFleetSubmit', 'click', this.FleetSend, this, true); + + var spyTabs = { + planetDetailSendSpies: 9, + planetDetailFetchSpies: 10, + }; + var tabChange = function (e, tabEl) { + if (e.newValue) { + this.ShowSpies(tabEl); + } + }, + hideEventFn = function () { + delete this.avail?.spyShips; + delete this.avail?.spies; + }; + for (var tabId in spyTabs) { + if (spyTabs.hasOwnProperty(tabId)) { + var tab = tv.getTab(spyTabs[tabId]); + var tabEl = Dom.get(tabId); + tab.subscribe('beforeActiveChange', tabChange, tabEl, this); + tabEl.elSpiesPane = Sel.query('.planetDetailSelectSpies', tabEl, true); + tabEl.elSpyShipsPane = Sel.query('.planetDetailSelectSpyShip', tabEl, true); + tabEl.elSendButton = Sel.query('.planetDetailSelectSpies button', tabEl, true); + tabEl.elSpiesList = Sel.query('.planetDetailSpiesList', tabEl, true); + tabEl.elSpyShipsList = Sel.query('.planetDetailSpyShipList', tabEl, true); + tabEl.elMessage = Sel.query('.planetDetailSpiesMessage', tabEl, true); + tabEl.elShipMessageCount = Sel.query( + '.planetDetailSpyShipMessage span.count', + tabEl, + true ); - this.planetDetails.hideEvent.subscribe( - function () { - this.planetDetails.resetDisplay(this); - }, - this, - true + Event.on(tabEl.elSendButton, 'click', this.MoveSpies, tabEl, this); + Event.on( + Sel.query('.planetDetailSelectSpyShip button', tabEl, true), + 'click', + this.MoveSpiesCancel, + tabEl, + this ); - this.planetDetails.showEvent.subscribe(function () { - this.bringToTop(); - }); - this.planetDetails.render(); - Game.OverlayManager.register(this.planetDetails); - }), - _buildFindPanel: _.once(function () { - var panelId = 'starFind'; - - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
                                                          Find
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - ' ', - ' ', - ' ', - '
                                                          ', - '
                                                          ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); - - this.starFind = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: false, - close: false, - underlay: false, - width: '300px', - zIndex: 10005, - context: ['footer', 'bl', 'tl', ['beforeShow', 'windowResize'], [0, -5]], - }); - this.starFind.createFind = function () { - var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'map'); - dataSource.connMethodPost = 'POST'; - dataSource.maxCacheEntries = 2; - dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - dataSource.responseSchema = { - resultsList: 'result.stars', - fields: ['name', 'color', 'x', 'y'], - }; - - var oTextboxList = new YAHOO.lacuna.TextboxList(this.findInput, dataSource, { - //config options - maxResultsDisplayed: 25, - minQueryLength: 3, - multiSelect: false, - forceSelection: false, - useIndicator: true, - }); - oTextboxList.formatResult = function (oResultData, sQuery, sResultMatch) { - return [ - '
                                                          ', - '
                                                          ', - ' ',
-                            oResultData,
-                            name,
-                            '', - '
                                                          ', - '
                                                          ', - '
                                                          ', - oResultData.name, - '
                                                          ', - '
                                                          ', - oResultData.x, - ' : ', - oResultData.y, - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - }; - oTextboxList.generateRequest = function (sQuery) { - var s = Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'search_stars', - jsonrpc: '2.0', - params: [Game.GetSession(''), decodeURIComponent(sQuery)], - }); - return s; - }; - oTextboxList.dirtyEvent.subscribe(function (event, isDirty, oSelf) { - var star = this._oTblSingleSelection.Object; - oSelf.X.value = star.x; - oSelf.Y.value = star.y; - }, this); - this.findStar = oTextboxList; - }; - this.starFind.renderEvent.subscribe( - function () { - this.starFind.findInput = Dom.get(panelId + 'Find'); - this.starFind.X = Dom.get(panelId + 'X'); - this.starFind.Y = Dom.get(panelId + 'Y'); - Event.on(panelId + 'Jump', 'click', this.FindJump, this, true); - this.starFind.createFind(); - }, - this, - true + Event.delegate( + tabEl, + 'click', + this.MoveSpyShip, + '.planetDetailSelectSpyShip ul button', + this, + true ); - this.starFind.showEvent.subscribe( - function () { - this.starFind.findInput.blur(); - }, - this, - true - ); - - this.starFind.render(); - }), - - IsVisible: function () { - return this._isVisible; - }, - MapVisible: function (visible) { - if (visible) { - // Build panels - this._buildFindPanel(); - this._buildDetailsPanel(); - this._buildPlanetDetailsPanel(); - - this.starFind.show(); - } else { - // This can get called before the panels have been built. :/ - this.starFind && this.starFind.hide(); - } - if (this._isVisible != visible) { - if (this._elGrid) { - this._isVisible = visible; - YAHOO.log(visible, 'info', 'MapStar.MapVisible'); - if (visible) { - if (!Dom.inDocument(this._elGrid)) { - document.getElementById('content').appendChild(this._elGrid); - } - //Dom.setStyle(this._elGrid, "display", visible ? "" : "none"); - } else { - this._elGrid = this._elGrid.parentNode.removeChild(this._elGrid); - } - if (visible) { - this.Resize(); - } - } - } - }, - - FindJump: function () { - var x = this.starFind.X.value * 1, - y = this.starFind.Y.value * 1; - - if (Lang.isNumber(x) && Lang.isNumber(y)) { - this.Jump(x, y); - } - }, - Jump: function (xC, yC) { - this.LoadGrid({ - x: xC, //(xC-1), - y: yC, //(yC+1) - }); - }, - Load: function () { - var cId = BodyRPCStore.id; - if (cId) { - var loc = EmpireRPCStore.planets[cId]; - if (loc) { - this.locationId = cId; - loc.x *= 1; - loc.y *= 1; - this.LoadGrid(loc); - } - } + this.planetDetails.hideEvent.subscribe(hideEventFn, tabEl, true); + } + } + Event.on('planetDetailRenameSubmit', 'click', this.Rename, this, true); + }, + this, + true + ); + this.planetDetails.hideEvent.subscribe( + function () { + this.planetDetails.resetDisplay(this); + }, + this, + true + ); + this.planetDetails.showEvent.subscribe(function () { + this.bringToTop(); + }); + this.planetDetails.render(); + Game.OverlayManager.register(this.planetDetails); + }), + _buildFindPanel: _.once(function () { + var panelId = 'starFind'; + + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
                                                          Find
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + ' ', + ' ', + ' ', + '
                                                          ', + '
                                                          ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); + + this.starFind = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: false, + close: false, + underlay: false, + width: '300px', + zIndex: 10005, + context: ['footer', 'bl', 'tl', ['beforeShow', 'windowResize'], [0, -5]], + }); + this.starFind.createFind = function () { + var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'map'); + dataSource.connMethodPost = 'POST'; + dataSource.maxCacheEntries = 2; + dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + dataSource.responseSchema = { + resultsList: 'result.stars', + fields: ['name', 'color', 'x', 'y'], + }; + + var oTextboxList = new YAHOO.lacuna.TextboxList(this.findInput, dataSource, { + //config options + maxResultsDisplayed: 25, + minQueryLength: 3, + multiSelect: false, + forceSelection: false, + useIndicator: true, + }); + oTextboxList.formatResult = function (oResultData, sQuery, sResultMatch) { + return [ + '
                                                          ', + '
                                                          ', + ' ',
+              oResultData,
+              name,
+              '', + '
                                                          ', + '
                                                          ', + '
                                                          ', + oResultData.name, + '
                                                          ', + '
                                                          ', + oResultData.x, + ' : ', + oResultData.y, + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + }; + oTextboxList.generateRequest = function (sQuery) { + var s = Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'search_stars', + jsonrpc: '2.0', + params: [Game.GetSession(''), decodeURIComponent(sQuery)], + }); + return s; + }; + oTextboxList.dirtyEvent.subscribe(function (event, isDirty, oSelf) { + var star = this._oTblSingleSelection.Object; + oSelf.X.value = star.x; + oSelf.Y.value = star.y; + }, this); + this.findStar = oTextboxList; + }; + this.starFind.renderEvent.subscribe( + function () { + this.starFind.findInput = Dom.get(panelId + 'Find'); + this.starFind.X = Dom.get(panelId + 'X'); + this.starFind.Y = Dom.get(panelId + 'Y'); + Event.on(panelId + 'Jump', 'click', this.FindJump, this, true); + this.starFind.createFind(); + }, + this, + true + ); + this.starFind.showEvent.subscribe( + function () { + this.starFind.findInput.blur(); + }, + this, + true + ); + + this.starFind.render(); + }), + + IsVisible: function () { + return this._isVisible; + }, + MapVisible: function (visible) { + if (visible) { + // Build panels + this._buildFindPanel(); + this._buildDetailsPanel(); + this._buildPlanetDetailsPanel(); + + this.starFind.show(); + } else { + // This can get called before the panels have been built. :/ + this.starFind && this.starFind.hide(); + } + if (this._isVisible != visible) { + if (this._elGrid) { + this._isVisible = visible; + YAHOO.log(visible, 'info', 'MapStar.MapVisible'); + if (visible) { + if (!Dom.inDocument(this._elGrid)) { + document.getElementById('content').appendChild(this._elGrid); + } + //Dom.setStyle(this._elGrid, "display", visible ? "" : "none"); + } else { + this._elGrid = this._elGrid.parentNode.removeChild(this._elGrid); + } + if (visible) { + this.Resize(); + } + } + } + }, + + FindJump: function () { + var x = this.starFind.X.value * 1, + y = this.starFind.Y.value * 1; + + if (Lang.isNumber(x) && Lang.isNumber(y)) { + this.Jump(x, y); + } + }, + Jump: function (xC, yC) { + this.LoadGrid({ + x: xC, //(xC-1), + y: yC, //(yC+1) + }); + }, + Load: function () { + var cId = BodyRPCStore.id; + if (cId) { + var loc = EmpireRPCStore.planets[cId]; + if (loc) { + this.locationId = cId; + loc.x *= 1; + loc.y *= 1; + this.LoadGrid(loc); + } + } + }, + LoadGrid: function (loc) { + MenuStore.showLoader(); + if (!this._gridCreated) { + var starMap = document.createElement('div'); + starMap.id = 'starMap'; + this._elGrid = document.getElementById('content').appendChild(starMap); + this.SetSize(); + + var map = new Lacuna.Mapper.StarMap('starMap'); + //map.imgUrlLoc = Lib.AssetUrl + 'ui/mapiator/'; + + //draw what we got + map.redraw(); + //move to current planet + map.setCenterTo(loc.x, loc.y); + + this._map = map; + this._gridCreated = true; + + Event.delegate(this._map.mapDiv, 'click', this.GridClick, 'div.tile', this, true); + } else { + //move to current planet + this._map.setCenterTo(loc.x, loc.y); + } + + this.MapVisible(true); + MenuStore.hideLoader(); + }, + GridClick: function (e, matchedEl, container) { + if (!this._map.controller.isDragging()) { + var tile = this._map.tileLayer.findTileById(matchedEl.id); + if (tile && tile.data) { + if (tile.data.isStar) { + this.ShowStar(tile); + WindowsStore.add('starPanel', tile); + } else if (tile.data.isPlanet) { + WindowsStore.add('planetPanel', tile); + } + } + } + }, + DetailsClick: function (e, matchedEl, container) { + if (this.selectedBody) { + if (matchedEl.innerHTML == 'View') { + var id = this.selectedBody.id; + this.planetDetails.hide(); + this.fireEvent('onChangeToPlanetView', id); + } + } + }, + SetSize: function () { + var size = Game.GetSize(); + Dom.setStyle(this._elGrid, 'width', size.w + 'px'); + Dom.setStyle(this._elGrid, 'height', size.h + 'px'); + }, + Resize: function () { + this.SetSize(); + this._map.resize(); + }, + Reset: function () { + delete this.locationId; + if (this._map) { + this._map.reset(); + } + this.MapVisible(false); + }, + + PopulateShipsIncomingTab: function (panel) { + var ships = this.currentShips.incoming || [], + details = Dom.get( + panel.isStarPanel ? 'starDetailIncomingShips' : 'planetDetailIncomingShips' + ); + + if (ships.length > 0) { + Event.purgeElement(details, true); + details.innerHTML = ''; + + var li = document.createElement('li'); + + ships = ships.slice(0); + ships.sort(function (a, b) { + if (a.date_arrives > b.date_arrives) { + return 1; + } else if (a.date_arrives < b.date_arrives) { + return -1; + } else { + return 0; + } + }); + + var serverTime = Lib.getTime(ServerRPCStore.time); + + for (var i = 0; i < ships.length; i++) { + var ship = ships[i], + nLi = li.cloneNode(false), + sec = (Lib.getTime(ship.date_arrives) - serverTime) / 1000; + + nLi.Ship = ship; + + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + '
                                                          [', + ship.type_human, + '] ', + ship.name, + ' - Arrives in: ', + Lib.formatTime(sec), + '
                                                          ', + '
                                                          ', + ' Task:', + ship.task, + '', + ' From:', + ship.from ? ship.from.name : 'Unknown', + '', + ' To:', + ship.to.name, + '', + '
                                                          ', + '
                                                          ', + ' Speed:', + ship.fleet_speed > 0 && ship.fleet_speed < ship.speed ? ship.fleet_speed : ship.speed, + ',', + ' Hold Size:', + ship.hold_size, + '', + ' Stealth:', + ship.stealth, + '', + ' Combat:', + ship.combat, + '', + '
                                                          ', + '
                                                          ', + ship.payload.join(', '), + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + + panel.addQueue(sec, this.ArrivesQueue, nLi); + + details.appendChild(nLi); + } + } else { + details.innerHTML = '
                                                        • No Incoming ships
                                                        • '; + } + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(details.parentNode, 'height', Ht + 'px'); + Dom.setStyle(details.parentNode, 'overflow-y', 'auto'); + }, 10); + }, + ArrivesQueue: function (remaining, elLine) { + var arrTime; + if (remaining <= 0) { + arrTime = 'Overdue ' + Lib.formatTime(Math.round(-remaining)); + } else { + arrTime = Lib.formatTime(Math.round(remaining)); + } + Sel.query('.shipArrives', elLine, true).innerHTML = arrTime; + }, + + PopulateShipsSendTab: function (panel) { + var ships = this.currentShips.available, + details = Dom.get(panel.isStarPanel ? 'starDetailSendShips' : 'planetDetailSendShips'), + detailsParent = details.parentNode, + li = document.createElement('li'); + + Event.purgeElement(details, true); //clear any events before we remove + details = detailsParent.removeChild(details); //remove from DOM to make this faster + details.innerHTML = ''; + + if (ships.length === 0) { + details.innerHTML = 'No available ships to send.'; + } else { + for (var i = 0; i < ships.length; i++) { + var ship = ships[i], + nLi = li.cloneNode(false); + + nLi.Ship = ship; + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + '
                                                          [', + ship.type_human, + '] ', + ship.name, + '
                                                          ', + '
                                                          ', + ' Task:', + ship.task, + ',', + ' Travel Time:', + Lib.formatTime(ship.estimated_travel_time), + '', + '
                                                          ', + '
                                                          ', + ' Speed:', + ship.speed, + ',', + ' Hold Size:', + ship.hold_size, + ',', + ' Stealth:', + ship.stealth, + '', + ' Combat:', + ship.combat, + '', + '
                                                          ', + '
                                                          ', + '
                                                          ', + ship.task == 'Docked' ? ' ' : '', + '
                                                          ', + '
                                                          ', + ].join(''); + + if (ship.task == 'Docked') { + Event.on( + Sel.query('button', nLi, true), + 'click', + this.ShipSend, + { Self: this, Ship: ship, Line: nLi }, + true + ); + } + + details.appendChild(nLi); + } + } + detailsParent.appendChild(details); //add back as child + + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(detailsParent, 'height', Ht + 'px'); + Dom.setStyle(detailsParent, 'overflow-y', 'auto'); + }, 10); + }, + ShipSend: function () { + var oSelf = this.Self, + ship = this.Ship, + target, + targetName, + panel; + + if (oSelf.selectedBody) { + target = { body_id: oSelf.selectedBody.id }; + targetName = oSelf.selectedBody.name; + panel = oSelf.planetDetails; + } else if (oSelf.selectedStar) { + target = { star_id: oSelf.selectedStar.id }; + targetName = oSelf.selectedStar.name; + panel = oSelf.starDetails; + } + + if (target && oSelf.NotIsolationist(ship)) { + Game.Services.Buildings.SpacePort.send_ship( + { + session_id: Game.GetSession(), + ship_id: ship.id, + target: target, }, - LoadGrid: function (loc) { - MenuStore.showLoader(); - if (!this._gridCreated) { - var starMap = document.createElement('div'); - starMap.id = 'starMap'; - this._elGrid = document.getElementById('content').appendChild(starMap); - this.SetSize(); - - var map = new Lacuna.Mapper.StarMap('starMap'); - //map.imgUrlLoc = Lib.AssetUrl + 'ui/mapiator/'; - - //draw what we got - map.redraw(); - //move to current planet - map.setCenterTo(loc.x, loc.y); - - this._map = map; - this._gridCreated = true; - - Event.delegate( - this._map.mapDiv, - 'click', - this.GridClick, - 'div.tile', - this, - true - ); - } else { - //move to current planet - this._map.setCenterTo(loc.x, loc.y); - } - - this.MapVisible(true); + { + success: function (o) { + YAHOO.log(o, 'info', 'MapStar.ShipSend.send_ship.success'); MenuStore.hideLoader(); - }, - GridClick: function (e, matchedEl, container) { - if (!this._map.controller.isDragging()) { - var tile = this._map.tileLayer.findTileById(matchedEl.id); - if (tile && tile.data) { - if (tile.data.isStar) { - this.ShowStar(tile); - WindowsStore.add('starPanel', tile); - } else if (tile.data.isPlanet) { - WindowsStore.add('planetPanel', tile); - } - } - } - }, - DetailsClick: function (e, matchedEl, container) { - if (this.selectedBody) { - if (matchedEl.innerHTML == 'View') { - var id = this.selectedBody.id; - this.planetDetails.hide(); - this.fireEvent('onChangeToPlanetView', id); - } - } - }, - SetSize: function () { - var size = Game.GetSize(); - Dom.setStyle(this._elGrid, 'width', size.w + 'px'); - Dom.setStyle(this._elGrid, 'height', size.h + 'px'); - }, - Resize: function () { - this.SetSize(); - this._map.resize(); - }, - Reset: function () { - delete this.locationId; - if (this._map) { - this._map.reset(); - } - this.MapVisible(false); - }, - - PopulateShipsIncomingTab: function (panel) { - var ships = this.currentShips.incoming || [], - details = Dom.get( - panel.isStarPanel ? 'starDetailIncomingShips' : 'planetDetailIncomingShips' - ); - - if (ships.length > 0) { - Event.purgeElement(details, true); - details.innerHTML = ''; - - var li = document.createElement('li'); - - ships = ships.slice(0); - ships.sort(function (a, b) { - if (a.date_arrives > b.date_arrives) { - return 1; - } else if (a.date_arrives < b.date_arrives) { - return -1; - } else { - return 0; - } - }); - - var serverTime = Lib.getTime(ServerRPCStore.time); - - for (var i = 0; i < ships.length; i++) { - var ship = ships[i], - nLi = li.cloneNode(false), - sec = (Lib.getTime(ship.date_arrives) - serverTime) / 1000; - - nLi.Ship = ship; - - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          [', - ship.type_human, - '] ', - ship.name, - ' - Arrives in: ', - Lib.formatTime(sec), - '
                                                          ', - '
                                                          ', - ' Task:', - ship.task, - '', - ' From:', - ship.from ? ship.from.name : 'Unknown', - '', - ' To:', - ship.to.name, - '', - '
                                                          ', - '
                                                          ', - ' Speed:', - ship.fleet_speed > 0 && ship.fleet_speed < ship.speed - ? ship.fleet_speed - : ship.speed, - ',', - ' Hold Size:', - ship.hold_size, - '', - ' Stealth:', - ship.stealth, - '', - ' Combat:', - ship.combat, - '', - '
                                                          ', - '
                                                          ', - ship.payload.join(', '), - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - - panel.addQueue(sec, this.ArrivesQueue, nLi); - - details.appendChild(nLi); - } - } else { - details.innerHTML = '
                                                        • No Incoming ships
                                                        • '; - } - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(details.parentNode, 'height', Ht + 'px'); - Dom.setStyle(details.parentNode, 'overflow-y', 'auto'); - }, 10); - }, - ArrivesQueue: function (remaining, elLine) { - var arrTime; - if (remaining <= 0) { - arrTime = 'Overdue ' + Lib.formatTime(Math.round(-remaining)); - } else { - arrTime = Lib.formatTime(Math.round(remaining)); - } - Sel.query('.shipArrives', elLine, true).innerHTML = arrTime; - }, - - PopulateShipsSendTab: function (panel) { - var ships = this.currentShips.available, - details = Dom.get( - panel.isStarPanel ? 'starDetailSendShips' : 'planetDetailSendShips' - ), - detailsParent = details.parentNode, - li = document.createElement('li'); - - Event.purgeElement(details, true); //clear any events before we remove - details = detailsParent.removeChild(details); //remove from DOM to make this faster - details.innerHTML = ''; - - if (ships.length === 0) { - details.innerHTML = 'No available ships to send.'; - } else { - for (var i = 0; i < ships.length; i++) { - var ship = ships[i], - nLi = li.cloneNode(false); - - nLi.Ship = ship; - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          [', - ship.type_human, - '] ', - ship.name, - '
                                                          ', - '
                                                          ', - ' Task:', - ship.task, - ',', - ' Travel Time:', - Lib.formatTime(ship.estimated_travel_time), - '', - '
                                                          ', - '
                                                          ', - ' Speed:', - ship.speed, - ',', - ' Hold Size:', - ship.hold_size, - ',', - ' Stealth:', - ship.stealth, - '', - ' Combat:', - ship.combat, - '', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ship.task == 'Docked' - ? ' ' - : '', - '
                                                          ', - '
                                                          ', - ].join(''); - - if (ship.task == 'Docked') { - Event.on( - Sel.query('button', nLi, true), - 'click', - this.ShipSend, - { Self: this, Ship: ship, Line: nLi }, - true - ); - } - - details.appendChild(nLi); - } - } - detailsParent.appendChild(details); //add back as child - - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(detailsParent, 'height', Ht + 'px'); - Dom.setStyle(detailsParent, 'overflow-y', 'auto'); - }, 10); - }, - ShipSend: function () { - var oSelf = this.Self, - ship = this.Ship, - target, - targetName, - panel; - - if (oSelf.selectedBody) { - target = { body_id: oSelf.selectedBody.id }; - targetName = oSelf.selectedBody.name; - panel = oSelf.planetDetails; - } else if (oSelf.selectedStar) { - target = { star_id: oSelf.selectedStar.id }; - targetName = oSelf.selectedStar.name; - panel = oSelf.starDetails; - } - - if (target && oSelf.NotIsolationist(ship)) { - Game.Services.Buildings.SpacePort.send_ship( - { - session_id: Game.GetSession(), - ship_id: ship.id, - target: target, - }, - { - success: function (o) { - YAHOO.log(o, 'info', 'MapStar.ShipSend.send_ship.success'); - MenuStore.hideLoader(); - this.Self.fireEvent('onMapRpc', o.result); - delete this.Self.currentShips; - this.Self.GetShips(panel, target); - Event.purgeElement(this.Line, true); - this.Line.innerHTML = - 'Successfully sent ' + - this.Ship.type_human + - ' to ' + - targetName + - '.'; - }, - scope: this, - } - ); - } - }, - NotIsolationist: function (ship) { - if ( - EmpireRPCStore.is_isolationist && - (ship.type == 'colony_ship' || ship.type == 'short_range_colony_ship') - ) { - return confirm( - 'If you colonize another planet you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' - ); - } - return true; - }, - - PopulateFleetSendTab: function (panel) { - var ships = this.currentShips.available, - details = Dom.get( + this.Self.fireEvent('onMapRpc', o.result); + delete this.Self.currentShips; + this.Self.GetShips(panel, target); + Event.purgeElement(this.Line, true); + this.Line.innerHTML = + 'Successfully sent ' + this.Ship.type_human + ' to ' + targetName + '.'; + }, + scope: this, + } + ); + } + }, + NotIsolationist: function (ship) { + if ( + EmpireRPCStore.is_isolationist && + (ship.type == 'colony_ship' || ship.type == 'short_range_colony_ship') + ) { + return confirm( + 'If you colonize another planet you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' + ); + } + return true; + }, + + PopulateFleetSendTab: function (panel) { + var ships = this.currentShips.available, + details = Dom.get(panel.isStarPanel ? 'starDetailSendFleet' : 'planetDetailSendFleet'), + btn = Dom.get( + panel.isStarPanel ? 'starDetailSendFleetSubmit' : 'planetDetailSendFleetSubmit' + ), + detailsParent = details.parentNode, + li = document.createElement('li'); + + details = detailsParent.removeChild(details); //remove from DOM to make this faster + details.innerHTML = ''; + + if (ships.length === 0) { + details.innerHTML = 'No available ships to send.'; + btn.disabled = true; + } else { + btn.disabled = false; + for (var i = 0; i < ships.length; i++) { + var ship = ships[i], + nLi = li.cloneNode(false); + + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + '
                                                          [', + ship.type_human, + '] ', + ship.name, + '
                                                          ', + '
                                                          ', + ' Task:', + ship.task, + ',', + ' Travel Time:', + Lib.formatTime(ship.estimated_travel_time), + '', + '
                                                          ', + '
                                                          ', + ' Speed:', + ship.speed, + ',', + ' Hold Size:', + ship.hold_size, + ',', + ' Stealth:', + ship.stealth, + '', + ' Combat:', + ship.combat, + '', + '
                                                          ', + '
                                                          ', + '
                                                          ', + ship.task == 'Docked' ? '' : '', + '
                                                          ', + '
                                                          ', + ].join(''); + + if (ship.task == 'Docked') { + Sel.query('input', nLi, true).Ship = ship; + } + + details.appendChild(nLi); + } + } + detailsParent.appendChild(details); //add back as child + + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(detailsParent, 'height', Ht + 'px'); + Dom.setStyle(detailsParent, 'overflow-y', 'auto'); + }, 10); + }, + FleetSend: function (e) { + var target, + targetName, + panel, + btn = Event.getTarget(e); + + btn.disabled = true; + + if (this.selectedBody) { + target = { body_id: this.selectedBody.id }; + targetName = this.selectedBody.name; + panel = this.planetDetails; + } else if (this.selectedStar) { + target = { star_id: this.selectedStar.id }; + targetName = this.selectedStar.name; + panel = this.starDetails; + } + + var speed = parseInt( + Dom.get(panel.isStarPanel ? 'starDetailSetSpeed' : 'planetDetailSetSpeed').value, + 10 + ); + var selected = Sel.query( + 'input:checked', + panel.isStarPanel ? 'starDetailSendFleet' : 'planetDetailSendFleet' + ); + if (selected.length > 0) { + var ships = [], + shipIds = [], + minSpeed = 999999999; + for (var n = 0; n < selected.length; n++) { + var s = selected[n].Ship; + s.speed = parseInt(s.speed, 10); // probably not needed but play it safe + ships.push(s); + shipIds.push(s.id); + if (s.speed < minSpeed) { + minSpeed = s.speed; + } + } + if (target && this.NotFleetIsolationist(ships)) { + if (speed < 0) { + alert('Set speed cannot be less than zero.'); + btn.disabled = false; + } else { + if (speed > 0 && speed > minSpeed) { + alert('Set speed cannot exceed the speed of the slowest ship.'); + btn.disabled = false; + } else { + Game.Services.Buildings.SpacePort.send_fleet( + { + session_id: Game.GetSession(), + ship_ids: shipIds, + target: target, + set_speed: speed, + }, + { + success: function (o) { + MenuStore.hideLoader(); + this.fireEvent('onMapRpc', o.result); + delete this.currentShips; + var details = Dom.get( panel.isStarPanel ? 'starDetailSendFleet' : 'planetDetailSendFleet' - ), - btn = Dom.get( - panel.isStarPanel - ? 'starDetailSendFleetSubmit' - : 'planetDetailSendFleetSubmit' - ), - detailsParent = details.parentNode, - li = document.createElement('li'); - - details = detailsParent.removeChild(details); //remove from DOM to make this faster - details.innerHTML = ''; - - if (ships.length === 0) { - details.innerHTML = 'No available ships to send.'; - btn.disabled = true; - } else { - btn.disabled = false; - for (var i = 0; i < ships.length; i++) { - var ship = ships[i], - nLi = li.cloneNode(false); - - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          [', - ship.type_human, - '] ', - ship.name, - '
                                                          ', - '
                                                          ', - ' Task:', - ship.task, - ',', - ' Travel Time:', - Lib.formatTime(ship.estimated_travel_time), - '', - '
                                                          ', - '
                                                          ', - ' Speed:', - ship.speed, - ',', - ' Hold Size:', - ship.hold_size, - ',', - ' Stealth:', - ship.stealth, - '', - ' Combat:', - ship.combat, - '', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ship.task == 'Docked' ? '' : '', - '
                                                          ', - '
                                                          ', - ].join(''); - - if (ship.task == 'Docked') { - Sel.query('input', nLi, true).Ship = ship; - } - - details.appendChild(nLi); - } - } - detailsParent.appendChild(details); //add back as child - - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(detailsParent, 'height', Ht + 'px'); - Dom.setStyle(detailsParent, 'overflow-y', 'auto'); - }, 10); - }, - FleetSend: function (e) { - var target, - targetName, - panel, - btn = Event.getTarget(e); - - btn.disabled = true; - - if (this.selectedBody) { - target = { body_id: this.selectedBody.id }; - targetName = this.selectedBody.name; - panel = this.planetDetails; - } else if (this.selectedStar) { - target = { star_id: this.selectedStar.id }; - targetName = this.selectedStar.name; - panel = this.starDetails; - } - - var speed = parseInt( - Dom.get(panel.isStarPanel ? 'starDetailSetSpeed' : 'planetDetailSetSpeed') - .value, - 10 - ); - var selected = Sel.query( - 'input:checked', - panel.isStarPanel ? 'starDetailSendFleet' : 'planetDetailSendFleet' + ); + details.innerHTML = '
                                                        • Sent ' + o.result.fleet.length + ' ships!
                                                        • '; + this.GetShips(panel, target); + }, + failure: function (o) { + btn.disabled = false; + }, + scope: this, + } ); - if (selected.length > 0) { - var ships = [], - shipIds = [], - minSpeed = 999999999; - for (var n = 0; n < selected.length; n++) { - var s = selected[n].Ship; - s.speed = parseInt(s.speed, 10); // probably not needed but play it safe - ships.push(s); - shipIds.push(s.id); - if (s.speed < minSpeed) { - minSpeed = s.speed; - } - } - if (target && this.NotFleetIsolationist(ships)) { - if (speed < 0) { - alert('Set speed cannot be less than zero.'); - btn.disabled = false; - } else { - if (speed > 0 && speed > minSpeed) { - alert('Set speed cannot exceed the speed of the slowest ship.'); - btn.disabled = false; - } else { - Game.Services.Buildings.SpacePort.send_fleet( - { - session_id: Game.GetSession(), - ship_ids: shipIds, - target: target, - set_speed: speed, - }, - { - success: function (o) { - MenuStore.hideLoader(); - this.fireEvent('onMapRpc', o.result); - delete this.currentShips; - var details = Dom.get( - panel.isStarPanel - ? 'starDetailSendFleet' - : 'planetDetailSendFleet' - ); - details.innerHTML = - '
                                                        • Sent ' + - o.result.fleet.length + - ' ships!
                                                        • '; - this.GetShips(panel, target); - }, - failure: function (o) { - btn.disabled = false; - }, - scope: this, - } - ); - } - } - } - } else { - btn.disabled = false; - } - }, - NotFleetIsolationist: function (ships) { - if (EmpireRPCStore.is_isolationist) { - var hasIsoShip; - for (var n = 0; n < ships.length; n++) { - if ( - ships[n].type == 'colony_ship' || - ships[n].type == 'short_range_colony_ship' - ) { - hasIsoShip = true; - break; - } - } - - if (hasIsoShip) { - return confirm( - 'If you colonize another planet you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' - ); - } - } - return true; + } + } + } + } else { + btn.disabled = false; + } + }, + NotFleetIsolationist: function (ships) { + if (EmpireRPCStore.is_isolationist) { + var hasIsoShip; + for (var n = 0; n < ships.length; n++) { + if (ships[n].type == 'colony_ship' || ships[n].type == 'short_range_colony_ship') { + hasIsoShip = true; + break; + } + } + + if (hasIsoShip) { + return confirm( + 'If you colonize another planet you will no longer be considered an Isolationist and you will be open to attack. Are you sure you want to do this?' + ); + } + } + return true; + }, + + PopulateShipsUnavailTab: function (panel) { + var ships = this.currentShips.unavailable, + details = Dom.get( + panel.isStarPanel ? 'starDetailUnavailShips' : 'planetDetailUnavailShips' + ), + detailsParent = details.parentNode, + li = document.createElement('li'); + + //Event.purgeElement(details, true); //clear any events before we remove + details = detailsParent.removeChild(details); //remove from DOM to make this faster + details.innerHTML = ''; + + if (ships.length === 0) { + details.innerHTML = 'No unavailable ships.'; + } else { + for (var i = 0; i < ships.length; i++) { + var ship = ships[i].ship, + nLi = li.cloneNode(false); + + nLi.Ship = ship; + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + '
                                                          [', + ship.type_human, + '] ', + ship.name, + '
                                                          ', + '
                                                          ', + ' Task:', + ship.task, + '', + '
                                                          ', + '
                                                          ', + ' Speed:', + ship.speed, + ',', + ' Berth Level:', + ship.berth_level, + ',', + ' Hold Size:', + ship.hold_size, + ',', + ' Stealth:', + ship.stealth, + '', + ' Combat:', + ship.combat, + '', + '
                                                          ', + '
                                                          ', + ships[i].reason[1], + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + + details.appendChild(nLi); + } + } + detailsParent.appendChild(details); //add back as child + + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(detailsParent, 'height', Ht + 'px'); + Dom.setStyle(detailsParent, 'overflow-y', 'auto'); + }, 10); + }, + + PopulateShipsOrbitingTab: function (panel) { + var ships = this.currentShips.orbiting || [], + details = Dom.get('planetDetailOrbitingShips'), + detailsParent = details.parentNode, + li = document.createElement('li'); + + Event.purgeElement(details, true); //clear any events before we remove + details = detailsParent.removeChild(details); //remove from DOM to make this faster + details.innerHTML = ''; + + if (ships.length === 0) { + details.innerHTML = 'No orbiting ships.'; + } else { + for (var i = 0; i < ships.length; i++) { + var ship = ships[i], + nLi = li.cloneNode(false); + + nLi.Ship = ship; + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + '
                                                          [', + ship.type_human, + '] ', + ship.name, + '
                                                          ', + '
                                                          ', + ' Task:', + ship.task, + ',', + ' From:', + ship.from.name, + '', + '
                                                          ', + '
                                                          ', + ' Speed:', + ship.speed, + ',', + ' Hold Size:', + ship.hold_size, + ',', + ' Stealth:', + ship.stealth, + '', + ' Combat:', + ship.combat, + '', + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + + details.appendChild(nLi); + } + } + detailsParent.appendChild(details); //add back as child + + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(detailsParent, 'height', Ht + 'px'); + Dom.setStyle(detailsParent, 'overflow-y', 'auto'); + }, 10); + }, + + PopulateShipsMiningPlatforms: function (panel) { + var ships = this.currentShips.mining_platforms || []; + var details = Dom.get('planetDetailMiningShips'); + + if (details) { + var parent = details.parentNode; + + details = parent.removeChild(details); + + if (ships.length > 0) { + Event.purgeElement(details, true); + details.innerHTML = ''; + + var li = document.createElement('li'); + + for (var i = 0; i < ships.length; i++) { + var ship = ships[i], + nLi = li.cloneNode(false); + + nLi.Ship = ship; + + Dom.addClass(nLi, 'shipName'); + nLi.innerHTML = ship.empire_name; + Event.on(nLi, 'click', this.ShowEmpire, ship.empire_id); + + details.appendChild(nLi); + } + } else { + details.innerHTML = '
                                                        • No mining ships
                                                        • '; + } + + parent.appendChild(details); + + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(details.parentNode, 'height', Ht + 'px'); + Dom.setStyle(details.parentNode, 'overflow-y', 'auto'); + }, 10); + } + }, + PopulateShipsExcavators: function (panel) { + var ships = this.currentShips.excavators || []; + var details = Dom.get('planetDetailExcavators'); + + if (details) { + var parent = details.parentNode; + + details = parent.removeChild(details); + + if (ships.length > 0) { + Event.purgeElement(details, true); + details.innerHTML = ''; + + var li = document.createElement('li'); + + for (var i = 0; i < ships.length; i++) { + var ship = ships[i], + nLi = li.cloneNode(false); + + nLi.Ship = ship; + + Dom.addClass(nLi, 'shipName'); + nLi.innerHTML = ship.empire_name; + Event.on(nLi, 'click', this.ShowEmpire, ship.empire_id); + + details.appendChild(nLi); + } + } else { + details.innerHTML = '
                                                        • No excavators
                                                        • '; + } + + parent.appendChild(details); + + //wait for tab to display first + setTimeout(function () { + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(details.parentNode, 'height', Ht + 'px'); + Dom.setStyle(details.parentNode, 'overflow-y', 'auto'); + }, 10); + } + }, + ShowEmpire: function (e, id) { + Lacuna.Info.Empire.Load(id); + }, + + GetShips: function (panel, target) { + if (!this.currentShips) { + MenuStore.showLoader(); + + Game.Services.Buildings.SpacePort.get_ships_for( + { + session_id: Game.GetSession(), + from_body_id: BodyRPCStore.id, + target: target, }, + { + success: function (o) { + YAHOO.log(o, 'info', 'MapStar.ShowStar.get_ships_for.success'); + MenuStore.hideLoader(); + this.fireEvent('onMapRpc', o.result); + this.currentShips = o.result; - PopulateShipsUnavailTab: function (panel) { - var ships = this.currentShips.unavailable, - details = Dom.get( - panel.isStarPanel ? 'starDetailUnavailShips' : 'planetDetailUnavailShips' - ), - detailsParent = details.parentNode, - li = document.createElement('li'); - - //Event.purgeElement(details, true); //clear any events before we remove - details = detailsParent.removeChild(details); //remove from DOM to make this faster - details.innerHTML = ''; - - if (ships.length === 0) { - details.innerHTML = 'No unavailable ships.'; - } else { - for (var i = 0; i < ships.length; i++) { - var ship = ships[i].ship, - nLi = li.cloneNode(false); - - nLi.Ship = ship; - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          [', - ship.type_human, - '] ', - ship.name, - '
                                                          ', - '
                                                          ', - ' Task:', - ship.task, - '', - '
                                                          ', - '
                                                          ', - ' Speed:', - ship.speed, - ',', - ' Berth Level:', - ship.berth_level, - ',', - ' Hold Size:', - ship.hold_size, - ',', - ' Stealth:', - ship.stealth, - '', - ' Combat:', - ship.combat, - '', - '
                                                          ', - '
                                                          ', - ships[i].reason[1], - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - - details.appendChild(nLi); - } - } - detailsParent.appendChild(details); //add back as child - - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(detailsParent, 'height', Ht + 'px'); - Dom.setStyle(detailsParent, 'overflow-y', 'auto'); - }, 10); - }, - - PopulateShipsOrbitingTab: function (panel) { - var ships = this.currentShips.orbiting || [], - details = Dom.get('planetDetailOrbitingShips'), - detailsParent = details.parentNode, - li = document.createElement('li'); - - Event.purgeElement(details, true); //clear any events before we remove - details = detailsParent.removeChild(details); //remove from DOM to make this faster - details.innerHTML = ''; - - if (ships.length === 0) { - details.innerHTML = 'No orbiting ships.'; - } else { - for (var i = 0; i < ships.length; i++) { - var ship = ships[i], - nLi = li.cloneNode(false); - - nLi.Ship = ship; - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          [', - ship.type_human, - '] ', - ship.name, - '
                                                          ', - '
                                                          ', - ' Task:', - ship.task, - ',', - ' From:', - ship.from.name, - '', - '
                                                          ', - '
                                                          ', - ' Speed:', - ship.speed, - ',', - ' Hold Size:', - ship.hold_size, - ',', - ' Stealth:', - ship.stealth, - '', - ' Combat:', - ship.combat, - '', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - - details.appendChild(nLi); - } - } - detailsParent.appendChild(details); //add back as child - - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(detailsParent, 'height', Ht + 'px'); - Dom.setStyle(detailsParent, 'overflow-y', 'auto'); - }, 10); - }, - - PopulateShipsMiningPlatforms: function (panel) { - var ships = this.currentShips.mining_platforms || []; - var details = Dom.get('planetDetailMiningShips'); - - if (details) { - var parent = details.parentNode; - - details = parent.removeChild(details); - - if (ships.length > 0) { - Event.purgeElement(details, true); - details.innerHTML = ''; - - var li = document.createElement('li'); - - for (var i = 0; i < ships.length; i++) { - var ship = ships[i], - nLi = li.cloneNode(false); - - nLi.Ship = ship; - - Dom.addClass(nLi, 'shipName'); - nLi.innerHTML = ship.empire_name; - Event.on(nLi, 'click', this.ShowEmpire, ship.empire_id); - - details.appendChild(nLi); - } - } else { - details.innerHTML = '
                                                        • No mining ships
                                                        • '; - } - - parent.appendChild(details); - - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(details.parentNode, 'height', Ht + 'px'); - Dom.setStyle(details.parentNode, 'overflow-y', 'auto'); - }, 10); - } - }, - PopulateShipsExcavators: function (panel) { - var ships = this.currentShips.excavators || []; - var details = Dom.get('planetDetailExcavators'); - - if (details) { - var parent = details.parentNode; - - details = parent.removeChild(details); - - if (ships.length > 0) { - Event.purgeElement(details, true); - details.innerHTML = ''; - - var li = document.createElement('li'); - - for (var i = 0; i < ships.length; i++) { - var ship = ships[i], - nLi = li.cloneNode(false); - - nLi.Ship = ship; - - Dom.addClass(nLi, 'shipName'); - nLi.innerHTML = ship.empire_name; - Event.on(nLi, 'click', this.ShowEmpire, ship.empire_id); - - details.appendChild(nLi); - } - } else { - details.innerHTML = '
                                                        • No excavators
                                                        • '; - } - - parent.appendChild(details); - - //wait for tab to display first - setTimeout(function () { - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(details.parentNode, 'height', Ht + 'px'); - Dom.setStyle(details.parentNode, 'overflow-y', 'auto'); - }, 10); - } - }, - ShowEmpire: function (e, id) { - Lacuna.Info.Empire.Load(id); - }, - - GetShips: function (panel, target) { - if (!this.currentShips) { - MenuStore.showLoader(); - - Game.Services.Buildings.SpacePort.get_ships_for( - { - session_id: Game.GetSession(), - from_body_id: BodyRPCStore.id, - target: target, - }, - { - success: function (o) { - YAHOO.log(o, 'info', 'MapStar.ShowStar.get_ships_for.success'); - MenuStore.hideLoader(); - this.fireEvent('onMapRpc', o.result); - this.currentShips = o.result; - - this.PopulateShipsSendTab(panel); + this.PopulateShipsSendTab(panel); - this.PopulateFleetSendTab(panel); + this.PopulateFleetSendTab(panel); - this.PopulateShipsUnavailTab(panel); + this.PopulateShipsUnavailTab(panel); - this.PopulateShipsIncomingTab(panel); + this.PopulateShipsIncomingTab(panel); - this.PopulateShipsOrbitingTab(panel); + this.PopulateShipsOrbitingTab(panel); - this.PopulateShipsMiningPlatforms(panel); + this.PopulateShipsMiningPlatforms(panel); - this.PopulateShipsExcavators(panel); + this.PopulateShipsExcavators(panel); - panel.removeTabs(); //remove any tabs that are removable before adding new ones + panel.removeTabs(); //remove any tabs that are removable before adding new ones - //select 0 index tab unless we already selected a different one - /*if(panel.tabView.get("activeIndex") <= 0) { + //select 0 index tab unless we already selected a different one + /*if(panel.tabView.get("activeIndex") <= 0) { panel.tabView.selectTab(0); }*/ - }, - scope: this, - } - ); - } - }, - ShowStar: function (tile, keepOpen) { - if (!keepOpen) { - Game.OverlayManager.hideAllBut(this.starDetails.id); - } - - var data = tile.data, - panel = this.starDetails; - - panel.resetDisplay(this); - - Dom.get('starDetailsImg').innerHTML = [ - '',
-                    data.name,
-                    '', - ].join(''); - - Dom.get('starDetailsInfo').innerHTML = [ - '
                                                            ', - '
                                                          • ', - data.name, - '
                                                          • ', - '
                                                          • ', - data.x, - '
                                                          • ', - '
                                                          • ', - data.y, - '
                                                          • ', - '
                                                          • ', - data.zone, - '
                                                          • ', - '
                                                          • ', - data.id, - '
                                                          • ', - '
                                                          • ', - data.influence, - '
                                                          • ', - data.station - ? '
                                                          • ' + - data.station.name + - ' (' + - data.station.x + - ' : ' + - data.station.y + - ')
                                                          • ' + - data.station.id + - '
                                                          • ' + - data.station.alliance.name + - '
                                                          • ' - : '', - '
                                                          ', - ].join(''); - - this.selectedStar = data; - - this.GetShips(panel, { star_id: data.id }); - - panel.show(); - }, - ShowPlanet: function (tile, keepOpen) { - if (!keepOpen) { - Game.OverlayManager.hideAllBut(this.planetDetails.id); - } - var panel = this.planetDetails; - - var data = { - session_id: Game.GetSession(''), - body_id: tile.data.id, - }; - - Game.Services.Body.get_body_status(data, { - success: function (o) { - YAHOO.log(o, 'info', 'ShowPlanet.get_status.success'); - - var body = o.result.body, - tab, - tabs, - empire = body.empire || { - alignment: 'none', - name: '', - }; - - panel.resetDisplay(this); - - Dom.get('planetDetailsImg').innerHTML = [ - '',
-                            body.name,
-                            '', - ].join(''); - Dom.get('planetDetailsInfo').innerHTML = [ - '
                                                            ', - '
                                                          • ', - body.name, - '
                                                          • ', - '
                                                          • ', - body.type, - '
                                                          • ', - '
                                                          • ', - empire.name, - '
                                                          • ', - empire.id - ? '
                                                          • ' + - (empire.is_isolationist == '1' ? 'Yes' : 'No') + - '
                                                          • ' - : '', - '
                                                          • ', - body.water, - '
                                                          • ', - '
                                                          • ', - body.size, - '
                                                          • ', - '
                                                          • ', - body.x, - 'x : ', - body.y, - 'y
                                                          • ', - '
                                                          • ', - body.zone, - '
                                                          • ', - '
                                                          • ', - body.id, - '
                                                          • ', - '
                                                          • ', - body.star_name, - ' (ID: ', - body.star_id, - ')
                                                          • ', - '
                                                          • ', - body.orbit, - '
                                                          • ', - empire.alignment == 'self' || - (empire.alignment == 'ally' && body.type == 'space station') - ? '
                                                          • ' - : '', - '
                                                          ', - ].join(''); - - Dom.get('planetDetailsAnthracite').innerHTML = body.ore.anthracite; - Dom.get('planetDetailsBauxite').innerHTML = body.ore.bauxite; - Dom.get('planetDetailsBeryl').innerHTML = body.ore.beryl; - Dom.get('planetDetailsChalcopyrite').innerHTML = body.ore.chalcopyrite; - Dom.get('planetDetailsChromite').innerHTML = body.ore.chromite; - Dom.get('planetDetailsFluorite').innerHTML = body.ore.fluorite; - Dom.get('planetDetailsGalena').innerHTML = body.ore.galena; - Dom.get('planetDetailsGoethite').innerHTML = body.ore.goethite; - Dom.get('planetDetailsGold').innerHTML = body.ore.gold; - Dom.get('planetDetailsGypsum').innerHTML = body.ore.gypsum; - Dom.get('planetDetailsHalite').innerHTML = body.ore.halite; - Dom.get('planetDetailsKerogen').innerHTML = body.ore.kerogen; - Dom.get('planetDetailsMagnetite').innerHTML = body.ore.magnetite; - Dom.get('planetDetailsMethane').innerHTML = body.ore.methane; - Dom.get('planetDetailsMonazite').innerHTML = body.ore.monazite; - Dom.get('planetDetailsRutile').innerHTML = body.ore.rutile; - Dom.get('planetDetailsSulfur').innerHTML = body.ore.sulfur; - Dom.get('planetDetailsTrona').innerHTML = body.ore.trona; - Dom.get('planetDetailsUraninite').innerHTML = body.ore.uraninite; - Dom.get('planetDetailsZircon').innerHTML = body.ore.zircon; - - if (empire.id) { - Dom.setStyle('planetDetailsEmpire', 'cursor', 'pointer'); - Dom.setStyle('planetDetailsEmpire', 'text-decoration', 'underline'); - Event.on( - 'planetDetailsEmpire', - 'click', - function () { - Lacuna.Info.Empire.Load(this.id); - }, - empire, - true - ); - } else { - Dom.setStyle('planetDetailsEmpire', 'cursor', 'normal'); - Dom.setStyle('planetDetailsEmpire', 'text-decoration', 'none'); - Event.removeListener('planetDetailsEmpire', 'click'); - } - - if (empire.alignment == 'self') { - if (panel.renameTab) { - panel.tabView.addTab(panel.renameTab, 1); - delete panel.renameTab; - } - - Dom.get('planetDetailNewName').value = ''; - } else { - tabs = panel.tabView.get('tabs'); - for (var nt = 0; nt < tabs.length; nt++) { - tab = panel.tabView.getTab(nt); - if (tab && tab.get('label') == this._renameLabel) { - panel.renameTab = tab; - panel.tabView.removeTab(tab); - break; - } - } - } - if (empire.alignment == 'none' || empire.is_isolationist == '1') { - tabs = panel.tabView.get('tabs'); - for (var snt = tabs.length; snt >= 0; snt--) { - tab = panel.tabView.getTab(snt); - if (tab && tab.get('label') == this._sendSpiesLabel) { - panel.sendSpiesTab = tab; - panel.tabView.removeTab(tab); - } else if (tab && tab.get('label') == this._fetchSpiesLabel) { - panel.fetchSpiesTab = tab; - panel.tabView.removeTab(tab); - } - } - } else { - if (panel.sendSpiesTab) { - panel.tabView.addTab(panel.sendSpiesTab); - delete panel.sendSpiesTab; - } - if (panel.fetchSpiesTab) { - panel.tabView.addTab(panel.fetchSpiesTab); - delete panel.fetchSpiesTab; - } - } - - if (body.type == 'asteroid') { - if (panel.miningTab) { - panel.tabView.addTab(panel.miningTab); - delete panel.miningTab; - } - } else { - tabs = panel.tabView.get('tabs'); - for (var mnt = tabs.length; mnt >= 0; mnt--) { - tab = panel.tabView.getTab(mnt); - if (tab && tab.get('label') == this._miningLabel) { - panel.miningTab = tab; - panel.tabView.removeTab(tab); - } - } - } - if (body.type !== 'gas giant' && !body.empire) { - if (panel.excavTab) { - panel.tabView.addTab(panel.excavTab); - delete panel.excavTab; - } - } else { - tabs = panel.tabView.get('tabs'); - for (var mnt = tabs.length; mnt >= 0; mnt--) { - tab = panel.tabView.getTab(mnt); - if (tab && tab.get('label') == this._excavLabel) { - panel.excavTab = tab; - panel.tabView.removeTab(tab); - } - } - } - - //this.GetShips(panel,{body_id:body.id}); - - this.selectedBody = body; - this.selectedTile = tile; - panel.tabView.selectTab(0); - panel.show(); - }, - failure: function (o) { - YAHOO.log(o, 'info', 'ShowPlanet.get_status.fail'); - - return true; - }, - scope: this, - }); - }, - - Rename: function () { - var newName = Dom.get('planetDetailNewName').value; - Game.Services.Body.rename( - { - session_id: Game.GetSession(''), - body_id: this.selectedBody.id, - name: newName, - }, - { - success: function (o) { - YAHOO.log(o, 'info', 'MapStar.Rename.success'); - if (o.result && this.selectedBody) { - Dom.get('planetDetailRenameMessage').innerHTML = [ - 'Successfully renamed your planet from ', - this.selectedBody.name, - ' to ', - newName, - '.', - ].join(''); - Lib.fadeOutElm('planetDetailRenameMessage'); - Dom.get('planetDetailsName').innerHTML = newName; - EmpireRPCStore.planets[this.selectedBody.id].name = newName; - if (this.selectedTile instanceof YAHOO.lacuna.Mapper.StarTile) { - this._map.tileCache[this.selectedTile.x][ - this.selectedTile.y - ].name = newName; - this.selectedTile.refresh(); - } - - this.selectedBody.name = newName; - } - }, - failure: function (o) { - Dom.get('planetDetailRenameMessage').innerHTML = o.error.message; - Lib.fadeOutElm('planetDetailRenameMessage'); - return true; - }, - scope: this, - } - ); - }, - ShowSpies: function (tab) { - Dom.setStyle(tab.elSpiesPane, 'display', 'block'); - Dom.setStyle(tab.elSpyShipsPane, 'display', 'none'); - if (tab.avail && tab.avail.spies && tab.avail.spyShips) { - return; - } - tab.elSpiesList.innerHTML = ''; - tab.elSpyShipsList.innerHTML = ''; - tab.elMessage.innerHTML = ''; - Dom.setStyle(tab.elSendButton, 'display', 'none'); - MenuStore.showLoader(); - var method, data; - if (tab.id == 'planetDetailSendSpies') { - method = 'prepare_send_spies'; - data = { - session_id: Game.GetSession(), - on_body_id: BodyRPCStore.id, - to_body_id: this.selectedBody.id, - }; - } else { - method = 'prepare_fetch_spies'; - data = { - session_id: Game.GetSession(), - on_body_id: this.selectedBody.id, - to_body_id: BodyRPCStore.id, - }; - } - - Game.Services.Buildings.SpacePort[method](data, { - success: function (o) { - YAHOO.log(o, 'info', 'MapStar.ShowSpies.' + method + '.success'); - this.fireEvent('onMapRpc', o.result); - MenuStore.hideLoader(); - tab.avail = { - spyShips: o.result.ships, - spies: o.result.spies, - }; - this.populateSpies(tab); - }, - scope: this, - }); - }, - populateSpies: function (tab) { - var list = tab.elSpiesList; - var spies = tab.avail.spies; - var ships = tab.avail.spyShips; - var verb = tab.id == 'planetDetailSendSpies' ? 'send' : 'fetch'; - - if (spies.length == 0) { - tab.elMessage.innerHTML = 'No spies available.'; - return; - } + }, + scope: this, + } + ); + } + }, + ShowStar: function (tile, keepOpen) { + if (!keepOpen) { + Game.OverlayManager.hideAllBut(this.starDetails.id); + } + + var data = tile.data, + panel = this.starDetails; + + panel.resetDisplay(this); + + Dom.get('starDetailsImg').innerHTML = [ + '',
+          data.name,
+          '', + ].join(''); + + Dom.get('starDetailsInfo').innerHTML = [ + '
                                                            ', + '
                                                          • ', + data.name, + '
                                                          • ', + '
                                                          • ', + data.x, + '
                                                          • ', + '
                                                          • ', + data.y, + '
                                                          • ', + '
                                                          • ', + data.zone, + '
                                                          • ', + '
                                                          • ', + data.id, + '
                                                          • ', + '
                                                          • ', + data.influence, + '
                                                          • ', + data.station + ? '
                                                          • ' + + data.station.name + + ' (' + + data.station.x + + ' : ' + + data.station.y + + ')
                                                          • ' + + data.station.id + + '
                                                          • ' + + data.station.alliance.name + + '
                                                          • ' + : '', + '
                                                          ', + ].join(''); + + this.selectedStar = data; + + this.GetShips(panel, { star_id: data.id }); + + panel.show(); + }, + ShowPlanet: function (tile, keepOpen) { + if (!keepOpen) { + Game.OverlayManager.hideAllBut(this.planetDetails.id); + } + var panel = this.planetDetails; + + var data = { + session_id: Game.GetSession(''), + body_id: tile.data.id, + }; - var maxSpies = 0; - for (var i = 0; i < ships.length; i++) { - var ship = ships[i]; - if (ship.max_occupants > maxSpies) { - maxSpies = ship.max_occupants; - } - if (maxSpies > 100) { - maxSpies = 100; - } - } - if (maxSpies == 0) { - tab.elMessage.innerHTML = 'No ships available.'; - } else { - tab.elMessage.innerHTML = - 'Select up to ' + maxSpies + ' spies to ' + verb + ':'; - Dom.setStyle(tab.elSendButton, 'display', 'inline'); + Game.Services.Body.get_body_status(data, { + success: function (o) { + YAHOO.log(o, 'info', 'ShowPlanet.get_status.success'); + + var body = o.result.body, + tab, + tabs, + empire = body.empire || { + alignment: 'none', + name: '', + }; + + panel.resetDisplay(this); + + Dom.get('planetDetailsImg').innerHTML = [ + '',
+              body.name,
+              '', + ].join(''); + Dom.get('planetDetailsInfo').innerHTML = [ + '
                                                            ', + '
                                                          • ', + body.name, + '
                                                          • ', + '
                                                          • ', + body.type, + '
                                                          • ', + '
                                                          • ', + empire.name, + '
                                                          • ', + empire.id + ? '
                                                          • ' + + (empire.is_isolationist == '1' ? 'Yes' : 'No') + + '
                                                          • ' + : '', + '
                                                          • ', + body.water, + '
                                                          • ', + '
                                                          • ', + body.size, + '
                                                          • ', + '
                                                          • ', + body.x, + 'x : ', + body.y, + 'y
                                                          • ', + '
                                                          • ', + body.zone, + '
                                                          • ', + '
                                                          • ', + body.id, + '
                                                          • ', + '
                                                          • ', + body.star_name, + ' (ID: ', + body.star_id, + ')
                                                          • ', + '
                                                          • ', + body.orbit, + '
                                                          • ', + empire.alignment == 'self' || + (empire.alignment == 'ally' && body.type == 'space station') + ? '
                                                          • ' + : '', + '
                                                          ', + ].join(''); + + Dom.get('planetDetailsAnthracite').innerHTML = body.ore.anthracite; + Dom.get('planetDetailsBauxite').innerHTML = body.ore.bauxite; + Dom.get('planetDetailsBeryl').innerHTML = body.ore.beryl; + Dom.get('planetDetailsChalcopyrite').innerHTML = body.ore.chalcopyrite; + Dom.get('planetDetailsChromite').innerHTML = body.ore.chromite; + Dom.get('planetDetailsFluorite').innerHTML = body.ore.fluorite; + Dom.get('planetDetailsGalena').innerHTML = body.ore.galena; + Dom.get('planetDetailsGoethite').innerHTML = body.ore.goethite; + Dom.get('planetDetailsGold').innerHTML = body.ore.gold; + Dom.get('planetDetailsGypsum').innerHTML = body.ore.gypsum; + Dom.get('planetDetailsHalite').innerHTML = body.ore.halite; + Dom.get('planetDetailsKerogen').innerHTML = body.ore.kerogen; + Dom.get('planetDetailsMagnetite').innerHTML = body.ore.magnetite; + Dom.get('planetDetailsMethane').innerHTML = body.ore.methane; + Dom.get('planetDetailsMonazite').innerHTML = body.ore.monazite; + Dom.get('planetDetailsRutile').innerHTML = body.ore.rutile; + Dom.get('planetDetailsSulfur').innerHTML = body.ore.sulfur; + Dom.get('planetDetailsTrona').innerHTML = body.ore.trona; + Dom.get('planetDetailsUraninite').innerHTML = body.ore.uraninite; + Dom.get('planetDetailsZircon').innerHTML = body.ore.zircon; + + if (empire.id) { + Dom.setStyle('planetDetailsEmpire', 'cursor', 'pointer'); + Dom.setStyle('planetDetailsEmpire', 'text-decoration', 'underline'); + Event.on( + 'planetDetailsEmpire', + 'click', + function () { + Lacuna.Info.Empire.Load(this.id); + }, + empire, + true + ); + } else { + Dom.setStyle('planetDetailsEmpire', 'cursor', 'normal'); + Dom.setStyle('planetDetailsEmpire', 'text-decoration', 'none'); + Event.removeListener('planetDetailsEmpire', 'click'); + } + + if (empire.alignment == 'self') { + if (panel.renameTab) { + panel.tabView.addTab(panel.renameTab, 1); + delete panel.renameTab; + } + + Dom.get('planetDetailNewName').value = ''; + } else { + tabs = panel.tabView.get('tabs'); + for (var nt = 0; nt < tabs.length; nt++) { + tab = panel.tabView.getTab(nt); + if (tab && tab.get('label') == this._renameLabel) { + panel.renameTab = tab; + panel.tabView.removeTab(tab); + break; } - tab.maxSpies = maxSpies; - - var li = document.createElement('li'); - - for (var si = 0; si < spies.length; si++) { - var spy = spies[si], - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - '
                                                          ', - spy.name, - '
                                                          Level ', - spy.level, - '
                                                          ', - '
                                                          ', - '
                                                          ', - maxSpies == 0 - ? '' - : '', - '
                                                          Offense: ', - spy.offense_rating, - 'Defense: ', - spy.defense_rating, - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - list.appendChild(nLi); + } + } + if (empire.alignment == 'none' || empire.is_isolationist == '1') { + tabs = panel.tabView.get('tabs'); + for (var snt = tabs.length; snt >= 0; snt--) { + tab = panel.tabView.getTab(snt); + if (tab && tab.get('label') == this._sendSpiesLabel) { + panel.sendSpiesTab = tab; + panel.tabView.removeTab(tab); + } else if (tab && tab.get('label') == this._fetchSpiesLabel) { + panel.fetchSpiesTab = tab; + panel.tabView.removeTab(tab); } - - var Ht = Game.GetSize().h - 330; - if (Ht > 240) { - Ht = 240; + } + } else { + if (panel.sendSpiesTab) { + panel.tabView.addTab(panel.sendSpiesTab); + delete panel.sendSpiesTab; + } + if (panel.fetchSpiesTab) { + panel.tabView.addTab(panel.fetchSpiesTab); + delete panel.fetchSpiesTab; + } + } + + if (body.type == 'asteroid') { + if (panel.miningTab) { + panel.tabView.addTab(panel.miningTab); + delete panel.miningTab; + } + } else { + tabs = panel.tabView.get('tabs'); + for (var mnt = tabs.length; mnt >= 0; mnt--) { + tab = panel.tabView.getTab(mnt); + if (tab && tab.get('label') == this._miningLabel) { + panel.miningTab = tab; + panel.tabView.removeTab(tab); } - Dom.setStyle(list, 'height', Ht + 'px'); - }, - MoveSpies: function (e, tab) { - Event.stopEvent(e); - var spies = []; - var ships = tab.avail.spyShips; - var list = tab.elSpyShipsList; - var verb = tab.id == 'planetDetailSendSpies' ? 'send' : 'fetch'; - Dom.batch(tab.elSpiesList.getElementsByTagName('input'), function (el) { - if (el.checked) { - spies.push(el.value); - } - }); - if (spies.length == 0) { - alert('You must select at least one spy to ' + verb + '!'); - return; + } + } + if (body.type !== 'gas giant' && !body.empire) { + if (panel.excavTab) { + panel.tabView.addTab(panel.excavTab); + delete panel.excavTab; + } + } else { + tabs = panel.tabView.get('tabs'); + for (var mnt = tabs.length; mnt >= 0; mnt--) { + tab = panel.tabView.getTab(mnt); + if (tab && tab.get('label') == this._excavLabel) { + panel.excavTab = tab; + panel.tabView.removeTab(tab); } - if (spies.length > tab.maxSpies) { - alert( - "You don't have any ships large enough to " + - verb + - ' ' + - spies.length + - ' spies.' - ); - return; + } + } + + //this.GetShips(panel,{body_id:body.id}); + + this.selectedBody = body; + this.selectedTile = tile; + panel.tabView.selectTab(0); + panel.show(); + }, + failure: function (o) { + YAHOO.log(o, 'info', 'ShowPlanet.get_status.fail'); + + return true; + }, + scope: this, + }); + }, + + Rename: function () { + var newName = Dom.get('planetDetailNewName').value; + Game.Services.Body.rename( + { + session_id: Game.GetSession(''), + body_id: this.selectedBody.id, + name: newName, + }, + { + success: function (o) { + YAHOO.log(o, 'info', 'MapStar.Rename.success'); + if (o.result && this.selectedBody) { + Dom.get('planetDetailRenameMessage').innerHTML = [ + 'Successfully renamed your planet from ', + this.selectedBody.name, + ' to ', + newName, + '.', + ].join(''); + Lib.fadeOutElm('planetDetailRenameMessage'); + Dom.get('planetDetailsName').innerHTML = newName; + EmpireRPCStore.planets[this.selectedBody.id].name = newName; + if (this.selectedTile instanceof YAHOO.lacuna.Mapper.StarTile) { + this._map.tileCache[this.selectedTile.x][this.selectedTile.y].name = newName; + this.selectedTile.refresh(); } - tab.spiesToMove = spies; - list.innerHTML = ''; - tab.elShipMessageCount.innerHTML = spies.length; - - var li = document.createElement('li'); - for (var i = 0; i < ships.length; i++) { - var ship = ships[i]; - var usable = ship.max_occupants >= spies.length; - var nLi = li.cloneNode(false); - nLi.shipId = ship.id; - nLi.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - usable - ? ' ' - : '', - '
                                                          [', - ship.type_human, - '] ', - ship.name, - '
                                                          ', - '
                                                          Attributes:', - ' Speed:', - ship.speed, - '', - ' Stealth:', - ship.stealth, - '', - ' Max Spies:', - ship.max_occupants, - '', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - list.appendChild(nLi); - } - var Ht = Game.GetSize().h - 260; - if (Ht > 240) { - Ht = 240; - } - Dom.setStyle(list, 'height', Ht + 'px'); - Dom.setStyle(tab.elSpiesPane, 'display', 'none'); - Dom.setStyle(tab.elSpyShipsPane, 'display', 'block'); + this.selectedBody.name = newName; + } }, - MoveSpyShip: function (e, matchedEl, tab) { - Event.stopEvent(e); - MenuStore.showLoader(); - var shipId = matchedEl.parentNode.parentNode.parentNode.shipId, - spies = tab.spiesToMove, - data = { - session_id: Game.GetSession(), - spy_ids: spies, - ship_id: shipId, - }, - successMessage, - method; - if (tab.id == 'planetDetailSendSpies') { - successMessage = 'Spies sent!'; - method = Game.Services.Buildings.SpacePort.send_spies; - data.on_body_id = BodyRPCStore.id; - data.to_body_id = this.selectedBody.id; - } else { - successMessage = 'Spies fetched!'; - method = Game.Services.Buildings.SpacePort.fetch_spies; - data.on_body_id = this.selectedBody.id; - data.to_body_id = BodyRPCStore.id; - } - method(data, { - success: function (o) { - MenuStore.hideLoader(); - this.fireEvent('onMapRpc', o.result); - alert( - successMessage + - ' Arrival time: ' + - Lib.formatServerDateShort(o.result.ship.date_arrives) - ); - delete tab.avail.spies; - delete tab.avail.spyShips; - this.ShowSpies(tab); - }, - scope: this, - }); - }, - MoveSpiesCancel: function (e, tab) { - Event.stopEvent(e); - Dom.setStyle(tab.elSpiesPane, 'display', 'block'); - Dom.setStyle(tab.elSpyShipsPane, 'display', 'none'); + failure: function (o) { + Dom.get('planetDetailRenameMessage').innerHTML = o.error.message; + Lib.fadeOutElm('planetDetailRenameMessage'); + return true; }, - }; - Lang.augmentProto(MapStar, Util.EventProvider); - - Lacuna.MapStar = new MapStar(); - })(); - YAHOO.register('mapStar', YAHOO.lacuna.MapStar, { - version: '1', - build: '0', - }); + scope: this, + } + ); + }, + ShowSpies: function (tab) { + Dom.setStyle(tab.elSpiesPane, 'display', 'block'); + Dom.setStyle(tab.elSpyShipsPane, 'display', 'none'); + if (tab.avail && tab.avail.spies && tab.avail.spyShips) { + return; + } + tab.elSpiesList.innerHTML = ''; + tab.elSpyShipsList.innerHTML = ''; + tab.elMessage.innerHTML = ''; + Dom.setStyle(tab.elSendButton, 'display', 'none'); + MenuStore.showLoader(); + var method, data; + if (tab.id == 'planetDetailSendSpies') { + method = 'prepare_send_spies'; + data = { + session_id: Game.GetSession(), + on_body_id: BodyRPCStore.id, + to_body_id: this.selectedBody.id, + }; + } else { + method = 'prepare_fetch_spies'; + data = { + session_id: Game.GetSession(), + on_body_id: this.selectedBody.id, + to_body_id: BodyRPCStore.id, + }; + } + + Game.Services.Buildings.SpacePort[method](data, { + success: function (o) { + YAHOO.log(o, 'info', 'MapStar.ShowSpies.' + method + '.success'); + this.fireEvent('onMapRpc', o.result); + MenuStore.hideLoader(); + tab.avail = { + spyShips: o.result.ships, + spies: o.result.spies, + }; + this.populateSpies(tab); + }, + scope: this, + }); + }, + populateSpies: function (tab) { + var list = tab.elSpiesList; + var spies = tab.avail.spies; + var ships = tab.avail.spyShips; + var verb = tab.id == 'planetDetailSendSpies' ? 'send' : 'fetch'; + + if (spies.length == 0) { + tab.elMessage.innerHTML = 'No spies available.'; + return; + } + + var maxSpies = 0; + for (var i = 0; i < ships.length; i++) { + var ship = ships[i]; + if (ship.max_occupants > maxSpies) { + maxSpies = ship.max_occupants; + } + if (maxSpies > 100) { + maxSpies = 100; + } + } + if (maxSpies == 0) { + tab.elMessage.innerHTML = 'No ships available.'; + } else { + tab.elMessage.innerHTML = 'Select up to ' + maxSpies + ' spies to ' + verb + ':'; + Dom.setStyle(tab.elSendButton, 'display', 'inline'); + } + tab.maxSpies = maxSpies; + + var li = document.createElement('li'); + + for (var si = 0; si < spies.length; si++) { + var spy = spies[si], + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + '
                                                          ', + spy.name, + '
                                                          Level ', + spy.level, + '
                                                          ', + '
                                                          ', + '
                                                          ', + maxSpies == 0 ? '' : '', + '
                                                          Offense: ', + spy.offense_rating, + 'Defense: ', + spy.defense_rating, + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + list.appendChild(nLi); + } + + var Ht = Game.GetSize().h - 330; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(list, 'height', Ht + 'px'); + }, + MoveSpies: function (e, tab) { + Event.stopEvent(e); + var spies = []; + var ships = tab.avail.spyShips; + var list = tab.elSpyShipsList; + var verb = tab.id == 'planetDetailSendSpies' ? 'send' : 'fetch'; + Dom.batch(tab.elSpiesList.getElementsByTagName('input'), function (el) { + if (el.checked) { + spies.push(el.value); + } + }); + if (spies.length == 0) { + alert('You must select at least one spy to ' + verb + '!'); + return; + } + if (spies.length > tab.maxSpies) { + alert( + "You don't have any ships large enough to " + verb + ' ' + spies.length + ' spies.' + ); + return; + } + + tab.spiesToMove = spies; + list.innerHTML = ''; + tab.elShipMessageCount.innerHTML = spies.length; + + var li = document.createElement('li'); + for (var i = 0; i < ships.length; i++) { + var ship = ships[i]; + var usable = ship.max_occupants >= spies.length; + var nLi = li.cloneNode(false); + nLi.shipId = ship.id; + nLi.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + usable + ? ' ' + : '', + '
                                                          [', + ship.type_human, + '] ', + ship.name, + '
                                                          ', + '
                                                          Attributes:', + ' Speed:', + ship.speed, + '', + ' Stealth:', + ship.stealth, + '', + ' Max Spies:', + ship.max_occupants, + '', + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + list.appendChild(nLi); + } + var Ht = Game.GetSize().h - 260; + if (Ht > 240) { + Ht = 240; + } + Dom.setStyle(list, 'height', Ht + 'px'); + Dom.setStyle(tab.elSpiesPane, 'display', 'none'); + Dom.setStyle(tab.elSpyShipsPane, 'display', 'block'); + }, + MoveSpyShip: function (e, matchedEl, tab) { + Event.stopEvent(e); + MenuStore.showLoader(); + var shipId = matchedEl.parentNode.parentNode.parentNode.shipId, + spies = tab.spiesToMove, + data = { + session_id: Game.GetSession(), + spy_ids: spies, + ship_id: shipId, + }, + successMessage, + method; + if (tab.id == 'planetDetailSendSpies') { + successMessage = 'Spies sent!'; + method = Game.Services.Buildings.SpacePort.send_spies; + data.on_body_id = BodyRPCStore.id; + data.to_body_id = this.selectedBody.id; + } else { + successMessage = 'Spies fetched!'; + method = Game.Services.Buildings.SpacePort.fetch_spies; + data.on_body_id = this.selectedBody.id; + data.to_body_id = BodyRPCStore.id; + } + method(data, { + success: function (o) { + MenuStore.hideLoader(); + this.fireEvent('onMapRpc', o.result); + alert( + successMessage + + ' Arrival time: ' + + Lib.formatServerDateShort(o.result.ship.date_arrives) + ); + delete tab.avail.spies; + delete tab.avail.spyShips; + this.ShowSpies(tab); + }, + scope: this, + }); + }, + MoveSpiesCancel: function (e, tab) { + Event.stopEvent(e); + Dom.setStyle(tab.elSpiesPane, 'display', 'block'); + Dom.setStyle(tab.elSpyShipsPane, 'display', 'none'); + }, + }; + Lang.augmentProto(MapStar, Util.EventProvider); + + Lacuna.MapStar = new MapStar(); + })(); + YAHOO.register('mapStar', YAHOO.lacuna.MapStar, { + version: '1', + build: '0', + }); } diff --git a/app/yui/mapper.js b/app/yui/mapper.js index cecb48a8..044f6356 100644 --- a/app/yui/mapper.js +++ b/app/yui/mapper.js @@ -5,466 +5,460 @@ import server from 'app/server'; import MenuStore from 'app/stores/menu'; if (typeof YAHOO.lacuna.Mapper == 'undefined' || !YAHOO.lacuna.Mapper) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - KL = Util.KeyListener, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; - - var Mapper = {}; - Mapper.util = { - modulo: function (val, mod) { - var res = val % mod; - if (res < 0) { - res += mod; - } - return res; - }, - copy: function (obj, c) { - if (!c) { - c = {}; - } - for (var k in obj) { - c[k] = obj[k]; - } - return c; - }, - clone: function (obj) { - function Constructor() {} - Constructor.prototype = obj; - return new Constructor(); - }, - forEach: function (array, fun) { - for (var i = 0; i < array.length; i++) { - fun(array[i], i); - } - }, - }; - - Mapper.MovableContainer = function (parentEl) { - var div = document.createElement('div'); - Dom.addClass(div, 'movableContainer'); - div.style.position = 'absolute'; - - this._container = div; - this._parentEl = parentEl; - - this.reset(); - parentEl.appendChild(div); - }; - Mapper.MovableContainer.prototype = { - move: function (x, y) { - this.offsetX += x; - this.offsetY += y; - this._container.style.left = '' + this.offsetX + 'px'; - this._container.style.top = '' + this.offsetY + 'px'; - Dom.setStyle( - this._parentEl, - 'background-position', - this.offsetX + 'px ' + this.offsetY + 'px' - ); - }, - reset: function () { - this.offsetX = 0; - this.offsetY = 0; - this.move(0, 0); - }, - appendChild: function (c) { - return this._container.appendChild(c); - }, - removeChild: function (c) { - return this._container.removeChild(c); - }, - }; - - Mapper.VisibleArea = function (map) { - this._map = map; - this.reset(); + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + KL = Util.KeyListener, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; + + var Mapper = {}; + Mapper.util = { + modulo: function (val, mod) { + var res = val % mod; + if (res < 0) { + res += mod; + } + return res; + }, + copy: function (obj, c) { + if (!c) { + c = {}; + } + for (var k in obj) { + c[k] = obj[k]; + } + return c; + }, + clone: function (obj) { + function Constructor() {} + Constructor.prototype = obj; + return new Constructor(); + }, + forEach: function (array, fun) { + for (var i = 0; i < array.length; i++) { + fun(array[i], i); + } + }, + }; + + Mapper.MovableContainer = function (parentEl) { + var div = document.createElement('div'); + Dom.addClass(div, 'movableContainer'); + div.style.position = 'absolute'; + + this._container = div; + this._parentEl = parentEl; + + this.reset(); + parentEl.appendChild(div); + }; + Mapper.MovableContainer.prototype = { + move: function (x, y) { + this.offsetX += x; + this.offsetY += y; + this._container.style.left = '' + this.offsetX + 'px'; + this._container.style.top = '' + this.offsetY + 'px'; + Dom.setStyle( + this._parentEl, + 'background-position', + this.offsetX + 'px ' + this.offsetY + 'px' + ); + }, + reset: function () { + this.offsetX = 0; + this.offsetY = 0; + this.move(0, 0); + }, + appendChild: function (c) { + return this._container.appendChild(c); + }, + removeChild: function (c) { + return this._container.removeChild(c); + }, + }; + + Mapper.VisibleArea = function (map) { + this._map = map; + this.reset(); + }; + Mapper.VisibleArea.prototype = { + move: function (mx, my) { + var maxWidth = this._map.width; + var maxHeight = this._map.height; + + this.left += mx; + this.top += my; + this.right = this.left + maxWidth; + this.bottom = this.top + maxHeight; + this.centerX = this.left + maxWidth / 2; + this.centerY = this.top + maxHeight / 2; + + return { x: mx, y: my }; + }, + coordBounds: function () { + return this.calcCoordBounds(this.left, this.top, this.right, this.bottom); + }, + calcCoordBounds: function (x1, y1, x2, y2) { + var tileSize = this._map.tileSizeInPx; + return { + x1: Math.floor(x1 / tileSize), + y1: Math.ceil((y1 * -1) / tileSize), + x2: Math.ceil(x2 / tileSize), + y2: Math.floor((y2 * -1) / tileSize), }; - Mapper.VisibleArea.prototype = { - move: function (mx, my) { - var maxWidth = this._map.width; - var maxHeight = this._map.height; - - this.left += mx; - this.top += my; - this.right = this.left + maxWidth; - this.bottom = this.top + maxHeight; - this.centerX = this.left + maxWidth / 2; - this.centerY = this.top + maxHeight / 2; - - return { x: mx, y: my }; - }, - coordBounds: function () { - return this.calcCoordBounds(this.left, this.top, this.right, this.bottom); - }, - calcCoordBounds: function (x1, y1, x2, y2) { - var tileSize = this._map.tileSizeInPx; - return { - x1: Math.floor(x1 / tileSize), - y1: Math.ceil((y1 * -1) / tileSize), - x2: Math.ceil(x2 / tileSize), - y2: Math.floor((y2 * -1) / tileSize), - }; - }, - topLeftLoc: function () { - var tileSize = this._map.tileSizeInPx; - return [Math.floor(this.left / tileSize), Math.ceil(this.top / tileSize)]; - }, - bottomRightLoc: function () { - var tileSize = this._map.tileSizeInPx; - return [Math.ceil(this.right / tileSize), Math.floor(this.bottom / tileSize)]; - }, - centerLoc: function () { - var tileSize = this._map.tileSizeInPx; - return [ - Math.floor(this.centerX / tileSize), - Math.ceil((this.centerY * -1) / tileSize), - ]; - }, - centerLocPx: function () { - return [this.centerX, this.centerY]; - }, - reset: function () { - this.left = 0; - this.top = 0; - this.move(0, 0); - }, - resize: function () { - //left and top don't change - this.right = this.left + this._map.width; - this.bottom = this.top + this._map.height; - }, - }; - - var Tile = function (x, y, z, ox, oy, layer) { - this.z = z; - this.x = x; - this.y = y; - this.offsetX = ox; - this.origOffsetX = ox; - this.offsetY = oy; - this.origOffsetY = oy; - this.layer = layer; - this.map = layer.map; - this.tileSizeInPx = layer.map.tileSizeInPx; - - this.id = Tile.idFor(this.x, this.y, this.z); - this.domElement = document.createElement('div'); - this.domElement.id = this.id; - - this.createEvent('onReload'); - - this.refresh(); - - var s = this.domElement.style; - s.position = 'absolute'; - s.width = '' + this.tileSizeInPx + 'px'; - s.height = '' + this.tileSizeInPx + 'px'; - s.zIndex = '5'; - s.left = '' + this.offsetX + 'px'; - s.top = '' + this.offsetY + 'px'; - if (this.url) { - s.background = 'transparent url(' + this.url + ') no-repeat scroll center'; + }, + topLeftLoc: function () { + var tileSize = this._map.tileSizeInPx; + return [Math.floor(this.left / tileSize), Math.ceil(this.top / tileSize)]; + }, + bottomRightLoc: function () { + var tileSize = this._map.tileSizeInPx; + return [Math.ceil(this.right / tileSize), Math.floor(this.bottom / tileSize)]; + }, + centerLoc: function () { + var tileSize = this._map.tileSizeInPx; + return [Math.floor(this.centerX / tileSize), Math.ceil((this.centerY * -1) / tileSize)]; + }, + centerLocPx: function () { + return [this.centerX, this.centerY]; + }, + reset: function () { + this.left = 0; + this.top = 0; + this.move(0, 0); + }, + resize: function () { + //left and top don't change + this.right = this.left + this._map.width; + this.bottom = this.top + this._map.height; + }, + }; + + var Tile = function (x, y, z, ox, oy, layer) { + this.z = z; + this.x = x; + this.y = y; + this.offsetX = ox; + this.origOffsetX = ox; + this.offsetY = oy; + this.origOffsetY = oy; + this.layer = layer; + this.map = layer.map; + this.tileSizeInPx = layer.map.tileSizeInPx; + + this.id = Tile.idFor(this.x, this.y, this.z); + this.domElement = document.createElement('div'); + this.domElement.id = this.id; + + this.createEvent('onReload'); + + this.refresh(); + + var s = this.domElement.style; + s.position = 'absolute'; + s.width = '' + this.tileSizeInPx + 'px'; + s.height = '' + this.tileSizeInPx + 'px'; + s.zIndex = '5'; + s.left = '' + this.offsetX + 'px'; + s.top = '' + this.offsetY + 'px'; + if (this.url) { + s.background = 'transparent url(' + this.url + ') no-repeat scroll center'; + } + + Dom.addClass(this.domElement, 'tile'); + }; + Tile.prototype = { + //blank init that will always get called. override in sub classes to change defaults + init: function () {}, + refresh: function () { + var obj = this.map.getTile(this.x, this.y, this.z); + this.blank = obj.blank; + this.data = obj.data; + if (this.url != obj.url) { + this.url = obj.url; + if (this.url) { + Dom.setStyle( + this.domElement, + 'background', + 'transparent url(' + this.url + ') no-repeat scroll center' + ); + } else { + Dom.setStyle(this.domElement, 'background', 'transparent'); + } + } + }, + + appendToDom: function () { + if ( + this.domElement && + !this.blank && + !Dom.isAncestor(this.layer.tileContainer, this.domElement) + ) { + this.layer.tileContainer.appendChild(this.domElement); + } + }, + destroy: function () { + this.unsubscribeAll(); + this.remove(); + delete this.domElement; + }, + remove: function () { + if (this.domElement && this.domElement.parentNode) { + this.domElement.parentNode.removeChild(this.domElement); + } + }, + }; + Lang.augmentProto(Tile, Util.EventProvider); + Tile.idFor = function (x, y, z) { + return 'tile_' + x + '_' + y + '_' + z; + }; + + Mapper.StarTile = function (x, y, z, ox, oy, layer) { + Mapper.StarTile.superclass.constructor.call(this, x, y, z, ox, oy, layer); + }; + Lang.extend(Mapper.StarTile, Tile, { + init: function () { + this.domElement.title = this.data + ? [this.data.name, ' (', this.x, ',', this.y, ')'].join('') + : 'Uncharted Space'; + + if (this.data) { + this._createImage(); + this._createAlignments(); + } + }, + refresh: function () { + var obj = this.map.getTile(this.x, this.y, this.z); + this.blank = obj.blank; + this.image = obj.image; + this.url = obj.url; + this.data = obj.data; + if (this.url) { + Dom.setStyle( + this.domElement, + 'background', + 'transparent url(' + this.url + ') no-repeat scroll center' + ); + } + + if (this.data) { + if (this.data.isStar) { + this.tileSizeInPx = this.map.tileSizeInPx * 3; + var q = this.map.tileSizeInPx; + this.offsetX = this.origOffsetX - q; + this.offsetY = this.origOffsetY - q; + } else { + this.tileSizeInPx = this.map.tileSizeInPx; + this.offsetX = this.origOffsetX; + this.offsetY = this.origOffsetY; + } + Dom.setStyle(this.domElement, 'width', '' + this.tileSizeInPx + 'px'); + Dom.setStyle(this.domElement, 'height', '' + this.tileSizeInPx + 'px'); + Dom.setStyle(this.domElement, 'left', '' + this.offsetX + 'px'); + Dom.setStyle(this.domElement, 'top', '' + this.offsetY + 'px'); + } + + this.init(); + }, + + _createImage: function () { + if (!this.imageHolder) { + var image = this.domElement.appendChild(document.createElement('div')); + Dom.setStyle(image, 'width', this.tileSizeInPx + 'px'); + Dom.setStyle(image, 'height', this.tileSizeInPx + 'px'); + Dom.setStyle(image, 'position', 'absolute'); + Dom.setStyle(image, 'top', '0'); + Dom.setStyle(image, 'left', '0'); + this.imageHolder = image; + } + this._buildFissureHolder(); + this._buildLogoHolder(); + if (this.data.orbit) { + if (this.map.hidePlanets) { + switch (this.data.type) { + case 'habitable planet': + this.imageHolder.innerHTML = 'H'; + break; + case 'gas giant': + this.imageHolder.innerHTML = 'G'; + break; + case 'asteroid': + this.imageHolder.innerHTML = 'A'; + break; + case 'space station': + this.imageHolder.innerHTML = 'S'; + break; + default: + this.imageHolder.innerHTML = 'U'; + break; } - - Dom.addClass(this.domElement, 'tile'); - }; - Tile.prototype = { - //blank init that will always get called. override in sub classes to change defaults - init: function () {}, - refresh: function () { - var obj = this.map.getTile(this.x, this.y, this.z); - this.blank = obj.blank; - this.data = obj.data; - if (this.url != obj.url) { - this.url = obj.url; - if (this.url) { - Dom.setStyle( - this.domElement, - 'background', - 'transparent url(' + this.url + ') no-repeat scroll center' - ); - } else { - Dom.setStyle(this.domElement, 'background', 'transparent'); - } - } - }, - - appendToDom: function () { - if ( - this.domElement && - !this.blank && - !Dom.isAncestor(this.layer.tileContainer, this.domElement) - ) { - this.layer.tileContainer.appendChild(this.domElement); - } - }, - destroy: function () { - this.unsubscribeAll(); - this.remove(); - delete this.domElement; - }, - remove: function () { - if (this.domElement && this.domElement.parentNode) { - this.domElement.parentNode.removeChild(this.domElement); - } - }, - }; - Lang.augmentProto(Tile, Util.EventProvider); - Tile.idFor = function (x, y, z) { - return 'tile_' + x + '_' + y + '_' + z; - }; - - Mapper.StarTile = function (x, y, z, ox, oy, layer) { - Mapper.StarTile.superclass.constructor.call(this, x, y, z, ox, oy, layer); - }; - Lang.extend(Mapper.StarTile, Tile, { - init: function () { - this.domElement.title = this.data - ? [this.data.name, ' (', this.x, ',', this.y, ')'].join('') - : 'Uncharted Space'; - - if (this.data) { - this._createImage(); - this._createAlignments(); - } - }, - refresh: function () { - var obj = this.map.getTile(this.x, this.y, this.z); - this.blank = obj.blank; - this.image = obj.image; - this.url = obj.url; - this.data = obj.data; - if (this.url) { - Dom.setStyle( - this.domElement, - 'background', - 'transparent url(' + this.url + ') no-repeat scroll center' - ); - } - - if (this.data) { - if (this.data.isStar) { - this.tileSizeInPx = this.map.tileSizeInPx * 3; - var q = this.map.tileSizeInPx; - this.offsetX = this.origOffsetX - q; - this.offsetY = this.origOffsetY - q; - } else { - this.tileSizeInPx = this.map.tileSizeInPx; - this.offsetX = this.origOffsetX; - this.offsetY = this.origOffsetY; - } - Dom.setStyle(this.domElement, 'width', '' + this.tileSizeInPx + 'px'); - Dom.setStyle(this.domElement, 'height', '' + this.tileSizeInPx + 'px'); - Dom.setStyle(this.domElement, 'left', '' + this.offsetX + 'px'); - Dom.setStyle(this.domElement, 'top', '' + this.offsetY + 'px'); - } - - this.init(); - }, - - _createImage: function () { - if (!this.imageHolder) { - var image = this.domElement.appendChild(document.createElement('div')); - Dom.setStyle(image, 'width', this.tileSizeInPx + 'px'); - Dom.setStyle(image, 'height', this.tileSizeInPx + 'px'); - Dom.setStyle(image, 'position', 'absolute'); - Dom.setStyle(image, 'top', '0'); - Dom.setStyle(image, 'left', '0'); - this.imageHolder = image; - } - this._buildFissureHolder(); - this._buildLogoHolder(); - if (this.data.orbit) { - if (this.map.hidePlanets) { - switch (this.data.type) { - case 'habitable planet': - this.imageHolder.innerHTML = 'H'; - break; - case 'gas giant': - this.imageHolder.innerHTML = 'G'; - break; - case 'asteroid': - this.imageHolder.innerHTML = 'A'; - break; - case 'space station': - this.imageHolder.innerHTML = 'S'; - break; - default: - this.imageHolder.innerHTML = 'U'; - break; - } - } else { - var pSize = - (100 - Math.abs(this.data.size - 100)) / (100 / this.tileSizeInPx) + 15; - this.imageHolder.innerHTML = [ - '', - ].join(''); - - if (this.data.body_has_fissure) { - this.fissureHolder.innerHTML = [ - '', - ].join(''); - } - } - } else { - if (this.data.station) { - var station = this.data.station; - var pSize = this.tileSizeInPx; - var opacity = (this.data.influence * 9) / 19000 + 0.1; - if (opacity > 1) { - opacity = 1; - } else if (opacity < 0.1) { - opacity = 0.1; - } - this.logoHolder.innerHTML = [ - '', - ].join(''); - } - this.imageHolder.innerHTML = [ - '', - ].join(''); - } - }, - _createAlignments: function () { - if (this.data.empire && this.data.empire.alignment) { - this._buildAlignmentHolder(); - if (this.data.orbit) { - if (this.map.hidePlanets) { - Dom.addClass(this.alignHolder, this.data.empire.alignment); - } else { - var pSize = - (100 - Math.abs(this.data.size - 100)) / (100 / this.tileSizeInPx) + - 15; - this.alignHolder.innerHTML = [ - '', - ].join(''); - } - } else { - this.alignHolder.innerHTML = [ - '', - ].join(''); - } - } else if (this.map.hidePlanets && this.data.orbit) { - this._buildAlignmentHolder(); - Dom.addClass(this.alignHolder, 'probed'); - } - }, - _buildLogoHolder: function () { - if (!this.logoHolder) { - var logo = this.domElement.appendChild(document.createElement('div')); - Dom.setStyle(logo, 'width', this.tileSizeInPx + 'px'); - Dom.setStyle(logo, 'height', this.tileSizeInPx + 'px'); - Dom.setStyle(logo, 'position', 'absolute'); - Dom.setStyle(logo, 'top', '0'); - Dom.setStyle(logo, 'left', '0'); - Dom.setStyle(logo, 'z-index', '3'); - this.logoHolder = logo; - } - }, - _buildFissureHolder: function () { - if (!this.fissureHolder) { - var fissure = this.domElement.appendChild(document.createElement('div')); - Dom.setStyle(fissure, 'width', this.tileSizeInPx + 'px'); - Dom.setStyle(fissure, 'height', this.tileSizeInPx + 'px'); - Dom.setStyle(fissure, 'position', 'absolute'); - Dom.setStyle(fissure, 'top', '0'); - Dom.setStyle(fissure, 'left', '0'); - Dom.setStyle(fissure, 'z-index', '3'); - this.fissureHolder = fissure; - } - }, - _buildAlignmentHolder: function () { - if (!this.alignHolder) { - var align = this.domElement.appendChild(document.createElement('div')); - Dom.setStyle(align, 'width', this.tileSizeInPx + 'px'); - Dom.setStyle(align, 'height', this.tileSizeInPx + 'px'); - Dom.setStyle(align, 'position', 'absolute'); - Dom.setStyle(align, 'top', '0'); - Dom.setStyle(align, 'left', '0'); - Dom.setStyle(align, 'z-index', '2'); - this.alignHolder = align; - } - }, - }); - - Mapper.PlanetTile = function (x, y, z, ox, oy, layer) { - Mapper.PlanetTile.superclass.constructor.call(this, x, y, z, ox, oy, layer); - Dom.addClass(this.domElement, 'tile' + this.tileSizeInPx); - }; - Lang.extend(Mapper.PlanetTile, Tile, { - init: function () { - this.domElement.title = this.data ? this.data.name : 'Ground'; - this._createActionIcon(); - - if (this.data && this.data.efficiency * 1 < 100) { - this._createEfficiencyBar(this.data.efficiency * 1); - } else if (this.cBar) { - this.cBar.parentNode.removeChild(this.cBar); - delete this.cBar; - delete this.eBar; - } - - this.startTick(); - /*if(this.data && this.data.pending_build) { + } else { + var pSize = (100 - Math.abs(this.data.size - 100)) / (100 / this.tileSizeInPx) + 15; + this.imageHolder.innerHTML = [ + '', + ].join(''); + + if (this.data.body_has_fissure) { + this.fissureHolder.innerHTML = [ + '', + ].join(''); + } + } + } else { + if (this.data.station) { + var station = this.data.station; + var pSize = this.tileSizeInPx; + var opacity = (this.data.influence * 9) / 19000 + 0.1; + if (opacity > 1) { + opacity = 1; + } else if (opacity < 0.1) { + opacity = 0.1; + } + this.logoHolder.innerHTML = [ + '', + ].join(''); + } + this.imageHolder.innerHTML = [ + '', + ].join(''); + } + }, + _createAlignments: function () { + if (this.data.empire && this.data.empire.alignment) { + this._buildAlignmentHolder(); + if (this.data.orbit) { + if (this.map.hidePlanets) { + Dom.addClass(this.alignHolder, this.data.empire.alignment); + } else { + var pSize = (100 - Math.abs(this.data.size - 100)) / (100 / this.tileSizeInPx) + 15; + this.alignHolder.innerHTML = [ + '', + ].join(''); + } + } else { + this.alignHolder.innerHTML = [ + '', + ].join(''); + } + } else if (this.map.hidePlanets && this.data.orbit) { + this._buildAlignmentHolder(); + Dom.addClass(this.alignHolder, 'probed'); + } + }, + _buildLogoHolder: function () { + if (!this.logoHolder) { + var logo = this.domElement.appendChild(document.createElement('div')); + Dom.setStyle(logo, 'width', this.tileSizeInPx + 'px'); + Dom.setStyle(logo, 'height', this.tileSizeInPx + 'px'); + Dom.setStyle(logo, 'position', 'absolute'); + Dom.setStyle(logo, 'top', '0'); + Dom.setStyle(logo, 'left', '0'); + Dom.setStyle(logo, 'z-index', '3'); + this.logoHolder = logo; + } + }, + _buildFissureHolder: function () { + if (!this.fissureHolder) { + var fissure = this.domElement.appendChild(document.createElement('div')); + Dom.setStyle(fissure, 'width', this.tileSizeInPx + 'px'); + Dom.setStyle(fissure, 'height', this.tileSizeInPx + 'px'); + Dom.setStyle(fissure, 'position', 'absolute'); + Dom.setStyle(fissure, 'top', '0'); + Dom.setStyle(fissure, 'left', '0'); + Dom.setStyle(fissure, 'z-index', '3'); + this.fissureHolder = fissure; + } + }, + _buildAlignmentHolder: function () { + if (!this.alignHolder) { + var align = this.domElement.appendChild(document.createElement('div')); + Dom.setStyle(align, 'width', this.tileSizeInPx + 'px'); + Dom.setStyle(align, 'height', this.tileSizeInPx + 'px'); + Dom.setStyle(align, 'position', 'absolute'); + Dom.setStyle(align, 'top', '0'); + Dom.setStyle(align, 'left', '0'); + Dom.setStyle(align, 'z-index', '2'); + this.alignHolder = align; + } + }, + }); + + Mapper.PlanetTile = function (x, y, z, ox, oy, layer) { + Mapper.PlanetTile.superclass.constructor.call(this, x, y, z, ox, oy, layer); + Dom.addClass(this.domElement, 'tile' + this.tileSizeInPx); + }; + Lang.extend(Mapper.PlanetTile, Tile, { + init: function () { + this.domElement.title = this.data ? this.data.name : 'Ground'; + this._createActionIcon(); + + if (this.data && this.data.efficiency * 1 < 100) { + this._createEfficiencyBar(this.data.efficiency * 1); + } else if (this.cBar) { + this.cBar.parentNode.removeChild(this.cBar); + delete this.cBar; + delete this.eBar; + } + + this.startTick(); + /*if(this.data && this.data.pending_build) { this._createCounter(); var remaining = Math.round(this.data.pending_build.seconds_remaining); if (remaining < 0) { @@ -476,136 +470,130 @@ if (typeof YAHOO.lacuna.Mapper == 'undefined' || !YAHOO.lacuna.Mapper) { this.counterBuild.parentNode.removeChild(this.counterBuild); delete this.counterBuild; }*/ - }, - refresh: function () { - Mapper.PlanetTile.superclass.refresh.call(this); - this.init(); - }, - appendToDom: function () { - if (this.domElement && !Dom.isAncestor(this.layer.tileContainer, this.domElement)) { - this.layer.tileContainer.appendChild(this.domElement); - } - }, - remove: function () { - this.stopTick(); - Mapper.PlanetTile.superclass.remove.call(this); - }, - - startTick: function () { - if (this.data) { - var subTick; - - if (this.data.pending_build && this.data.pending_build.seconds_remaining > 0) { - this._createBuildCounter(); - subTick = true; - } else if (this.counterBuild) { - this.counterBuild.parentNode.removeChild(this.counterBuild); - delete this.counterBuild; - } - - if (this.data.work && this.data.work.seconds_remaining > 0) { - this._createWorkCounter(); - subTick = true; - } else if (this.counterWork) { - this.counterWork.parentNode.removeChild(this.counterWork); - delete this.counterWork; - } - - if (subTick && !this.isTicking) { - this.isTicking = true; - Game.onTick.subscribe(this.tick, this, true); - } - } - }, - stopTick: function () { - if (this.isTicking) { - Game.onTick.unsubscribe(this.tick, this); - delete this.isTicking; - - if (this.counterBuild) { - this.counterBuild.parentNode.removeChild(this.counterBuild); - delete this.counterBuild; - } - if (this.counterWork) { - this.counterWork.parentNode.removeChild(this.counterWork); - delete this.counterWork; - } - } - }, - finishTick: function () { - this.stopTick(); - if (this.data.pending_build && this.data.upgrade) { - delete this.data.pending_build; - this.data.level = this.data.level * 1 + 1; - this.data.image = this.data.upgrade.image; - this.map.addSingleTileData(this.data); - this.refresh(); - } else { - this.fireEvent('onReload', this); - } - }, - tick: function (e, oArgs) { - var tickSec = oArgs[0] / 1000, - hasUpgrade, - hasWork; - if (this.data.pending_build) { - this.data.pending_build.seconds_remaining -= tickSec; - var remainingBuild = Math.round(this.data.pending_build.seconds_remaining); - var upgrade = this.data.upgrade; - if ( - remainingBuild > 0 && - remainingBuild < 15 && - upgrade && - upgrade.image && - !upgrade.preloaded - ) { - upgrade.preloaded = true; - var imgSize = this.map.getTileImageSize(); - var img = new Image(); - img.src = [ - Lib.AssetUrl, - 'planet_side/', - imgSize, - upgrade.image, - '.png', - ].join(''); - } - if (remainingBuild < 0) { - remainingBuild = 0; - } - hasUpgrade = remainingBuild > 0; - this.counterBuild.innerHTML = Lib.formatTime(remainingBuild); - } - if (this.data.work) { - this.data.work.seconds_remaining -= tickSec; - var remainingWork = Math.round(this.data.work.seconds_remaining); - if (remainingWork < 0) { - remainingWork = 0; - } - hasWork = remainingWork > 0; - this.counterWork.innerHTML = Lib.formatTime(remainingWork); - } - if (!hasUpgrade && !hasWork) { - this.finishTick(); - } else if ( - !hasUpgrade && - this.data.pending_build && - this.data.pending_build.seconds_remaining <= 0 - ) { - this.finishTick(); - } else if (!hasWork && this.data.work && this.data.work.seconds_remaining <= 0) { - this.finishTick(); - } - }, - - refreshCounter: function () { - var obj = this.map.getTile(this.x, this.y, this.z); - this.blank = obj.blank; - this.url = obj.url; - this.data = obj.data; - //make sure we're ticking if we need too - this.startTick(); - /* + }, + refresh: function () { + Mapper.PlanetTile.superclass.refresh.call(this); + this.init(); + }, + appendToDom: function () { + if (this.domElement && !Dom.isAncestor(this.layer.tileContainer, this.domElement)) { + this.layer.tileContainer.appendChild(this.domElement); + } + }, + remove: function () { + this.stopTick(); + Mapper.PlanetTile.superclass.remove.call(this); + }, + + startTick: function () { + if (this.data) { + var subTick; + + if (this.data.pending_build && this.data.pending_build.seconds_remaining > 0) { + this._createBuildCounter(); + subTick = true; + } else if (this.counterBuild) { + this.counterBuild.parentNode.removeChild(this.counterBuild); + delete this.counterBuild; + } + + if (this.data.work && this.data.work.seconds_remaining > 0) { + this._createWorkCounter(); + subTick = true; + } else if (this.counterWork) { + this.counterWork.parentNode.removeChild(this.counterWork); + delete this.counterWork; + } + + if (subTick && !this.isTicking) { + this.isTicking = true; + Game.onTick.subscribe(this.tick, this, true); + } + } + }, + stopTick: function () { + if (this.isTicking) { + Game.onTick.unsubscribe(this.tick, this); + delete this.isTicking; + + if (this.counterBuild) { + this.counterBuild.parentNode.removeChild(this.counterBuild); + delete this.counterBuild; + } + if (this.counterWork) { + this.counterWork.parentNode.removeChild(this.counterWork); + delete this.counterWork; + } + } + }, + finishTick: function () { + this.stopTick(); + if (this.data.pending_build && this.data.upgrade) { + delete this.data.pending_build; + this.data.level = this.data.level * 1 + 1; + this.data.image = this.data.upgrade.image; + this.map.addSingleTileData(this.data); + this.refresh(); + } else { + this.fireEvent('onReload', this); + } + }, + tick: function (e, oArgs) { + var tickSec = oArgs[0] / 1000, + hasUpgrade, + hasWork; + if (this.data.pending_build) { + this.data.pending_build.seconds_remaining -= tickSec; + var remainingBuild = Math.round(this.data.pending_build.seconds_remaining); + var upgrade = this.data.upgrade; + if ( + remainingBuild > 0 && + remainingBuild < 15 && + upgrade && + upgrade.image && + !upgrade.preloaded + ) { + upgrade.preloaded = true; + var imgSize = this.map.getTileImageSize(); + var img = new Image(); + img.src = [Lib.AssetUrl, 'planet_side/', imgSize, upgrade.image, '.png'].join(''); + } + if (remainingBuild < 0) { + remainingBuild = 0; + } + hasUpgrade = remainingBuild > 0; + this.counterBuild.innerHTML = Lib.formatTime(remainingBuild); + } + if (this.data.work) { + this.data.work.seconds_remaining -= tickSec; + var remainingWork = Math.round(this.data.work.seconds_remaining); + if (remainingWork < 0) { + remainingWork = 0; + } + hasWork = remainingWork > 0; + this.counterWork.innerHTML = Lib.formatTime(remainingWork); + } + if (!hasUpgrade && !hasWork) { + this.finishTick(); + } else if ( + !hasUpgrade && + this.data.pending_build && + this.data.pending_build.seconds_remaining <= 0 + ) { + this.finishTick(); + } else if (!hasWork && this.data.work && this.data.work.seconds_remaining <= 0) { + this.finishTick(); + } + }, + + refreshCounter: function () { + var obj = this.map.getTile(this.x, this.y, this.z); + this.blank = obj.blank; + this.url = obj.url; + this.data = obj.data; + //make sure we're ticking if we need too + this.startTick(); + /* if(!(this.data && this.data.pending_build && this.data.pending_build.seconds_remaining > 0.1)) { this.counterBuild.parentNode.removeChild(this.counterBuild); delete this.counterBuild; @@ -623,1178 +611,1131 @@ if (typeof YAHOO.lacuna.Mapper == 'undefined' || !YAHOO.lacuna.Mapper) { delete this.counterBuild; } */ - }, - _createBuildCounter: function () { - if (!this.counterBuild) { - var counterBuild = this.domElement.appendChild(document.createElement('div')); - Dom.addClass(counterBuild, 'planetMapTileCounter'); - Dom.setStyle(counterBuild, 'width', this.tileSizeInPx + 'px'); - Dom.setStyle(counterBuild, 'height', this.tileSizeInPx + 'px'); - this.counterBuild = counterBuild; - } - }, - _createWorkCounter: function () { - if (!this.counterWork) { - var counterWork = this.domElement.appendChild(document.createElement('div')); - Dom.addClass(counterWork, 'planetMapTileCounterWork'); - //Dom.setStyle(counterWork, "width", this.tileSizeInPx + 'px'); - //Dom.setStyle(counterWork, "height", this.tileSizeInPx + 'px'); - this.counterWork = counterWork; - } - if (this.cBar) { - Dom.setStyle(this.counterWork, 'bottom', '20px'); - } else { - Dom.setStyle(this.counterWork, 'bottom', '0'); - } - }, - _createActionIcon: function () { - if (this.actionIcon) { - if (this.data) { - if (Game.GetCookieSettings('showLevels', '0') == '1') { - Dom.setStyle(this.actionIcon, 'visibility', 'visible'); - } - this.actionIcon.innerHTML = [ - '
                                                          ', - this.data.level, - '
                                                          ', - ].join(''); - } else { - this.actionIcon.innerHTML = '
                                                          '; - } - } else { - var div = this.domElement.appendChild(document.createElement('div')); - Dom.addClass(div, 'planetMapTileActionContainer'); - Dom.setStyle(div, 'width', this.tileSizeInPx + 'px'); - Dom.setStyle(div, 'height', Math.round(this.tileSizeInPx / 2) + 'px'); - if (this.data) { - if (Game.GetCookieSettings('showLevels', '0') == '1') { - Dom.setStyle(div, 'visibility', 'visible'); - } - div.innerHTML = [ - '
                                                          ', - this.data.level, - '
                                                          ', - ].join(''); - } else { - div.innerHTML = '
                                                          '; - } - this.actionIcon = div; - } - }, - _createEfficiencyBar: function (efficiency) { - if (!this.cBar) { - var bar = this.domElement.appendChild(document.createElement('div')); - Dom.addClass(bar, 'planetMapEfficiencyBarContainer'); - Dom.setStyle(bar, 'width', this.tileSizeInPx + 'px'); - this.eBar = bar.appendChild(document.createElement('div')); - Dom.addClass(this.eBar, 'planetMapEfficiencyBar'); - this.cBar = bar; - } - Dom.setStyle( - this.eBar, - 'width', - Math.floor(this.tileSizeInPx * (efficiency / 100)) + 'px' - ); - this.eBar.innerHTML = efficiency + '%'; - if (efficiency > 60) { - Dom.setStyle(this.cBar, 'border-color', 'yellow'); - Dom.setStyle(this.eBar, 'background-color', 'yellow'); - Dom.setStyle(this.eBar, 'color', 'black'); - } else if (efficiency > 30) { - Dom.setStyle(this.cBar, 'border-color', 'orange'); - Dom.setStyle(this.eBar, 'background-color', 'orange'); - Dom.setStyle(this.eBar, 'color', 'white'); - } else { - Dom.setStyle(this.cBar, 'border-color', 'red'); - Dom.setStyle(this.eBar, 'background-color', 'red'); - Dom.setStyle(this.eBar, 'color', 'white'); - } - }, - }); - - var TileLayer = function (map, visibleArea, TileConstructor) { - this.tileCache = {}; - // tile layer expects map.movableContainer to be at the upper left corner of - // the visibleArea on creation - this.map = map; - this.visibleArea = visibleArea; - this.TileConstructor = TileConstructor; - - var offsetX = visibleArea.left % map.tileSizeInPx; - var offsetY = visibleArea.top % map.tileSizeInPx; - - this.baseTileLoc = visibleArea.topLeftLoc(); - - var tileContainer = document.createElement('div'); - Dom.addClass(tileContainer, 'tileContainer'); - var s = tileContainer.style; - s.position = 'absolute'; - s.left = offsetX + 'px'; - s.top = offsetY + 'px'; - s.zIndex = '10'; - // for debuging: - // s.width = ''+visibleArea.width+'px'; - // s.height = ''+visibleArea.height+'px'; - // s.backgroundColor = '#477'; - this.tileContainer = map.movableContainer.appendChild(tileContainer); - - this.createEvent('onReloadTile'); - - this.render(); - }; - TileLayer.prototype = { - findTile: function (x, y, zoom) { - //if(this.tileCache) {} - return this.tileCache[Tile.idFor(x, y, zoom)]; - }, - findTileById: function (id) { - return this.tileCache[id]; - }, - tileAtPosition: function (x, y) { - var tileSizeInPx = this.map.tileSizeInPx; - return [Math.floor(x / tileSizeInPx), Math.floor(y / tileSizeInPx)]; - }, - _getTiles: function (x1, x2, y1, y2) { - //show anything we already have - this._showCachedTiles(); - //get any new tiles we need - this.map.getTileData( - { - success: function () { - this.showTiles(); - }, - scope: this, - }, - x1, - x2, - y1, - y2 - ); - }, - - onReloadTile: function (tile) { - this.fireEvent('onReloadTile', tile); - }, - render: function (getNew) { - if (getNew) { - var bounds = this.visibleArea.coordBounds(); - - this._getTiles(bounds.x1, bounds.x2, bounds.y1, bounds.y2); - } else { - this.showTiles(); - } - }, - removeAllTilesNotContainedIn: function (hash) { - for (var key in this.tileCache) { - if (this.tileCache.hasOwnProperty(key) && !hash[key]) { - var tile = this.tileCache[key]; - tile.remove(); - } - } - }, - deleteCache: function () { - for (var key in this.tileCache) { - if (this.tileCache.hasOwnProperty(key)) { - this.tileCache[key].destroy(); - } - } - }, - destroy: function () { - this.unsubscribeAll(); - this.deleteCache(); - //this.map.movableContainer.removeChild( this.tileContainer ); - Event.purgeElement(this.tileContainer); - this.tileContainer.parentNode.removeChild(this.tileContainer); - delete this.tileContainer; - delete this.tileCache; - }, - clear: function () { - this.removeAllTilesNotContainedIn({}); - }, - reset: function () { - this.removeAllTilesNotContainedIn({}); - this.tileCache = {}; - }, - }; - Lang.augmentProto(TileLayer, Util.EventProvider); - - Mapper.StarTileLayer = function (map, visibleArea, TileConstructor) { - Mapper.StarTileLayer.superclass.constructor.call( - this, - map, - visibleArea, - TileConstructor - ); - }; - Lang.extend(Mapper.StarTileLayer, TileLayer, { - _showCachedTiles: function () { - if (this.tileCache) { - var bounds = this.visibleArea.coordBounds(); - var planets = {}; - - //from left to right (smaller to bigger) - for (var xc = bounds.x1; xc <= bounds.x2; xc++) { - //from bottom to top (smaller to bigger) - for (var yc = bounds.y2; yc <= bounds.y1; yc++) { - var tile = this.findTile(xc, yc, this.map.zoom); - if (tile) { - if (tile.data && tile.data.name) { - if (planets.hasOwnProperty(tile.data.name)) { - if ( - Lacuna.MapStar._map.tileCache[tile.x] && - Lacuna.MapStar._map.tileCache[tile.x][tile.y] - ) { - delete Lacuna.MapStar._map.tileCache[tile.x][tile.y]; // Remove the planet from the cache - } - tile.blank = true; - } - } - if (tile.blank) { - tile.refresh(); - } - tile.appendToDom(); - tile.unsubscribeAll(); //so we don't get multiple subs on the same tile - tile.subscribe('onReload', this.onReloadTile, this, true); - } - } - } - } - }, - showTiles: function (refresh) { - if (this.tileCache) { - var bounds = this.visibleArea.coordBounds(); - var tiles = {}; - //from left to right (smaller to bigger) - for (var xc = bounds.x1; xc <= bounds.x2; xc++) { - //from bottom to top (smaller to bigger) - for (var yc = bounds.y2; yc <= bounds.y1; yc++) { - var tile = this.findTile(xc, yc, this.map.zoom), - doSub; - if (!tile) { - var ox = (xc - this.baseTileLoc[0]) * this.map.tileSizeInPx; - var oy = (yc * -1 - this.baseTileLoc[1]) * this.map.tileSizeInPx; - //var offsets = this.visibleArea.getOffsetFromCoords(xc, xy, this.baseTileCoords[0], this.baseTileCoords[1]); - tile = new this.TileConstructor( - xc, - yc, - this.map.zoom, - ox, - oy, - this - ); - this.tileCache[tile.id] = tile; - tile.appendToDom(); - doSub = true; - } else if (refresh) { - tile.refresh(); - doSub = true; - } else { - if (tile.blank) { - tile.refresh(); - } - tile.appendToDom(); - doSub = true; - } - if (doSub) { - tile.unsubscribeAll(); //so we don't get multiple subs on the same tile - tile.subscribe('onReload', this.onReloadTile, this, true); - } - tiles[tile.id] = tile; - } - } - this.removeAllTilesNotContainedIn(tiles); - } - }, - }); - - Mapper.PlanetTileLayer = function (map, visibleArea, TileConstructor) { - this.bounds = { - x1: map.maxBounds.x1Left, - x2: map.maxBounds.x2Right, - y1: map.maxBounds.y1Top, - y2: map.maxBounds.y2Bottom, - }; - - Mapper.PlanetTileLayer.superclass.constructor.call( - this, - map, - visibleArea, - TileConstructor - ); - }; - Lang.extend(Mapper.PlanetTileLayer, TileLayer, { - _showCachedTiles: function () { - if (this.tileCache) { - var bounds = this.bounds; - - //from left to right (smaller to bigger) - for (var xc = bounds.x1; xc <= bounds.x2; xc++) { - //from bottom to top (smaller to bigger) - for (var yc = bounds.y2; yc <= bounds.y1; yc++) { - var tile = this.findTile(xc, yc, this.map.zoom); - if (tile) { - if (tile.blank) { - tile.refresh(); - } - tile.appendToDom(); - tile.unsubscribeAll(); //so we don't get multiple subs on the same tile - tile.subscribe('onReload', this.onReloadTile, this, true); - } - } + }, + _createBuildCounter: function () { + if (!this.counterBuild) { + var counterBuild = this.domElement.appendChild(document.createElement('div')); + Dom.addClass(counterBuild, 'planetMapTileCounter'); + Dom.setStyle(counterBuild, 'width', this.tileSizeInPx + 'px'); + Dom.setStyle(counterBuild, 'height', this.tileSizeInPx + 'px'); + this.counterBuild = counterBuild; + } + }, + _createWorkCounter: function () { + if (!this.counterWork) { + var counterWork = this.domElement.appendChild(document.createElement('div')); + Dom.addClass(counterWork, 'planetMapTileCounterWork'); + //Dom.setStyle(counterWork, "width", this.tileSizeInPx + 'px'); + //Dom.setStyle(counterWork, "height", this.tileSizeInPx + 'px'); + this.counterWork = counterWork; + } + if (this.cBar) { + Dom.setStyle(this.counterWork, 'bottom', '20px'); + } else { + Dom.setStyle(this.counterWork, 'bottom', '0'); + } + }, + _createActionIcon: function () { + if (this.actionIcon) { + if (this.data) { + if (Game.GetCookieSettings('showLevels', '0') == '1') { + Dom.setStyle(this.actionIcon, 'visibility', 'visible'); + } + this.actionIcon.innerHTML = [ + '
                                                          ', + this.data.level, + '
                                                          ', + ].join(''); + } else { + this.actionIcon.innerHTML = '
                                                          '; + } + } else { + var div = this.domElement.appendChild(document.createElement('div')); + Dom.addClass(div, 'planetMapTileActionContainer'); + Dom.setStyle(div, 'width', this.tileSizeInPx + 'px'); + Dom.setStyle(div, 'height', Math.round(this.tileSizeInPx / 2) + 'px'); + if (this.data) { + if (Game.GetCookieSettings('showLevels', '0') == '1') { + Dom.setStyle(div, 'visibility', 'visible'); + } + div.innerHTML = [ + '
                                                          ', + this.data.level, + '
                                                          ', + ].join(''); + } else { + div.innerHTML = '
                                                          '; + } + this.actionIcon = div; + } + }, + _createEfficiencyBar: function (efficiency) { + if (!this.cBar) { + var bar = this.domElement.appendChild(document.createElement('div')); + Dom.addClass(bar, 'planetMapEfficiencyBarContainer'); + Dom.setStyle(bar, 'width', this.tileSizeInPx + 'px'); + this.eBar = bar.appendChild(document.createElement('div')); + Dom.addClass(this.eBar, 'planetMapEfficiencyBar'); + this.cBar = bar; + } + Dom.setStyle(this.eBar, 'width', Math.floor(this.tileSizeInPx * (efficiency / 100)) + 'px'); + this.eBar.innerHTML = efficiency + '%'; + if (efficiency > 60) { + Dom.setStyle(this.cBar, 'border-color', 'yellow'); + Dom.setStyle(this.eBar, 'background-color', 'yellow'); + Dom.setStyle(this.eBar, 'color', 'black'); + } else if (efficiency > 30) { + Dom.setStyle(this.cBar, 'border-color', 'orange'); + Dom.setStyle(this.eBar, 'background-color', 'orange'); + Dom.setStyle(this.eBar, 'color', 'white'); + } else { + Dom.setStyle(this.cBar, 'border-color', 'red'); + Dom.setStyle(this.eBar, 'background-color', 'red'); + Dom.setStyle(this.eBar, 'color', 'white'); + } + }, + }); + + var TileLayer = function (map, visibleArea, TileConstructor) { + this.tileCache = {}; + // tile layer expects map.movableContainer to be at the upper left corner of + // the visibleArea on creation + this.map = map; + this.visibleArea = visibleArea; + this.TileConstructor = TileConstructor; + + var offsetX = visibleArea.left % map.tileSizeInPx; + var offsetY = visibleArea.top % map.tileSizeInPx; + + this.baseTileLoc = visibleArea.topLeftLoc(); + + var tileContainer = document.createElement('div'); + Dom.addClass(tileContainer, 'tileContainer'); + var s = tileContainer.style; + s.position = 'absolute'; + s.left = offsetX + 'px'; + s.top = offsetY + 'px'; + s.zIndex = '10'; + // for debuging: + // s.width = ''+visibleArea.width+'px'; + // s.height = ''+visibleArea.height+'px'; + // s.backgroundColor = '#477'; + this.tileContainer = map.movableContainer.appendChild(tileContainer); + + this.createEvent('onReloadTile'); + + this.render(); + }; + TileLayer.prototype = { + findTile: function (x, y, zoom) { + //if(this.tileCache) {} + return this.tileCache[Tile.idFor(x, y, zoom)]; + }, + findTileById: function (id) { + return this.tileCache[id]; + }, + tileAtPosition: function (x, y) { + var tileSizeInPx = this.map.tileSizeInPx; + return [Math.floor(x / tileSizeInPx), Math.floor(y / tileSizeInPx)]; + }, + _getTiles: function (x1, x2, y1, y2) { + //show anything we already have + this._showCachedTiles(); + //get any new tiles we need + this.map.getTileData( + { + success: function () { + this.showTiles(); + }, + scope: this, + }, + x1, + x2, + y1, + y2 + ); + }, + + onReloadTile: function (tile) { + this.fireEvent('onReloadTile', tile); + }, + render: function (getNew) { + if (getNew) { + var bounds = this.visibleArea.coordBounds(); + + this._getTiles(bounds.x1, bounds.x2, bounds.y1, bounds.y2); + } else { + this.showTiles(); + } + }, + removeAllTilesNotContainedIn: function (hash) { + for (var key in this.tileCache) { + if (this.tileCache.hasOwnProperty(key) && !hash[key]) { + var tile = this.tileCache[key]; + tile.remove(); + } + } + }, + deleteCache: function () { + for (var key in this.tileCache) { + if (this.tileCache.hasOwnProperty(key)) { + this.tileCache[key].destroy(); + } + } + }, + destroy: function () { + this.unsubscribeAll(); + this.deleteCache(); + //this.map.movableContainer.removeChild( this.tileContainer ); + Event.purgeElement(this.tileContainer); + this.tileContainer.parentNode.removeChild(this.tileContainer); + delete this.tileContainer; + delete this.tileCache; + }, + clear: function () { + this.removeAllTilesNotContainedIn({}); + }, + reset: function () { + this.removeAllTilesNotContainedIn({}); + this.tileCache = {}; + }, + }; + Lang.augmentProto(TileLayer, Util.EventProvider); + + Mapper.StarTileLayer = function (map, visibleArea, TileConstructor) { + Mapper.StarTileLayer.superclass.constructor.call(this, map, visibleArea, TileConstructor); + }; + Lang.extend(Mapper.StarTileLayer, TileLayer, { + _showCachedTiles: function () { + if (this.tileCache) { + var bounds = this.visibleArea.coordBounds(); + var planets = {}; + + //from left to right (smaller to bigger) + for (var xc = bounds.x1; xc <= bounds.x2; xc++) { + //from bottom to top (smaller to bigger) + for (var yc = bounds.y2; yc <= bounds.y1; yc++) { + var tile = this.findTile(xc, yc, this.map.zoom); + if (tile) { + if (tile.data && tile.data.name) { + if (planets.hasOwnProperty(tile.data.name)) { + if ( + Lacuna.MapStar._map.tileCache[tile.x] && + Lacuna.MapStar._map.tileCache[tile.x][tile.y] + ) { + delete Lacuna.MapStar._map.tileCache[tile.x][tile.y]; // Remove the planet from the cache } + tile.blank = true; + } } - }, - showTiles: function (refresh) { - if (this.tileCache) { - var bounds = this.bounds; - var tiles = {}; - //from left to right (smaller to bigger) - for (var xc = bounds.x1; xc <= bounds.x2; xc++) { - //from bottom to top (smaller to bigger) - for (var yc = bounds.y2; yc <= bounds.y1; yc++) { - var tile = this.findTile(xc, yc, this.map.zoom), - doSub; - if (!tile) { - var ox = (xc - this.baseTileLoc[0]) * this.map.tileSizeInPx; - var oy = (yc * -1 - this.baseTileLoc[1]) * this.map.tileSizeInPx; - //var offsets = this.visibleArea.getOffsetFromCoords(xc, xy, this.baseTileCoords[0], this.baseTileCoords[1]); - tile = new this.TileConstructor( - xc, - yc, - this.map.zoom, - ox, - oy, - this - ); - this.tileCache[tile.id] = tile; - tile.appendToDom(); - doSub = true; - } else if (refresh) { - tile.refresh(); - doSub = true; - } else { - if (tile.blank) { - tile.refresh(); - } - tile.appendToDom(); - doSub = true; - } - if (doSub) { - tile.unsubscribeAll(); //so we don't get multiple subs on the same tile - tile.subscribe('onReload', this.onReloadTile, this, true); - } - tiles[tile.id] = tile; - } - } + if (tile.blank) { + tile.refresh(); } - }, - }); - - var Map = function (divId, options) { - var IE = '\v' == 'v'; // detect IE - this.IE = IE; - - //this.tileSizeInPx = undefined; - this.maxZoom = 15; - this.minZoom = -15; - //this.visibleArea = undefined; - //this.centerX = 0; - //this.centerY = 0; - this.diffX = 0; - this.diffY = 0; - this._pathsAndPolygons = {}; - this._projectedPoints = {}; - this.tileCache = {}; - this.bounds = {}; - this.maxBounds = {}; - - this.createEvent('onReloadTile'); - - this.mapDiv = document.getElementById(divId); - this.mapDiv.style.overflow = 'hidden'; - this.movableContainer = new Mapper.MovableContainer(this.mapDiv); - - this.init(); - - var ua = navigator.userAgent; - if (ua.match(/iPhone|iPod|iPad/i)) { - this.controller = new Mapper.iPhoneController(this); + tile.appendToDom(); + tile.unsubscribeAll(); //so we don't get multiple subs on the same tile + tile.subscribe('onReload', this.onReloadTile, this, true); + } + } + } + } + }, + showTiles: function (refresh) { + if (this.tileCache) { + var bounds = this.visibleArea.coordBounds(); + var tiles = {}; + //from left to right (smaller to bigger) + for (var xc = bounds.x1; xc <= bounds.x2; xc++) { + //from bottom to top (smaller to bigger) + for (var yc = bounds.y2; yc <= bounds.y1; yc++) { + var tile = this.findTile(xc, yc, this.map.zoom), + doSub; + if (!tile) { + var ox = (xc - this.baseTileLoc[0]) * this.map.tileSizeInPx; + var oy = (yc * -1 - this.baseTileLoc[1]) * this.map.tileSizeInPx; + //var offsets = this.visibleArea.getOffsetFromCoords(xc, xy, this.baseTileCoords[0], this.baseTileCoords[1]); + tile = new this.TileConstructor(xc, yc, this.map.zoom, ox, oy, this); + this.tileCache[tile.id] = tile; + tile.appendToDom(); + doSub = true; + } else if (refresh) { + tile.refresh(); + doSub = true; + } else { + if (tile.blank) { + tile.refresh(); + } + tile.appendToDom(); + doSub = true; + } + if (doSub) { + tile.unsubscribeAll(); //so we don't get multiple subs on the same tile + tile.subscribe('onReload', this.onReloadTile, this, true); + } + tiles[tile.id] = tile; + } + } + this.removeAllTilesNotContainedIn(tiles); + } + }, + }); + + Mapper.PlanetTileLayer = function (map, visibleArea, TileConstructor) { + this.bounds = { + x1: map.maxBounds.x1Left, + x2: map.maxBounds.x2Right, + y1: map.maxBounds.y1Top, + y2: map.maxBounds.y2Bottom, + }; + + Mapper.PlanetTileLayer.superclass.constructor.call(this, map, visibleArea, TileConstructor); + }; + Lang.extend(Mapper.PlanetTileLayer, TileLayer, { + _showCachedTiles: function () { + if (this.tileCache) { + var bounds = this.bounds; + + //from left to right (smaller to bigger) + for (var xc = bounds.x1; xc <= bounds.x2; xc++) { + //from bottom to top (smaller to bigger) + for (var yc = bounds.y2; yc <= bounds.y1; yc++) { + var tile = this.findTile(xc, yc, this.map.zoom); + if (tile) { + if (tile.blank) { + tile.refresh(); + } + tile.appendToDom(); + tile.unsubscribeAll(); //so we don't get multiple subs on the same tile + tile.subscribe('onReload', this.onReloadTile, this, true); + } + } + } + } + }, + showTiles: function (refresh) { + if (this.tileCache) { + var bounds = this.bounds; + var tiles = {}; + //from left to right (smaller to bigger) + for (var xc = bounds.x1; xc <= bounds.x2; xc++) { + //from bottom to top (smaller to bigger) + for (var yc = bounds.y2; yc <= bounds.y1; yc++) { + var tile = this.findTile(xc, yc, this.map.zoom), + doSub; + if (!tile) { + var ox = (xc - this.baseTileLoc[0]) * this.map.tileSizeInPx; + var oy = (yc * -1 - this.baseTileLoc[1]) * this.map.tileSizeInPx; + //var offsets = this.visibleArea.getOffsetFromCoords(xc, xy, this.baseTileCoords[0], this.baseTileCoords[1]); + tile = new this.TileConstructor(xc, yc, this.map.zoom, ox, oy, this); + this.tileCache[tile.id] = tile; + tile.appendToDom(); + doSub = true; + } else if (refresh) { + tile.refresh(); + doSub = true; + } else { + if (tile.blank) { + tile.refresh(); + } + tile.appendToDom(); + doSub = true; + } + if (doSub) { + tile.unsubscribeAll(); //so we don't get multiple subs on the same tile + tile.subscribe('onReload', this.onReloadTile, this, true); + } + tiles[tile.id] = tile; + } + } + } + }, + }); + + var Map = function (divId, options) { + var IE = '\v' == 'v'; // detect IE + this.IE = IE; + + //this.tileSizeInPx = undefined; + this.maxZoom = 15; + this.minZoom = -15; + //this.visibleArea = undefined; + //this.centerX = 0; + //this.centerY = 0; + this.diffX = 0; + this.diffY = 0; + this._pathsAndPolygons = {}; + this._projectedPoints = {}; + this.tileCache = {}; + this.bounds = {}; + this.maxBounds = {}; + + this.createEvent('onReloadTile'); + + this.mapDiv = document.getElementById(divId); + this.mapDiv.style.overflow = 'hidden'; + this.movableContainer = new Mapper.MovableContainer(this.mapDiv); + + this.init(); + + var ua = navigator.userAgent; + if (ua.match(/iPhone|iPod|iPad/i)) { + this.controller = new Mapper.iPhoneController(this); + } else { + this.controller = new Mapper.TraditionalController(this); + } + }; + Map.prototype = { + //blank init that will always get called. override in sub classes to change defaults + init: function () {}, + // pX and pY are optional pixel coordinates. If set they + // define the center of the map after the zoom. Otherwise + // the center will be the same as before the zoom + zoomIn: function () { + //YAHOO.log("zooming in", "info", "Mapper.Map"); + if (this.zoom >= this.maxZoom) { + return; + } + this.setZoomLevel(this.zoom + 1); + //called by zoom display change //this.refresh(); + }, + zoomOut: function () { + //YAHOO.log("zooming out", "info", "Mapper.Map"); + if (this.zoom <= this.minZoom) { + return; + } + this.setZoomLevel(this.zoom - 1); + //called by zoom display change //this.refresh(); + }, + setTileSizeInPx: function (size) { + this.tileSizeInPx = size; + //this.mapExtendInPx = this.tileSizeInPx * (1< absY ? this.tileSizeInPx * absX : this.tileSizeInPx * absY, //get the longest duration if we're moving both x and y + totalX = x * this.tileSizeInPx, + totalY = y * this.tileSizeInPx, + stepX = Math.round(totalX / durMS) || (x < 0 ? -1 : 1), //put this in to cover the possibility of total/dur rounding to 0. 0 will + stepY = Math.round(totalY / durMS) || (y < 0 ? -1 : 1), + progX = 0, + progY = 0, + lastDuration = 0, + anim = new Util.Anim(undefined, undefined, durMS); + + anim.useSeconds = false; //keep everything in ms + anim.onTween.subscribe( + function (type, data) { + var completed = data[0].duration, + factor = completed - lastDuration, + moveX, + moveY; + lastDuration = completed; + + if (Math.abs(progX) >= Math.abs(totalX)) { + moveX = 0; } else { - this.controller = new Mapper.TraditionalController(this); + moveX = stepX * factor; + progX += moveX; + } + if (Math.abs(progY) >= Math.abs(totalY)) { + moveY = 0; + } else { + moveY = stepY * factor; + progY += moveY; } - }; - Map.prototype = { - //blank init that will always get called. override in sub classes to change defaults - init: function () {}, - // pX and pY are optional pixel coordinates. If set they - // define the center of the map after the zoom. Otherwise - // the center will be the same as before the zoom - zoomIn: function () { - //YAHOO.log("zooming in", "info", "Mapper.Map"); - if (this.zoom >= this.maxZoom) { - return; - } - this.setZoomLevel(this.zoom + 1); - //called by zoom display change //this.refresh(); - }, - zoomOut: function () { - //YAHOO.log("zooming out", "info", "Mapper.Map"); - if (this.zoom <= this.minZoom) { - return; - } - this.setZoomLevel(this.zoom - 1); - //called by zoom display change //this.refresh(); - }, - setTileSizeInPx: function (size) { - this.tileSizeInPx = size; - //this.mapExtendInPx = this.tileSizeInPx * (1< absY ? this.tileSizeInPx * absX : this.tileSizeInPx * absY, //get the longest duration if we're moving both x and y - totalX = x * this.tileSizeInPx, - totalY = y * this.tileSizeInPx, - stepX = Math.round(totalX / durMS) || (x < 0 ? -1 : 1), //put this in to cover the possibility of total/dur rounding to 0. 0 will - stepY = Math.round(totalY / durMS) || (y < 0 ? -1 : 1), - progX = 0, - progY = 0, - lastDuration = 0, - anim = new Util.Anim(undefined, undefined, durMS); - - anim.useSeconds = false; //keep everything in ms - anim.onTween.subscribe( - function (type, data) { - var completed = data[0].duration, - factor = completed - lastDuration, - moveX, - moveY; - lastDuration = completed; - - if (Math.abs(progX) >= Math.abs(totalX)) { - moveX = 0; - } else { - moveX = stepX * factor; - progX += moveX; - } - if (Math.abs(progY) >= Math.abs(totalY)) { - moveY = 0; - } else { - moveY = stepY * factor; - progY += moveY; - } - - this.moveByPx(moveX, moveY); - }, - this, - true - ); - - anim.animate(); - }, - moveByPx: function (x, y) { - var n = this.visibleArea.move(x * -1, y * -1); - - //move values back to positive for us to use - x = n.x * -1; - y = n.y * -1; - - this.movableContainer.move(x, y); - return { x: x, y: y }; - }, - setZoomLevel: function (level) { - this.zoom = level * 1; - this.controller.setZoomDisplay(this.zoom); - if (this.tileLayer) { - this.tileLayer.clear(); - } - }, - redraw: function () { - this.width = $(window.document.body).width(); - this.height = $(window.document.body).height(); - - this.movableContainer.reset(); - this.visibleArea = new Mapper.VisibleArea(this); - - if (this.tileLayer) { - this.tileLayer.destroy(); - } - this.tileLayer = new this.TileLayer( - this, - Mapper.util.clone(this.visibleArea), - this.Tile - ); - //pass through - this.tileLayer.subscribe( - 'onReloadTile', - function (tile) { - this.fireEvent('onReloadTile', tile.data.id); - }, - this, - true - ); - }, - refresh: function (isZoom) { - //store location before we redraw - var vac = isZoom ? this.visibleArea.centerLoc() : this.visibleArea.centerLocPx(); - //set tile size - this._setTileSizeByZoom(); - //draw - this.redraw(); - //reset location after draw - if (isZoom) { - this.setCenterTo(vac[0], vac[1]); - } else { - this.setCenterToPx(vac[0], vac[1]); - } - }, - resize: function () { - this.width = this.mapDiv.offsetWidth; - this.height = this.mapDiv.offsetHeight; - - this.visibleArea.resize(); - - this.tileLayer.showTiles(); - }, - setCenterTo: function (locX, locY) { - if (Lang.isNumber(locX) && Lang.isNumber(locY) && this.tileLayer) { - var otherWidth = this.visibleArea.centerX, - otherHeight = this.visibleArea.centerY, - ox = locX * this.tileSizeInPx + this.tileSizeInPx / 2 - otherWidth, - oy = locY * -1 * this.tileSizeInPx + this.tileSizeInPx / 2 - otherHeight; - - this.moveByPx(ox * -1, oy * -1); - this.tileLayer.render(true); - } - }, - setCenterToPx: function (pX, pY) { - if (Lang.isNumber(pX) && Lang.isNumber(pY) && this.tileLayer) { - var otherWidth = this.visibleArea.centerX, - otherHeight = this.visibleArea.centerY, - ox = pX - otherWidth, - oy = pY - otherHeight; - - this.moveByPx(ox * -1, oy * -1); - this.tileLayer.render(true); - } - }, - - // override these for specific tile handling - getTile: function (x, y, z) {}, - getBounds: function () {}, - updateBounds: function (oTile) {}, - addTileData: function (aTiles) {}, - }; - Lang.augmentProto(Map, Util.EventProvider); - var MAX_STAR_AREA = 3001; - Mapper.StarMap = function (divId, options) { - Mapper.StarMap.superclass.constructor.call(this, divId, options); - Dom.setStyle( - this.mapDiv, - 'background-image', - 'url("' + Lib.AssetUrl + 'star_system/field.png")' - ); + this.moveByPx(moveX, moveY); + }, + this, + true + ); + + anim.animate(); + }, + moveByPx: function (x, y) { + var n = this.visibleArea.move(x * -1, y * -1); + + //move values back to positive for us to use + x = n.x * -1; + y = n.y * -1; + + this.movableContainer.move(x, y); + return { x: x, y: y }; + }, + setZoomLevel: function (level) { + this.zoom = level * 1; + this.controller.setZoomDisplay(this.zoom); + if (this.tileLayer) { + this.tileLayer.clear(); + } + }, + redraw: function () { + this.width = $(window.document.body).width(); + this.height = $(window.document.body).height(); + + this.movableContainer.reset(); + this.visibleArea = new Mapper.VisibleArea(this); + + if (this.tileLayer) { + this.tileLayer.destroy(); + } + this.tileLayer = new this.TileLayer(this, Mapper.util.clone(this.visibleArea), this.Tile); + //pass through + this.tileLayer.subscribe( + 'onReloadTile', + function (tile) { + this.fireEvent('onReloadTile', tile.data.id); + }, + this, + true + ); + }, + refresh: function (isZoom) { + //store location before we redraw + var vac = isZoom ? this.visibleArea.centerLoc() : this.visibleArea.centerLocPx(); + //set tile size + this._setTileSizeByZoom(); + //draw + this.redraw(); + //reset location after draw + if (isZoom) { + this.setCenterTo(vac[0], vac[1]); + } else { + this.setCenterToPx(vac[0], vac[1]); + } + }, + resize: function () { + this.width = this.mapDiv.offsetWidth; + this.height = this.mapDiv.offsetHeight; + + this.visibleArea.resize(); + + this.tileLayer.showTiles(); + }, + setCenterTo: function (locX, locY) { + if (Lang.isNumber(locX) && Lang.isNumber(locY) && this.tileLayer) { + var otherWidth = this.visibleArea.centerX, + otherHeight = this.visibleArea.centerY, + ox = locX * this.tileSizeInPx + this.tileSizeInPx / 2 - otherWidth, + oy = locY * -1 * this.tileSizeInPx + this.tileSizeInPx / 2 - otherHeight; + + this.moveByPx(ox * -1, oy * -1); + this.tileLayer.render(true); + } + }, + setCenterToPx: function (pX, pY) { + if (Lang.isNumber(pX) && Lang.isNumber(pY) && this.tileLayer) { + var otherWidth = this.visibleArea.centerX, + otherHeight = this.visibleArea.centerY, + ox = pX - otherWidth, + oy = pY - otherHeight; + + this.moveByPx(ox * -1, oy * -1); + this.tileLayer.render(true); + } + }, + + // override these for specific tile handling + getTile: function (x, y, z) {}, + getBounds: function () {}, + updateBounds: function (oTile) {}, + addTileData: function (aTiles) {}, + }; + Lang.augmentProto(Map, Util.EventProvider); + + var MAX_STAR_AREA = 3001; + Mapper.StarMap = function (divId, options) { + Mapper.StarMap.superclass.constructor.call(this, divId, options); + Dom.setStyle( + this.mapDiv, + 'background-image', + 'url("' + Lib.AssetUrl + 'star_system/field.png")' + ); + }; + Lang.extend(Mapper.StarMap, Map, { + _setTileSizeByZoom: function () { + Game.SetCookieSettings('starZoom', this.zoom); + switch (this.zoom) { + case 2: + this.setTileSizeInPx(150); + break; + case 1: + this.setTileSizeInPx(100); + break; + case -1: + this.setTileSizeInPx(50); + break; + case -2: + this.setTileSizeInPx(35); + break; + case -3: + this.setTileSizeInPx(20); + break; + default: + this.setTileSizeInPx(75); + break; + } + }, + init: function () { + this.maxZoom = 2; + this.minZoom = -3; + + var mapSize = ServerRPCStore.star_map_size; + this.maxBounds = { + x1Left: mapSize.x[0], + x2Right: mapSize.x[1], + y1Top: mapSize.y[1], + y2Bottom: mapSize.y[0], }; - Lang.extend(Mapper.StarMap, Map, { - _setTileSizeByZoom: function () { - Game.SetCookieSettings('starZoom', this.zoom); - switch (this.zoom) { - case 2: - this.setTileSizeInPx(150); - break; - case 1: - this.setTileSizeInPx(100); - break; - case -1: - this.setTileSizeInPx(50); - break; - case -2: - this.setTileSizeInPx(35); - break; - case -3: - this.setTileSizeInPx(20); - break; - default: - this.setTileSizeInPx(75); - break; - } - }, - init: function () { - this.maxZoom = 2; - this.minZoom = -3; - - var mapSize = ServerRPCStore.star_map_size; - this.maxBounds = { - x1Left: mapSize.x[0], - x2Right: mapSize.x[1], - y1Top: mapSize.y[1], - y2Bottom: mapSize.y[0], - }; - this.requestQueue = []; - - this.Tile = Mapper.StarTile; - this.TileLayer = Mapper.StarTileLayer; - - this.zoom = Game.GetCookieSettings('starZoom', 0) * 1; - this.hidePlanets = Game.GetCookieSettings('hidePlanets', 0) * 1; - - this._setTileSizeByZoom(); - }, - getTile: function (x, y) { - var xSet = this.tileCache[x], - body = xSet ? xSet[y] : null; - - if (body) { - if (body.isStar) { - return { - data: body, - image: [Lib.AssetUrl, 'star_map/', body.color, '.png'].join(''), - }; - } else if (body.isPlanet) { - return { - data: body, - image: [Lib.AssetUrl, 'star_system/', body.image, '.png'].join(''), - }; - } - } else { - return { blank: true }; - } - }, - getTileData: function (callback, x1, x2, y1, y2) { - var xDiff = Math.abs(x2 - x1), - yDiff = Math.abs(y2 - y1); - - if (xDiff * yDiff > MAX_STAR_AREA) { - //if out of bounds split and try again - var half; - if (xDiff > 0) { - //make sure x diff isn't zero so we can split it in half, other wise use Y axis - half = Math.floor(xDiff / 2); - this.getTileData(callback, x1, x1 + half, y1, y2); - this.getTileData(callback, x2 - half, x2, y1, y2); - } else { - half = Math.floor(yDiff / 2); - this.getTileData(callback, x1, x2, y1, y1 - half); - this.getTileData(callback, x1, x2, y2 + half, y2); - } - } else { - //YAHOO.log(data, "debug", "StarMap.getTileData.requestData"); - MenuStore.showLoader(); - Game.Services.Map.get_star_map( - { - args: { - session_id: Game.GetSession(''), - left: x1, - right: x2, - top: y1, - bottom: y2, - }, - }, - { - success: function (o) { - //YAHOO.log(o, "debug", "StarMap.getTileData.get_stars.success"); - MenuStore.hideLoader(); - if (o && o.result) { - server.splitStatus(o.result); - this.addTileData(o.result.stars); - callback.success.call( - callback.scope || this, - callback.argument - ); - } - }, - failure: function (o) { - if (callback.failure) { - callback.failure.call(callback.scope || this, o); - return true; - } - }, - scope: this, - } - ); - } - }, - getBounds: function () { - return ( - this.bounds[this.zoom] || { - x1Left: 0, - x2Right: 0, - y1Top: 0, - y2Bottom: 0, - } - ); - }, + this.requestQueue = []; - addTileData: function (aStars) { - //var startZoomLevel = 0; + this.Tile = Mapper.StarTile; + this.TileLayer = Mapper.StarTileLayer; - for (var i = 0; i < aStars.length; i++) { - var star = aStars[i]; - star.isStar = true; - if (!this.tileCache[star.x]) { - this.tileCache[star.x] = {}; - } - this.tileCache[star.x][star.y] = star; - - if (star.bodies) { - for (var bKey in star.bodies) { - if (star.bodies.hasOwnProperty(bKey)) { - var body = star.bodies[bKey]; - body.isPlanet = true; - if (!this.tileCache[body.x]) { - this.tileCache[body.x] = {}; - } - this.tileCache[body.x][body.y] = body; - } - } - } + this.zoom = Game.GetCookieSettings('starZoom', 0) * 1; + this.hidePlanets = Game.GetCookieSettings('hidePlanets', 0) * 1; - //this.updateBounds(star); - } - //return startZoomLevel; - }, - reset: function () { - this.tileCache = {}; - this.bounds = {}; - this.tileLayer.reset(); - }, - }); + this._setTileSizeByZoom(); + }, + getTile: function (x, y) { + var xSet = this.tileCache[x], + body = xSet ? xSet[y] : null; - Mapper.PlanetMap = function (divId, options) { - Mapper.PlanetMap.superclass.constructor.call(this, divId); - this.setSurfaceUrl(options.surfaceUrl); - }; - Lang.extend(Mapper.PlanetMap, Map, { - _setTileSizeByZoom: function () { - Game.SetCookieSettings('planetZoom', this.zoom); - switch (this.zoom) { - case 2: - this.setTileSizeInPx(400); - break; - case 1: - this.setTileSizeInPx(300); - break; - case -1: - this.setTileSizeInPx(100); - break; - case -2: - this.setTileSizeInPx(50); - break; - default: - this.setTileSizeInPx(200); - break; - } - }, - init: function () { - this.maxZoom = 2; - this.minZoom = -2; - - this.bounds = { - x1Left: -5, - x2Right: 5, - y1Top: 5, - y2Bottom: -5, - }; - this.maxBounds = { - x1Left: -5, - x2Right: 5, - y1Top: 5, - y2Bottom: -5, - }; - - this.Tile = Mapper.PlanetTile; - this.TileLayer = Mapper.PlanetTileLayer; - - this.zoom = Game.GetCookieSettings('planetZoom', 0) * 1; - this._setTileSizeByZoom(); - }, - setCenterToCommand: function () { - if (this.command) { - this.setCenterTo(this.command.x, this.command.y); - } - }, - getTileImageSize: function () { - switch (this.zoom) { - case 2: - return '400/'; - case 1: - return '300/'; - case -1: - return '100/'; - case -2: - return '50/'; - } - }, - getTile: function (x, y, z) { - var ySet = this.tileCache[x], - building = ySet ? ySet[y] : null; - - if (building && building.image) { - return { - blank: building.level == 0, - data: building, - url: [ - Lib.AssetUrl, - 'planet_side/', - this.getTileImageSize(), - building.image, - '.png', - ].join(''), - }; - } else { - return { blank: true }; - } - }, - getTileData: function (callback, x1, x2, y1, y2) { - //since we should have all the data already, just call success - callback.success.call(callback.scope || this, callback.argument); - }, - getBounds: function () { - return this.bounds; - }, - setSurfaceUrl: function (surfaceUrl) { - this._surfaceUrl = surfaceUrl; - Dom.setStyle(this.mapDiv, 'background-image', 'url("' + surfaceUrl + '")'); - }, - setPlotsAvailable: function (plots) { - if (plots > 0) { - Dom.removeClass(this.mapDiv, 'plots-full'); - } else { - Dom.addClass(this.mapDiv, 'plots-full'); - } - }, - //don't update bounds on plant. We have all data at start - /*updateBounds : function(oTile) { - },*/ - addTileData: function (oTiles, filterOutDeleted) { - var startZoomLevel = 0, - newTileCache = {}; - for (var tKey in oTiles) { - if (oTiles.hasOwnProperty(tKey)) { - var tile = oTiles[tKey]; - tile.id = tKey; - if (tile.url == '/planetarycommand' || tile.url == '/stationcommand') { - this.command = tile; - this.command.x *= 1; - this.command.y *= 1; - } - if (!newTileCache[tile.x]) { - newTileCache[tile.x] = {}; - } - newTileCache[tile.x][tile.y] = tile; - } - } - if (filterOutDeleted) { - for (var x in this.tileCache) { - for (var y in this.tileCache[x]) { - if (!newTileCache[x] || !newTileCache[x][y]) { - this.removeTile(x, y); - } - } - } - } - this.tileCache = newTileCache; - - return startZoomLevel; - }, - addSingleTileData: function (oBuilding) { - if (oBuilding.url == '/planetarycommand' || oBuilding.url == '/stationcommand') { - this.command = oBuilding; - this.command.x *= 1; - this.command.y *= 1; - } - if (!this.tileCache[oBuilding.x]) { - this.tileCache[oBuilding.x] = {}; - } - if (!this.tileCache[oBuilding.x][oBuilding.y]) { - this.tileCache[oBuilding.x][oBuilding.y] = {}; - } - this.tileCache[oBuilding.x][oBuilding.y] = oBuilding; - }, - refreshTile: function (building) { - if (this.tileLayer) { - this.addSingleTileData(building); - var tile = this.tileLayer.findTile(building.x, building.y, this.zoom); - if (tile) { - tile.refresh(); - } - } - }, - refreshTileCounter: function (building) { - if (this.tileLayer) { - this.addSingleTileData(building); - var tile = this.tileLayer.findTile(building.x, building.y, this.zoom); - if (tile) { - tile.refreshCounter(); - } - } - }, - removeTile: function (x, y) { - if (this.tileCache && this.tileCache[x] && this.tileCache[x][y]) { - delete this.tileCache[x][y]; - } - var tile = this.tileLayer.findTile(x, y, this.zoom); - if (tile) { - tile.refresh(); - } - }, - reset: function () { - this.tileCache = {}; - this.tileLayer.reset(); - }, - }); - - Mapper.TraditionalController = function (map) { - this.map = map; - this.dd = new YAHOO.util.DragDrop(map.mapDiv, 'mapper'); - this.dd.subscribe('dragEvent', this.moveMap, this, true); - this.dd.subscribe('startDragEvent', this.startDrag, this, true); - this.dd.subscribe('endDragEvent', this.endDrag, this, true); - - var moveKeyListener = new KL( - document, - { - keys: [KL.KEY.UP, KL.KEY.DOWN, KL.KEY.LEFT, KL.KEY.RIGHT], - }, - { fn: this.moveKey, scope: this, correctScope: true }, - KL.KEYDOWN - ); - var moveKeyUpListener = new KL( - document, - { - keys: [KL.KEY.UP, KL.KEY.DOWN, KL.KEY.LEFT, KL.KEY.RIGHT], - }, - { fn: this.moveKeyUp, scope: this, correctScope: true }, - KL.KEYUP - ); - - var xMove = 0; - var yMove = 0; - var lastMove = new Date(0).getTime(); - var timerActive = false; - Game.onScroll(map.mapDiv, function (e, x, y) { - xMove += x; - yMove += y; - - // we get tons of events, so only move every 50 milliseconds - var now = new Date().getTime(); - if (now - lastMove > 50) { - lastMove = now; - map.moveByPx(xMove, yMove); - xMove = 0; - yMove = 0; - } - // refresh screen every second during scrolling, and once afterward - if (!timerActive) { - timerActive = true; - setTimeout(function () { - map.tileLayer.render(true); - timerActive = false; - }, 1000); - } - }); - - // Move map with arrow keys. - moveKeyListener.enable(); - moveKeyUpListener.enable(); - - if (map.maxZoom - map.minZoom != 0) { - var zoomEl = document.createElement('div'); - zoomEl.className = 'mapiator_zoom'; - zoomEl.innerHTML = [ - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ].join(''); - map.mapDiv.appendChild(zoomEl); - Event.on( - Sel.query('.mapiator_zoom_in', zoomEl, true), - 'click', - map.zoomIn, - map, - true - ); - Event.on( - Sel.query('.mapiator_zoom_out', zoomEl, true), - 'click', - map.zoomOut, - map, - true - ); - var sliderId = Dom.generateId( - Sel.query('.mapiator_zoom_slider', zoomEl, true), - 'mapiator_zoom_slider' - ); - var thumbId = Dom.generateId( - Sel.query('.mapiator_zoom_slider_thumb', zoomEl, true), - 'mapiator_zoom_slider_thumb' - ); - - var zoomSize = 140; - var zoomScale = Math.floor(zoomSize / (map.maxZoom - map.minZoom)); - var zoomSlider = YAHOO.widget.Slider.getVertSlider( - sliderId, - thumbId, - 0, - zoomSize, - zoomScale - ); - zoomSlider.setZoom = function (zoom, skipAnim, force, silent) { - this.setValue((map.maxZoom - zoom) * zoomScale, skipAnim, force, silent); - }; - zoomSlider.getZoom = function () { - return map.maxZoom - this.getValue() / zoomScale; - }; - zoomSlider.setZoom(map.zoom, true, true, true); - zoomSlider.subscribe('change', function () { - map.setZoomLevel(this.getZoom()); - map.refresh(true); - }); - this.zoomSlider = zoomSlider; + if (body) { + if (body.isStar) { + return { + data: body, + image: [Lib.AssetUrl, 'star_map/', body.color, '.png'].join(''), + }; + } else if (body.isPlanet) { + return { + data: body, + image: [Lib.AssetUrl, 'star_system/', body.image, '.png'].join(''), + }; + } + } else { + return { blank: true }; + } + }, + getTileData: function (callback, x1, x2, y1, y2) { + var xDiff = Math.abs(x2 - x1), + yDiff = Math.abs(y2 - y1); + + if (xDiff * yDiff > MAX_STAR_AREA) { + //if out of bounds split and try again + var half; + if (xDiff > 0) { + //make sure x diff isn't zero so we can split it in half, other wise use Y axis + half = Math.floor(xDiff / 2); + this.getTileData(callback, x1, x1 + half, y1, y2); + this.getTileData(callback, x2 - half, x2, y1, y2); + } else { + half = Math.floor(yDiff / 2); + this.getTileData(callback, x1, x2, y1, y1 - half); + this.getTileData(callback, x1, x2, y2 + half, y2); + } + } else { + //YAHOO.log(data, "debug", "StarMap.getTileData.requestData"); + MenuStore.showLoader(); + Game.Services.Map.get_star_map( + { + args: { + session_id: Game.GetSession(''), + left: x1, + right: x2, + top: y1, + bottom: y2, + }, + }, + { + success: function (o) { + //YAHOO.log(o, "debug", "StarMap.getTileData.get_stars.success"); + MenuStore.hideLoader(); + if (o && o.result) { + server.splitStatus(o.result); + this.addTileData(o.result.stars); + callback.success.call(callback.scope || this, callback.argument); + } + }, + failure: function (o) { + if (callback.failure) { + callback.failure.call(callback.scope || this, o); + return true; + } + }, + scope: this, } + ); + } + }, + getBounds: function () { + return ( + this.bounds[this.zoom] || { + x1Left: 0, + x2Right: 0, + y1Top: 0, + y2Bottom: 0, + } + ); + }, + + addTileData: function (aStars) { + //var startZoomLevel = 0; + + for (var i = 0; i < aStars.length; i++) { + var star = aStars[i]; + star.isStar = true; + if (!this.tileCache[star.x]) { + this.tileCache[star.x] = {}; + } + this.tileCache[star.x][star.y] = star; + + if (star.bodies) { + for (var bKey in star.bodies) { + if (star.bodies.hasOwnProperty(bKey)) { + var body = star.bodies[bKey]; + body.isPlanet = true; + if (!this.tileCache[body.x]) { + this.tileCache[body.x] = {}; + } + this.tileCache[body.x][body.y] = body; + } + } + } + + //this.updateBounds(star); + } + //return startZoomLevel; + }, + reset: function () { + this.tileCache = {}; + this.bounds = {}; + this.tileLayer.reset(); + }, + }); + + Mapper.PlanetMap = function (divId, options) { + Mapper.PlanetMap.superclass.constructor.call(this, divId); + this.setSurfaceUrl(options.surfaceUrl); + }; + Lang.extend(Mapper.PlanetMap, Map, { + _setTileSizeByZoom: function () { + Game.SetCookieSettings('planetZoom', this.zoom); + switch (this.zoom) { + case 2: + this.setTileSizeInPx(400); + break; + case 1: + this.setTileSizeInPx(300); + break; + case -1: + this.setTileSizeInPx(100); + break; + case -2: + this.setTileSizeInPx(50); + break; + default: + this.setTileSizeInPx(200); + break; + } + }, + init: function () { + this.maxZoom = 2; + this.minZoom = -2; + + this.bounds = { + x1Left: -5, + x2Right: 5, + y1Top: 5, + y2Bottom: -5, }; - Mapper.TraditionalController.prototype = { - setZoomDisplay: function (zoom) { - if (this.zoomSlider && this.zoomSlider.getZoom() != zoom) { - this.zoomSlider.setZoom(zoom); - } - }, - startDrag: function (e) { - clearTimeout(this._timeout); - this.xmove = this.ymove = undefined; - this._dragging = true; - }, - moveMap: function (oArgs) { - Event.preventDefault(oArgs.e); - - var x = Event.getPageX(oArgs.e), - y = Event.getPageY(oArgs.e); - - if (this.xmove) { - this.map.moveByPx(x - this.xmove, y - this.ymove); - } - this.xmove = x; - this.ymove = y; - }, - endDrag: function (e) { - var oSelf = this; - this._timeout = setTimeout(function () { - clearTimeout(oSelf._timeout); - oSelf.xmove = oSelf.ymove = undefined; - oSelf.map.tileLayer.render(true); - oSelf._dragging = false; - }, 500); - }, - isDragging: function () { - return this._dragging; // Math.abs(this.xmove) > 5; - }, - moveKey: function (evName, evInfo) { - var keyCode = evInfo[0], - e = evInfo[1]; - if (!Dom.inDocument(this.map.mapDiv)) { - return; - } - switch (e.target.tagName) { - case 'INPUT': - case 'SELECT': - case 'TEXTAREA': - return; - } - - if (keyCode == KL.KEY.UP) { - this.map.moveByTiles(0, 1); - } else if (keyCode == KL.KEY.DOWN) { - this.map.moveByTiles(0, -1); - } else if (keyCode == KL.KEY.LEFT) { - this.map.moveByTiles(1, 0); - } else if (keyCode == KL.KEY.RIGHT) { - this.map.moveByTiles(-1, 0); - } - }, - moveKeyUp: function (evName, evInfo) { - var keyCode = evInfo[0]; - var e = evInfo[1]; - if (!Dom.inDocument(this.map.mapDiv)) { - return; - } - switch (e.target.tagName) { - case 'INPUT': - case 'SELECT': - case 'TEXTAREA': - return; - } - this.map.tileLayer.render(true); - }, + this.maxBounds = { + x1Left: -5, + x2Right: 5, + y1Top: 5, + y2Bottom: -5, }; - Mapper.iPhoneController = function (map) { - this.map = map; - this.currentX = 0; - this.currentY = 0; - - Event.on(map.mapDiv, 'touchstart', this.touchStart, this, true); - Event.on(map.mapDiv, 'touchend', this.touchEnd, this, true); - Event.on(map.mapDiv, 'touchmove', this.touchMove, this, true); - - if (map.maxZoom - map.minZoom != 0) { - Event.on(map.mapDiv, 'gestureend', this.gestureEnd, this, true); + this.Tile = Mapper.PlanetTile; + this.TileLayer = Mapper.PlanetTileLayer; + + this.zoom = Game.GetCookieSettings('planetZoom', 0) * 1; + this._setTileSizeByZoom(); + }, + setCenterToCommand: function () { + if (this.command) { + this.setCenterTo(this.command.x, this.command.y); + } + }, + getTileImageSize: function () { + switch (this.zoom) { + case 2: + return '400/'; + case 1: + return '300/'; + case -1: + return '100/'; + case -2: + return '50/'; + } + }, + getTile: function (x, y, z) { + var ySet = this.tileCache[x], + building = ySet ? ySet[y] : null; + + if (building && building.image) { + return { + blank: building.level == 0, + data: building, + url: [ + Lib.AssetUrl, + 'planet_side/', + this.getTileImageSize(), + building.image, + '.png', + ].join(''), + }; + } else { + return { blank: true }; + } + }, + getTileData: function (callback, x1, x2, y1, y2) { + //since we should have all the data already, just call success + callback.success.call(callback.scope || this, callback.argument); + }, + getBounds: function () { + return this.bounds; + }, + setSurfaceUrl: function (surfaceUrl) { + this._surfaceUrl = surfaceUrl; + Dom.setStyle(this.mapDiv, 'background-image', 'url("' + surfaceUrl + '")'); + }, + setPlotsAvailable: function (plots) { + if (plots > 0) { + Dom.removeClass(this.mapDiv, 'plots-full'); + } else { + Dom.addClass(this.mapDiv, 'plots-full'); + } + }, + //don't update bounds on plant. We have all data at start + /*updateBounds : function(oTile) { + },*/ + addTileData: function (oTiles, filterOutDeleted) { + var startZoomLevel = 0, + newTileCache = {}; + for (var tKey in oTiles) { + if (oTiles.hasOwnProperty(tKey)) { + var tile = oTiles[tKey]; + tile.id = tKey; + if (tile.url == '/planetarycommand' || tile.url == '/stationcommand') { + this.command = tile; + this.command.x *= 1; + this.command.y *= 1; + } + if (!newTileCache[tile.x]) { + newTileCache[tile.x] = {}; } + newTileCache[tile.x][tile.y] = tile; + } + } + if (filterOutDeleted) { + for (var x in this.tileCache) { + for (var y in this.tileCache[x]) { + if (!newTileCache[x] || !newTileCache[x][y]) { + this.removeTile(x, y); + } + } + } + } + this.tileCache = newTileCache; + + return startZoomLevel; + }, + addSingleTileData: function (oBuilding) { + if (oBuilding.url == '/planetarycommand' || oBuilding.url == '/stationcommand') { + this.command = oBuilding; + this.command.x *= 1; + this.command.y *= 1; + } + if (!this.tileCache[oBuilding.x]) { + this.tileCache[oBuilding.x] = {}; + } + if (!this.tileCache[oBuilding.x][oBuilding.y]) { + this.tileCache[oBuilding.x][oBuilding.y] = {}; + } + this.tileCache[oBuilding.x][oBuilding.y] = oBuilding; + }, + refreshTile: function (building) { + if (this.tileLayer) { + this.addSingleTileData(building); + var tile = this.tileLayer.findTile(building.x, building.y, this.zoom); + if (tile) { + tile.refresh(); + } + } + }, + refreshTileCounter: function (building) { + if (this.tileLayer) { + this.addSingleTileData(building); + var tile = this.tileLayer.findTile(building.x, building.y, this.zoom); + if (tile) { + tile.refreshCounter(); + } + } + }, + removeTile: function (x, y) { + if (this.tileCache && this.tileCache[x] && this.tileCache[x][y]) { + delete this.tileCache[x][y]; + } + var tile = this.tileLayer.findTile(x, y, this.zoom); + if (tile) { + tile.refresh(); + } + }, + reset: function () { + this.tileCache = {}; + this.tileLayer.reset(); + }, + }); + + Mapper.TraditionalController = function (map) { + this.map = map; + this.dd = new YAHOO.util.DragDrop(map.mapDiv, 'mapper'); + this.dd.subscribe('dragEvent', this.moveMap, this, true); + this.dd.subscribe('startDragEvent', this.startDrag, this, true); + this.dd.subscribe('endDragEvent', this.endDrag, this, true); + + var moveKeyListener = new KL( + document, + { + keys: [KL.KEY.UP, KL.KEY.DOWN, KL.KEY.LEFT, KL.KEY.RIGHT], + }, + { fn: this.moveKey, scope: this, correctScope: true }, + KL.KEYDOWN + ); + var moveKeyUpListener = new KL( + document, + { + keys: [KL.KEY.UP, KL.KEY.DOWN, KL.KEY.LEFT, KL.KEY.RIGHT], + }, + { fn: this.moveKeyUp, scope: this, correctScope: true }, + KL.KEYUP + ); + + var xMove = 0; + var yMove = 0; + var lastMove = new Date(0).getTime(); + var timerActive = false; + Game.onScroll(map.mapDiv, function (e, x, y) { + xMove += x; + yMove += y; + + // we get tons of events, so only move every 50 milliseconds + var now = new Date().getTime(); + if (now - lastMove > 50) { + lastMove = now; + map.moveByPx(xMove, yMove); + xMove = 0; + yMove = 0; + } + // refresh screen every second during scrolling, and once afterward + if (!timerActive) { + timerActive = true; + setTimeout(function () { + map.tileLayer.render(true); + timerActive = false; + }, 1000); + } + }); + + // Move map with arrow keys. + moveKeyListener.enable(); + moveKeyUpListener.enable(); + + if (map.maxZoom - map.minZoom != 0) { + var zoomEl = document.createElement('div'); + zoomEl.className = 'mapiator_zoom'; + zoomEl.innerHTML = [ + '
                                                          ', + '
                                                          ', + ' ', + '
                                                          ', + '
                                                          ', + '
                                                          ', + '
                                                          ', + ].join(''); + map.mapDiv.appendChild(zoomEl); + Event.on(Sel.query('.mapiator_zoom_in', zoomEl, true), 'click', map.zoomIn, map, true); + Event.on(Sel.query('.mapiator_zoom_out', zoomEl, true), 'click', map.zoomOut, map, true); + var sliderId = Dom.generateId( + Sel.query('.mapiator_zoom_slider', zoomEl, true), + 'mapiator_zoom_slider' + ); + var thumbId = Dom.generateId( + Sel.query('.mapiator_zoom_slider_thumb', zoomEl, true), + 'mapiator_zoom_slider_thumb' + ); + + var zoomSize = 140; + var zoomScale = Math.floor(zoomSize / (map.maxZoom - map.minZoom)); + var zoomSlider = YAHOO.widget.Slider.getVertSlider( + sliderId, + thumbId, + 0, + zoomSize, + zoomScale + ); + zoomSlider.setZoom = function (zoom, skipAnim, force, silent) { + this.setValue((map.maxZoom - zoom) * zoomScale, skipAnim, force, silent); }; - Mapper.iPhoneController.prototype = { - touchStart: function (e) { - if (e.touches.length == 1) { - // Only deal with one finger - var touch = e.touches[0]; // Get the information for finger #1 - this.currentX = touch.pageX; - this.currentY = touch.pageY; - } - }, - touchEnd: function (e) { - if (e.touches.length == 1) { - // Only deal with one finger - this.currentX = 0; - this.currentY = 0; - } - }, - touchMove: function (e) { - if (e.touches.length == 1) { - e.preventDefault(); - var touch = e.touches[0]; - diffX = touch.pageX - this.currentX; - diffY = touch.pageY - this.currentY; - - this.map.moveByPx(diffX, diffY); - - this.currentX = touch.pageX; - this.currentY = touch.pageY; - } - }, - gestureEnd: function (e) { - // note: this does not work if the default is prevented! - if (e.scale > 1) { - this.map.zoomIn(); - } - if (e.scale < 1) { - this.map.zoomOut(); - } - }, - isDragging: function () { - return false; - }, + zoomSlider.getZoom = function () { + return map.maxZoom - this.getValue() / zoomScale; }; - - YAHOO.lacuna.Mapper = Mapper; - })(); - YAHOO.register('mapper', YAHOO.lacuna.Mapper, { version: '1', build: '0' }); + zoomSlider.setZoom(map.zoom, true, true, true); + zoomSlider.subscribe('change', function () { + map.setZoomLevel(this.getZoom()); + map.refresh(true); + }); + this.zoomSlider = zoomSlider; + } + }; + Mapper.TraditionalController.prototype = { + setZoomDisplay: function (zoom) { + if (this.zoomSlider && this.zoomSlider.getZoom() != zoom) { + this.zoomSlider.setZoom(zoom); + } + }, + startDrag: function (e) { + clearTimeout(this._timeout); + this.xmove = this.ymove = undefined; + this._dragging = true; + }, + moveMap: function (oArgs) { + Event.preventDefault(oArgs.e); + + var x = Event.getPageX(oArgs.e), + y = Event.getPageY(oArgs.e); + + if (this.xmove) { + this.map.moveByPx(x - this.xmove, y - this.ymove); + } + this.xmove = x; + this.ymove = y; + }, + endDrag: function (e) { + var oSelf = this; + this._timeout = setTimeout(function () { + clearTimeout(oSelf._timeout); + oSelf.xmove = oSelf.ymove = undefined; + oSelf.map.tileLayer.render(true); + oSelf._dragging = false; + }, 500); + }, + isDragging: function () { + return this._dragging; // Math.abs(this.xmove) > 5; + }, + moveKey: function (evName, evInfo) { + var keyCode = evInfo[0], + e = evInfo[1]; + if (!Dom.inDocument(this.map.mapDiv)) { + return; + } + switch (e.target.tagName) { + case 'INPUT': + case 'SELECT': + case 'TEXTAREA': + return; + } + + if (keyCode == KL.KEY.UP) { + this.map.moveByTiles(0, 1); + } else if (keyCode == KL.KEY.DOWN) { + this.map.moveByTiles(0, -1); + } else if (keyCode == KL.KEY.LEFT) { + this.map.moveByTiles(1, 0); + } else if (keyCode == KL.KEY.RIGHT) { + this.map.moveByTiles(-1, 0); + } + }, + moveKeyUp: function (evName, evInfo) { + var keyCode = evInfo[0]; + var e = evInfo[1]; + if (!Dom.inDocument(this.map.mapDiv)) { + return; + } + switch (e.target.tagName) { + case 'INPUT': + case 'SELECT': + case 'TEXTAREA': + return; + } + this.map.tileLayer.render(true); + }, + }; + + Mapper.iPhoneController = function (map) { + this.map = map; + this.currentX = 0; + this.currentY = 0; + + Event.on(map.mapDiv, 'touchstart', this.touchStart, this, true); + Event.on(map.mapDiv, 'touchend', this.touchEnd, this, true); + Event.on(map.mapDiv, 'touchmove', this.touchMove, this, true); + + if (map.maxZoom - map.minZoom != 0) { + Event.on(map.mapDiv, 'gestureend', this.gestureEnd, this, true); + } + }; + Mapper.iPhoneController.prototype = { + touchStart: function (e) { + if (e.touches.length == 1) { + // Only deal with one finger + var touch = e.touches[0]; // Get the information for finger #1 + this.currentX = touch.pageX; + this.currentY = touch.pageY; + } + }, + touchEnd: function (e) { + if (e.touches.length == 1) { + // Only deal with one finger + this.currentX = 0; + this.currentY = 0; + } + }, + touchMove: function (e) { + if (e.touches.length == 1) { + e.preventDefault(); + var touch = e.touches[0]; + diffX = touch.pageX - this.currentX; + diffY = touch.pageY - this.currentY; + + this.map.moveByPx(diffX, diffY); + + this.currentX = touch.pageX; + this.currentY = touch.pageY; + } + }, + gestureEnd: function (e) { + // note: this does not work if the default is prevented! + if (e.scale > 1) { + this.map.zoomIn(); + } + if (e.scale < 1) { + this.map.zoomOut(); + } + }, + isDragging: function () { + return false; + }, + }; + + YAHOO.lacuna.Mapper = Mapper; + })(); + YAHOO.register('mapper', YAHOO.lacuna.Mapper, { version: '1', build: '0' }); } diff --git a/app/yui/messaging.js b/app/yui/messaging.js index 5f1a17ac..17d6ae47 100644 --- a/app/yui/messaging.js +++ b/app/yui/messaging.js @@ -9,882 +9,834 @@ import _ from 'lodash'; YAHOO.namespace('lacuna'); if (typeof YAHOO.lacuna.Messaging == 'undefined' || !YAHOO.lacuna.Messaging) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Pager = YAHOO.widget.Paginator, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Pager = YAHOO.widget.Paginator, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; - var Messaging = function () { - this.createEvent('onRpc'); - this.createEvent('onShow'); - this.createEvent('onPageLoaded'); - }; - Messaging.prototype = { - _buildPanel: _.once(function () { - var panelId = 'messagingPanel'; - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
                                                          Messaging
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - ' ', - '
                                                          ', - '
                                                          ', - ' ', - ' ', - ' ', - ' ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                          ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - ' ', - ' ', - ' ', - ' ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - '
                                                            ', - ' ', - '
                                                            ', - '
                                                            ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); + var Messaging = function () { + this.createEvent('onRpc'); + this.createEvent('onShow'); + this.createEvent('onPageLoaded'); + }; + Messaging.prototype = { + _buildPanel: _.once(function () { + var panelId = 'messagingPanel'; + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
                                                            Messaging
                                                            ', + '
                                                            ', + '
                                                            ', + '
                                                            ', + ' ', + '
                                                            ', + '
                                                            ', + ' ', + ' ', + ' ', + ' ', + '
                                                            ', + '
                                                            ', + '
                                                            ', + '
                                                            ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + ' ', + ' ', + ' ', + ' ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + ' ', + '
                                                              ', + '
                                                              ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); - this.messagingPanel = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: true, - close: true, - underlay: false, - width: '700px', - zIndex: 9999, - }); - this.messagingPanel.renderEvent.subscribe( - function () { - //tabs - this.create = Dom.get('messagingCreate'); - this.inbox = Dom.get('messagingInbox'); - this.inboxTag = Dom.get('inboxTag'); - this.tag = this.inboxTag.options[this.inboxTag.selectedIndex].value; - Event.on('inboxTag', 'change', this.updateTag, this, true); - this.sent = Dom.get('messagingSent'); - this.archive = Dom.get('messagingArchive'); - this.trash = Dom.get('messagingTrash'); - this.announce = Dom.get('messagingAnnounce'); - //list and display view - Event.on('messagingReply', 'click', this.replyMessage, this, true); - Event.on('messagingReplyAll', 'click', this.replyAllMessage, this, true); - Event.on('messagingForward', 'click', this.forwardMessage, this, true); - Event.on( - 'messagingArchiveDisplayed', - 'click', - this.archiveMessage, - this, - true - ); - Event.on('messagingTrashDisplayed', 'click', this.trashMessage, this, true); - this.list = Dom.get('messagingList'); - this.timestamp = Dom.get('messagingTimestamp'); - this.from = Dom.get('messagingFrom'); - this.to = Dom.get('messagingTo'); - this.subject = Dom.get('messagingSubject'); - this.body = Dom.get('messagingBody'); - this.display = Dom.get('messagingDisplay'); - Event.delegate( - this.display, - 'click', - this.handleProfileLink, - 'a.profile_link', - this, - true - ); - Event.delegate( - this.display, - 'click', - this.handleStarmapLink, - 'a.starmap_link', - this, - true - ); - Event.delegate( - this.display, - 'click', - this.handlePlanetLink, - 'a.planet_link', - this, - true - ); - Event.delegate( - this.display, - 'click', - this.handleAllianceLink, - 'a.alliance_link', - this, - true - ); - Event.delegate( - this.display, - 'click', - this.handleVoteYesLink, - 'a.voteyes_link', - this, - true - ); - Event.delegate( - this.display, - 'click', - this.handleVoteNoLink, - 'a.voteno_link', - this, - true - ); - //archiving setup - this.archiver = Dom.get('messagingArchiver'); - this.archiveButton = Dom.get('messagingArchiveSelected'); - Event.on(this.archiveButton, 'click', this.archiveMessages, this, true); - this.trashButton = Dom.get('messagingTrashSelected'); - Event.on(this.trashButton, 'click', this.trashMessages, this, true); - this.select = Dom.get('messagingSelectAll'); - Event.on(this.select, 'click', this.selectAllMessages, this, true); - //create - this._createToSelect(); - //this.createTo = Dom.get("messagingCreateTo"); - this.createSubject = Dom.get('messagingCreateSubject'); - this.createText = Dom.get('messagingCreateText'); - this.createResponse = Dom.get('messagingCreateResponse'); - Event.on('messagingCreateSend', 'click', this.sendMessage, this, true); - //set start display - Dom.setStyle(this.display, 'visibility', 'hidden'); - Event.delegate( - 'messagingTabs', - 'click', - this.tabClick, - 'li.tab', - this, - true - ); - }, - this, - true - ); - this.messagingPanel.hideEvent.subscribe( - function () { - // Let the React component know that we are going away now. - MailWindowStore.hide(); + this.messagingPanel = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: true, + close: true, + underlay: false, + width: '700px', + zIndex: 9999, + }); + this.messagingPanel.renderEvent.subscribe( + function () { + //tabs + this.create = Dom.get('messagingCreate'); + this.inbox = Dom.get('messagingInbox'); + this.inboxTag = Dom.get('inboxTag'); + this.tag = this.inboxTag.options[this.inboxTag.selectedIndex].value; + Event.on('inboxTag', 'change', this.updateTag, this, true); + this.sent = Dom.get('messagingSent'); + this.archive = Dom.get('messagingArchive'); + this.trash = Dom.get('messagingTrash'); + this.announce = Dom.get('messagingAnnounce'); + //list and display view + Event.on('messagingReply', 'click', this.replyMessage, this, true); + Event.on('messagingReplyAll', 'click', this.replyAllMessage, this, true); + Event.on('messagingForward', 'click', this.forwardMessage, this, true); + Event.on('messagingArchiveDisplayed', 'click', this.archiveMessage, this, true); + Event.on('messagingTrashDisplayed', 'click', this.trashMessage, this, true); + this.list = Dom.get('messagingList'); + this.timestamp = Dom.get('messagingTimestamp'); + this.from = Dom.get('messagingFrom'); + this.to = Dom.get('messagingTo'); + this.subject = Dom.get('messagingSubject'); + this.body = Dom.get('messagingBody'); + this.display = Dom.get('messagingDisplay'); + Event.delegate( + this.display, + 'click', + this.handleProfileLink, + 'a.profile_link', + this, + true + ); + Event.delegate( + this.display, + 'click', + this.handleStarmapLink, + 'a.starmap_link', + this, + true + ); + Event.delegate( + this.display, + 'click', + this.handlePlanetLink, + 'a.planet_link', + this, + true + ); + Event.delegate( + this.display, + 'click', + this.handleAllianceLink, + 'a.alliance_link', + this, + true + ); + Event.delegate( + this.display, + 'click', + this.handleVoteYesLink, + 'a.voteyes_link', + this, + true + ); + Event.delegate( + this.display, + 'click', + this.handleVoteNoLink, + 'a.voteno_link', + this, + true + ); + //archiving setup + this.archiver = Dom.get('messagingArchiver'); + this.archiveButton = Dom.get('messagingArchiveSelected'); + Event.on(this.archiveButton, 'click', this.archiveMessages, this, true); + this.trashButton = Dom.get('messagingTrashSelected'); + Event.on(this.trashButton, 'click', this.trashMessages, this, true); + this.select = Dom.get('messagingSelectAll'); + Event.on(this.select, 'click', this.selectAllMessages, this, true); + //create + this._createToSelect(); + //this.createTo = Dom.get("messagingCreateTo"); + this.createSubject = Dom.get('messagingCreateSubject'); + this.createText = Dom.get('messagingCreateText'); + this.createResponse = Dom.get('messagingCreateResponse'); + Event.on('messagingCreateSend', 'click', this.sendMessage, this, true); + //set start display + Dom.setStyle(this.display, 'visibility', 'hidden'); + Event.delegate('messagingTabs', 'click', this.tabClick, 'li.tab', this, true); + }, + this, + true + ); + this.messagingPanel.hideEvent.subscribe( + function () { + // Let the React component know that we are going away now. + MailWindowStore.hide(); - this.attachmentPanel.hide(); - }, - this, - true - ); + this.attachmentPanel.hide(); + }, + this, + true + ); - this.messagingPanel.render(); - Game.OverlayManager.register(this.messagingPanel); - }), - _buildAttachmentPanel: _.once(function () { - var panelId = 'attachmentPanel'; + this.messagingPanel.render(); + Game.OverlayManager.register(this.messagingPanel); + }), + _buildAttachmentPanel: _.once(function () { + var panelId = 'attachmentPanel'; - var panel = document.createElement('div'); - panel.id = panelId; - panel.innerHTML = [ - '
                                                              Map
                                                              ', - '
                                                              ', - '
                                                              ', - '
                                                              ', - '
                                                              ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(panel); - Dom.addClass(panel, 'nofooter'); + var panel = document.createElement('div'); + panel.id = panelId; + panel.innerHTML = [ + '
                                                              Map
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + '
                                                              ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(panel); + Dom.addClass(panel, 'nofooter'); - this.attachmentPanel = new YAHOO.widget.Panel(panelId, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - fixedcenter: true, - close: true, - underlay: false, - width: '575px', - zIndex: 1000, - }); - this.attachmentPanel.renderEvent.subscribe(function () { - this.map = Dom.get('attachmentMap'); - }); - this.attachmentPanel.hideEvent.subscribe(function () { - this.map.innerHTML = ''; - }); - this.attachmentPanel.load = function (map) { - this.map.innerHTML = ''; + this.attachmentPanel = new YAHOO.widget.Panel(panelId, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + fixedcenter: true, + close: true, + underlay: false, + width: '575px', + zIndex: 1000, + }); + this.attachmentPanel.renderEvent.subscribe(function () { + this.map = Dom.get('attachmentMap'); + }); + this.attachmentPanel.hideEvent.subscribe(function () { + this.map.innerHTML = ''; + }); + this.attachmentPanel.load = function (map) { + this.map.innerHTML = ''; - if (map) { - Dom.setStyle( - this.map, - 'background', - [ - 'url("', - Lib.AssetUrl, - 'planet_side/', - map.surface || map.surface_image, - '.jpg") repeat scroll 0 0 black', - ].join('') - ); + if (map) { + Dom.setStyle( + this.map, + 'background', + [ + 'url("', + Lib.AssetUrl, + 'planet_side/', + map.surface || map.surface_image, + '.jpg") repeat scroll 0 0 black', + ].join('') + ); - var tiles = {}, - tbody = []; + var tiles = {}, + tbody = []; - for (var t = 0; t < map.buildings.length; t++) { - var b = map.buildings[t]; - if (!tiles[b.y]) { - tiles[b.y] = {}; - } - tiles[b.y][b.x] = b.image; - } + for (var t = 0; t < map.buildings.length; t++) { + var b = map.buildings[t]; + if (!tiles[b.y]) { + tiles[b.y] = {}; + } + tiles[b.y][b.x] = b.image; + } - for (var x = 5; x >= -5; x--) { - for (var y = -5; y <= 5; y++) { - tbody.push('
                                                              '); - if (tiles[x] && tiles[x][y]) { - tbody.push( - [ - '', - ].join('') - ); - } - tbody.push('
                                                              '); - } - } + for (var x = 5; x >= -5; x--) { + for (var y = -5; y <= 5; y++) { + tbody.push('
                                                              '); + if (tiles[x] && tiles[x][y]) { + tbody.push( + [ + '', + ].join('') + ); + } + tbody.push('
                                                              '); + } + } - this.map.innerHTML = tbody.join(''); + this.map.innerHTML = tbody.join(''); - this.show(); - this.bringToTop(); - } - }; + this.show(); + this.bringToTop(); + } + }; - this.attachmentPanel.render(); - Game.OverlayManager.register(this.attachmentPanel); - }), - _createToSelect: function () { - var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'empire'); - dataSource.connMethodPost = 'POST'; - dataSource.maxCacheEntries = 2; - dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - dataSource.responseSchema = { - resultsList: 'result.empires', - fields: ['name', 'id'], - }; + this.attachmentPanel.render(); + Game.OverlayManager.register(this.attachmentPanel); + }), + _createToSelect: function () { + var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'empire'); + dataSource.connMethodPost = 'POST'; + dataSource.maxCacheEntries = 2; + dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + dataSource.responseSchema = { + resultsList: 'result.empires', + fields: ['name', 'id'], + }; - var oTextboxList = new YAHOO.lacuna.TextboxList('messagingCreateTo', dataSource, { - //config options - maxResultsDisplayed: 10, - minQueryLength: 3, - multiSelect: true, - forceSelection: true, - formatResultLabelKey: 'name', - formatResultColumnKeys: ['name'], - useIndicator: true, - }); - oTextboxList.generateRequest = function (sQuery) { - var s = Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'find', - jsonrpc: '2.0', - params: [Game.GetSession(''), decodeURIComponent(sQuery)], - }); - return s; - }; - oTextboxList.doBeforeLoadData = function (sQuery, oResponse, oPayload) { - var tq = decodeURIComponent(sQuery); - if (tq[0] == '@') { - if (tq[1].toLowerCase() == 'a') { - oResponse.results.push({ name: '@ally' }); - } - } - return true; - }; + var oTextboxList = new YAHOO.lacuna.TextboxList('messagingCreateTo', dataSource, { + //config options + maxResultsDisplayed: 10, + minQueryLength: 3, + multiSelect: true, + forceSelection: true, + formatResultLabelKey: 'name', + formatResultColumnKeys: ['name'], + useIndicator: true, + }); + oTextboxList.generateRequest = function (sQuery) { + var s = Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'find', + jsonrpc: '2.0', + params: [Game.GetSession(''), decodeURIComponent(sQuery)], + }); + return s; + }; + oTextboxList.doBeforeLoadData = function (sQuery, oResponse, oPayload) { + var tq = decodeURIComponent(sQuery); + if (tq[0] == '@') { + if (tq[1].toLowerCase() == 'a') { + oResponse.results.push({ name: '@ally' }); + } + } + return true; + }; - this.createTo = oTextboxList; - }, - _setTab: function (el) { - var list = this.list; - Event.purgeElement(list, true); - list.innerHTML = ''; - Dom.removeClass( - [ - this.create, - this.inbox, - this.alerts, - this.intel, - this.medals, - this.tutorial, - this.sent, - this.archive, - this.trash, - this.announce, - ], - 'selected' - ); - Dom.addClass(el, 'selected'); - switch (el.id) { - case this.create.id: - Dom.setStyle('messagingCreator', 'display', ''); - Dom.setStyle('messagingReader', 'display', 'none'); - Dom.setStyle('messagingAnnouncement', 'display', 'none'); - break; - case this.announce.id: - Dom.setStyle('messagingCreator', 'display', 'none'); - Dom.setStyle('messagingReader', 'display', 'none'); - Dom.setStyle('messagingAnnouncement', 'display', ''); - Dom.get('messagingAnnounceFrame').src = - constants.RPC_BASE + '/announcement?session_id=' + Game.GetSession(); - break; - default: - this.viewingMessage = null; - Dom.setStyle('messagingCreator', 'display', 'none'); - Dom.setStyle('messagingReader', 'display', ''); - Dom.setStyle('messagingAnnouncement', 'display', 'none'); - break; - } - Dom.setStyle(this.display, 'visibility', 'hidden'); - this.toArchive = {}; - this.toArchiveCount = 0; - }, + this.createTo = oTextboxList; + }, + _setTab: function (el) { + var list = this.list; + Event.purgeElement(list, true); + list.innerHTML = ''; + Dom.removeClass( + [ + this.create, + this.inbox, + this.alerts, + this.intel, + this.medals, + this.tutorial, + this.sent, + this.archive, + this.trash, + this.announce, + ], + 'selected' + ); + Dom.addClass(el, 'selected'); + switch (el.id) { + case this.create.id: + Dom.setStyle('messagingCreator', 'display', ''); + Dom.setStyle('messagingReader', 'display', 'none'); + Dom.setStyle('messagingAnnouncement', 'display', 'none'); + break; + case this.announce.id: + Dom.setStyle('messagingCreator', 'display', 'none'); + Dom.setStyle('messagingReader', 'display', 'none'); + Dom.setStyle('messagingAnnouncement', 'display', ''); + Dom.get('messagingAnnounceFrame').src = + constants.RPC_BASE + '/announcement?session_id=' + Game.GetSession(); + break; + default: + this.viewingMessage = null; + Dom.setStyle('messagingCreator', 'display', 'none'); + Dom.setStyle('messagingReader', 'display', ''); + Dom.setStyle('messagingAnnouncement', 'display', 'none'); + break; + } + Dom.setStyle(this.display, 'visibility', 'hidden'); + this.toArchive = {}; + this.toArchiveCount = 0; + }, - tabClick: function (e, matchedEl, container) { - var id = matchedEl.id; - if (this.currentTab != id) { - this.viewingMessage = null; - this.currentTab = id; - this.loadTab(); - } - }, - loadTab: function (isAll) { - switch (this.currentTab) { - case this.create.id: - Dom.setStyle(this.archiver, 'display', 'none'); - this.loadCreate(isAll); - break; - case this.announce.id: - this._setTab(this.announce); - break; - case this.sent.id: - Dom.setStyle(this.archiver, 'display', 'none'); - this.loadSentMessages(); - break; - case this.archive.id: - Dom.setStyle(this.archiver, 'display', ''); - Dom.setStyle(this.archiveButton, 'display', 'none'); - Dom.setStyle(this.trashButton, 'display', ''); - Dom.setStyle(this.inboxTag, 'display', 'none'); - this.loadArchiveMessages(); - break; - case this.trash.id: - Dom.setStyle(this.archiver, 'display', ''); - Dom.setStyle(this.archiveButton, 'display', ''); - Dom.setStyle(this.trashButton, 'display', 'none'); - Dom.setStyle(this.inboxTag, 'display', 'none'); - this.loadTrashMessages(); - break; - default: - Dom.setStyle(this.archiver, 'display', ''); - Dom.setStyle(this.archiveButton, 'display', ''); - Dom.setStyle(this.trashButton, 'display', ''); - Dom.setStyle(this.inboxTag, 'display', ''); - this.loadInboxMessages(); - break; - } - }, + tabClick: function (e, matchedEl, container) { + var id = matchedEl.id; + if (this.currentTab != id) { + this.viewingMessage = null; + this.currentTab = id; + this.loadTab(); + } + }, + loadTab: function (isAll) { + switch (this.currentTab) { + case this.create.id: + Dom.setStyle(this.archiver, 'display', 'none'); + this.loadCreate(isAll); + break; + case this.announce.id: + this._setTab(this.announce); + break; + case this.sent.id: + Dom.setStyle(this.archiver, 'display', 'none'); + this.loadSentMessages(); + break; + case this.archive.id: + Dom.setStyle(this.archiver, 'display', ''); + Dom.setStyle(this.archiveButton, 'display', 'none'); + Dom.setStyle(this.trashButton, 'display', ''); + Dom.setStyle(this.inboxTag, 'display', 'none'); + this.loadArchiveMessages(); + break; + case this.trash.id: + Dom.setStyle(this.archiver, 'display', ''); + Dom.setStyle(this.archiveButton, 'display', ''); + Dom.setStyle(this.trashButton, 'display', 'none'); + Dom.setStyle(this.inboxTag, 'display', 'none'); + this.loadTrashMessages(); + break; + default: + Dom.setStyle(this.archiver, 'display', ''); + Dom.setStyle(this.archiveButton, 'display', ''); + Dom.setStyle(this.trashButton, 'display', ''); + Dom.setStyle(this.inboxTag, 'display', ''); + this.loadInboxMessages(); + break; + } + }, - loadCreate: function (isAll) { - this.createResponse.innerHTML = ''; - if (this.viewingMessage) { - if (isAll) { - var to = [{ name: this.viewingMessage.from }]; - for (var i = 0; i < this.viewingMessage.recipients.length; i++) { - var nm = this.viewingMessage.recipients[i]; - if (nm != EmpireRPCStore.name) { - to.push({ name: nm }); - } - } - this.createTo.SelectItems(to); - } else { - this.createTo.SelectItems([{ name: this.viewingMessage.from }]); - } - this.createSubject.value = - (this.viewingMessage.forwarding ? 'Fwd: ' : 'Re: ') + - this.viewingMessage.subject; - this.createText.value = - '\n\n--------------\nOn ' + - Lib.formatServerDate(this.viewingMessage.date) + - ' ' + - this.viewingMessage.from + - ' wrote:\n' + - this.viewingMessage.body; - } else { - this.createTo.ResetSelections(); - this.createSubject.value = ''; - this.createText.value = ''; + loadCreate: function (isAll) { + this.createResponse.innerHTML = ''; + if (this.viewingMessage) { + if (isAll) { + var to = [{ name: this.viewingMessage.from }]; + for (var i = 0; i < this.viewingMessage.recipients.length; i++) { + var nm = this.viewingMessage.recipients[i]; + if (nm != EmpireRPCStore.name) { + to.push({ name: nm }); + } + } + this.createTo.SelectItems(to); + } else { + this.createTo.SelectItems([{ name: this.viewingMessage.from }]); + } + this.createSubject.value = + (this.viewingMessage.forwarding ? 'Fwd: ' : 'Re: ') + this.viewingMessage.subject; + this.createText.value = + '\n\n--------------\nOn ' + + Lib.formatServerDate(this.viewingMessage.date) + + ' ' + + this.viewingMessage.from + + ' wrote:\n' + + this.viewingMessage.body; + } else { + this.createTo.ResetSelections(); + this.createSubject.value = ''; + this.createText.value = ''; + } + this._setTab(this.create); + }, + updateTag: function () { + this.tag = this.inboxTag.options[this.inboxTag.selectedIndex].value; + this.loadInboxMessages(); + }, + loadInboxMessages: function () { + this._setTab(this.inbox); + if (this.pager) { + this.pager.destroy(); + } + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: 1 }, + }, + cb = { + success: function (o) { + this.fireEvent('onRpc', o.result); + if (o.result.message_count > 25) { + var template = '{PreviousPageLink} {PageLinks} {NextPageLink}'; + if (o.result.message_count > 149) { + template = + '{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}'; } - this._setTab(this.create); - }, - updateTag: function () { - this.tag = this.inboxTag.options[this.inboxTag.selectedIndex].value; - this.loadInboxMessages(); - }, - loadInboxMessages: function () { - this._setTab(this.inbox); - if (this.pager) { - this.pager.destroy(); - } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: 1 }, - }, - cb = { - success: function (o) { - this.fireEvent('onRpc', o.result); - if (o.result.message_count > 25) { - var template = '{PreviousPageLink} {PageLinks} {NextPageLink}'; - if (o.result.message_count > 149) { - template = - '{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}'; - } - this.pager = new Pager({ - rowsPerPage: 25, - totalRecords: o.result.message_count, - containers: 'messagingPaginator', - template: template, - pageLinks: 5, - alwaysVisible: false, - }); - this.pager.subscribe( - 'changeRequest', - this.handleInboxPagination, - this, - true - ); - this.pager.render(); - } else { - delete this.pager; - } - - this.processMessages(o.result, { inbox: 1 }); - this.fireEvent('onPageLoaded', o); - MenuStore.hideLoader(); - }, - scope: this, - }; + this.pager = new Pager({ + rowsPerPage: 25, + totalRecords: o.result.message_count, + containers: 'messagingPaginator', + template: template, + pageLinks: 5, + alwaysVisible: false, + }); + this.pager.subscribe('changeRequest', this.handleInboxPagination, this, true); + this.pager.render(); + } else { + delete this.pager; + } - MenuStore.showLoader(); - if (this.tag && this.tag == 'Unread') { - InboxServ.view_unread(data, cb); - } else { - if (this.tag) { - data.options.tags = [this.tag]; - } - InboxServ.view_inbox(data, cb); - } + this.processMessages(o.result, { inbox: 1 }); + this.fireEvent('onPageLoaded', o); + MenuStore.hideLoader(); }, - loadSentMessages: function () { - this._setTab(this.sent); - if (this.pager) { - this.pager.destroy(); - } + scope: this, + }; - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: 1 }, - }; - MenuStore.showLoader(); - InboxServ.view_sent(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - if (o.result.message_count > 25) { - this.pager = new Pager({ - rowsPerPage: 25, - totalRecords: o.result.message_count, - containers: 'messagingPaginator', - template: '{PreviousPageLink} {PageLinks} {NextPageLink}', - alwaysVisible: false, - }); - this.pager.subscribe( - 'changeRequest', - this.handleSentPagination, - this, - true - ); - this.pager.render(); - } else { - delete this.pager; - } + MenuStore.showLoader(); + if (this.tag && this.tag == 'Unread') { + InboxServ.view_unread(data, cb); + } else { + if (this.tag) { + data.options.tags = [this.tag]; + } + InboxServ.view_inbox(data, cb); + } + }, + loadSentMessages: function () { + this._setTab(this.sent); + if (this.pager) { + this.pager.destroy(); + } - this.processMessages(o.result, { sent: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }); - }, - loadArchiveMessages: function () { - this._setTab(this.archive); - if (this.pager) { - this.pager.destroy(); - } + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: 1 }, + }; + MenuStore.showLoader(); + InboxServ.view_sent(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + if (o.result.message_count > 25) { + this.pager = new Pager({ + rowsPerPage: 25, + totalRecords: o.result.message_count, + containers: 'messagingPaginator', + template: '{PreviousPageLink} {PageLinks} {NextPageLink}', + alwaysVisible: false, + }); + this.pager.subscribe('changeRequest', this.handleSentPagination, this, true); + this.pager.render(); + } else { + delete this.pager; + } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: 1 }, - }; - MenuStore.showLoader(); - InboxServ.view_archived(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - if (o.result.message_count > 25) { - this.pager = new Pager({ - rowsPerPage: 25, - totalRecords: o.result.message_count, - containers: 'messagingPaginator', - template: '{PreviousPageLink} {PageLinks} {NextPageLink}', - alwaysVisible: false, - }); - this.pager.subscribe( - 'changeRequest', - this.handleArchivePagination, - this, - true - ); - this.pager.render(); - } else { - delete this.pager; - } + this.processMessages(o.result, { sent: 1 }); + MenuStore.hideLoader(); + }, + scope: this, + }); + }, + loadArchiveMessages: function () { + this._setTab(this.archive); + if (this.pager) { + this.pager.destroy(); + } - this.processMessages(o.result, { archive: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }); - }, - loadTrashMessages: function () { - this._setTab(this.trash); - if (this.pager) { - this.pager.destroy(); - } + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: 1 }, + }; + MenuStore.showLoader(); + InboxServ.view_archived(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + if (o.result.message_count > 25) { + this.pager = new Pager({ + rowsPerPage: 25, + totalRecords: o.result.message_count, + containers: 'messagingPaginator', + template: '{PreviousPageLink} {PageLinks} {NextPageLink}', + alwaysVisible: false, + }); + this.pager.subscribe('changeRequest', this.handleArchivePagination, this, true); + this.pager.render(); + } else { + delete this.pager; + } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: 1 }, - }; - MenuStore.showLoader(); - InboxServ.view_trashed(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - if (o.result.message_count > 25) { - this.pager = new Pager({ - rowsPerPage: 25, - totalRecords: o.result.message_count, - containers: 'messagingPaginator', - template: '{PreviousPageLink} {PageLinks} {NextPageLink}', - alwaysVisible: false, - }); - this.pager.subscribe( - 'changeRequest', - this.handleTrashPagination, - this, - true - ); - this.pager.render(); - } else { - delete this.pager; - } + this.processMessages(o.result, { archive: 1 }); + MenuStore.hideLoader(); + }, + scope: this, + }); + }, + loadTrashMessages: function () { + this._setTab(this.trash); + if (this.pager) { + this.pager.destroy(); + } - this.processMessages(o.result, { trash: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }); - }, + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: 1 }, + }; + MenuStore.showLoader(); + InboxServ.view_trashed(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + if (o.result.message_count > 25) { + this.pager = new Pager({ + rowsPerPage: 25, + totalRecords: o.result.message_count, + containers: 'messagingPaginator', + template: '{PreviousPageLink} {PageLinks} {NextPageLink}', + alwaysVisible: false, + }); + this.pager.subscribe('changeRequest', this.handleTrashPagination, this, true); + this.pager.render(); + } else { + delete this.pager; + } - handleInboxPagination: function (newState) { - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: newState.page }, - }, - cb = { - success: function (o) { - this.fireEvent('onRpc', o.result); - this.processMessages(o.result, { inbox: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }; - MenuStore.showLoader(); - if (this.tag && this.tag == 'Unread') { - InboxServ.view_unread(data, cb); - } else { - if (this.tag) { - data.options.tags = [this.tag]; - } - InboxServ.view_inbox(data, cb); - } + this.processMessages(o.result, { trash: 1 }); + MenuStore.hideLoader(); + }, + scope: this, + }); + }, - // Update the Paginator's state - this.pager.setState(newState); + handleInboxPagination: function (newState) { + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: newState.page }, + }, + cb = { + success: function (o) { + this.fireEvent('onRpc', o.result); + this.processMessages(o.result, { inbox: 1 }); + MenuStore.hideLoader(); }, - handleSentPagination: function (newState) { - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: newState.page }, - }; - MenuStore.showLoader(); - InboxServ.view_sent(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - this.processMessages(o.result, { sent: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }); + scope: this, + }; + MenuStore.showLoader(); + if (this.tag && this.tag == 'Unread') { + InboxServ.view_unread(data, cb); + } else { + if (this.tag) { + data.options.tags = [this.tag]; + } + InboxServ.view_inbox(data, cb); + } - // Update the Paginator's state - this.pager.setState(newState); - }, - handleArchivePagination: function (newState) { - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: newState.page }, - }; - MenuStore.showLoader(); - InboxServ.view_archived(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - this.processMessages(o.result, { archive: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }); + // Update the Paginator's state + this.pager.setState(newState); + }, + handleSentPagination: function (newState) { + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: newState.page }, + }; + MenuStore.showLoader(); + InboxServ.view_sent(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + this.processMessages(o.result, { sent: 1 }); + MenuStore.hideLoader(); + }, + scope: this, + }); - // Update the Paginator's state - this.pager.setState(newState); - }, - handleTrashPagination: function (newState) { - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - options: { page_number: newState.page }, - }; - MenuStore.showLoader(); - InboxServ.view_trashed(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - this.processMessages(o.result, { trash: 1 }); - MenuStore.hideLoader(); - }, - scope: this, - }); + // Update the Paginator's state + this.pager.setState(newState); + }, + handleArchivePagination: function (newState) { + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: newState.page }, + }; + MenuStore.showLoader(); + InboxServ.view_archived(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + this.processMessages(o.result, { archive: 1 }); + MenuStore.hideLoader(); + }, + scope: this, + }); - // Update the Paginator's state - this.pager.setState(newState); - }, + // Update the Paginator's state + this.pager.setState(newState); + }, + handleTrashPagination: function (newState) { + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + options: { page_number: newState.page }, + }; + MenuStore.showLoader(); + InboxServ.view_trashed(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + this.processMessages(o.result, { trash: 1 }); + MenuStore.hideLoader(); + }, + scope: this, + }); - processMessages: function (results, is) { - var list = this.list, - messages = results.messages, - li = document.createElement('li'), - isTab = is || {}; + // Update the Paginator's state + this.pager.setState(newState); + }, - //reset selected - delete this.selectedAll; - this.select.innerHTML = 'Select All'; + processMessages: function (results, is) { + var list = this.list, + messages = results.messages, + li = document.createElement('li'), + isTab = is || {}; - //clear list here - Event.purgeElement(list, true); - list.innerHTML = ''; + //reset selected + delete this.selectedAll; + this.select.innerHTML = 'Select All'; - if (messages.length == 0) { - li.innerHTML = 'No messages to display.'; - list.appendChild(li); - } else { - for (var i = 0; i < messages.length; i++) { - var msg = messages[i], - nLi = li.cloneNode(false); - msg.is = isTab; - nLi.Message = msg; - Dom.addClass(nLi, 'message'); - var img; - if (msg.has_read == '0') { - Dom.addClass(nLi, 'unread'); - img = 'unread'; - } else { - img = 'read'; - } - if (msg.has_replied == '1') { - img = 'replied'; - } - nLi.innerHTML = [ - '

                                                              ', - !isTab.sent ? ' ' : '', - '
                                                              ', - '
                                                              ', - '
                                                              ', - Lib.formatServerDate(msg.date), - '
                                                              ', - '
                                                              ', - isTab.sent ? msg.to : msg.from, - '
                                                              ', - '
                                                              ', - msg.subject, - '
                                                              ', - //'
                                                              ',msg.body_preview,'
                                                              ', - '
                                                              ', - ].join(''); - list.appendChild(nLi); - } + //clear list here + Event.purgeElement(list, true); + list.innerHTML = ''; - Event.delegate( - list, - 'click', - this.loadMessage, - 'div.messageContainer', - this, - true - ); - Event.delegate( - list, - 'click', - this.checkSelect, - 'input[type=checkbox]', - this, - true - ); - } + if (messages.length == 0) { + li.innerHTML = 'No messages to display.'; + list.appendChild(li); + } else { + for (var i = 0; i < messages.length; i++) { + var msg = messages[i], + nLi = li.cloneNode(false); + msg.is = isTab; + nLi.Message = msg; + Dom.addClass(nLi, 'message'); + var img; + if (msg.has_read == '0') { + Dom.addClass(nLi, 'unread'); + img = 'unread'; + } else { + img = 'read'; + } + if (msg.has_replied == '1') { + img = 'replied'; + } + nLi.innerHTML = [ + '

                                                              ', + !isTab.sent ? ' ' : '', + '
                                                              ', + '
                                                              ', + '
                                                              ', + Lib.formatServerDate(msg.date), + '
                                                              ', + '
                                                              ', + isTab.sent ? msg.to : msg.from, + '
                                                              ', + '
                                                              ', + msg.subject, + '
                                                              ', + //'
                                                              ',msg.body_preview,'
                                                              ', + '
                                                              ', + ].join(''); + list.appendChild(nLi); + } - //wait for tab to display first - var panel = this.messagingPanel; - setTimeout(function () { - var size = Game.GetSize(); - var Ht = size.h - 90; - if (Ht > 400) { - Ht = 400; - } - var dHt = Ht - 31; - Dom.setStyle('mHt', 'height', Ht + 'px'); - Dom.setStyle('dHt', 'height', dHt + 'px'); - Dom.setStyle('messagingCreateBody', 'height', Ht + 'px'); - panel.center(); - }, 10); - }, + Event.delegate(list, 'click', this.loadMessage, 'div.messageContainer', this, true); + Event.delegate(list, 'click', this.checkSelect, 'input[type=checkbox]', this, true); + } - checkSelect: function (e, matchedEl, container) { - var msg = matchedEl.parentNode.parentNode.Message; - if (msg) { - if (matchedEl.checked) { - this.toArchive[msg.id] = msg; - this.toArchiveCount++; - } else { - delete this.toArchive[msg.id]; - this.toArchiveCount--; - } - } - }, - loadMessage: function (e, matchedEl, container) { - var msg = matchedEl.parentNode.Message; - if (msg && msg.id) { - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - message_id: msg.id, - }; + //wait for tab to display first + var panel = this.messagingPanel; + setTimeout(function () { + var size = Game.GetSize(); + var Ht = size.h - 90; + if (Ht > 400) { + Ht = 400; + } + var dHt = Ht - 31; + Dom.setStyle('mHt', 'height', Ht + 'px'); + Dom.setStyle('dHt', 'height', dHt + 'px'); + Dom.setStyle('messagingCreateBody', 'height', Ht + 'px'); + panel.center(); + }, 10); + }, - MenuStore.showLoader(); - InboxServ.read_message(data, { - success: function (o) { - var message = matchedEl.parentNode; - var messageSelect = message.childNodes[1]; - var img = messageSelect.childNodes[0]; - Dom.setAttribute(img, 'src', Lib.AssetUrl + 'ui/mail-read.png'); - Dom.removeClass(matchedEl.parentNode, 'unread'); - this.fireEvent('onRpc', o.result); - this.displayMessage(o.result.message); - MenuStore.hideLoader(); - }, - scope: this, - }); - } + checkSelect: function (e, matchedEl, container) { + var msg = matchedEl.parentNode.parentNode.Message; + if (msg) { + if (matchedEl.checked) { + this.toArchive[msg.id] = msg; + this.toArchiveCount++; + } else { + delete this.toArchive[msg.id]; + this.toArchiveCount--; + } + } + }, + loadMessage: function (e, matchedEl, container) { + var msg = matchedEl.parentNode.Message; + if (msg && msg.id) { + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + message_id: msg.id, + }; + + MenuStore.showLoader(); + InboxServ.read_message(data, { + success: function (o) { + var message = matchedEl.parentNode; + var messageSelect = message.childNodes[1]; + var img = messageSelect.childNodes[0]; + Dom.setAttribute(img, 'src', Lib.AssetUrl + 'ui/mail-read.png'); + Dom.removeClass(matchedEl.parentNode, 'unread'); + this.fireEvent('onRpc', o.result); + this.displayMessage(o.result.message); + MenuStore.hideLoader(); }, - displayMessage: function (msg) { - if (msg) { - /* { + scope: this, + }); + } + }, + displayMessage: function (msg) { + if (msg) { + /* { "id" : "id-goes-here", "from" : "Dr. Stephen T. Colbert DFA", "to" : "Jon Stewart", @@ -899,512 +851,503 @@ if (typeof YAHOO.lacuna.Messaging == 'undefined' || !YAHOO.lacuna.Messaging) { }, */ - Dom.setStyle(this.display, 'visibility', ''); - - if (msg.from != msg.to) { - Dom.setStyle('messagingReplyC', 'display', ''); - } else { - Dom.setStyle('messagingReplyC', 'display', 'none'); - } + Dom.setStyle(this.display, 'visibility', ''); - this.viewingMessage = msg; - this.timestamp.innerHTML = Lib.formatServerDate(msg.date); - this.from.innerHTML = [ - '', - msg.from, - '', - ].join(''); - this.to.innerHTML = msg.recipients.join(', '); - this.subject.innerHTML = msg.subject; - this.body.parentNode.scrollTop = 0; - this.body.innerHTML = msg.body ? this.formatBody(msg.body) : ''; - if (msg.attachments) { - this.body.appendChild(document.createElement('hr')); - if (msg.attachments.image) { - var img = msg.attachments.image, - imgDiv = this.body.appendChild(document.createElement('div')); - imgDiv.id = 'attachmentImage'; - if (img.link) { - imgDiv.innerHTML = [ - '',
-                                    img.title,
-                                    '', - ].join(''); - } else { - imgDiv.innerHTML = [ - '',
-                                    img.title,
-                                    '', - ].join(''); - } - } - if (msg.attachments.link) { - var lnk = msg.attachments.link, - lnkDiv = this.body.appendChild(document.createElement('div')); - lnkDiv.id = 'attachmentLink'; - lnkDiv.innerHTML = [ - '', - lnk.label, - '', - ].join(''); - } - if (msg.attachments.table) { - var tbl = msg.attachments.table, - tblDiv = this.body.appendChild(document.createElement('div')), - tblOut = [''], - hdRow = tbl[0]; - tblDiv.id = 'attachmentTable'; - //first row always headers - tblOut.push(''); - for (var c = 0; c < hdRow.length; c++) { - tblOut.push(''); - } - tblOut.push(''); + if (msg.from != msg.to) { + Dom.setStyle('messagingReplyC', 'display', ''); + } else { + Dom.setStyle('messagingReplyC', 'display', 'none'); + } - for (var i = 1; i < tbl.length; i++) { - var row = tbl[i]; - tblOut.push(''); - for (var d = 0; d < row.length; d++) { - tblOut.push(''); - } - tblOut.push(''); - } - tblOut.push('
                                                              '); - tblOut.push(hdRow[c]); - tblOut.push('
                                                              '); - tblOut.push(row[d]); - tblOut.push('
                                                              '); + this.viewingMessage = msg; + this.timestamp.innerHTML = Lib.formatServerDate(msg.date); + this.from.innerHTML = [ + '', + msg.from, + '', + ].join(''); + this.to.innerHTML = msg.recipients.join(', '); + this.subject.innerHTML = msg.subject; + this.body.parentNode.scrollTop = 0; + this.body.innerHTML = msg.body ? this.formatBody(msg.body) : ''; + if (msg.attachments) { + this.body.appendChild(document.createElement('hr')); + if (msg.attachments.image) { + var img = msg.attachments.image, + imgDiv = this.body.appendChild(document.createElement('div')); + imgDiv.id = 'attachmentImage'; + if (img.link) { + imgDiv.innerHTML = [ + '',
+                  img.title,
+                  '', + ].join(''); + } else { + imgDiv.innerHTML = [ + '',
+                  img.title,
+                  '', + ].join(''); + } + } + if (msg.attachments.link) { + var lnk = msg.attachments.link, + lnkDiv = this.body.appendChild(document.createElement('div')); + lnkDiv.id = 'attachmentLink'; + lnkDiv.innerHTML = [ + '', + lnk.label, + '', + ].join(''); + } + if (msg.attachments.table) { + var tbl = msg.attachments.table, + tblDiv = this.body.appendChild(document.createElement('div')), + tblOut = [''], + hdRow = tbl[0]; + tblDiv.id = 'attachmentTable'; + //first row always headers + tblOut.push(''); + for (var c = 0; c < hdRow.length; c++) { + tblOut.push(''); + } + tblOut.push(''); - tblDiv.innerHTML = tblOut.join(''); - } - if (msg.attachments.map) { - this.body.appendChild(document.createElement('br')); - var va = document.createElement('button'); - va.setAttribute('type', 'button'); - va.innerHTML = 'Open Map'; - va = this.body.appendChild(va); - Event.on(va, 'click', this.displayAttachment, this, true); - } - } + for (var i = 1; i < tbl.length; i++) { + var row = tbl[i]; + tblOut.push(''); + for (var d = 0; d < row.length; d++) { + tblOut.push(''); } - }, - displayAttachment: function () { - this.attachmentPanel.load(this.viewingMessage.attachments.map); - }, - sendMessage: function () { - var to = this.createTo.Selections(); - if (to.length == 0) { - this.createResponse.innerHTML = 'Must send a message To someone.'; - } else { - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - recipients: to.join(','), - subject: this.createSubject.value, - body: this.createText.value, - }; + tblOut.push(''); + } + tblOut.push('
                                                              '); + tblOut.push(hdRow[c]); + tblOut.push('
                                                              '); + tblOut.push(row[d]); + tblOut.push('
                                                              '); - if (this.viewingMessage) { - if (this.viewingMessage.forwarding) { - data.options = { - forward: this.viewingMessage.id, - }; - } else { - data.options = { - in_reply_to: this.viewingMessage.id, - }; - } - } + tblDiv.innerHTML = tblOut.join(''); + } + if (msg.attachments.map) { + this.body.appendChild(document.createElement('br')); + var va = document.createElement('button'); + va.setAttribute('type', 'button'); + va.innerHTML = 'Open Map'; + va = this.body.appendChild(va); + Event.on(va, 'click', this.displayAttachment, this, true); + } + } + } + }, + displayAttachment: function () { + this.attachmentPanel.load(this.viewingMessage.attachments.map); + }, + sendMessage: function () { + var to = this.createTo.Selections(); + if (to.length == 0) { + this.createResponse.innerHTML = 'Must send a message To someone.'; + } else { + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + recipients: to.join(','), + subject: this.createSubject.value, + body: this.createText.value, + }; - InboxServ.send_message(data, { - success: function (o) { - this.fireEvent('onRpc', o.result); - var u = o.result.message.unknown; - if (u && u.length > 0) { - this.createResponse.innerHTML = - 'Unable to send to: ' + u.join(', '); - } else { - this.createResponse.innerHTML = ''; - this.createTo.ResetSelections(); - this.createSubject.value = ''; - this.createText.value = ''; - this.currentTab = this.inbox.id; - this.loadTab(); - } - }, - failure: function (o) { - if (o.error.code == 1005) { - this.createResponse.innerHTML = o.error.message; - return true; - } - }, - scope: this, - }); - } - }, - replyMessage: function (e) { - this.currentTab = this.create.id; + if (this.viewingMessage) { + if (this.viewingMessage.forwarding) { + data.options = { + forward: this.viewingMessage.id, + }; + } else { + data.options = { + in_reply_to: this.viewingMessage.id, + }; + } + } + + InboxServ.send_message(data, { + success: function (o) { + this.fireEvent('onRpc', o.result); + var u = o.result.message.unknown; + if (u && u.length > 0) { + this.createResponse.innerHTML = 'Unable to send to: ' + u.join(', '); + } else { + this.createResponse.innerHTML = ''; + this.createTo.ResetSelections(); + this.createSubject.value = ''; + this.createText.value = ''; + this.currentTab = this.inbox.id; this.loadTab(); + } }, - replyAllMessage: function (e) { - this.currentTab = this.create.id; - this.loadTab(true); + failure: function (o) { + if (o.error.code == 1005) { + this.createResponse.innerHTML = o.error.message; + return true; + } }, - forwardMessage: function (e) { - this.currentTab = this.create.id; - this.viewingMessage.forwarding = true; - this.loadTab(); - }, - archiveMessage: function (e) { - if (!this.toArchive[this.viewingMessage.id]) { - this.toArchive[this.viewingMessage.id] = this.viewingMessage; - this.toArchiveCount++; - } + scope: this, + }); + } + }, + replyMessage: function (e) { + this.currentTab = this.create.id; + this.loadTab(); + }, + replyAllMessage: function (e) { + this.currentTab = this.create.id; + this.loadTab(true); + }, + forwardMessage: function (e) { + this.currentTab = this.create.id; + this.viewingMessage.forwarding = true; + this.loadTab(); + }, + archiveMessage: function (e) { + if (!this.toArchive[this.viewingMessage.id]) { + this.toArchive[this.viewingMessage.id] = this.viewingMessage; + this.toArchiveCount++; + } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - message_ids: [this.viewingMessage.id], - }; - InboxServ.archive_messages(data, { - success: function (o) { - this.archiveProcess(o.result); - this.fireEvent('onRpc', o.result); - }, - scope: this, - }); + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + message_ids: [this.viewingMessage.id], + }; + InboxServ.archive_messages(data, { + success: function (o) { + this.archiveProcess(o.result); + this.fireEvent('onRpc', o.result); + }, + scope: this, + }); + }, + archiveMessages: function () { + if (this.toArchiveCount > 0) { + var mIds = []; + for (var key in this.toArchive) { + if (this.toArchive.hasOwnProperty(key)) { + mIds.push(key); + } + } + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + message_ids: mIds, + }; + InboxServ.archive_messages(data, { + success: function (o) { + this.archiveProcess(o.result); + this.fireEvent('onRpc', o.result); }, - archiveMessages: function () { - if (this.toArchiveCount > 0) { - var mIds = []; - for (var key in this.toArchive) { - if (this.toArchive.hasOwnProperty(key)) { - mIds.push(key); - } - } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - message_ids: mIds, - }; - InboxServ.archive_messages(data, { - success: function (o) { - this.archiveProcess(o.result); - this.fireEvent('onRpc', o.result); - }, - scope: this, - }); + scope: this, + }); + } + }, + archiveProcess: function (results) { + Dom.batch( + Sel.query('li.message', this.list), + function (el) { + if (results.success.indexOf(el.Message.id) >= 0) { + delete this.toArchive[el.Message.id]; + if (el.Message.has_read * 1 == 0) { + EmpireRPCStore.has_new_messages--; + if (EmpireRPCStore.has_new_messages < 0) { + EmpireRPCStore.has_new_messages = 0; } - }, - archiveProcess: function (results) { - Dom.batch( - Sel.query('li.message', this.list), - function (el) { - if (results.success.indexOf(el.Message.id) >= 0) { - delete this.toArchive[el.Message.id]; - if (el.Message.has_read * 1 == 0) { - EmpireRPCStore.has_new_messages--; - if (EmpireRPCStore.has_new_messages < 0) { - EmpireRPCStore.has_new_messages = 0; - } - } - this.toArchiveCount--; - Event.purgeElement(el); - el.parentNode.removeChild(el); - } - }, - this, - true - ); + } + this.toArchiveCount--; + Event.purgeElement(el); + el.parentNode.removeChild(el); + } + }, + this, + true + ); - if (this.pager) { - //reload messages if we had a pager - this.loadTab(); - } + if (this.pager) { + //reload messages if we had a pager + this.loadTab(); + } - Dom.setStyle(this.display, 'visibility', 'hidden'); - delete this.selectedAll; - this.select.innerHTML = 'Select All'; - }, - trashMessage: function (e) { - if (!this.toArchive[this.viewingMessage.id]) { - this.toArchive[this.viewingMessage.id] = this.viewingMessage; - this.toArchiveCount++; - } + Dom.setStyle(this.display, 'visibility', 'hidden'); + delete this.selectedAll; + this.select.innerHTML = 'Select All'; + }, + trashMessage: function (e) { + if (!this.toArchive[this.viewingMessage.id]) { + this.toArchive[this.viewingMessage.id] = this.viewingMessage; + this.toArchiveCount++; + } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - message_ids: [this.viewingMessage.id], - }; - InboxServ.trash_messages(data, { - success: function (o) { - this.trashProcess(o.result); - this.fireEvent('onRpc', o.result); - }, - scope: this, - }); + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + message_ids: [this.viewingMessage.id], + }; + InboxServ.trash_messages(data, { + success: function (o) { + this.trashProcess(o.result); + this.fireEvent('onRpc', o.result); + }, + scope: this, + }); + }, + trashMessages: function () { + if (this.toArchiveCount > 0) { + var mIds = []; + for (var key in this.toArchive) { + if (this.toArchive.hasOwnProperty(key)) { + mIds.push(key); + } + } + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + message_ids: mIds, + }; + InboxServ.trash_messages(data, { + success: function (o) { + this.trashProcess(o.result); + this.fireEvent('onRpc', o.result); }, - trashMessages: function () { - if (this.toArchiveCount > 0) { - var mIds = []; - for (var key in this.toArchive) { - if (this.toArchive.hasOwnProperty(key)) { - mIds.push(key); - } - } - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - message_ids: mIds, - }; - InboxServ.trash_messages(data, { - success: function (o) { - this.trashProcess(o.result); - this.fireEvent('onRpc', o.result); - }, - scope: this, - }); + scope: this, + }); + } + }, + trashProcess: function (results) { + Dom.batch( + Sel.query('li.message', this.list), + function (el) { + if (results.success.indexOf(el.Message.id) >= 0) { + delete this.toArchive[el.Message.id]; + if (el.Message.has_read * 1 == 0) { + EmpireRPCStore.has_new_messages--; + if (EmpireRPCStore.has_new_messages < 0) { + EmpireRPCStore.has_new_messages = 0; } - }, - trashProcess: function (results) { - Dom.batch( - Sel.query('li.message', this.list), - function (el) { - if (results.success.indexOf(el.Message.id) >= 0) { - delete this.toArchive[el.Message.id]; - if (el.Message.has_read * 1 == 0) { - EmpireRPCStore.has_new_messages--; - if (EmpireRPCStore.has_new_messages < 0) { - EmpireRPCStore.has_new_messages = 0; - } - } - this.toArchiveCount--; - Event.purgeElement(el); - el.parentNode.removeChild(el); - } - }, - this, - true - ); + } + this.toArchiveCount--; + Event.purgeElement(el); + el.parentNode.removeChild(el); + } + }, + this, + true + ); - if (this.pager) { - //reload messages if we had a pager - this.loadTab(); - } + if (this.pager) { + //reload messages if we had a pager + this.loadTab(); + } - Dom.setStyle(this.display, 'visibility', 'hidden'); - delete this.selectedAll; - this.select.innerHTML = 'Select All'; - }, - selectAllMessages: function () { - var els = Sel.query('input[type=checkbox]', this.list); - Dom.batch( - els, - function (el) { - el.checked = !this.selectedAll; - this.checkSelect(null, el); - }, - this, - true - ); - if (this.selectedAll) { - delete this.selectedAll; - this.select.innerHTML = 'Select All'; - } else { - this.selectedAll = 1; - this.select.innerHTML = 'Select None'; - } - }, + Dom.setStyle(this.display, 'visibility', 'hidden'); + delete this.selectedAll; + this.select.innerHTML = 'Select All'; + }, + selectAllMessages: function () { + var els = Sel.query('input[type=checkbox]', this.list); + Dom.batch( + els, + function (el) { + el.checked = !this.selectedAll; + this.checkSelect(null, el); + }, + this, + true + ); + if (this.selectedAll) { + delete this.selectedAll; + this.select.innerHTML = 'Select All'; + } else { + this.selectedAll = 1; + this.select.innerHTML = 'Select None'; + } + }, - formatBody: function (body) { - body = body.replace(/&/g, '&'); - body = body.replace(//g, '>'); - body = body.replace(/\*([^* \n][^*\n]*)\*/gi, '$1'); - body = body.replace(/\n/g, '
                                                              '); - body = body.replace( - /\{(food|water|ore|energy|waste|happiness|time|essentia|plots|build)\}/gi, - function (str, icon) { - var cl = 'small' + icon.substr(0, 1).toUpperCase() + icon.substr(1); - return ( - '' - ); - } - ); - body = body.replace(/\[(https?:\/\/[a-z0-9_.\/\-]+)\]/gi, '$1'); - body = body.replace( - /\{Empire\s+(-?\d+)\s+([^\}]+)\}/gi, - '$2' - ); - //body = body.replace(/\{Empire\s+(\d+)\s+([^\}]+)}/gi,'$2'); - body = body.replace( - /\{Starmap\s+(-?\d+)\s+(-?\d+)\s+([^\}]+)\}/gi, - '$3' - ); - body = body.replace( - /\{Planet\s+(-?\d+)\s+([^\}]+)\}/gi, - '$2' - ); - body = body.replace( - /\{Alliance\s+(-?\d+)\s+([^\}]+)\}/gi, - '$2' - ); - body = body.replace( - /\{VoteYes\s(-*\d+)\s(-*\d+)\s(-*\d+)\}/gi, - 'Yes!' - ); - body = body.replace( - /\{VoteNo\s(-*\d+)\s(-*\d+)\s(-*\d+)\}/gi, - 'No!' - ); - //body = body.replace(/\{Alliance\s+(\d+)\s+([^\}]+)}/gi,'$2'); - return body; - }, - handleProfileLink: function (e, el) { - Event.stopEvent(e); - var res = el.href.match(/\#(-?\d+)$/); - if (res) { - Lacuna.Info.Empire.Load(res[1]); - } - }, - handleStarmapLink: function (e, el) { - Event.stopEvent(e); - var res = el.href.match(/\#(-?\d+)x(-?\d+)$/); - Game.StarJump({ x: res[1], y: res[2] }); - }, - handlePlanetLink: function (e, el) { - Event.stopEvent(e); - var res = el.href.match(/\#(-?\d+)$/); - this.hide(); - MenuStore.changePlanet(res[1]); - //Game.PlanetJump(planet); - }, - handleAllianceLink: function (e, el) { - Event.stopEvent(e); - var res = el.href.match(/\#(-?\d+)$/); - Lacuna.Info.Alliance.Load(res[1]); + formatBody: function (body) { + body = body.replace(/&/g, '&'); + body = body.replace(//g, '>'); + body = body.replace(/\*([^* \n][^*\n]*)\*/gi, '$1'); + body = body.replace(/\n/g, '
                                                              '); + body = body.replace( + /\{(food|water|ore|energy|waste|happiness|time|essentia|plots|build)\}/gi, + function (str, icon) { + var cl = 'small' + icon.substr(0, 1).toUpperCase() + icon.substr(1); + return ''; + } + ); + body = body.replace(/\[(https?:\/\/[a-z0-9_.\/\-]+)\]/gi, '$1'); + body = body.replace( + /\{Empire\s+(-?\d+)\s+([^\}]+)\}/gi, + '$2' + ); + //body = body.replace(/\{Empire\s+(\d+)\s+([^\}]+)}/gi,'$2'); + body = body.replace( + /\{Starmap\s+(-?\d+)\s+(-?\d+)\s+([^\}]+)\}/gi, + '$3' + ); + body = body.replace( + /\{Planet\s+(-?\d+)\s+([^\}]+)\}/gi, + '$2' + ); + body = body.replace( + /\{Alliance\s+(-?\d+)\s+([^\}]+)\}/gi, + '$2' + ); + body = body.replace( + /\{VoteYes\s(-*\d+)\s(-*\d+)\s(-*\d+)\}/gi, + 'Yes!' + ); + body = body.replace( + /\{VoteNo\s(-*\d+)\s(-*\d+)\s(-*\d+)\}/gi, + 'No!' + ); + //body = body.replace(/\{Alliance\s+(\d+)\s+([^\}]+)}/gi,'$2'); + return body; + }, + handleProfileLink: function (e, el) { + Event.stopEvent(e); + var res = el.href.match(/\#(-?\d+)$/); + if (res) { + Lacuna.Info.Empire.Load(res[1]); + } + }, + handleStarmapLink: function (e, el) { + Event.stopEvent(e); + var res = el.href.match(/\#(-?\d+)x(-?\d+)$/); + Game.StarJump({ x: res[1], y: res[2] }); + }, + handlePlanetLink: function (e, el) { + Event.stopEvent(e); + var res = el.href.match(/\#(-?\d+)$/); + this.hide(); + MenuStore.changePlanet(res[1]); + //Game.PlanetJump(planet); + }, + handleAllianceLink: function (e, el) { + Event.stopEvent(e); + var res = el.href.match(/\#(-?\d+)$/); + Lacuna.Info.Alliance.Load(res[1]); + }, + handleVoteYesLink: function (e, el) { + Event.stopEvent(e); + var res = el.href.match(/\#(-?\d+)&(-?\d+)&(-?\d+)$/); + Game.Services.Modules.Parliament.cast_vote( + { + session_id: Game.GetSession(''), + building_id: res[2], + proposition_id: res[3], + vote: 1, + }, + { + success: function (o) { + alert('Voted Yes!'); }, - handleVoteYesLink: function (e, el) { - Event.stopEvent(e); - var res = el.href.match(/\#(-?\d+)&(-?\d+)&(-?\d+)$/); - Game.Services.Modules.Parliament.cast_vote( - { - session_id: Game.GetSession(''), - building_id: res[2], - proposition_id: res[3], - vote: 1, - }, - { - success: function (o) { - alert('Voted Yes!'); - }, - scope: this, - } - ); - }, - handleVoteNoLink: function (e, el) { - Event.stopEvent(e); - var res = el.href.match(/\#(-?\d+)&(-?\d+)&(-?\d+)$/); - Game.Services.Modules.Parliament.cast_vote( - { - session_id: Game.GetSession(''), - building_id: res[2], - proposition_id: res[3], - vote: 0, - }, - { - success: function (o) { - alert('Voted No!'); - }, - scope: this, - } - ); + scope: this, + } + ); + }, + handleVoteNoLink: function (e, el) { + Event.stopEvent(e); + var res = el.href.match(/\#(-?\d+)&(-?\d+)&(-?\d+)$/); + Game.Services.Modules.Parliament.cast_vote( + { + session_id: Game.GetSession(''), + building_id: res[2], + proposition_id: res[3], + vote: 0, + }, + { + success: function (o) { + alert('Voted No!'); }, + scope: this, + } + ); + }, - isVisible: function () { - return this.messagingPanel.cfg.getProperty('visible'); - }, - _load: _.once(function () { - this._buildPanel(); - this._buildAttachmentPanel(); - }), - show: function () { - Game.OverlayManager.hideAll(); + isVisible: function () { + return this.messagingPanel.cfg.getProperty('visible'); + }, + _load: _.once(function () { + this._buildPanel(); + this._buildAttachmentPanel(); + }), + show: function () { + Game.OverlayManager.hideAll(); - this._load(); + this._load(); - this.messagingPanel.show(); - this.currentTab = this.inbox.id; - this.loadTab(); - this.fireEvent('onShow'); - }, - sendTo: function (empireName) { - Game.OverlayManager.hideAll(); - delete this.viewingMessage; - this.messagingPanel.show(); - this.currentTab = this.create.id; - this.loadTab(); - this.createTo.SelectItems([{ name: empireName }]); - this.fireEvent('onShow'); - }, - showMessage: function (msg) { - Game.OverlayManager.hideAll(); - this.messagingPanel.show(); - var InboxServ = Game.Services.Inbox, - data = { - session_id: Game.GetSession(''), - message_id: msg, - }; - InboxServ.read_message(data, { - success: function (o) { - var message = o.result.message; - if (message.has_archived != '0') { - this.currentTab = this.archive.id; - } else { - this.currentTab = this.inbox.id; - } - this.fireEvent('onRpc', o); - this.loadTab(); - this.displayMessage(message); - }, - scope: this, - }); - }, - hide: function () { - this.messagingPanel.hide(); - }, - }; - Lang.augmentProto(Messaging, Util.EventProvider); + this.messagingPanel.show(); + this.currentTab = this.inbox.id; + this.loadTab(); + this.fireEvent('onShow'); + }, + sendTo: function (empireName) { + Game.OverlayManager.hideAll(); + delete this.viewingMessage; + this.messagingPanel.show(); + this.currentTab = this.create.id; + this.loadTab(); + this.createTo.SelectItems([{ name: empireName }]); + this.fireEvent('onShow'); + }, + showMessage: function (msg) { + Game.OverlayManager.hideAll(); + this.messagingPanel.show(); + var InboxServ = Game.Services.Inbox, + data = { + session_id: Game.GetSession(''), + message_id: msg, + }; + InboxServ.read_message(data, { + success: function (o) { + var message = o.result.message; + if (message.has_archived != '0') { + this.currentTab = this.archive.id; + } else { + this.currentTab = this.inbox.id; + } + this.fireEvent('onRpc', o); + this.loadTab(); + this.displayMessage(message); + }, + scope: this, + }); + }, + hide: function () { + this.messagingPanel.hide(); + }, + }; + Lang.augmentProto(Messaging, Util.EventProvider); - Lacuna.Messaging = new Messaging(); - })(); - YAHOO.register('messaging', YAHOO.lacuna.Messaging, { - version: '1', - build: '0', - }); + Lacuna.Messaging = new Messaging(); + })(); + YAHOO.register('messaging', YAHOO.lacuna.Messaging, { + version: '1', + build: '0', + }); } diff --git a/app/yui/notify.js b/app/yui/notify.js index c4c9d6c8..1eb55bf0 100644 --- a/app/yui/notify.js +++ b/app/yui/notify.js @@ -1,182 +1,162 @@ import BodyRPCStore from 'app/stores/rpc/body'; if (typeof YAHOO.lacuna.Notify == 'undefined' || !YAHOO.lacuna.Notify) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; - var Notify = function () {}; - Notify.prototype = { - build: function () { - if (!this.Display) { - var container = document.createElement('div'); - container.id = 'notify'; - Dom.addClass(container, Lib.Styles.HIDDEN); - Dom.addClass(container, 'nofooter'); - container.innerHTML = this._getHtml(); - document.getElementById('oldYUIPanelContainer').appendChild(container); + var Notify = function () {}; + Notify.prototype = { + build: function () { + if (!this.Display) { + var container = document.createElement('div'); + container.id = 'notify'; + Dom.addClass(container, Lib.Styles.HIDDEN); + Dom.addClass(container, 'nofooter'); + container.innerHTML = this._getHtml(); + document.getElementById('oldYUIPanelContainer').appendChild(container); - this.Display = new YAHOO.widget.Panel('notify', { - constraintoviewport: true, - visible: false, - draggable: false, - effect: Game.GetContainerEffect(), - close: false, - underlay: false, - modal: false, - width: '180px', - zIndex: 20000, - }); - this.Display.renderEvent.subscribe(function () { - this.notifyList = Dom.get('notifyList'); - this.notify = Dom.get('notify'); + this.Display = new YAHOO.widget.Panel('notify', { + constraintoviewport: true, + visible: false, + draggable: false, + effect: Game.GetContainerEffect(), + close: false, + underlay: false, + modal: false, + width: '180px', + zIndex: 20000, + }); + this.Display.renderEvent.subscribe(function () { + this.notifyList = Dom.get('notifyList'); + this.notify = Dom.get('notify'); - // Listen for new data. - // TODO: figure out how to do this - // BodyRPCStore.listen(self.update, self); + // Listen for new data. + // TODO: figure out how to do this + // BodyRPCStore.listen(self.update, self); - Dom.removeClass(this.notify, Lib.Styles.HIDDEN); - }); - this.Display.showEvent.subscribe(function () { - Dom.setStyle( - this.notifyList.parentNode, - 'max-height', - Game.GetSize().h - 125 + 'px' - ); - }); + Dom.removeClass(this.notify, Lib.Styles.HIDDEN); + }); + this.Display.showEvent.subscribe(function () { + Dom.setStyle(this.notifyList.parentNode, 'max-height', Game.GetSize().h - 125 + 'px'); + }); - this.Display.render(); - } - }, - _getHtml: function () { - return [ - '
                                                              Incoming Ships
                                                              ', - '
                                                              ', - '
                                                              ', - '
                                                                ', - '
                                                                ', - '
                                                                ', - ].join(''); - }, - update: function (body) { - if (!this.Display) { - return; // Make sure we don't try to update something that isn't there. - } + this.Display.render(); + } + }, + _getHtml: function () { + return [ + '
                                                                Incoming Ships
                                                                ', + '
                                                                ', + '
                                                                ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ].join(''); + }, + update: function (body) { + if (!this.Display) { + return; // Make sure we don't try to update something that isn't there. + } - var list = this.Display.notifyList; - var incoming_own = body.incoming_own_ships || [], - incoming_ally = body.incoming_ally_ships || [], - incoming_enemy = body.incoming_enemy_ships || [], - num_incoming_own = body.num_incoming_own || 0, - num_incoming_ally = body.num_incoming_ally || 0, - num_incoming_enemy = body.num_incoming_enemy || 0; - var arr = []; + var list = this.Display.notifyList; + var incoming_own = body.incoming_own_ships || [], + incoming_ally = body.incoming_ally_ships || [], + incoming_enemy = body.incoming_enemy_ships || [], + num_incoming_own = body.num_incoming_own || 0, + num_incoming_ally = body.num_incoming_ally || 0, + num_incoming_enemy = body.num_incoming_enemy || 0; + var arr = []; - if (num_incoming_enemy > 0) { - arr = arr.concat([ - '
                                                                • ', - num_incoming_enemy, - ' foreign
                                                                • ', - ]); - var len = incoming_enemy.length; - for (var s = 0; s < len; s++) { - var ship = incoming_enemy[s], - ms = ship.arrival_ms, - arrTime; - if (ms > 0) { - arrTime = Lib.formatMillisecondTime(ms); - } else { - arrTime = 'Overdue ' + Lib.formatMillisecondTime(-ms); - } - arr = arr.concat([ - '
                                                                • ', - arrTime, - '
                                                                • ', - ]); - } - } - if (num_incoming_ally > 0) { - arr = arr.concat([ - '
                                                                • ', - num_incoming_ally, - ' allied
                                                                • ', - ]); - var len = incoming_ally.length; - for (var s = 0; s < len; s++) { - var ship = incoming_ally[s], - ms = ship.arrival_ms, - arrTime; - if (ms > 0) { - arrTime = Lib.formatMillisecondTime(ms); - } else { - arrTime = 'Overdue ' + Lib.formatMillisecondTime(-ms); - } - arr = arr.concat([ - '
                                                                • ', - arrTime, - '
                                                                • ', - ]); - } - } - if (num_incoming_own > 0) { - arr = arr.concat([ - '
                                                                • ', - num_incoming_own, - ' own
                                                                • ', - ]); - var len = incoming_own.length; - for (var s = 0; s < len; s++) { - var ship = incoming_own[s], - ms = ship.arrival_ms, - arrTime; - if (ms > 0) { - arrTime = Lib.formatMillisecondTime(ms); - } else { - arrTime = 'Overdue ' + Lib.formatMillisecondTime(-ms); - } - arr = arr.concat([ - '
                                                                • ', - arrTime, - '
                                                                • ', - ]); - } - } + if (num_incoming_enemy > 0) { + arr = arr.concat([ + '
                                                                • ', + num_incoming_enemy, + ' foreign
                                                                • ', + ]); + var len = incoming_enemy.length; + for (var s = 0; s < len; s++) { + var ship = incoming_enemy[s], + ms = ship.arrival_ms, + arrTime; + if (ms > 0) { + arrTime = Lib.formatMillisecondTime(ms); + } else { + arrTime = 'Overdue ' + Lib.formatMillisecondTime(-ms); + } + arr = arr.concat(['
                                                                • ', arrTime, '
                                                                • ']); + } + } + if (num_incoming_ally > 0) { + arr = arr.concat([ + '
                                                                • ', + num_incoming_ally, + ' allied
                                                                • ', + ]); + var len = incoming_ally.length; + for (var s = 0; s < len; s++) { + var ship = incoming_ally[s], + ms = ship.arrival_ms, + arrTime; + if (ms > 0) { + arrTime = Lib.formatMillisecondTime(ms); + } else { + arrTime = 'Overdue ' + Lib.formatMillisecondTime(-ms); + } + arr = arr.concat(['
                                                                • ', arrTime, '
                                                                • ']); + } + } + if (num_incoming_own > 0) { + arr = arr.concat(['
                                                                • ', num_incoming_own, ' own
                                                                • ']); + var len = incoming_own.length; + for (var s = 0; s < len; s++) { + var ship = incoming_own[s], + ms = ship.arrival_ms, + arrTime; + if (ms > 0) { + arrTime = Lib.formatMillisecondTime(ms); + } else { + arrTime = 'Overdue ' + Lib.formatMillisecondTime(-ms); + } + arr = arr.concat(['
                                                                • ', arrTime, '
                                                                • ']); + } + } - list.innerHTML = arr.join(''); + list.innerHTML = arr.join(''); - if (num_incoming_own + num_incoming_ally + num_incoming_enemy === 0) { - this.Display.hide(); - } else { - this.Display.show(); - } - }, + if (num_incoming_own + num_incoming_ally + num_incoming_enemy === 0) { + this.Display.hide(); + } else { + this.Display.show(); + } + }, - Show: function () { - this.build(); - this.Display.show(); - this.Display.bringToTop(); - }, - Hide: function () { - if (this.Display) { - this.Display.hide(); - } - }, - Destroy: function () { - if (this.Display) { - this.Display.destroy(); - delete this.Display; - } - }, - }; + Show: function () { + this.build(); + this.Display.show(); + this.Display.bringToTop(); + }, + Hide: function () { + if (this.Display) { + this.Display.hide(); + } + }, + Destroy: function () { + if (this.Display) { + this.Display.destroy(); + delete this.Display; + } + }, + }; - Lacuna.Notify = new Notify(); - })(); - YAHOO.register('notify', YAHOO.lacuna.Notify, { version: '1', build: '0' }); + Lacuna.Notify = new Notify(); + })(); + YAHOO.register('notify', YAHOO.lacuna.Notify, { version: '1', build: '0' }); } diff --git a/app/yui/profile.js b/app/yui/profile.js index 4de2daba..f3483545 100644 --- a/app/yui/profile.js +++ b/app/yui/profile.js @@ -7,830 +7,790 @@ import MenuStore from 'app/stores/menu'; import OptionsWindowStore from 'app/stores/window/options'; if (typeof YAHOO.lacuna.Profile == 'undefined' || !YAHOO.lacuna.Profile) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; - - var Profile = function () {}; - Profile.prototype = { - build: _.once(function () { - this.createEvent('onRpc'); - this.id = 'profile'; - - var container = document.createElement('div'); - container.id = this.id; - Dom.addClass(container, Lib.Styles.HIDDEN); - container.innerHTML = this._getHtml(); - document.getElementById('oldYUIPanelContainer').appendChild(container); - - this.Dialog = new YAHOO.widget.Dialog(this.id, { - constraintoviewport: true, - postmethod: 'none', - buttons: [ - { - text: 'Update', - handler: { fn: this.handleUpdate, scope: this }, - isDefault: true, - }, - ], - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - underlay: false, - close: true, - width: '500px', - zIndex: 9999, - }); - this.Dialog.renderEvent.subscribe( - function () { - this.description = Dom.get('profileDescription'); - this.status = Dom.get('profileStatus'); - this.email = Dom.get('profileEmail'); - this.city = Dom.get('profileCity'); - this.country = Dom.get('profileCountry'); - this.skype = Dom.get('profileSkype'); - this.player_name = Dom.get('profilePlayerName'); - this.skipFacebook = Dom.get('profileSkipFacebookWallPosts'); - this.skipMedal = Dom.get('profileSkipMedal'); - this.skipHappiness = Dom.get('profileSkipHappiness'); - this.skipResource = Dom.get('profileSkipResource'); - this.skipPollution = Dom.get('profileSkipPollution'); - this.skipFoundNothing = Dom.get('profileSkipFoundNothing'); - this.skipExcavatorResources = Dom.get('profileSkipExcavatorResources'); - this.skipExcavatorGlyph = Dom.get('profileSkipExcavatorGlyph'); - this.skipExcavatorPlan = Dom.get('profileSkipExcavatorPlan'); - this.skipExcavatorArtifact = Dom.get('profileSkipExcavatorArtifact'); - this.skipExcavatorDestroyed = Dom.get('profileSkipExcavatorDestroyed'); - this.skipAllExcavator = Dom.get('profileSkipAllExcavator'); - this.skipSpyRecovery = Dom.get('profileSkipSpyRecovery'); - this.skipProbeDetected = Dom.get('profileSkipProbeDetected'); - this.skipAttackMessages = Dom.get('profileSkipAttackMessages'); - this.skipIncomingShips = Dom.get('profileSkipIncomingShips'); - this.skipExcavatorReplaceMsg = Dom.get('profileSkipExcavatorReplaceMsg'); - this.dontReplaceExcavator = Dom.get('profileDontReplaceExcavator'); - Event.on(this.skipFoundNothing, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipAllExcavator').checked = false; - } - }); - Event.on(this.skipExcavatorResources, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipAllExcavator').checked = false; - } - }); - Event.on(this.skipExcavatorGlyph, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipAllExcavator').checked = false; - } - }); - Event.on(this.skipExcavatorPlan, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipAllExcavator').checked = false; - } - }); - Event.on(this.skipExcavatorArtifact, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipAllExcavator').checked = false; - } - }); - Event.on(this.skipExcavatorDestroyed, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipAllExcavator').checked = false; - } - }); - Event.on(this.skipExcavatorReplaceMsg, 'change', function () { - if (!this.checked) { - Dom.get('profileSkipExcavatorReplaceMsg').checked = false; - } - }); - Event.on(this.skipAllExcavator, 'change', function () { - if (this.checked) { - Dom.get('profileSkipFoundNothing').checked = true; - Dom.get('profileSkipExcavatorResources').checked = true; - Dom.get('profileSkipExcavatorGlyph').checked = true; - Dom.get('profileSkipExcavatorPlan').checked = true; - Dom.get('profileSkipExcavatorArtifact').checked = true; - Dom.get('profileSkipExcavatorDestroyed').checked = true; - Dom.get('profileSkipExcavatorReplaceMsg').checked = true; - } - }); - - this.iso_status = Dom.get('isolationistStatus'); - this.medals = Dom.get('profileMedalsList'); - this.species = Dom.get('profileSpecies'); - this.notes = Dom.get('profileNotes'); - this.sitter_password = Dom.get('profileSitterPassword'); - this.userID = Dom.get('profileUserID'); - this.allianceID = Dom.get('profileAllianceID'); - this.new_password = Dom.get('profileNewPassword'); - this.confirm_password = Dom.get('profileConfirmPassword'); - this.account_tab = Dom.get('detailsAccount'); - Event.on(this.sitter_password, 'focus', function () { - this.type = 'text'; - }); - Event.on(this.sitter_password, 'blur', function () { - this.type = 'password'; - }); - - this.stopAnim = Dom.get('profileDisableDialogAnim'); - this.showLevels = Dom.get('profileShowBuildingLevels'); - this.hidePlanets = Dom.get('profileHidePlanets'); - - this.tabView = new YAHOO.widget.TabView('profileTabs'); - //species tab - this.hasSpecies = false; - this.tabView.getTab(2).subscribe( - 'activeChange', - function (e) { - if (e.newValue && !this.hasSpecies) { - this.hasSpecies = true; - var requests = 0; - Game.Services.Empire.view_species_stats( - { session_id: Game.GetSession('') }, - { - success: function (o) { - YAHOO.log( - o, - 'info', - 'Profile.show.view_stats.success' - ); - this.fireEvent('onRpc', o.result); - this.speciesStats = o.result.species; - requests++; - if (requests == 2) { - this.populateSpecies(); - } - }, - scope: this, - } - ); - Game.Services.Empire.redefine_species_limits( - { session_id: Game.GetSession('') }, - { - success: function (o) { - YAHOO.log( - o, - 'info', - 'Profile.redefine_species_limits.success' - ); - this.fireEvent('onRpc', o.result); - this.speciesRedefineLimits = o.result; - requests++; - if (requests == 2) { - this.populateSpecies(); - } - }, - scope: this, - } - ); - } - }, - this, - true - ); - this.tabView.set('activeIndex', 0); - Dom.removeClass(this.id, Lib.Styles.HIDDEN); - }, - this, - true - ); - // Let the React component know that we're going away now. - this.Dialog.hideEvent.subscribe(() => OptionsWindowStore.hide()); - this.Dialog.render(); - Game.OverlayManager.register(this.Dialog); - - this.speciesId = 'profileSpeciesRedefine'; - var speciesContainer = document.createElement('div'); - speciesContainer.id = this.speciesId; - Dom.addClass(speciesContainer, Lib.Styles.HIDDEN); - speciesContainer.innerHTML = [ - '
                                                                  Redefine Species
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ' Changing your species affinities is risky business and will affect the game in many ways you cannot foresee. ', - ' In addition, you can only change your affinities once per month. Use at your own risk!', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ' ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ].join(''); - document.getElementById('oldYUIPanelContainer').appendChild(speciesContainer); - this.SpeciesDialog = new YAHOO.widget.Dialog(this.speciesId, { - constraintoviewport: true, - postmethod: 'none', - buttons: [ - { - text: - ' Update', - handler: { fn: this.redefineSpecies, scope: this }, - isDefault: true, - }, - { - text: 'Cancel', - handler: { - fn: function () { - this.hide(); - }, - }, - }, - ], - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - underlay: false, - close: true, - width: '735px', - zIndex: 99999, - }); - this.SpeciesDialog.renderEvent.subscribe( - function () { - this.SpeciesDesigner = new Lacuna.SpeciesDesigner({ - templates: false, - }); - this.SpeciesDesigner.render('profileSpeciesDesigner'); - Dom.removeClass(this.speciesId, Lib.Styles.HIDDEN); - }, - this, - true - ); - - this.SpeciesDialog.render(); - Game.OverlayManager.register(this.SpeciesDialog); - }), - _getHtml: function () { - return [ - '
                                                                  Options
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - ' ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  • ', - '

                                                                  • Isolationist status:
                                                                  • ', - '

                                                                  • ', - '
                                                                    ', - '
                                                                    • Stop Facebook Wall posts
                                                                    • ', - '
                                                                    • Stop Medal Messages
                                                                    • ', - '
                                                                    • Stop Probe Detected
                                                                    • ', - '
                                                                    • Stop Spy Recovery Messages
                                                                    • ', - '
                                                                    • Stop Resource Warnings
                                                                    • ', - '
                                                                    • Stop Pollution Warnings
                                                                    • ', - '
                                                                    • Stop Happiness Warnings
                                                                    • ', - '
                                                                    • Stop Attack Messages
                                                                    • ', - '
                                                                    • Stop Incoming Ships Notification
                                                                    • ', - '
                                                                    ', - '
                                                                    ', - '
                                                                      ', - '
                                                                    • Stop All Excavator Messages
                                                                    • ', - '
                                                                    • Stop Excavator Found Nothing
                                                                    • ', - '
                                                                    • Stop Excavator Glyph
                                                                    • ', - '
                                                                    • Stop Excavator Resources
                                                                    • ', - '
                                                                    • Stop Excavator Plan
                                                                    • ', - '
                                                                    • Stop Excavator Artifact
                                                                    • ', - '
                                                                    • Stop Excavator Destroyed
                                                                    • ', - '
                                                                    • Stop Excavator Replace Alert
                                                                    • ', - '
                                                                    • Do not replace Excavator automatically
                                                                    • ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  Select the medals to display on your profile :
                                                                  ', - '
                                                                    ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ' ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • Change Account Password:
                                                                  • ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • Account information:
                                                                  • ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • Stop Dialog Animation
                                                                  • ', - '
                                                                  • Always Show Building Levels
                                                                  • ', - '
                                                                  • Hide Planet Images in Star Map
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ].join(''); + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; + + var Profile = function () {}; + Profile.prototype = { + build: _.once(function () { + this.createEvent('onRpc'); + this.id = 'profile'; + + var container = document.createElement('div'); + container.id = this.id; + Dom.addClass(container, Lib.Styles.HIDDEN); + container.innerHTML = this._getHtml(); + document.getElementById('oldYUIPanelContainer').appendChild(container); + + this.Dialog = new YAHOO.widget.Dialog(this.id, { + constraintoviewport: true, + postmethod: 'none', + buttons: [ + { + text: 'Update', + handler: { fn: this.handleUpdate, scope: this }, + isDefault: true, }, - handleUpdate: function () { - var updatesLeft = 1; - if (this.new_password.value != '') { - if (this.new_password.value != this.confirm_password.value) { - alert("Passwords don't match!"); - this.tabView.set('activeIndex', 4); - this.confirm_password.focus(); - return; - } else { - updatesLeft++; - Game.Services.Empire.change_password( - { - session_id: Game.GetSession(''), - password1: this.new_password.value, - password2: this.confirm_password.value, - }, - { - success: function (o) { - YAHOO.log(o, 'info', 'Profile.handleUpdate.password.success'); - Dom.removeClass(this.account_tab, 'password-changed'); - if (--updatesLeft == 0) { - this.hide(); - } - }, - failure: function (o) { - this.tabView.set('activeIndex', 4); - this.new_password.focus(); - return true; - }, - scope: this, - } - ); - } - } - - var pmc = Sel.query('li', 'profileMedalsList'), - publicMedals = []; - for (var i = 0; i < pmc.length; i++) { - if (Sel.query('input[type="checkbox"]', pmc[i], true).checked) { - publicMedals.push(pmc[i].MedalId); - } - } - - if ( - Game.GetCookieSettings('disableDialogAnim', '0') != - (this.stopAnim.checked ? '1' : '0') - ) { - var newEffect; - if (this.stopAnim.checked) { - Game.SetCookieSettings('disableDialogAnim', '1'); - } else { - Game.RemoveCookieSettings('disableDialogAnim'); - newEffect = Game.GetContainerEffect(); - } - var cs = Game.OverlayManager.overlays; - for (var m = 0; m < cs.length; m++) { - cs[m].cfg.setProperty('effect', newEffect); - } - } - if ( - Game.GetCookieSettings('showLevels', '0') != - (this.showLevels.checked ? '1' : '0') - ) { - if (this.showLevels.checked) { - Game.SetCookieSettings('showLevels', '1'); - } else { - Game.RemoveCookieSettings('showLevels'); - } - var levels = Sel.query('#planetMap .tileContainer .planetMapTileActionLevel'); - for (var n = 0; n < levels.length; n++) { - Dom.setStyle( - levels[n].parentNode, - 'visibility', - this.showLevels.checked ? 'visible' : '' - ); - } - } - if ( - Game.GetCookieSettings('hidePlanets', '0') != - (this.hidePlanets.checked ? '1' : '0') - ) { - if (this.hidePlanets.checked) { - Game.SetCookieSettings('hidePlanets', '1'); - } else { - Game.RemoveCookieSettings('hidePlanets'); - } - if (YAHOO.lacuna.MapStar.IsVisible()) { - YAHOO.lacuna.MapStar._map.hidePlanets = - Game.GetCookieSettings('hidePlanets', 0) * 1; - YAHOO.lacuna.MapStar._map.redraw(); - } - } - - Game.Services.Empire.edit_profile( - { - session_id: Game.GetSession(''), - profile: { - description: this.description.value, - status_message: this.status.value, - email: this.email.value, - city: this.city.value, - country: this.country.value, - skype: this.skype.value, - player_name: this.player_name.value, - notes: this.notes.value, - sitter_password: this.sitter_password.value, - public_medals: publicMedals, - skip_happiness_warnings: this.skipHappiness.checked ? 1 : 0, - skip_resource_warnings: this.skipResource.checked ? 1 : 0, - skip_pollution_warnings: this.skipPollution.checked ? 1 : 0, - skip_medal_messages: this.skipMedal.checked ? 1 : 0, - skip_facebook_wall_posts: this.skipFacebook.checked ? 1 : 0, - skip_found_nothing: this.skipFoundNothing.checked ? 1 : 0, - skip_excavator_resources: this.skipExcavatorResources.checked ? 1 : 0, - skip_excavator_glyph: this.skipExcavatorGlyph.checked ? 1 : 0, - skip_excavator_plan: this.skipExcavatorPlan.checked ? 1 : 0, - skip_excavator_artifact: this.skipExcavatorArtifact.checked ? 1 : 0, - skip_excavator_destroyed: this.skipExcavatorDestroyed.checked ? 1 : 0, - skip_excavator_replace_msg: this.skipExcavatorReplaceMsg.checked - ? 1 - : 0, - dont_replace_excavator: this.dontReplaceExcavator.checked ? 1 : 0, - skip_spy_recovery: this.skipSpyRecovery.checked ? 1 : 0, - skip_probe_detected: this.skipProbeDetected.checked ? 1 : 0, - skip_attack_messages: this.skipAttackMessages.checked ? 1 : 0, - skip_incoming_ships: this.skipIncomingShips.checked ? 1 : 0, - }, - }, + ], + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + underlay: false, + close: true, + width: '500px', + zIndex: 9999, + }); + this.Dialog.renderEvent.subscribe( + function () { + this.description = Dom.get('profileDescription'); + this.status = Dom.get('profileStatus'); + this.email = Dom.get('profileEmail'); + this.city = Dom.get('profileCity'); + this.country = Dom.get('profileCountry'); + this.skype = Dom.get('profileSkype'); + this.player_name = Dom.get('profilePlayerName'); + this.skipFacebook = Dom.get('profileSkipFacebookWallPosts'); + this.skipMedal = Dom.get('profileSkipMedal'); + this.skipHappiness = Dom.get('profileSkipHappiness'); + this.skipResource = Dom.get('profileSkipResource'); + this.skipPollution = Dom.get('profileSkipPollution'); + this.skipFoundNothing = Dom.get('profileSkipFoundNothing'); + this.skipExcavatorResources = Dom.get('profileSkipExcavatorResources'); + this.skipExcavatorGlyph = Dom.get('profileSkipExcavatorGlyph'); + this.skipExcavatorPlan = Dom.get('profileSkipExcavatorPlan'); + this.skipExcavatorArtifact = Dom.get('profileSkipExcavatorArtifact'); + this.skipExcavatorDestroyed = Dom.get('profileSkipExcavatorDestroyed'); + this.skipAllExcavator = Dom.get('profileSkipAllExcavator'); + this.skipSpyRecovery = Dom.get('profileSkipSpyRecovery'); + this.skipProbeDetected = Dom.get('profileSkipProbeDetected'); + this.skipAttackMessages = Dom.get('profileSkipAttackMessages'); + this.skipIncomingShips = Dom.get('profileSkipIncomingShips'); + this.skipExcavatorReplaceMsg = Dom.get('profileSkipExcavatorReplaceMsg'); + this.dontReplaceExcavator = Dom.get('profileDontReplaceExcavator'); + Event.on(this.skipFoundNothing, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipAllExcavator').checked = false; + } + }); + Event.on(this.skipExcavatorResources, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipAllExcavator').checked = false; + } + }); + Event.on(this.skipExcavatorGlyph, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipAllExcavator').checked = false; + } + }); + Event.on(this.skipExcavatorPlan, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipAllExcavator').checked = false; + } + }); + Event.on(this.skipExcavatorArtifact, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipAllExcavator').checked = false; + } + }); + Event.on(this.skipExcavatorDestroyed, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipAllExcavator').checked = false; + } + }); + Event.on(this.skipExcavatorReplaceMsg, 'change', function () { + if (!this.checked) { + Dom.get('profileSkipExcavatorReplaceMsg').checked = false; + } + }); + Event.on(this.skipAllExcavator, 'change', function () { + if (this.checked) { + Dom.get('profileSkipFoundNothing').checked = true; + Dom.get('profileSkipExcavatorResources').checked = true; + Dom.get('profileSkipExcavatorGlyph').checked = true; + Dom.get('profileSkipExcavatorPlan').checked = true; + Dom.get('profileSkipExcavatorArtifact').checked = true; + Dom.get('profileSkipExcavatorDestroyed').checked = true; + Dom.get('profileSkipExcavatorReplaceMsg').checked = true; + } + }); + + this.iso_status = Dom.get('isolationistStatus'); + this.medals = Dom.get('profileMedalsList'); + this.species = Dom.get('profileSpecies'); + this.notes = Dom.get('profileNotes'); + this.sitter_password = Dom.get('profileSitterPassword'); + this.userID = Dom.get('profileUserID'); + this.allianceID = Dom.get('profileAllianceID'); + this.new_password = Dom.get('profileNewPassword'); + this.confirm_password = Dom.get('profileConfirmPassword'); + this.account_tab = Dom.get('detailsAccount'); + Event.on(this.sitter_password, 'focus', function () { + this.type = 'text'; + }); + Event.on(this.sitter_password, 'blur', function () { + this.type = 'password'; + }); + + this.stopAnim = Dom.get('profileDisableDialogAnim'); + this.showLevels = Dom.get('profileShowBuildingLevels'); + this.hidePlanets = Dom.get('profileHidePlanets'); + + this.tabView = new YAHOO.widget.TabView('profileTabs'); + //species tab + this.hasSpecies = false; + this.tabView.getTab(2).subscribe( + 'activeChange', + function (e) { + if (e.newValue && !this.hasSpecies) { + this.hasSpecies = true; + var requests = 0; + Game.Services.Empire.view_species_stats( + { session_id: Game.GetSession('') }, { - success: function (o) { - YAHOO.log(o, 'info', 'Profile.handleUpdate.success'); - if (--updatesLeft == 0) { - this.hide(); - } - }, - scope: this, + success: function (o) { + YAHOO.log(o, 'info', 'Profile.show.view_stats.success'); + this.fireEvent('onRpc', o.result); + this.speciesStats = o.result.species; + requests++; + if (requests == 2) { + this.populateSpecies(); + } + }, + scope: this, } - ); - }, - show: function () { - Lacuna.Profile.build(); - - //this is called out of scope so make sure to pass the correct scope in - Game.Services.Empire.get_own_profile( + ); + Game.Services.Empire.redefine_species_limits( { session_id: Game.GetSession('') }, { - success: function (o) { - this.fireEvent('onRpc', o.result); - this.populateProfile(o.result); - }, - scope: Lacuna.Profile, + success: function (o) { + YAHOO.log(o, 'info', 'Profile.redefine_species_limits.success'); + this.fireEvent('onRpc', o.result); + this.speciesRedefineLimits = o.result; + requests++; + if (requests == 2) { + this.populateSpecies(); + } + }, + scope: this, } - ); - Game.OverlayManager.hideAll(); - Lacuna.Profile.tabView.set('activeIndex', 0); - Lacuna.Profile.Dialog.center(); - Lacuna.Profile.Dialog.show(); + ); + } + }, + this, + true + ); + this.tabView.set('activeIndex', 0); + Dom.removeClass(this.id, Lib.Styles.HIDDEN); + }, + this, + true + ); + // Let the React component know that we're going away now. + this.Dialog.hideEvent.subscribe(() => OptionsWindowStore.hide()); + this.Dialog.render(); + Game.OverlayManager.register(this.Dialog); + + this.speciesId = 'profileSpeciesRedefine'; + var speciesContainer = document.createElement('div'); + speciesContainer.id = this.speciesId; + Dom.addClass(speciesContainer, Lib.Styles.HIDDEN); + speciesContainer.innerHTML = [ + '
                                                                  Redefine Species
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ' Changing your species affinities is risky business and will affect the game in many ways you cannot foresee. ', + ' In addition, you can only change your affinities once per month. Use at your own risk!', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ' ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ].join(''); + document.getElementById('oldYUIPanelContainer').appendChild(speciesContainer); + this.SpeciesDialog = new YAHOO.widget.Dialog(this.speciesId, { + constraintoviewport: true, + postmethod: 'none', + buttons: [ + { + text: + ' Update', + handler: { fn: this.redefineSpecies, scope: this }, + isDefault: true, }, - hide: function () { - this.Dialog.hide(); + { + text: 'Cancel', + handler: { + fn: function () { + this.hide(); + }, + }, }, - - populateProfile: function (results) { - var p = results.profile; - this.description.value = p.description; - this.status.value = p.status_message; - this.email.value = p.email; - this.city.value = p.city; - this.country.value = p.country; - this.skype.value = p.skype; - this.player_name.value = p.player_name; - this.userID.innerHTML = ['#', results.status.empire.id].join(''); - if (results.status.empire.alliance_id) { - this.allianceID.innerHTML = results.status.empire.alliance_id; - } - - this.skipFacebook.checked = p.skip_facebook_wall_posts == '1'; - this.skipMedal.checked = p.skip_medal_messages == '1'; - this.skipHappiness.checked = p.skip_happiness_warnings == '1'; - this.skipResource.checked = p.skip_resource_warnings == '1'; - this.skipPollution.checked = p.skip_pollution_warnings == '1'; - this.skipFoundNothing.checked = p.skip_found_nothing == '1'; - this.skipExcavatorResources.checked = p.skip_excavator_resources == '1'; - this.skipExcavatorGlyph.checked = p.skip_excavator_glyph == '1'; - this.skipExcavatorPlan.checked = p.skip_excavator_plan == '1'; - this.skipExcavatorArtifact.checked = p.skip_excavator_artifact == '1'; - this.skipExcavatorDestroyed.checked = p.skip_excavator_destroyed == '1'; - this.skipSpyRecovery.checked = p.skip_spy_recovery == '1'; - this.skipProbeDetected.checked = p.skip_probe_detected == '1'; - this.skipAttackMessages.checked = p.skip_attack_messages == '1'; - this.skipIncomingShips.checked = p.skip_incoming_ships == '1'; - this.skipExcavatorReplaceMsg.checked = p.skip_excavator_replace_msg == '1'; - this.dontReplaceExcavator.checked = p.dont_replace_excavator == '1'; - this.skipAllExcavator.checked = - this.skipFoundNothing.checked && - this.skipExcavatorResources.checked && - this.skipExcavatorGlyph.checked && - this.skipExcavatorPlan.checked && - this.skipExcavatorArtifact.checked && - this.skipExcavatorDestroyed.checked && - this.skipExcavatorReplaceMsg.checked; - - this.stopAnim.checked = Game.GetCookieSettings('disableDialogAnim', '0') == '1'; - this.showLevels.checked = Game.GetCookieSettings('showLevels', '0') == '1'; - this.hidePlanets.checked = Game.GetCookieSettings('hidePlanets', '0') == '1'; - - this.iso_status.innerHTML = EmpireRPCStore.is_isolationist - ? 'Isolationist' - : 'Not Isolationist'; - - this.notes.value = p.notes; - this.sitter_password.value = p.sitter_password; - this.sitter_password.type = 'password'; - this.new_password.value = this.confirm_password.value = ''; - Dom.removeClass(this.account_tab, 'password-changed'); - - var frag = document.createDocumentFragment(), - li = document.createElement('li'); - for (var id in p.medals) { - if (p.medals.hasOwnProperty(id)) { - var medal = p.medals[id], - nLi = li.cloneNode(false); - - Dom.addClass(nLi, 'medal'); - nLi.MedalId = id; - nLi.innerHTML = [ - '
                                                                  ', - '
                                                                  ', - ' ',
-                            medal.name,
-                            '', - '
                                                                  ', - ].join(''); - - frag.appendChild(nLi); - } - } - - this.medals.innerHTML = ''; - this.medals.appendChild(frag); - - var Ht = Game.GetSize().h - 195; - if (Ht > 270) { - Ht = 270; - } - Dom.setStyle('profilePlayer', 'height', Ht + 'px'); - Dom.setStyle(this.notes, 'height', Ht + 'px'); - Dom.setStyle(this.medals, 'height', Ht + 'px'); - - this.Dialog.center(); + ], + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + underlay: false, + close: true, + width: '735px', + zIndex: 99999, + }); + this.SpeciesDialog.renderEvent.subscribe( + function () { + this.SpeciesDesigner = new Lacuna.SpeciesDesigner({ + templates: false, + }); + this.SpeciesDesigner.render('profileSpeciesDesigner'); + Dom.removeClass(this.speciesId, Lib.Styles.HIDDEN); + }, + this, + true + ); + + this.SpeciesDialog.render(); + Game.OverlayManager.register(this.SpeciesDialog); + }), + _getHtml: function () { + return [ + '
                                                                  Options
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + ' ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  • ', + '

                                                                  • Isolationist status:
                                                                  • ', + '

                                                                  • ', + '
                                                                    ', + '
                                                                    • Stop Facebook Wall posts
                                                                    • ', + '
                                                                    • Stop Medal Messages
                                                                    • ', + '
                                                                    • Stop Probe Detected
                                                                    • ', + '
                                                                    • Stop Spy Recovery Messages
                                                                    • ', + '
                                                                    • Stop Resource Warnings
                                                                    • ', + '
                                                                    • Stop Pollution Warnings
                                                                    • ', + '
                                                                    • Stop Happiness Warnings
                                                                    • ', + '
                                                                    • Stop Attack Messages
                                                                    • ', + '
                                                                    • Stop Incoming Ships Notification
                                                                    • ', + '
                                                                    ', + '
                                                                    ', + '
                                                                      ', + '
                                                                    • Stop All Excavator Messages
                                                                    • ', + '
                                                                    • Stop Excavator Found Nothing
                                                                    • ', + '
                                                                    • Stop Excavator Glyph
                                                                    • ', + '
                                                                    • Stop Excavator Resources
                                                                    • ', + '
                                                                    • Stop Excavator Plan
                                                                    • ', + '
                                                                    • Stop Excavator Artifact
                                                                    • ', + '
                                                                    • Stop Excavator Destroyed
                                                                    • ', + '
                                                                    • Stop Excavator Replace Alert
                                                                    • ', + '
                                                                    • Do not replace Excavator automatically
                                                                    • ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  Select the medals to display on your profile :
                                                                  ', + '
                                                                    ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ' ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • Change Account Password:
                                                                  • ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • Account information:
                                                                  • ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • Stop Dialog Animation
                                                                  • ', + '
                                                                  • Always Show Building Levels
                                                                  • ', + '
                                                                  • Hide Planet Images in Star Map
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ].join(''); + }, + handleUpdate: function () { + var updatesLeft = 1; + if (this.new_password.value != '') { + if (this.new_password.value != this.confirm_password.value) { + alert("Passwords don't match!"); + this.tabView.set('activeIndex', 4); + this.confirm_password.focus(); + return; + } else { + updatesLeft++; + Game.Services.Empire.change_password( + { + session_id: Game.GetSession(''), + password1: this.new_password.value, + password2: this.confirm_password.value, + }, + { + success: function (o) { + YAHOO.log(o, 'info', 'Profile.handleUpdate.password.success'); + Dom.removeClass(this.account_tab, 'password-changed'); + if (--updatesLeft == 0) { + this.hide(); + } + }, + failure: function (o) { + this.tabView.set('activeIndex', 4); + this.new_password.focus(); + return true; + }, + scope: this, + } + ); + } + } + + var pmc = Sel.query('li', 'profileMedalsList'), + publicMedals = []; + for (var i = 0; i < pmc.length; i++) { + if (Sel.query('input[type="checkbox"]', pmc[i], true).checked) { + publicMedals.push(pmc[i].MedalId); + } + } + + if ( + Game.GetCookieSettings('disableDialogAnim', '0') != (this.stopAnim.checked ? '1' : '0') + ) { + var newEffect; + if (this.stopAnim.checked) { + Game.SetCookieSettings('disableDialogAnim', '1'); + } else { + Game.RemoveCookieSettings('disableDialogAnim'); + newEffect = Game.GetContainerEffect(); + } + var cs = Game.OverlayManager.overlays; + for (var m = 0; m < cs.length; m++) { + cs[m].cfg.setProperty('effect', newEffect); + } + } + if (Game.GetCookieSettings('showLevels', '0') != (this.showLevels.checked ? '1' : '0')) { + if (this.showLevels.checked) { + Game.SetCookieSettings('showLevels', '1'); + } else { + Game.RemoveCookieSettings('showLevels'); + } + var levels = Sel.query('#planetMap .tileContainer .planetMapTileActionLevel'); + for (var n = 0; n < levels.length; n++) { + Dom.setStyle( + levels[n].parentNode, + 'visibility', + this.showLevels.checked ? 'visible' : '' + ); + } + } + if (Game.GetCookieSettings('hidePlanets', '0') != (this.hidePlanets.checked ? '1' : '0')) { + if (this.hidePlanets.checked) { + Game.SetCookieSettings('hidePlanets', '1'); + } else { + Game.RemoveCookieSettings('hidePlanets'); + } + if (YAHOO.lacuna.MapStar.IsVisible()) { + YAHOO.lacuna.MapStar._map.hidePlanets = Game.GetCookieSettings('hidePlanets', 0) * 1; + YAHOO.lacuna.MapStar._map.redraw(); + } + } + + Game.Services.Empire.edit_profile( + { + session_id: Game.GetSession(''), + profile: { + description: this.description.value, + status_message: this.status.value, + email: this.email.value, + city: this.city.value, + country: this.country.value, + skype: this.skype.value, + player_name: this.player_name.value, + notes: this.notes.value, + sitter_password: this.sitter_password.value, + public_medals: publicMedals, + skip_happiness_warnings: this.skipHappiness.checked ? 1 : 0, + skip_resource_warnings: this.skipResource.checked ? 1 : 0, + skip_pollution_warnings: this.skipPollution.checked ? 1 : 0, + skip_medal_messages: this.skipMedal.checked ? 1 : 0, + skip_facebook_wall_posts: this.skipFacebook.checked ? 1 : 0, + skip_found_nothing: this.skipFoundNothing.checked ? 1 : 0, + skip_excavator_resources: this.skipExcavatorResources.checked ? 1 : 0, + skip_excavator_glyph: this.skipExcavatorGlyph.checked ? 1 : 0, + skip_excavator_plan: this.skipExcavatorPlan.checked ? 1 : 0, + skip_excavator_artifact: this.skipExcavatorArtifact.checked ? 1 : 0, + skip_excavator_destroyed: this.skipExcavatorDestroyed.checked ? 1 : 0, + skip_excavator_replace_msg: this.skipExcavatorReplaceMsg.checked ? 1 : 0, + dont_replace_excavator: this.dontReplaceExcavator.checked ? 1 : 0, + skip_spy_recovery: this.skipSpyRecovery.checked ? 1 : 0, + skip_probe_detected: this.skipProbeDetected.checked ? 1 : 0, + skip_attack_messages: this.skipAttackMessages.checked ? 1 : 0, + skip_incoming_ships: this.skipIncomingShips.checked ? 1 : 0, }, - populateSpecies: function () { - var frag = document.createDocumentFragment(), - li = document.createElement('li'); - var stat = this.speciesStats; - - var nLi = li.cloneNode(false); - nLi.innerHTML = ['', '', stat.name, ''].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.description, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.min_orbit, - stat.max_orbit > stat.min_orbit ? ' to ' + stat.max_orbit : '', - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.manufacturing_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.deception_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.research_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.management_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.farming_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.mining_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.science_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.environmental_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.political_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.trade_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - nLi.innerHTML = [ - '', - '', - stat.growth_affinity, - '', - ].join(''); - frag.appendChild(nLi); - - nLi = li.cloneNode(false); - Dom.addClass(nLi, 'profileSpeciesRedefineButton'); - var redefineButton = document.createElement('button'); - redefineButton.innerHTML = [ - this.speciesRedefineLimits.essentia_cost, - ' Redefine Species', - ].join(''); - nLi.appendChild(redefineButton); - frag.appendChild(nLi); - - Event.on(redefineButton, 'click', this.showSpeciesRedefine, this, true); - - this.species.innerHTML = ''; - this.species.appendChild(frag); - var Ht = Game.GetSize().h - 180; - if (Ht > 290) { - Ht = 290; - } - Dom.setStyle(this.species, 'height', Ht + 'px'); + }, + { + success: function (o) { + YAHOO.log(o, 'info', 'Profile.handleUpdate.success'); + if (--updatesLeft == 0) { + this.hide(); + } }, - showSpeciesRedefine: function (e) { - Event.stopEvent(e); - if (this.speciesRedefineLimits.can) { - this.Dialog.hide(); - this.SpeciesDesigner.setSpeciesData(this.speciesStats); - if (this.SpeciesDesigner.needsExpert(this.speciesStats)) { - this.SpeciesDesigner.setExpert(); - } - this.SpeciesDesigner.setSpeciesLocks(this.speciesRedefineLimits); - this.SpeciesDialog.getButtons()[0].innerHTML = [ - this.speciesRedefineLimits.essentia_cost, - ' Update', - ].join(''); - this.SpeciesDialog.show(); - } else { - alert("Can't redefine species: " + this.speciesRedefineLimits.reason); - } + scope: this, + } + ); + }, + show: function () { + Lacuna.Profile.build(); + + //this is called out of scope so make sure to pass the correct scope in + Game.Services.Empire.get_own_profile( + { session_id: Game.GetSession('') }, + { + success: function (o) { + this.fireEvent('onRpc', o.result); + this.populateProfile(o.result); }, - redefineSpecies: function () { - var data = this.SpeciesDesigner.getSpeciesData(); - if (this.SpeciesDesigner.compareSpeciesData(data, this.speciesStats)) { - this.SpeciesDialog.hide(); - return; - } - try { - if (!this.SpeciesDesigner.validateSpecies(data)) { - return; - } - } catch (e) { - alert(e); - return; - } - MenuStore.showLoader(); - Game.Services.Empire.redefine_species( - { session_id: Game.GetSession(''), params: data }, - { - success: function (o) { - YAHOO.log(o, 'info', 'Profile.redefine_species.success'); - MenuStore.hideLoader(); - this.hasSpecies = false; - this.SpeciesDialog.hide(); - this.fireEvent('onRpc', o.result); - }, - scope: this, - } - ); + scope: Lacuna.Profile, + } + ); + Game.OverlayManager.hideAll(); + Lacuna.Profile.tabView.set('activeIndex', 0); + Lacuna.Profile.Dialog.center(); + Lacuna.Profile.Dialog.show(); + }, + hide: function () { + this.Dialog.hide(); + }, + + populateProfile: function (results) { + var p = results.profile; + this.description.value = p.description; + this.status.value = p.status_message; + this.email.value = p.email; + this.city.value = p.city; + this.country.value = p.country; + this.skype.value = p.skype; + this.player_name.value = p.player_name; + this.userID.innerHTML = ['#', results.status.empire.id].join(''); + if (results.status.empire.alliance_id) { + this.allianceID.innerHTML = results.status.empire.alliance_id; + } + + this.skipFacebook.checked = p.skip_facebook_wall_posts == '1'; + this.skipMedal.checked = p.skip_medal_messages == '1'; + this.skipHappiness.checked = p.skip_happiness_warnings == '1'; + this.skipResource.checked = p.skip_resource_warnings == '1'; + this.skipPollution.checked = p.skip_pollution_warnings == '1'; + this.skipFoundNothing.checked = p.skip_found_nothing == '1'; + this.skipExcavatorResources.checked = p.skip_excavator_resources == '1'; + this.skipExcavatorGlyph.checked = p.skip_excavator_glyph == '1'; + this.skipExcavatorPlan.checked = p.skip_excavator_plan == '1'; + this.skipExcavatorArtifact.checked = p.skip_excavator_artifact == '1'; + this.skipExcavatorDestroyed.checked = p.skip_excavator_destroyed == '1'; + this.skipSpyRecovery.checked = p.skip_spy_recovery == '1'; + this.skipProbeDetected.checked = p.skip_probe_detected == '1'; + this.skipAttackMessages.checked = p.skip_attack_messages == '1'; + this.skipIncomingShips.checked = p.skip_incoming_ships == '1'; + this.skipExcavatorReplaceMsg.checked = p.skip_excavator_replace_msg == '1'; + this.dontReplaceExcavator.checked = p.dont_replace_excavator == '1'; + this.skipAllExcavator.checked = + this.skipFoundNothing.checked && + this.skipExcavatorResources.checked && + this.skipExcavatorGlyph.checked && + this.skipExcavatorPlan.checked && + this.skipExcavatorArtifact.checked && + this.skipExcavatorDestroyed.checked && + this.skipExcavatorReplaceMsg.checked; + + this.stopAnim.checked = Game.GetCookieSettings('disableDialogAnim', '0') == '1'; + this.showLevels.checked = Game.GetCookieSettings('showLevels', '0') == '1'; + this.hidePlanets.checked = Game.GetCookieSettings('hidePlanets', '0') == '1'; + + this.iso_status.innerHTML = EmpireRPCStore.is_isolationist + ? 'Isolationist' + : 'Not Isolationist'; + + this.notes.value = p.notes; + this.sitter_password.value = p.sitter_password; + this.sitter_password.type = 'password'; + this.new_password.value = this.confirm_password.value = ''; + Dom.removeClass(this.account_tab, 'password-changed'); + + var frag = document.createDocumentFragment(), + li = document.createElement('li'); + for (var id in p.medals) { + if (p.medals.hasOwnProperty(id)) { + var medal = p.medals[id], + nLi = li.cloneNode(false); + + Dom.addClass(nLi, 'medal'); + nLi.MedalId = id; + nLi.innerHTML = [ + '
                                                                  ', + '
                                                                  ', + ' ',
+              medal.name,
+              '', + '
                                                                  ', + ].join(''); + + frag.appendChild(nLi); + } + } + + this.medals.innerHTML = ''; + this.medals.appendChild(frag); + + var Ht = Game.GetSize().h - 195; + if (Ht > 270) { + Ht = 270; + } + Dom.setStyle('profilePlayer', 'height', Ht + 'px'); + Dom.setStyle(this.notes, 'height', Ht + 'px'); + Dom.setStyle(this.medals, 'height', Ht + 'px'); + + this.Dialog.center(); + }, + populateSpecies: function () { + var frag = document.createDocumentFragment(), + li = document.createElement('li'); + var stat = this.speciesStats; + + var nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.name, ''].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.description, ''].join( + '' + ); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.min_orbit, + stat.max_orbit > stat.min_orbit ? ' to ' + stat.max_orbit : '', + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.manufacturing_affinity, + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.deception_affinity, + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.research_affinity, + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.management_affinity, + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.farming_affinity, ''].join( + '' + ); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.mining_affinity, ''].join( + '' + ); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.science_affinity, ''].join( + '' + ); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.environmental_affinity, + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = [ + '', + '', + stat.political_affinity, + '', + ].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.trade_affinity, ''].join(''); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + nLi.innerHTML = ['', '', stat.growth_affinity, ''].join( + '' + ); + frag.appendChild(nLi); + + nLi = li.cloneNode(false); + Dom.addClass(nLi, 'profileSpeciesRedefineButton'); + var redefineButton = document.createElement('button'); + redefineButton.innerHTML = [ + this.speciesRedefineLimits.essentia_cost, + ' Redefine Species', + ].join(''); + nLi.appendChild(redefineButton); + frag.appendChild(nLi); + + Event.on(redefineButton, 'click', this.showSpeciesRedefine, this, true); + + this.species.innerHTML = ''; + this.species.appendChild(frag); + var Ht = Game.GetSize().h - 180; + if (Ht > 290) { + Ht = 290; + } + Dom.setStyle(this.species, 'height', Ht + 'px'); + }, + showSpeciesRedefine: function (e) { + Event.stopEvent(e); + if (this.speciesRedefineLimits.can) { + this.Dialog.hide(); + this.SpeciesDesigner.setSpeciesData(this.speciesStats); + if (this.SpeciesDesigner.needsExpert(this.speciesStats)) { + this.SpeciesDesigner.setExpert(); + } + this.SpeciesDesigner.setSpeciesLocks(this.speciesRedefineLimits); + this.SpeciesDialog.getButtons()[0].innerHTML = [ + this.speciesRedefineLimits.essentia_cost, + ' Update', + ].join(''); + this.SpeciesDialog.show(); + } else { + alert("Can't redefine species: " + this.speciesRedefineLimits.reason); + } + }, + redefineSpecies: function () { + var data = this.SpeciesDesigner.getSpeciesData(); + if (this.SpeciesDesigner.compareSpeciesData(data, this.speciesStats)) { + this.SpeciesDialog.hide(); + return; + } + try { + if (!this.SpeciesDesigner.validateSpecies(data)) { + return; + } + } catch (e) { + alert(e); + return; + } + MenuStore.showLoader(); + Game.Services.Empire.redefine_species( + { session_id: Game.GetSession(''), params: data }, + { + success: function (o) { + YAHOO.log(o, 'info', 'Profile.redefine_species.success'); + MenuStore.hideLoader(); + this.hasSpecies = false; + this.SpeciesDialog.hide(); + this.fireEvent('onRpc', o.result); }, - }; - Lang.augmentProto(Profile, Util.EventProvider); - - Lacuna.Profile = new Profile(); - })(); - YAHOO.register('profile', YAHOO.lacuna.Profile, { - version: '1', - build: '0', - }); + scope: this, + } + ); + }, + }; + Lang.augmentProto(Profile, Util.EventProvider); + + Lacuna.Profile = new Profile(); + })(); + YAHOO.register('profile', YAHOO.lacuna.Profile, { + version: '1', + build: '0', + }); } diff --git a/app/yui/rpc.js b/app/yui/rpc.js index 61155e96..170ec73a 100644 --- a/app/yui/rpc.js +++ b/app/yui/rpc.js @@ -7,347 +7,345 @@ import server from 'app/server'; YAHOO.namespace('rpc'); if (typeof YAHOO.rpc.Service == 'undefined' || !YAHOO.rpc.Service) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util; - - var Service = function (smd, callback, baseUrl) { - if (Lang.isString(smd)) { - this.smdUrl = smd; - this.fetch(smd, callback); - } else if (Lang.isObject(smd)) { - this._smd = smd; - this._baseUrl = baseUrl; - this.process(callback); - } else { - throw new Error('smd should be an object or an url'); - } - }; - - Service.prototype = { - /** - * Generate the function from a service definition - * @method _generateService - * @param {String} serviceName - * @param {Method definition} method - */ - _generateService: function (serviceName, method) { - if (this[method]) { - throw new Error( - 'WARNING: ' + - serviceName + - ' already exists for service. Unable to generate function' - ); + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util; + + var Service = function (smd, callback, baseUrl) { + if (Lang.isString(smd)) { + this.smdUrl = smd; + this.fetch(smd, callback); + } else if (Lang.isObject(smd)) { + this._smd = smd; + this._baseUrl = baseUrl; + this.process(callback); + } else { + throw new Error('smd should be an object or an url'); + } + }; + + Service.prototype = { + /** + * Generate the function from a service definition + * @method _generateService + * @param {String} serviceName + * @param {Method definition} method + */ + _generateService: function (serviceName, method) { + if (this[method]) { + throw new Error( + 'WARNING: ' + serviceName + ' already exists for service. Unable to generate function' + ); + } + method.name = serviceName; + + var self = this; + var func = function (oParams, opts) { + // Note: oParams = Object Parameters. + var smd = self._smd; + var baseUrl = self._baseUrl; + + var envelope = YAHOO.rpc.Envelope[method.envelope || smd.envelope]; + + var callback = { + success: function (o) { + var results = envelope.deserialize(o); + + // Send the status block off to relevant stores to update UI. + if (results.result && results.result.status) { + server.splitStatus(results.result.status); + } + + opts.success.call(opts.scope || self, results); + }, + failure: function (o) { + if (Lang.isFunction(opts.failure)) { + var results; + try { + results = envelope.deserialize(o); + } catch (e) { + results = o; } - method.name = serviceName; - - var self = this; - var func = function (oParams, opts) { - // Note: oParams = Object Parameters. - var smd = self._smd; - var baseUrl = self._baseUrl; - - var envelope = YAHOO.rpc.Envelope[method.envelope || smd.envelope]; - - var callback = { - success: function (o) { - var results = envelope.deserialize(o); - - // Send the status block off to relevant stores to update UI. - if (results.result && results.result.status) { - server.splitStatus(results.result.status); - } - - opts.success.call(opts.scope || self, results); - }, - failure: function (o) { - if (Lang.isFunction(opts.failure)) { - var results; - try { - results = envelope.deserialize(o); - } catch (e) { - results = o; - } - opts.failure.call(opts.scope || self, results); - } - }, - scope: self, - }; - - if (opts.timeout) { - callback.timeout = opts.timeout; - } - - var params = [], - p; - - // Handle any SMD parameters. - if (smd.additionalParameters && Lang.isArray(smd.parameters)) { - for (var i = 0; i < smd.parameters.length; i++) { - p = smd.parameters[i]; - params.push(p['default']); - } - } - - // Then make sure that all the other params are in order. - for (var i = 0; i < method.parameters.length; i++) { - params.push(oParams[method.parameters[i].name]); - } - - // Now make sure that it all came out right. - if (params) { - if (!params[0] || params[0].name == 'args') { - params = oParams; - } - } else { - params = oParams; - } - - // console.log('Calling ' + method.name + ' with the parameters of ' + Lang.JSON.stringify(params) + '.'); //debug - var url = opts.target || method.target || smd.target; - var urlRegexp = - /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/i; - - if (smd.target && !url.match(urlRegexp) && url != smd.target) { - url = smd.target + url; - } - - if (!!self.smdUrl && !url.match(urlRegexp)) { - // URL is still relative ! - var a = self.smdUrl.split('/'); - a[a.length - 1] = ''; - url = a.join('/') + url; - } else if (baseUrl) { - baseUrl = baseUrl.replace(/\/?$/, '/'); - url = url.replace(/^\//, baseUrl); - } - - var r = { - target: url, - callback: callback, - data: params, - origData: oParams, - opts: opts, - callbackParamName: method.callbackParamName || smd.callbackParamName, - transport: method.transport || smd.transport, - }; - - //YAHOO.log('Sending ' + r.data + '.', 'debug', 'RPC._generateService');//debug - - var serialized = envelope.serialize(smd, method, params); - Lang.augmentObject(r, serialized, true); - - return YAHOO.rpc.Transport[r.transport].call(self, r); - }; + opts.failure.call(opts.scope || self, results); + } + }, + scope: self, + }; - func.description = method.description; - func._parameters = method.parameters; + if (opts.timeout) { + callback.timeout = opts.timeout; + } - return func; - }, + var params = [], + p; - /** - * Process the SMD definition. - * @method process - */ - process: function (callback) { - var serviceDefs = this._smd.services; - - // Generate the methods to this object - for (var serviceName in serviceDefs) { - if (serviceDefs.hasOwnProperty(serviceName)) { - // Get the object that will contain the method. - // handles "namespaced" services by breaking apart by '.' - var current = this; - var pieces = serviceName.split('.'); - for (var i = 0; i < pieces.length - 1; i++) { - current = current[pieces[i]] || (current[pieces[i]] = {}); - } - - current[pieces[pieces.length - 1]] = this._generateService( - serviceName, - serviceDefs[serviceName] - ); - } - } + // Handle any SMD parameters. + if (smd.additionalParameters && Lang.isArray(smd.parameters)) { + for (var i = 0; i < smd.parameters.length; i++) { + p = smd.parameters[i]; + params.push(p['default']); + } + } - // call the success handler - if (Lang.isObject(callback) && Lang.isFunction(callback.success)) { - callback.success.call(callback.scope || this); - } - }, + // Then make sure that all the other params are in order. + for (var i = 0; i < method.parameters.length; i++) { + params.push(oParams[method.parameters[i].name]); + } - /** - * Download the SMD at the given url - * @method fetch - * @param {String} Absolute or relative url - */ - fetch: function (url, callback) { - if (YAHOO.rpc.Service._smdCache[url]) { - this._smd = YAHOO.rpc.Service._smdCache[url]; - this.process(callback); - } else { - // TODO: if url is not in the same domain, we should use jsonp ! - Util.Connect.asyncRequest('GET', url, { - success: function (o) { - try { - this._smd = Lang.JSON.parse(o.responseText); - YAHOO.rpc.Service._smdCache[url] = this._smd; - this.process(callback); - } catch (ex) { - //YAHOO.log(ex); - if (Lang.isFunction(callback.failure)) { - callback.failure.call(callback.scope || this, { error: ex }); - } - } - }, - failure: function (o) { - if (Lang.isFunction(callback.failure)) { - callback.failure.call(callback.scope || this, { - error: 'unable to fetch url ' + url, - }); - } - }, - scope: this, - }); - } - }, + // Now make sure that it all came out right. + if (params) { + if (!params[0] || params[0].name == 'args') { + params = oParams; + } + } else { + params = oParams; + } + + // console.log('Calling ' + method.name + ' with the parameters of ' + Lang.JSON.stringify(params) + '.'); //debug + var url = opts.target || method.target || smd.target; + var urlRegexp = + /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/i; + + if (smd.target && !url.match(urlRegexp) && url != smd.target) { + url = smd.target + url; + } + + if (!!self.smdUrl && !url.match(urlRegexp)) { + // URL is still relative ! + var a = self.smdUrl.split('/'); + a[a.length - 1] = ''; + url = a.join('/') + url; + } else if (baseUrl) { + baseUrl = baseUrl.replace(/\/?$/, '/'); + url = url.replace(/^\//, baseUrl); + } + + var r = { + target: url, + callback: callback, + data: params, + origData: oParams, + opts: opts, + callbackParamName: method.callbackParamName || smd.callbackParamName, + transport: method.transport || smd.transport, + }; + + //YAHOO.log('Sending ' + r.data + '.', 'debug', 'RPC._generateService');//debug + + var serialized = envelope.serialize(smd, method, params); + Lang.augmentObject(r, serialized, true); + + return YAHOO.rpc.Transport[r.transport].call(self, r); }; - Service._smdCache = {}; //collection of smd objects by URL - Service._requestId = 1; - - /** - * YAHOO.rpc.Transport - * @class YAHOO.rpc.Transport - * @static - */ - YAHOO.rpc.Transport = { - /** - * Build a ajax request using 'POST' method - * @method POST - * @param {Object} r Object specifying target, callback and data attributes - */ - POST: function (r) { - return Util.Connect.asyncRequest('POST', r.target, r.callback, r.data); - }, + func.description = method.description; + func._parameters = method.parameters; + + return func; + }, + + /** + * Process the SMD definition. + * @method process + */ + process: function (callback) { + var serviceDefs = this._smd.services; + + // Generate the methods to this object + for (var serviceName in serviceDefs) { + if (serviceDefs.hasOwnProperty(serviceName)) { + // Get the object that will contain the method. + // handles "namespaced" services by breaking apart by '.' + var current = this; + var pieces = serviceName.split('.'); + for (var i = 0; i < pieces.length - 1; i++) { + current = current[pieces[i]] || (current[pieces[i]] = {}); + } - /** - * Build a ajax request using 'GET' method - * @method GET - * @param {Object} r Object specifying target, callback and data attributes - */ - GET: function (r) { - return Util.Connect.asyncRequest( - 'GET', - r.target + (r.data ? '?' + r.data : ''), - r.callback, - '' - ); + current[pieces[pieces.length - 1]] = this._generateService( + serviceName, + serviceDefs[serviceName] + ); + } + } + + // call the success handler + if (Lang.isObject(callback) && Lang.isFunction(callback.success)) { + callback.success.call(callback.scope || this); + } + }, + + /** + * Download the SMD at the given url + * @method fetch + * @param {String} Absolute or relative url + */ + fetch: function (url, callback) { + if (YAHOO.rpc.Service._smdCache[url]) { + this._smd = YAHOO.rpc.Service._smdCache[url]; + this.process(callback); + } else { + // TODO: if url is not in the same domain, we should use jsonp ! + Util.Connect.asyncRequest('GET', url, { + success: function (o) { + try { + this._smd = Lang.JSON.parse(o.responseText); + YAHOO.rpc.Service._smdCache[url] = this._smd; + this.process(callback); + } catch (ex) { + //YAHOO.log(ex); + if (Lang.isFunction(callback.failure)) { + callback.failure.call(callback.scope || this, { error: ex }); + } + } }, - - jsonp_id: 0, - /** - * Receive data through JSONP (insert a script tag within the page) - * @method JSONP - * @param {Object} r Object specifying target, callback and data attributes - */ - JSONP: function (r) { - r.callbackParamName = r.callbackParamName || 'callback'; - var fctName = encodeURIComponent( - 'YAHOO.rpc.Transport.JSONP.jsonpCallback' + YAHOO.rpc.Transport.jsonp_id - ); - YAHOO.rpc.Transport.JSONP['jsonpCallback' + YAHOO.rpc.Transport.jsonp_id] = - function (results) { - if (Lang.isObject(r.callback) && Lang.isFunction(r.callback.success)) { - r.callback.success.call(r.callback.scope || this, results); - } - }; - YAHOO.rpc.Transport.jsonp_id += 1; - return Util.Get.script( - r.target + - (r.target.indexOf('?') == -1 ? '?' : '&') + - r.data + - '&' + - r.callbackParamName + - '=' + - fctName - ); + failure: function (o) { + if (Lang.isFunction(callback.failure)) { + callback.failure.call(callback.scope || this, { + error: 'unable to fetch url ' + url, + }); + } }, + scope: this, + }); + } + }, + }; + + Service._smdCache = {}; //collection of smd objects by URL + Service._requestId = 1; + + /** + * YAHOO.rpc.Transport + * @class YAHOO.rpc.Transport + * @static + */ + YAHOO.rpc.Transport = { + /** + * Build a ajax request using 'POST' method + * @method POST + * @param {Object} r Object specifying target, callback and data attributes + */ + POST: function (r) { + return Util.Connect.asyncRequest('POST', r.target, r.callback, r.data); + }, + + /** + * Build a ajax request using 'GET' method + * @method GET + * @param {Object} r Object specifying target, callback and data attributes + */ + GET: function (r) { + return Util.Connect.asyncRequest( + 'GET', + r.target + (r.data ? '?' + r.data : ''), + r.callback, + '' + ); + }, + + jsonp_id: 0, + /** + * Receive data through JSONP (insert a script tag within the page) + * @method JSONP + * @param {Object} r Object specifying target, callback and data attributes + */ + JSONP: function (r) { + r.callbackParamName = r.callbackParamName || 'callback'; + var fctName = encodeURIComponent( + 'YAHOO.rpc.Transport.JSONP.jsonpCallback' + YAHOO.rpc.Transport.jsonp_id + ); + YAHOO.rpc.Transport.JSONP['jsonpCallback' + YAHOO.rpc.Transport.jsonp_id] = function ( + results + ) { + if (Lang.isObject(r.callback) && Lang.isFunction(r.callback.success)) { + r.callback.success.call(r.callback.scope || this, results); + } }; - + YAHOO.rpc.Transport.jsonp_id += 1; + return Util.Get.script( + r.target + + (r.target.indexOf('?') == -1 ? '?' : '&') + + r.data + + '&' + + r.callbackParamName + + '=' + + fctName + ); + }, + }; + + /** + * YAHOO.rpc.Envelope + * @class YAHOO.rpc.Envelope + * @static + */ + YAHOO.rpc.Envelope = { + /** + * JSON-RPC-2.0 envelope + * @class YAHOO.rpc.Envelope.JSON-RPC-2.0 + * @static + */ + 'JSON-RPC-2.0': { /** - * YAHOO.rpc.Envelope - * @class YAHOO.rpc.Envelope - * @static + * serialize */ - YAHOO.rpc.Envelope = { - /** - * JSON-RPC-2.0 envelope - * @class YAHOO.rpc.Envelope.JSON-RPC-2.0 - * @static - */ - 'JSON-RPC-2.0': { - /** - * serialize - */ - serialize: function (smd, method, data) { - return { - data: Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: method.name, - jsonrpc: '2.0', - params: data, - }), - }; + serialize: function (smd, method, data) { + return { + data: Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: method.name, + jsonrpc: '2.0', + params: data, + }), + }; + }, + /** + * deserialize + */ + deserialize: function (results) { + if ( + results.getResponseHeader && + (results.getResponseHeader['Content-Type'] == 'application/json-rpc' || + results.getResponseHeader['Content-Type'] == 'application/json') + ) { + return Lang.JSON.parse(results.responseText); + } else { + if (results.status == -1) { + return { + error: { + message: 'The Request has been Aborted because it was taking too long.', }, - /** - * deserialize - */ - deserialize: function (results) { - if ( - results.getResponseHeader && - (results.getResponseHeader['Content-Type'] == 'application/json-rpc' || - results.getResponseHeader['Content-Type'] == 'application/json') - ) { - return Lang.JSON.parse(results.responseText); - } else { - if (results.status == -1) { - return { - error: { - message: - 'The Request has been Aborted because it was taking too long.', - }, - }; - } else if (results.status === 0) { - return { - error: { - message: - 'Communication with the server has been interrupted for an unknown reason.', - }, - }; - } else { - // YUI loses headers for Cross-Origin requests, so try as JSON anyway - try { - return Lang.JSON.parse(results.responseText); - } catch (e) { - return { - error: { - message: 'Response Content-Type is not JSON', - }, - }; - } - } - } + }; + } else if (results.status === 0) { + return { + error: { + message: + 'Communication with the server has been interrupted for an unknown reason.', }, - }, - }; - - //set connects post header to json - Util.Connect.setDefaultPostHeader('application/json'); - Util.Connect.setDefaultPostHeader(true); - //assign to global - YAHOO.rpc.Service = Service; - })(); - YAHOO.register('rpc', YAHOO.rpc.Service, { version: '1', build: '0' }); + }; + } else { + // YUI loses headers for Cross-Origin requests, so try as JSON anyway + try { + return Lang.JSON.parse(results.responseText); + } catch (e) { + return { + error: { + message: 'Response Content-Type is not JSON', + }, + }; + } + } + } + }, + }, + }; + + //set connects post header to json + Util.Connect.setDefaultPostHeader('application/json'); + Util.Connect.setDefaultPostHeader(true); + //assign to global + YAHOO.rpc.Service = Service; + })(); + YAHOO.register('rpc', YAHOO.rpc.Service, { version: '1', build: '0' }); } diff --git a/app/yui/smd.js b/app/yui/smd.js index 46b44821..324d93f0 100644 --- a/app/yui/smd.js +++ b/app/yui/smd.js @@ -1,413 +1,403 @@ YAHOO.namespace('lacuna'); if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { - (function() { - var smd = { - Alliance: { - SMDVersion: '2.0', - description: 'Body', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/alliance', + (function () { + var smd = { + Alliance: { + SMDVersion: '2.0', + description: 'Body', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/alliance', - services: { - find: { - description: - 'Find an alliance by name. Returns a hash reference containing alliance ids and alliance names', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'name', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - }, - view_profile: { - description: - "Provides a list of the data that's publicly known about this alliance.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'alliance_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, + services: { + find: { + description: + 'Find an alliance by name. Returns a hash reference containing alliance ids and alliance names', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'name', type: 'string', optional: false }, + ], + returns: { type: 'object' }, + }, + view_profile: { + description: "Provides a list of the data that's publicly known about this alliance.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'alliance_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Body: { + SMDVersion: '2.0', + description: 'Body', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/body', + + services: { + abandon: { + description: "Abandon's a colony, and destroys everything on the planet.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_buildings: { + description: 'Retrieves a list of the buildings on a planet.', + parameters: { + session_id: { type: 'string', optional: false }, + body_id: { type: 'string', optional: false }, }, - Body: { - SMDVersion: '2.0', - description: 'Body', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/body', + returns: { type: 'object' }, + }, + get_buildable: { + description: + 'Provides a list of all the building types that are available to be built on a given space on a planet.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + { name: 'x', type: 'string', optional: false }, + { name: 'y', type: 'string', optional: false }, + { name: 'tag', type: 'string', optional: false }, + ], + returns: { type: 'object' }, + }, + get_build_queue: { + description: 'Returns a list of the buildings being constructed or upgraded', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_body_status: { + description: 'Retrieves the status of a body to display in the star map.', + parameters: { + session_id: { type: 'string', optional: false }, + body_id: { type: 'string', optional: false }, + }, + returns: { type: 'object' }, + }, + get_status: { + description: 'Returns detailed statistics about a planet.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + rename: { + description: + 'Renames a body, provided the empire attached to the session owns the body. Returns a 1 on success.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + { name: 'name', type: 'string', optional: false }, + ], + returns: { type: 'object' }, + }, + set_colony_notes: { + description: 'Sets the colony notes', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + { + name: 'options', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Buildings: { + Generic: { + SMDVersion: '2.0', + description: 'Buildings', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + //Target will be passed in "target":"/buildings", - services: { - abandon: { - description: - "Abandon's a colony, and destroys everything on the planet.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_buildings: { - description: - 'Retrieves a list of the buildings on a planet.', - parameters: { - session_id: { type: 'string', optional: false }, - body_id: { type: 'string', optional: false }, - }, - returns: { type: 'object' }, - }, - get_buildable: { - description: - 'Provides a list of all the building types that are available to be built on a given space on a planet.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - { name: 'x', type: 'string', optional: false }, - { name: 'y', type: 'string', optional: false }, - { name: 'tag', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - }, - get_build_queue: { - description: - 'Returns a list of the buildings being constructed or upgraded', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_body_status: { - description: - 'Retrieves the status of a body to display in the star map.', - parameters: { - session_id: { type: 'string', optional: false }, - body_id: { type: 'string', optional: false }, - }, - returns: { type: 'object' }, - }, - get_status: { - description: - 'Returns detailed statistics about a planet.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - rename: { - description: - 'Renames a body, provided the empire attached to the session owns the body. Returns a 1 on success.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - { name: 'name', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - }, - set_colony_notes: { - description: 'Sets the colony notes', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - { - name: 'options', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, + services: { + build: { + description: "Adds this building to the planet's build queue.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'planet_id', + type: 'string', + optional: false, }, + { name: 'x', type: 'string', optional: false }, + { name: 'y', type: 'string', optional: false }, + ], + returns: { type: 'object' }, }, - Buildings: { - Generic: { - SMDVersion: '2.0', - description: 'Buildings', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - //Target will be passed in "target":"/buildings", - - services: { - build: { - description: - "Adds this building to the planet's build queue.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'planet_id', - type: 'string', - optional: false, - }, - { name: 'x', type: 'string', optional: false }, - { name: 'y', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - }, - demolish: { - description: - "Allows you to instantly destroy a building provided it wouldn't put you into a negative resource production situation. For example, if you're producing only a net positive of 100 food per hour, and you destroy a corn field that would take away 200 food per hour, then the game won't allow you to demolish that building.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - downgrade: { - description: - 'Downgrades a building by one level and then returns view.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view: { - description: - 'Retrieves the properties of the building.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - upgrade: { - description: - 'Adds the requested upgrade to the build queue. On success returns the view() method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - repair: { - description: 'Repair buildings Efficiency to 100%', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Archaeology: { - SMDVersion: '2.0', - description: 'Archaeology Ministry', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/archaeology', + demolish: { + description: + "Allows you to instantly destroy a building provided it wouldn't put you into a negative resource production situation. For example, if you're producing only a net positive of 100 food per hour, and you destroy a corn field that would take away 200 food per hour, then the game won't allow you to demolish that building.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + downgrade: { + description: 'Downgrades a building by one level and then returns view.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view: { + description: 'Retrieves the properties of the building.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + upgrade: { + description: + 'Adds the requested upgrade to the build queue. On success returns the view() method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + repair: { + description: 'Repair buildings Efficiency to 100%', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Archaeology: { + SMDVersion: '2.0', + description: 'Archaeology Ministry', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/archaeology', - services: { - search_for_glyph: { - description: - 'Searches through ore looking for glyphs left behind by the ancient race. Takes 10,000 of one type of ore to search.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ore_type', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_glyph_summary: { - description: - 'Returns a list of glyphs that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_glyphs: { - description: - 'Returns a list of glyphs that have been found by this archaeology ministry.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - assemble_glyphs: { - description: - 'Turns glyphs into rare ancient items.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'glyphs', - type: 'array', - optional: false, - }, - { - name: 'quantity', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + services: { + search_for_glyph: { + description: + 'Searches through ore looking for glyphs left behind by the ancient race. Takes 10,000 of one type of ore to search.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ore_type', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_glyph_summary: { + description: + 'Returns a list of glyphs that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_glyphs: { + description: + 'Returns a list of glyphs that have been found by this archaeology ministry.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + assemble_glyphs: { + description: 'Turns glyphs into rare ancient items.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'glyphs', + type: 'array', + optional: false, + }, + { + name: 'quantity', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "item_name" : "Volcano" } */ - }, - get_ores_available_for_processing: { - description: - 'Returns a list of ore names that the user has enough of to process for glyphs.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + get_ores_available_for_processing: { + description: + 'Returns a list of ore names that the user has enough of to process for glyphs.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "ore" : { @@ -416,41 +406,41 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } } */ - }, - subsidize_search: { - description: - 'Will spend 2 essentia to complete the current glyph search immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_excavators: { - description: - 'Returns a list of the excavators currently controlled by this ministry.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + subsidize_search: { + description: + 'Will spend 2 essentia to complete the current glyph search immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_excavators: { + description: + 'Returns a list of the excavators currently controlled by this ministry.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "max_excavators" : 1, @@ -471,347 +461,338 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - abandon_excavator: { - description: - 'Close down an existing excavator site.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'excavator_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, //status - }, - mass_abandon_excavator: { - description: - 'Close down all existing excavator sites.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, //status - }, - }, - }, - BlackHoleGenerator: { - SMDVersion: '2.0', - description: 'Black Hole Generator', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/blackholegenerator', + }, + abandon_excavator: { + description: 'Close down an existing excavator site.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'excavator_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, //status + }, + mass_abandon_excavator: { + description: 'Close down all existing excavator sites.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, //status + }, + }, + }, + BlackHoleGenerator: { + SMDVersion: '2.0', + description: 'Black Hole Generator', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/blackholegenerator', - services: { - get_actions_for: { - description: - 'Provides a list of actions that the BHG can do. Use with generate_singularity.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'target', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - generate_singularity: { - description: 'Performs action on specified target.', - parameters: [ - { - name: 'params', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_cooldown: { - description: - 'Will spend 2 essentia to cool down the BHG immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Capitol: { - SMDVersion: '2.0', - description: 'Capitol', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/capitol', + services: { + get_actions_for: { + description: + 'Provides a list of actions that the BHG can do. Use with generate_singularity.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'target', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + generate_singularity: { + description: 'Performs action on specified target.', + parameters: [ + { + name: 'params', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_cooldown: { + description: 'Will spend 2 essentia to cool down the BHG immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Capitol: { + SMDVersion: '2.0', + description: 'Capitol', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/capitol', - services: { - rename_empire: { - description: - 'Spend some essentia to rename your empire.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Development: { - SMDVersion: '2.0', - description: 'Development Ministry', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/development', + services: { + rename_empire: { + description: 'Spend some essentia to rename your empire.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Development: { + SMDVersion: '2.0', + description: 'Development Ministry', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/development', - services: { - subsidize_one_build: { - description: - 'Instantly finish any one building on the build queue.', - parameters: [ - { - name: 'args', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - cancel_build: { - description: - 'Cancel any one building on the build queue.', - parameters: [ - { - name: 'args', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_build_queue: { - description: - 'Allows a player to instantly finish all buildings in their build queue. The cost is returned by the view method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - DistributionCenter: { - SMDVersion: '2.0', - description: 'Distribution Center', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/distributioncenter', + services: { + subsidize_one_build: { + description: 'Instantly finish any one building on the build queue.', + parameters: [ + { + name: 'args', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + cancel_build: { + description: 'Cancel any one building on the build queue.', + parameters: [ + { + name: 'args', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_build_queue: { + description: + 'Allows a player to instantly finish all buildings in their build queue. The cost is returned by the view method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + DistributionCenter: { + SMDVersion: '2.0', + description: 'Distribution Center', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/distributioncenter', - services: { - reserve: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'resources', - type: 'array', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - release_reserve: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_stored_resources: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Embassy: { - SMDVersion: '2.0', - description: 'Embassy', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/embassy', + services: { + reserve: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'resources', + type: 'array', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + release_reserve: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_stored_resources: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Embassy: { + SMDVersion: '2.0', + description: 'Embassy', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/embassy', - services: { - create_alliance: { - description: - 'Create a new alliance. Returns the same output as get_alliance_status.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - /* + services: { + create_alliance: { + description: 'Create a new alliance. Returns the same output as get_alliance_status.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + /* # create_alliance ( session_id, building_id, name ) * session_id * building_id * name */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, } */ - }, - dissolve_alliance: { - description: - 'Can only be called by alliance leader. Disbands and existing alliance.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - /* + }, + dissolve_alliance: { + description: 'Can only be called by alliance leader. Disbands and existing alliance.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + /* # dissolve_alliance ( session_id, building_id ) * session_id * building_id */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, } */ - }, - get_alliance_status: { - description: - 'Returns everything about an alliance that members should know.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - /* + }, + get_alliance_status: { + description: 'Returns everything about an alliance that members should know.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + /* # get_alliance_status ( session_id, building_id ) * session_id * building_id */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, "alliance" : { @@ -832,33 +813,33 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } } */ - }, - send_invite: { - description: - 'Can only be called by alliance leader. Invite an empire to an alliance.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'invitee_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - /* + }, + send_invite: { + description: + 'Can only be called by alliance leader. Invite an empire to an alliance.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'invitee_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + /* # send_invite ( session_id, building_id, invitee_id, [ message ] ) * session_id @@ -866,39 +847,38 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { * invitee_id * message */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, } */ - }, - withdraw_invite: { - description: - 'Can only be called by alliance leader. Delete an invitation.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'invite_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - /* + }, + withdraw_invite: { + description: 'Can only be called by alliance leader. Delete an invitation.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'invite_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + /* # withdraw_invite ( session_id, building_id, invite_id, [ message ] ) * session_id @@ -906,39 +886,38 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { * invite_id * message */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, } */ - }, - accept_invite: { - description: - 'Accept an invitation. Returns the same output as get_alliance_status.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'invite_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - /* + }, + accept_invite: { + description: 'Accept an invitation. Returns the same output as get_alliance_status.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'invite_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + /* # accept_invite ( session_id, building_id, invite_id, [ message ] ) * session_id @@ -946,38 +925,38 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { * invite_id * message */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "get_alliance_status" : { ... }, } */ - }, - reject_invite: { - description: 'Delete an invitation.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'invite_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - /* + }, + reject_invite: { + description: 'Delete an invitation.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'invite_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + /* # reject_invite ( session_id, building_id, invite_id, [ message ] ) * session_id @@ -985,36 +964,36 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { * invite_id * message */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, } */ - }, - get_pending_invites: { - description: - 'Can only be called by the alliance leader. Returns a list of invitations that have been sent out, but that have not been accepted, rejected, or withdrawn.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - /* + }, + get_pending_invites: { + description: + 'Can only be called by the alliance leader. Returns a list of invitations that have been sent out, but that have not been accepted, rejected, or withdrawn.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + /* # get_pending_invites ( session_id, building_id ) * session_id * building_id */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, "invites" : [ @@ -1027,30 +1006,29 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - get_my_invites: { - description: - 'Returns a list of invitations that have been offered to this empire.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - /* + }, + get_my_invites: { + description: 'Returns a list of invitations that have been offered to this empire.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + /* # get_my_invites ( session_id, building_id ) * session_id * building_id */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, "invites" : [ @@ -1063,62 +1041,62 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - assign_alliance_leader: { - description: - 'Sets a new empire to lead the alliance. Can only be called by the current alliance leader. Returns the same thing as get_alliance_status.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'new_leader_id', - type: 'string', - optional: false, - }, - ], - /* + }, + assign_alliance_leader: { + description: + 'Sets a new empire to lead the alliance. Can only be called by the current alliance leader. Returns the same thing as get_alliance_status.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'new_leader_id', + type: 'string', + optional: false, + }, + ], + /* # assign_alliance_leader ( session_id, building_id, new_leader_id ) * session_id * building_id * new_leader_id */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "get_alliance_status" : { ... }, } */ - }, - update_alliance: { - description: - 'Updates the properties of an alliance. Returns the same thing as get_alliance_status. Can only be called by the alliance leader.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'params', - type: 'object', - optional: false, - }, - ], - /* + }, + update_alliance: { + description: + 'Updates the properties of an alliance. Returns the same thing as get_alliance_status. Can only be called by the alliance leader.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'params', + type: 'object', + optional: false, + }, + ], + /* # update_alliance ( session_id, building_id, params ) * session_id @@ -1128,73 +1106,72 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { - description - announcements */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "get_alliance_status" : { ... }, } */ - }, - leave_alliance: { - description: - 'A member of an alliance revokes their own membership.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - /* + }, + leave_alliance: { + description: 'A member of an alliance revokes their own membership.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + /* # leave_alliance ( session_id, building_id, [ message ] ) * session_id * building_id * message */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "status" : { ... }, } */ - }, - expel_member: { - description: - 'Forcibly removes a member from an alliance. Returns the same thing as get_alliance_status. Can only be called by the alliance leader.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'empire_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - /* + }, + expel_member: { + description: + 'Forcibly removes a member from an alliance. Returns the same thing as get_alliance_status. Can only be called by the alliance leader.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'empire_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + /* # expel_member ( session_id, building_id, empire_id, [ message ] ) * session_id @@ -1202,437 +1179,436 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { * empire_id * message */ - returns: { type: 'object' }, - /* + returns: { type: 'object' }, + /* { "get_alliance_status" : { ... }, } */ - }, - view_stash: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_propositions: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - cast_vote: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'proposition_id', - type: 'string', - optional: false, - }, - { - name: 'vote', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - donate_to_stash: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'donation', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - exchange_with_stash: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'donation', - type: 'string', - optional: false, - }, - { - name: 'request', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - EnergyReserve: { - SMDVersion: '2.0', - description: 'Energy Reserve', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/energyreserve', + }, + view_stash: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_propositions: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + cast_vote: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'proposition_id', + type: 'string', + optional: false, + }, + { + name: 'vote', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + donate_to_stash: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'donation', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + exchange_with_stash: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'donation', + type: 'string', + optional: false, + }, + { + name: 'request', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + EnergyReserve: { + SMDVersion: '2.0', + description: 'Energy Reserve', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/energyreserve', + + services: { + dump: { + description: 'Converts energy into waste', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'amount', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Entertainment: { + SMDVersion: '2.0', + description: 'Entertainment', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/entertainment', - services: { - dump: { - description: 'Converts energy into waste', - parameters: [ + services: { + get_lottery_voting_options: { + description: + 'This is the starting point to a voting lottery system. The user can vote on a site once and only once per day and each vote enters him/her into a lottery. At the end of the day a lottery ticket will be drawn, and a winner will be chosen to receive 10 essentia. Every vote is equal, but the more votes you have the greater your odds of winning.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "options" : [ { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'amount', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Entertainment: { - SMDVersion: '2.0', - description: 'Entertainment', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/entertainment', - - services: { - get_lottery_voting_options: { - description: - 'This is the starting point to a voting lottery system. The user can vote on a site once and only once per day and each vote enters him/her into a lottery. At the end of the day a lottery ticket will be drawn, and a winner will be chosen to receive 10 essentia. Every vote is equal, but the more votes you have the greater your odds of winning.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "options" : [ - { - "name" : "Some Site", - "url" : "http://www.somesite.com/vote?id=44" + "name" : "Some Site", + "url" : "http://www.somesite.com/vote?id=44" }, ... ], "status" : { ... } } */ - }, - duck_quack: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'string' }, - }, - }, - }, - Exchanger: { - SMDVersion: '2.0', - description: 'Waste Exchanger', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/wasteexchanger', + }, + duck_quack: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'string' }, + }, + }, + }, + Exchanger: { + SMDVersion: '2.0', + description: 'Waste Exchanger', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/wasteexchanger', - services: { - recycle: { - description: - 'Converts waste into water, ore, and energy. You can choose which amounts of each you want, so long as their total does not go over the amount of waste you have on hand. For each unit of waste converted, the recycling center will take 1 second to complete the recycling process. However, the amount of time is reduced a bit by the level of the Waste Exchanger.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'water', - type: 'number', - optional: false, - }, - { - name: 'ore', - type: 'number', - optional: false, - }, - { - name: 'energy', - type: 'number', - optional: false, - }, - { - name: 'use_essentia', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_recycling: { - description: - 'Will spend 2 essentia to complete the current recycling job immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - FoodReserve: { - SMDVersion: '2.0', - description: 'Food Reserve', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/foodreserve', + services: { + recycle: { + description: + 'Converts waste into water, ore, and energy. You can choose which amounts of each you want, so long as their total does not go over the amount of waste you have on hand. For each unit of waste converted, the recycling center will take 1 second to complete the recycling process. However, the amount of time is reduced a bit by the level of the Waste Exchanger.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'water', + type: 'number', + optional: false, + }, + { + name: 'ore', + type: 'number', + optional: false, + }, + { + name: 'energy', + type: 'number', + optional: false, + }, + { + name: 'use_essentia', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_recycling: { + description: + 'Will spend 2 essentia to complete the current recycling job immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + FoodReserve: { + SMDVersion: '2.0', + description: 'Food Reserve', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/foodreserve', - services: { - dump: { - description: 'Converts food into waste', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'type', - type: 'string', - optional: false, - }, - { - name: 'amount', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - GeneticsLab: { - SMDVersion: '2.0', - description: 'Genetics Lab', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/geneticslab', + services: { + dump: { + description: 'Converts food into waste', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'type', + type: 'string', + optional: false, + }, + { + name: 'amount', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + GeneticsLab: { + SMDVersion: '2.0', + description: 'Genetics Lab', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/geneticslab', - services: { - prepare_experiment: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - run_experiment: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'spy_id', - type: 'string', - optional: false, - }, - { - name: 'affinity', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - rename_species: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'params', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Intelligence: { - SMDVersion: '2.0', - description: 'Intelligence', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/intelligence', + services: { + prepare_experiment: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + run_experiment: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'spy_id', + type: 'string', + optional: false, + }, + { + name: 'affinity', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + rename_species: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'params', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Intelligence: { + SMDVersion: '2.0', + description: 'Intelligence', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/intelligence', - services: { - train_spy: { - description: 'Allows you to train more spies', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'quantity', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + services: { + train_spy: { + description: 'Allows you to train more spies', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'quantity', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "trained" : 3, "not_trained" : 2 } */ - }, - view_spies: { - description: - 'Returns the list of spies you have on your roster.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + }, + view_spies: { + description: 'Returns the list of spies you have on your roster.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "spies" : { @@ -1649,201 +1625,200 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } } */ - }, - burn_spy: { - description: - 'Allows you to eliminate one of your spies from your payroll.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'spy_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + burn_spy: { + description: 'Allows you to eliminate one of your spies from your payroll.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'spy_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, } */ - }, - assign_spy: { - description: 'Set a spy on a new task.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'spy_id', - type: 'string', - optional: false, - }, - { - name: 'assignment', - type: 'string', - optional: false, - }, // "Idle", "Counter Intelligence", "Sting" - ], - returns: { type: 'object' }, - }, - name_spy: { - description: 'Set the name of the spy', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'spy_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - name_spies: { - description: 'Set the name of all spies', - parameters: [ - { - name: 'options', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_training: { - description: - 'Will spend 1 essentia per spy to complete the training of all spies immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, // view - }, - }, - }, - LibraryOfJith: { - SMDVersion: '2.0', - description: 'Library Of Jith', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/libraryofjith', + }, + assign_spy: { + description: 'Set a spy on a new task.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'spy_id', + type: 'string', + optional: false, + }, + { + name: 'assignment', + type: 'string', + optional: false, + }, // "Idle", "Counter Intelligence", "Sting" + ], + returns: { type: 'object' }, + }, + name_spy: { + description: 'Set the name of the spy', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'spy_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + name_spies: { + description: 'Set the name of all spies', + parameters: [ + { + name: 'options', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_training: { + description: + 'Will spend 1 essentia per spy to complete the training of all spies immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, // view + }, + }, + }, + LibraryOfJith: { + SMDVersion: '2.0', + description: 'Library Of Jith', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/libraryofjith', - services: { - research_species: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'empire_id', - type: 'string', - optional: false, - }, - ], - }, - }, - }, - MercenariesGuild: { - SMDVersion: '2.0', - description: 'Mercenaries Guild', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/mercenariesguild', + services: { + research_species: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'empire_id', + type: 'string', + optional: false, + }, + ], + }, + }, + }, + MercenariesGuild: { + SMDVersion: '2.0', + description: 'Mercenaries Guild', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/mercenariesguild', - services: { - add_to_market: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'spy_id', - type: 'string', - optional: false, - }, - { - name: 'ask', - type: 'number', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - get_spies: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + add_to_market: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'spy_id', + type: 'string', + optional: false, + }, + { + name: 'ask', + type: 'number', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + get_spies: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "spies" : [ { @@ -1857,163 +1832,161 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - withdraw_from_market: { - description: - 'Remove a trade that you have offered and collect the items up for trade.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - accept_from_market: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_market: { - description: - 'Displays a list of trades available at the present time.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - view_my_market: { - description: - 'Displays a list of trades the current user has posted.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - get_trade_ships: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'target_body_id', - type: 'string', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - report_abuse: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Mining: { - SMDVersion: '2.0', - description: 'Mining Ministry', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/miningministry', + }, + withdraw_from_market: { + description: + 'Remove a trade that you have offered and collect the items up for trade.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + accept_from_market: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_market: { + description: 'Displays a list of trades available at the present time.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + view_my_market: { + description: 'Displays a list of trades the current user has posted.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + get_trade_ships: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'target_body_id', + type: 'string', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + report_abuse: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Mining: { + SMDVersion: '2.0', + description: 'Mining Ministry', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/miningministry', - services: { - view_platforms: { - description: - 'Returns a list of the mining platforms currently controlled by this ministry.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + view_platforms: { + description: + 'Returns a list of the mining platforms currently controlled by this ministry.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "max_platforms" : 1, @@ -2051,24 +2024,24 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - view_ships: { - description: - 'Shows you the ships that are working in the mining fleet, and available to work in the mining fleet.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + view_ships: { + description: + 'Shows you the ships that are working in the mining fleet, and available to work in the mining fleet.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "ships" : [ { @@ -2084,207 +2057,204 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - add_cargo_ship_to_fleet: { - description: - 'Take a cargo ship from the space port and add it to the mining fleet.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, //status - }, - remove_cargo_ship_from_fleet: { - description: - 'Tell one of the cargo ships in the mining fleet to come home and park at the space port.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, //status - }, - abandon_platform: { - description: - 'Close down an existing mining platform.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'platform_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, //status - }, - mass_abandon_platform: { - description: - 'Close down all existing mining platforms.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, //status - }, - }, - }, - MissionCommand: { - SMDVersion: '2.0', - description: 'Mission Command', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/missioncommand', + }, + add_cargo_ship_to_fleet: { + description: 'Take a cargo ship from the space port and add it to the mining fleet.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, //status + }, + remove_cargo_ship_from_fleet: { + description: + 'Tell one of the cargo ships in the mining fleet to come home and park at the space port.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, //status + }, + abandon_platform: { + description: 'Close down an existing mining platform.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'platform_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, //status + }, + mass_abandon_platform: { + description: 'Close down all existing mining platforms.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, //status + }, + }, + }, + MissionCommand: { + SMDVersion: '2.0', + description: 'Mission Command', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/missioncommand', - services: { - get_missions: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - complete_mission: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'mission_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - skip_mission: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'mission_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Network19: { - SMDVersion: '2.0', - description: 'Network19', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/network19', + services: { + get_missions: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + complete_mission: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'mission_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + skip_mission: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'mission_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Network19: { + SMDVersion: '2.0', + description: 'Network19', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/network19', - services: { - restrict_coverage: { - description: - 'You can enact or disband a policy to restrict what Network 19 covers about your planet. Restricting coverage does make your citizens unhappy.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'onoff', - type: 'number', - optional: false, - }, // 0 or 1 - ], - returns: { type: 'object' }, - }, - view_news: { - description: - 'Get the top 100 headlines from your region of space. It also returns a list of RSS feeds that can be used outside the game to see the same news in a given region.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + restrict_coverage: { + description: + 'You can enact or disband a policy to restrict what Network 19 covers about your planet. Restricting coverage does make your citizens unhappy.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'onoff', + type: 'number', + optional: false, + }, // 0 or 1 + ], + returns: { type: 'object' }, + }, + view_news: { + description: + 'Get the top 100 headlines from your region of space. It also returns a list of RSS feeds that can be used outside the game to see the same news in a given region.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "news" : [ { @@ -2299,78 +2269,75 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { get_status() } } */ - }, - }, - }, - Observatory: { - SMDVersion: '2.0', - description: 'Observatory', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/observatory', + }, + }, + }, + Observatory: { + SMDVersion: '2.0', + description: 'Observatory', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/observatory', - services: { - abandon_probe: { - description: - 'The probe is deactivated, and allowed to burn up in the star.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'star_id', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, // status - }, - abandon_all_probes: { - description: - 'All probes are deactivated, and allowed to burn up in the stars.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, // status - }, - get_probed_stars: { - description: - 'Returns a list of the stars that have been probed by this planet.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + abandon_probe: { + description: 'The probe is deactivated, and allowed to burn up in the star.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'star_id', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, // status + }, + abandon_all_probes: { + description: 'All probes are deactivated, and allowed to burn up in the stars.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, // status + }, + get_probed_stars: { + description: 'Returns a list of the stars that have been probed by this planet.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "stars" : [ @@ -2383,115 +2350,114 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - }, - }, - OreStorage: { - SMDVersion: '2.0', - description: 'Ore Storage', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/orestorage', + }, + }, + }, + OreStorage: { + SMDVersion: '2.0', + description: 'Ore Storage', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/orestorage', - services: { - dump: { - description: 'Converts ore into waste', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'type', - type: 'string', - optional: false, - }, - { - name: 'amount', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Park: { - SMDVersion: '2.0', - description: 'Park', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/park', + services: { + dump: { + description: 'Converts ore into waste', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'type', + type: 'string', + optional: false, + }, + { + name: 'amount', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Park: { + SMDVersion: '2.0', + description: 'Park', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/park', - services: { - throw_a_party: { - description: - "Initiates a party. It will cost you 10,000 food, and the party will last for a day. For 10,000 food you'll get 3,000 happiness. For each type of food available in quantities of 500 or more, you'll get a multiplier added to that. So if you have 4 types of food, you'll get 12,000 happiness. In addition, you get a 0.3 to your multiplier for each level of park that you have. Therefore a level 10 park is the same as adding three extra foods to your party!", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, // status - }, - subsidize_party: { - description: - 'Will spend 2 essentia to complete the current party immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, // view - }, - }, + services: { + throw_a_party: { + description: + "Initiates a party. It will cost you 10,000 food, and the party will last for a day. For 10,000 food you'll get 3,000 happiness. For each type of food available in quantities of 500 or more, you'll get a multiplier added to that. So if you have 4 types of food, you'll get 12,000 happiness. In addition, you get a 0.3 to your multiplier for each level of park that you have. Therefore a level 10 park is the same as adding three extra foods to your party!", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, // status + }, + subsidize_party: { + description: 'Will spend 2 essentia to complete the current party immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, }, - PlanetaryCommand: { - SMDVersion: '2.0', - description: 'Planetary Command', + ], + returns: { type: 'object' }, // view + }, + }, + }, + PlanetaryCommand: { + SMDVersion: '2.0', + description: 'Planetary Command', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/planetarycommand', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/planetarycommand', - services: { - view_plans: { - description: - "Returns a list of all the plans you've collected through various means.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + view_plans: { + description: + "Returns a list of all the plans you've collected through various means.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "plans" : [ @@ -2504,119 +2470,118 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - view_incoming_supply_chains: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Recycler: { - SMDVersion: '2.0', - description: 'Waste Recycler', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/wasterecycling', + }, + view_incoming_supply_chains: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Recycler: { + SMDVersion: '2.0', + description: 'Waste Recycler', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/wasterecycling', - services: { - recycle: { - description: - 'Converts waste into water, ore, and energy. You can choose which amounts of each you want, so long as their total does not go over the amount of waste you have on hand. For each unit of waste converted, the recycling center will take 1 second to complete the recycling process. However, the amount of time is reduced a bit by the level of the Recycling Center.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'water', - type: 'number', - optional: false, - }, - { - name: 'ore', - type: 'number', - optional: false, - }, - { - name: 'energy', - type: 'number', - optional: false, - }, - { - name: 'use_essentia', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_recycling: { - description: - 'Will spend 2 essentia to complete the current recycling job immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Security: { - SMDVersion: '2.0', - description: 'Security', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/security', + services: { + recycle: { + description: + 'Converts waste into water, ore, and energy. You can choose which amounts of each you want, so long as their total does not go over the amount of waste you have on hand. For each unit of waste converted, the recycling center will take 1 second to complete the recycling process. However, the amount of time is reduced a bit by the level of the Recycling Center.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'water', + type: 'number', + optional: false, + }, + { + name: 'ore', + type: 'number', + optional: false, + }, + { + name: 'energy', + type: 'number', + optional: false, + }, + { + name: 'use_essentia', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_recycling: { + description: + 'Will spend 2 essentia to complete the current recycling job immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Security: { + SMDVersion: '2.0', + description: 'Security', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/security', - services: { - view_prisoners: { - description: - 'Displays a list of the spies that have been captured.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + services: { + view_prisoners: { + description: 'Displays a list of the spies that have been captured.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "prisoners" : [ @@ -2630,73 +2595,72 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - execute_prisoner: { - description: - "You may choose to execute a prisoner rather than letting him serve his sentence and be released. However, that will cost you 10,000 times the prisoner's level in happiness from your planet. So a level 11 prisoner would cost you 110,000 happiness.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'prisoner_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - release_prisoner: { - description: - 'You may choose to release a prisoner by calling this method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'prisoner_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_foreign_spies: { - description: - 'Displays a list of the spies that are on your planet, and have a level lower than your security ministry.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + }, + execute_prisoner: { + description: + "You may choose to execute a prisoner rather than letting him serve his sentence and be released. However, that will cost you 10,000 times the prisoner's level in happiness from your planet. So a level 11 prisoner would cost you 110,000 happiness.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'prisoner_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + release_prisoner: { + description: 'You may choose to release a prisoner by calling this method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'prisoner_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_foreign_spies: { + description: + 'Displays a list of the spies that are on your planet, and have a level lower than your security ministry.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "spies" : [ @@ -2709,85 +2673,83 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - }, - }, - Shipyard: { - SMDVersion: '2.0', - description: 'Shipyard', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/shipyard', + }, + }, + }, + Shipyard: { + SMDVersion: '2.0', + description: 'Shipyard', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/shipyard', - services: { - view_build_queue: { - description: - 'Retrieves what is already being built at this shipyard.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - subsidize_build_queue: { - description: - 'Will spend 1 essentia per ship to complete the current build queue immediately.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_ship: { - description: - 'Will spend 1 essentia to build the ship immediately.', - parameters: [ - { - name: 'args', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_buildable: { - description: - "Returns a list of buildable ships and their costs, and if they're not buildable, gives a reason why not in the form of an exception.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + view_build_queue: { + description: 'Retrieves what is already being built at this shipyard.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + subsidize_build_queue: { + description: + 'Will spend 1 essentia per ship to complete the current build queue immediately.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_ship: { + description: 'Will spend 1 essentia to build the ship immediately.', + parameters: [ + { + name: 'args', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_buildable: { + description: + "Returns a list of buildable ships and their costs, and if they're not buildable, gives a reason why not in the form of an exception.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "buildable" : { "probe" : { @@ -2811,33 +2773,33 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { get_status() }, } */ - }, - build_ship: { - description: 'Adds a ship to the build queue.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'type', - type: 'string', - optional: false, - }, //'probe','colony_ship','spy_pod','cargo_ship','space_station','smuggler_ship','mining_platform_ship','terraforming_platform_ship', or 'gas_giant_settlement_ship' - { - name: 'quantity', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + build_ship: { + description: 'Adds a ship to the build queue.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'type', + type: 'string', + optional: false, + }, //'probe','colony_ship','spy_pod','cargo_ship','space_station','smuggler_ship','mining_platform_ship','terraforming_platform_ship', or 'gas_giant_settlement_ship' + { + name: 'quantity', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "ship_build_queue" : { "next_completed" : "01 31 2010 13:09:05 +0600", @@ -2853,60 +2815,59 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { get_status() } } */ - }, - build_ships: { - description: 'Adds ships to build queues.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'options', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + build_ships: { + description: 'Adds ships to build queues.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'options', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() } } */ - }, - }, - }, - SpacePort: { - SMDVersion: '2.0', - description: 'SpacePort', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/spaceport', + }, + }, + }, + SpacePort: { + SMDVersion: '2.0', + description: 'SpacePort', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/spaceport', - services: { - prepare_fetch_spies: { - description: - 'Gathers the information needed to call the fetch_spies method', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'on_body_id', - type: 'string', - optional: false, - }, - { - name: 'to_body_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + prepare_fetch_spies: { + description: 'Gathers the information needed to call the fetch_spies method', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'on_body_id', + type: 'string', + optional: false, + }, + { + name: 'to_body_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "ships" : [ @@ -2936,39 +2897,39 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - fetch_spies: { - description: - 'Sends a specified ship to fetch specified spies from on_body_id, and bring them back to to_body_id. See also prepare_fetch_spies', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'on_body_id', - type: 'string', - optional: false, - }, - { - name: 'to_body_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - { - name: 'spy_ids', - type: 'array', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + fetch_spies: { + description: + 'Sends a specified ship to fetch specified spies from on_body_id, and bring them back to to_body_id. See also prepare_fetch_spies', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'on_body_id', + type: 'string', + optional: false, + }, + { + name: 'to_body_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + { + name: 'spy_ids', + type: 'array', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "ship" : { "id" : "id-goes-here", @@ -2982,29 +2943,28 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - prepare_send_spies: { - description: - 'Gathers the information needed to call the send_spies method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'on_body_id', - type: 'string', - optional: false, - }, - { - name: 'to_body_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + prepare_send_spies: { + description: 'Gathers the information needed to call the send_spies method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'on_body_id', + type: 'string', + optional: false, + }, + { + name: 'to_body_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "ships" : [ @@ -3033,39 +2993,39 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - send_spies: { - description: - 'Sends one or more of spies to a planet using a selected ship. See also prepare_send_spies.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'on_body_id', - type: 'string', - optional: false, - }, - { - name: 'to_body_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - { - name: 'spy_ids', - type: 'array', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + send_spies: { + description: + 'Sends one or more of spies to a planet using a selected ship. See also prepare_send_spies.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'on_body_id', + type: 'string', + optional: false, + }, + { + name: 'to_body_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + { + name: 'spy_ids', + type: 'array', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "ship" : { "id" : "id-goes-here", @@ -3082,52 +3042,52 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } * */ - }, + }, - get_fleet_for: { - description: - 'Provides a list of incoming ships and ships that are available to send to a specific target. Use with send_ship_types.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'from_body_id', - type: 'string', - optional: false, - }, - { - name: 'target', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_ships_for: { - description: - 'Provides a list of incoming ships and ships that are available to send to a specific target. Use with send_ship.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'from_body_id', - type: 'string', - optional: false, - }, - { - name: 'target', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + get_fleet_for: { + description: + 'Provides a list of incoming ships and ships that are available to send to a specific target. Use with send_ship_types.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'from_body_id', + type: 'string', + optional: false, + }, + { + name: 'target', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_ships_for: { + description: + 'Provides a list of incoming ships and ships that are available to send to a specific target. Use with send_ship.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'from_body_id', + type: 'string', + optional: false, + }, + { + name: 'target', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "incoming" : [ { @@ -3182,179 +3142,178 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - name_ship: { - description: 'Set the name of a ship.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - * session_id - * building_id - * ship_id - * name - */ - }, - recall_ship: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - recall_all: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, + }, + name_ship: { + description: 'Set the name of a ship.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + * session_id + * building_id + * ship_id + * name + */ + }, + recall_ship: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + recall_all: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, - scuttle_ship: { - description: - 'Destroy a ship that you no longer need. It must be docked to scuttle it.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - send_fleet: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'ship_ids', - type: 'array', - optional: false, - }, - { - name: 'target', - type: 'string', - optional: false, - }, - { - name: 'set_speed', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - send_ship_types: { - description: - 'Sends a group of ships to a specified body or star. Use with get_fleet_for.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - { - name: 'target', - type: 'string', - optional: false, - }, - { - name: 'type_params', - type: 'object', - optional: false, - }, - { - name: 'arrival', - type: 'object', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - send_ship: { - description: - 'Sends a ship to a specified body or star. Use with get_ships_for.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'string', - optional: false, - }, - { - name: 'target', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + scuttle_ship: { + description: + 'Destroy a ship that you no longer need. It must be docked to scuttle it.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + send_fleet: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'ship_ids', + type: 'array', + optional: false, + }, + { + name: 'target', + type: 'string', + optional: false, + }, + { + name: 'set_speed', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + send_ship_types: { + description: + 'Sends a group of ships to a specified body or star. Use with get_fleet_for.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + { + name: 'target', + type: 'string', + optional: false, + }, + { + name: 'type_params', + type: 'object', + optional: false, + }, + { + name: 'arrival', + type: 'object', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + send_ship: { + description: 'Sends a ship to a specified body or star. Use with get_ships_for.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'string', + optional: false, + }, + { + name: 'target', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "ship" : { @@ -3382,38 +3341,38 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } } */ - }, - view_all_ships: { - description: 'Returns a list of all ships', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'paging', - type: 'object', - optional: true, - }, - { - name: 'filter', - type: 'object', - optional: true, - }, - { - name: 'sort', - type: 'string', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + }, + view_all_ships: { + description: 'Returns a list of all ships', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'paging', + type: 'object', + optional: true, + }, + { + name: 'filter', + type: 'object', + optional: true, + }, + { + name: 'sort', + type: 'string', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "ships" : [ { @@ -3430,29 +3389,29 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - view_foreign_ships: { - description: - 'Shows you all the foreign ships that are incoming. However, the list is filtered by the stealth of the ship vs the level of the SpacePort.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + }, + view_foreign_ships: { + description: + 'Shows you all the foreign ships that are incoming. However, the list is filtered by the stealth of the ship vs the level of the SpacePort.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "ships" : [ { @@ -3476,29 +3435,29 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - view_ships_travelling: { - description: - 'Returns a list of the ships that are travelling to or from this planet. NOTE: All inbound/outbound ships are shown regardless of which space port they will eventually land at.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + }, + view_ships_travelling: { + description: + 'Returns a list of the ships that are travelling to or from this planet. NOTE: All inbound/outbound ships are shown regardless of which space port they will eventually land at.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "number_of_ships_travelling" : 30, @@ -3522,434 +3481,1116 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - view_ships_orbiting: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - view_battle_logs: { - description: - 'Shows you the battle logs for your empire with the most recent action listed first. This data will be cleaned out every seven days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - }, + }, + view_ships_orbiting: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + view_battle_logs: { + description: + 'Shows you the battle logs for your empire with the most recent action listed first. This data will be cleaned out every seven days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, }, - SpaceStationLab: { - SMDVersion: '2.0', - description: 'Space Station Lab', + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + SpaceStationLab: { + SMDVersion: '2.0', + description: 'Space Station Lab', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/ssla', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/ssla', - services: { - make_plan: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'type', - type: 'string', - optional: false, - }, - { - name: 'level', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize_plan: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - SubspaceSupplyDepot: { - SMDVersion: '2.0', - description: 'Subspace Supply Depot', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/subspacesupplydepot', + services: { + make_plan: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'type', + type: 'string', + optional: false, + }, + { + name: 'level', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize_plan: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + SubspaceSupplyDepot: { + SMDVersion: '2.0', + description: 'Subspace Supply Depot', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/subspacesupplydepot', - services: { - transmit_food: { - description: 'Convert 3600 seconds into 3600 food.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, + services: { + transmit_food: { + description: 'Convert 3600 seconds into 3600 food.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + transmit_energy: { + description: 'Convert 3600 seconds into 3600 energy.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + transmit_ore: { + description: 'Convert 3600 seconds into 3600 ore.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + transmit_water: { + description: 'Convert 3600 seconds into 3600 water.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + complete_build_queue: { + description: 'Trade seconds for build queue time.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + TempleOfTheDrajilites: { + SMDVersion: '2.0', + description: 'Temple Of The Drajilites', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/templeofthedrajilites', + + services: { + list_planets: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'star_id', + type: 'string', + optional: true, + }, + ], + }, + view_planet: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'planet_id', + type: 'string', + optional: false, + }, + ], + }, + }, + }, + ThemePark: { + SMDVersion: '2.0', + description: 'Theme Park', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/themepark', + + services: { + operate: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + TheDillonForge: { + SMDVersion: '2.0', + description: 'The Dillon Forge', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/thedillonforge', + + services: { + make_plan: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'plan_class', + type: 'string', + optional: false, + }, + { + name: 'level', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + split_plan: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'plan_class', + type: 'string', + optional: false, + }, + { + name: 'level', + type: 'number', + optional: false, + }, + { + name: 'extra_build_level', + type: 'number', + optional: false, + }, + { + name: 'quantity', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + subsidize: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Trade: { + SMDVersion: '2.0', + description: 'Trade', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/trade', + + services: { + add_to_market: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'offer', + type: 'object', + optional: false, + }, + { + name: 'ask', + type: 'number', + optional: false, + }, + { + name: 'options', + type: 'object', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + get_ship_summary: { + description: + 'Returns a list of ships that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_ships: { + description: + 'Returns a list of ships that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "ships" : [ { - name: 'building_id', - type: 'string', - optional: false, + "id" : "id-goes-here", + "name" : "Enterprise", + "type" : "probe", + "hold_size" : 0, + "berth_level" : 1, + "speed" : 3900 }, + ... ], - returns: { type: 'object' }, - }, - transmit_energy: { - description: - 'Convert 3600 seconds into 3600 energy.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, + "cargo_space_used_each" : 10000, + "status" : { ... } + } + */ + }, + get_prisoners: { + description: + 'Returns a list of prisoners that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "prisoners" : [ { - name: 'building_id', - type: 'string', - optional: false, + "id" : "id-goes-here", + "name" : "Jack Bauer", + "level" : "5" }, + ... ], - returns: { type: 'object' }, - }, - transmit_ore: { - description: 'Convert 3600 seconds into 3600 ore.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, + "cargo_space_used_each" : 100, + "status" : { ... } + } + */ + }, + get_plan_summary: { + description: + 'Returns a list of plans that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_plans: { + description: + 'Returns a list of plans that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "plans" : [ { - name: 'building_id', - type: 'string', - optional: false, + "id" : "id-goes-here", + "name" : "Intelligence Ministry", + "level" : "7", + "extra_build_level" : "0" # some special plans will build a building from their level all the way to this number }, + ... ], - returns: { type: 'object' }, - }, - transmit_water: { - description: - 'Convert 3600 seconds into 3600 water.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, + "cargo_space_used_each" : 100, + "status" : { ... } + } + */ + }, + get_glyph_summary: { + description: + 'Returns a list of glyphs that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_glyphs: { + description: + 'Returns a list of glyphs that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "glyphs" : [ { - name: 'building_id', - type: 'string', - optional: false, + "id" : "id-goes-here", + "type" : "bauxite" }, + ... ], - returns: { type: 'object' }, - }, - complete_build_queue: { - description: 'Trade seconds for build queue time.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - TempleOfTheDrajilites: { - SMDVersion: '2.0', - description: 'Temple Of The Drajilites', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/templeofthedrajilites', - - services: { - list_planets: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'star_id', - type: 'string', - optional: true, - }, - ], - }, - view_planet: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'planet_id', - type: 'string', - optional: false, - }, - ], - }, - }, - }, - ThemePark: { - SMDVersion: '2.0', - description: 'Theme Park', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/themepark', - - services: { - operate: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - TheDillonForge: { - SMDVersion: '2.0', - description: 'The Dillon Forge', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/thedillonforge', - - services: { - make_plan: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'plan_class', - type: 'string', - optional: false, - }, - { - name: 'level', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - split_plan: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'plan_class', - type: 'string', - optional: false, - }, - { - name: 'level', - type: 'number', - optional: false, - }, - { - name: 'extra_build_level', - type: 'number', - optional: false, - }, - { - name: 'quantity', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - subsidize: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Trade: { - SMDVersion: '2.0', - description: 'Trade', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/trade', + "cargo_space_used_each" : 100, + "status" : { ... } + } + */ + }, + withdraw_from_market: { + description: + 'Remove a trade that you have offered and collect the items up for trade.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + accept_from_market: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_market: { + description: 'Displays a list of trades available at the present time.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + { + name: 'filter', + type: 'string', + optional: true, + }, //food ore water waste energy glyph prisoner ship plan + ], + returns: { type: 'object' }, + }, + view_my_market: { + description: 'Displays a list of trades the current user has posted.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + get_trade_ships: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'target_body_id', + type: 'string', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + get_waste_ships: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_supply_ships: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_supply_chains: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_waste_chains: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + create_supply_chain: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'target_id', + type: 'number', + optional: false, + }, + { + name: 'resource_type', + type: 'number', + optional: false, + }, + { + name: 'resource_hour', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + delete_supply_chain: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'supply_chain_id', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + update_supply_chain: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'supply_chain_id', + type: 'number', + optional: false, + }, + { + name: 'resource_type', + type: 'number', + optional: false, + }, + { + name: 'resource_hour', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + update_waste_chain: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'waste_chain_id', + type: 'number', + optional: false, + }, + { + name: 'waste_hour', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + add_supply_ship_to_fleet: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + add_waste_ship_to_fleet: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + remove_supply_ship_from_fleet: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + remove_waste_ship_from_fleet: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'ship_id', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_stored_resources: { + description: + 'Returns a list of the resources you have stored to make it easier to identify what you want to trade.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "status" : { ... }, + "cargo_space_used_each" : 100, + "resources" : { + "water" : 14000, + "waste" : 393, + "bauxite" : 47, + "cheese" : 1193, + ... + } + } + */ + }, + push_items: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'target_id', + type: 'string', + optional: false, + }, + { + name: 'items', + type: 'object', + optional: false, + }, + { + name: 'options', + type: 'object', + optional: true, + }, + ], + /* + items array of objects + resouce format = { + "type" : "bauxite", //allowed = water, energy, waste, essentia, bean, lapis, potato, apple, root, corn, cider, wheat, bread, soup, chip, pie, pancake, milk, meal, algae, syrup, fungus, burger, shake, beetle, rutile, chromite, chalcopyrite, galena, gold, uraninite, bauxite, goethite, halite, gypsum, trona, kerogen, methane, anthracite, sulfur, zircon, monazite, fluorite, beryl, or magnetite + "quantity" : 10000 + } + plan format = { + "type" : "plan", + "plan_id" : "id-goes-here" + } + glyph format = { + "type" : "glyph", + "glyph_id" : "id-goes-here" + } + options + + ship_id + + stay (if == 1 then it will stay on planet if there is an available dock) + */ + returns: { type: 'object' }, + /* + */ + }, + report_abuse: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Transporter: { + SMDVersion: '2.0', + description: 'Transporter', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/transporter', - services: { - add_to_market: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'offer', - type: 'object', - optional: false, - }, - { - name: 'ask', - type: 'number', - optional: false, - }, - { - name: 'options', - type: 'object', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - get_ship_summary: { - description: - 'Returns a list of ships that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_ships: { - description: - 'Returns a list of ships that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + services: { + add_to_market: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'offer', + type: 'object', + optional: false, + }, + { + name: 'ask', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_ship_summary: { + description: + 'Returns a list of ships that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_ships: { + description: + 'Returns a list of ships that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "ships" : [ { @@ -3966,24 +4607,24 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - get_prisoners: { - description: - 'Returns a list of prisoners that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + get_prisoners: { + description: + 'Returns a list of prisoners that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "prisoners" : [ { @@ -3997,41 +4638,41 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - get_plan_summary: { - description: - 'Returns a list of plans that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_plans: { - description: - 'Returns a list of plans that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + get_plan_summary: { + description: + 'Returns a list of plans that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_plans: { + description: + 'Returns a list of plans that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "plans" : [ { @@ -4046,41 +4687,41 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - get_glyph_summary: { - description: - 'Returns a list of glyphs that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_glyphs: { - description: - 'Returns a list of glyphs that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + get_glyph_summary: { + description: + 'Returns a list of glyphs that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_glyphs: { + description: + 'Returns a list of glyphs that may be traded. Used with the add_trade method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "glyphs" : [ { @@ -4093,394 +4734,114 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - withdraw_from_market: { - description: - 'Remove a trade that you have offered and collect the items up for trade.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - accept_from_market: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_market: { - description: - 'Displays a list of trades available at the present time.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - { - name: 'filter', - type: 'string', - optional: true, - }, //food ore water waste energy glyph prisoner ship plan - ], - returns: { type: 'object' }, - }, - view_my_market: { - description: - 'Displays a list of trades the current user has posted.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - get_trade_ships: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'target_body_id', - type: 'string', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - get_waste_ships: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_supply_ships: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_supply_chains: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_waste_chains: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - create_supply_chain: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'target_id', - type: 'number', - optional: false, - }, - { - name: 'resource_type', - type: 'number', - optional: false, - }, - { - name: 'resource_hour', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - delete_supply_chain: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'supply_chain_id', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - update_supply_chain: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'supply_chain_id', - type: 'number', - optional: false, - }, - { - name: 'resource_type', - type: 'number', - optional: false, - }, - { - name: 'resource_hour', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - update_waste_chain: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'waste_chain_id', - type: 'number', - optional: false, - }, - { - name: 'waste_hour', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - add_supply_ship_to_fleet: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - add_waste_ship_to_fleet: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - remove_supply_ship_from_fleet: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - remove_waste_ship_from_fleet: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'ship_id', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_stored_resources: { - description: - 'Returns a list of the resources you have stored to make it easier to identify what you want to trade.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + withdraw_from_market: { + description: + 'Remove a trade that you have offered and collect the items up for trade.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + accept_from_market: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_market: { + description: 'Displays a list of trades available at the present time.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + { + name: 'filter', + type: 'string', + optional: true, + }, //food ore water waste energy glyph prisoner ship plan + ], + returns: { type: 'object' }, + }, + view_my_market: { + description: 'Displays a list of trades the current user has posted.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + get_stored_resources: { + description: + 'Returns a list of the resources you have stored to make it easier to identify what you want to trade.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "cargo_space_used_each" : 100, @@ -4493,37 +4854,32 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } } */ - }, - push_items: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'target_id', - type: 'string', - optional: false, - }, - { - name: 'items', - type: 'object', - optional: false, - }, - { - name: 'options', - type: 'object', - optional: true, - }, - ], - /* + }, + push_items: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'target_id', + type: 'string', + optional: false, + }, + { + name: 'items', + type: 'object', + optional: false, + }, + ], + /* items array of objects resouce format = { "type" : "bauxite", //allowed = water, energy, waste, essentia, bean, lapis, potato, apple, root, corn, cider, wheat, bread, soup, chip, pie, pancake, milk, meal, algae, syrup, fungus, burger, shake, beetle, rutile, chromite, chalcopyrite, galena, gold, uraninite, bauxite, goethite, halite, gypsum, trona, kerogen, methane, anthracite, sulfur, zircon, monazite, fluorite, beryl, or magnetite @@ -4537,641 +4893,235 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "type" : "glyph", "glyph_id" : "id-goes-here" } - options - + ship_id - + stay (if == 1 then it will stay on planet if there is an available dock) */ - returns: { type: 'object' }, - /* - */ - }, - report_abuse: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Transporter: { - SMDVersion: '2.0', - description: 'Transporter', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/transporter', + returns: { type: 'object' }, + /* + */ + }, + trade_one_for_one: { + description: + 'Lacuna Expanse Corp will do one for one trades of any resource in exchange for 3 essentia.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'have', + type: 'string', + optional: false, + }, //resource type + { + name: 'want', + type: 'string', + optional: false, + }, //resource type + { + name: 'quantity', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + */ + }, + report_abuse: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'trade_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + WaterStorage: { + SMDVersion: '2.0', + description: 'Water Storage', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/waterstorage', - services: { - add_to_market: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'offer', - type: 'object', - optional: false, - }, - { - name: 'ask', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, + services: { + dump: { + description: 'Converts water into waste', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'amount', + type: 'number', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + }, + Empire: { + SMDVersion: '2.0', + description: 'SMD service demonstration', + + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/empire', + + services: { + is_name_available: { + description: 'check if empire name is available', + parameters: [{ name: 'name', type: 'string', optional: false }], + returns: { type: 'object' }, + }, + logout: { + description: 'logout empire', + parameters: { + session_id: { type: 'string', optional: false }, + }, + returns: { type: 'object' }, + }, + login: { + description: 'login empire', + parameters: { + name: { type: 'string', optional: false }, + password: { type: 'string', optional: false }, + api_key: { type: 'string', optional: false }, + browser: { type: 'string', optional: false }, + }, + returns: { type: 'object' }, + }, + fetch_captcha: { + description: 'fetch a captcha for account creation', + parameters: [], + returns: { type: 'object' }, + }, + create: { + description: 'create empire', + parameters: { + name: { type: 'string', optional: false }, + password: { type: 'string', optional: true }, + password1: { type: 'string', optional: true }, + captcha_guid: { type: 'string', optional: true }, + captcha_solution: { + type: 'string', + optional: true, + }, + email: { type: 'string', optional: true }, + facebook_uid: { type: 'string', optional: true }, + facebook_token: { type: 'string', optional: true }, + invite_code: { type: 'string', optional: true }, + }, + returns: { type: 'object' }, + }, + found: { + description: 'found empire', + parameters: { + empire_id: { type: 'string', optional: true }, + api_key: { type: 'string', optional: true }, + invite_code: { type: 'string', optional: true }, + }, + returns: { type: 'object' }, + }, + get_status: { + description: 'get quick empire status', + parameters: { + session_id: { type: 'string', optional: false }, + }, + returns: { type: 'object' }, + }, + get_own_profile: { + description: + "Provides a list of the editable properties of the current empire's profile. See also the edit_profile and view_public_profile methods.", + parameters: { + session_id: { type: 'string', optional: false }, + }, + returns: { type: 'object' }, + /* + { + "profile" : { + "description" : "description goes here", + "status_message" : "status message goes here", + "medals" : { + "building1" : { + "name" : "Built Level 1 Building", + "image" : "building1", + "note" : "note about how this was achieved, if any, goes here", + "date" : "01 31 2010 13:09:05 +0600", + "public" : 1 + }, + ... + } }, - get_ship_summary: { - description: - 'Returns a list of ships that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_ships: { - description: - 'Returns a list of ships that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "ships" : [ - { - "id" : "id-goes-here", - "name" : "Enterprise", - "type" : "probe", - "hold_size" : 0, - "berth_level" : 1, - "speed" : 3900 - }, - ... - ], - "cargo_space_used_each" : 10000, - "status" : { ... } - } - */ - }, - get_prisoners: { - description: - 'Returns a list of prisoners that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "prisoners" : [ - { - "id" : "id-goes-here", - "name" : "Jack Bauer", - "level" : "5" - }, - ... - ], - "cargo_space_used_each" : 100, - "status" : { ... } - } - */ - }, - get_plan_summary: { - description: - 'Returns a list of plans that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_plans: { - description: - 'Returns a list of plans that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "plans" : [ - { - "id" : "id-goes-here", - "name" : "Intelligence Ministry", - "level" : "7", - "extra_build_level" : "0" # some special plans will build a building from their level all the way to this number - }, - ... - ], - "cargo_space_used_each" : 100, - "status" : { ... } - } - */ - }, - get_glyph_summary: { - description: - 'Returns a list of glyphs that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_glyphs: { - description: - 'Returns a list of glyphs that may be traded. Used with the add_trade method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "glyphs" : [ - { - "id" : "id-goes-here", - "type" : "bauxite" - }, - ... - ], - "cargo_space_used_each" : 100, - "status" : { ... } - } - */ - }, - withdraw_from_market: { - description: - 'Remove a trade that you have offered and collect the items up for trade.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - accept_from_market: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_market: { - description: - 'Displays a list of trades available at the present time.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - { - name: 'filter', - type: 'string', - optional: true, - }, //food ore water waste energy glyph prisoner ship plan - ], - returns: { type: 'object' }, - }, - view_my_market: { - description: - 'Displays a list of trades the current user has posted.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - get_stored_resources: { - description: - 'Returns a list of the resources you have stored to make it easier to identify what you want to trade.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "status" : { ... }, - "cargo_space_used_each" : 100, - "resources" : { - "water" : 14000, - "waste" : 393, - "bauxite" : 47, - "cheese" : 1193, - ... - } - } - */ - }, - push_items: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'target_id', - type: 'string', - optional: false, - }, - { - name: 'items', - type: 'object', - optional: false, - }, - ], - /* - items array of objects - resouce format = { - "type" : "bauxite", //allowed = water, energy, waste, essentia, bean, lapis, potato, apple, root, corn, cider, wheat, bread, soup, chip, pie, pancake, milk, meal, algae, syrup, fungus, burger, shake, beetle, rutile, chromite, chalcopyrite, galena, gold, uraninite, bauxite, goethite, halite, gypsum, trona, kerogen, methane, anthracite, sulfur, zircon, monazite, fluorite, beryl, or magnetite - "quantity" : 10000 - } - plan format = { - "type" : "plan", - "plan_id" : "id-goes-here" - } - glyph format = { - "type" : "glyph", - "glyph_id" : "id-goes-here" - } - */ - returns: { type: 'object' }, - /* - */ - }, - trade_one_for_one: { - description: - 'Lacuna Expanse Corp will do one for one trades of any resource in exchange for 3 essentia.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'have', - type: 'string', - optional: false, - }, //resource type - { - name: 'want', - type: 'string', - optional: false, - }, //resource type - { - name: 'quantity', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - */ - }, - report_abuse: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'trade_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - WaterStorage: { - SMDVersion: '2.0', - description: 'Water Storage', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/waterstorage', - - services: { - dump: { - description: 'Converts water into waste', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'amount', - type: 'number', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - }, - Empire: { - SMDVersion: '2.0', - description: 'SMD service demonstration', - - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/empire', - - services: { - is_name_available: { - description: 'check if empire name is available', - parameters: [ - { name: 'name', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - }, - logout: { - description: 'logout empire', - parameters: { - session_id: { type: 'string', optional: false }, - }, - returns: { type: 'object' }, - }, - login: { - description: 'login empire', - parameters: { - name: { type: 'string', optional: false }, - password: { type: 'string', optional: false }, - api_key: { type: 'string', optional: false }, - browser: { type: 'string', optional: false }, - }, - returns: { type: 'object' }, - }, - fetch_captcha: { - description: 'fetch a captcha for account creation', - parameters: [], - returns: { type: 'object' }, - }, - create: { - description: 'create empire', - parameters: { - name: { type: 'string', optional: false }, - password: { type: 'string', optional: true }, - password1: { type: 'string', optional: true }, - captcha_guid: { type: 'string', optional: true }, - captcha_solution: { - type: 'string', - optional: true, - }, - email: { type: 'string', optional: true }, - facebook_uid: { type: 'string', optional: true }, - facebook_token: { type: 'string', optional: true }, - invite_code: { type: 'string', optional: true }, - }, - returns: { type: 'object' }, - }, - found: { - description: 'found empire', - parameters: { - empire_id: { type: 'string', optional: true }, - api_key: { type: 'string', optional: true }, - invite_code: { type: 'string', optional: true }, - }, - returns: { type: 'object' }, - }, - get_status: { - description: 'get quick empire status', - parameters: { - session_id: { type: 'string', optional: false }, - }, - returns: { type: 'object' }, - }, - get_own_profile: { - description: - "Provides a list of the editable properties of the current empire's profile. See also the edit_profile and view_public_profile methods.", - parameters: { - session_id: { type: 'string', optional: false }, - }, - returns: { type: 'object' }, - /* - { - "profile" : { - "description" : "description goes here", - "status_message" : "status message goes here", - "medals" : { - "building1" : { - "name" : "Built Level 1 Building", - "image" : "building1", - "note" : "note about how this was achieved, if any, goes here", - "date" : "01 31 2010 13:09:05 +0600", - "public" : 1 - }, - ... - } - }, - "status" : { get_status() } - } - */ - }, - edit_profile: { - description: - 'Edits properties of an empire. Returns the get_own_profile method. See also the get_own_profile and view_public_profile methods.', - parameters: { - session_id: { type: 'string', optional: false }, - profile: { type: 'object', optional: false }, - }, - returns: { type: 'object' }, - }, - view_public_profile: { - description: - "Provides a list of the data that's publicly known about this empire.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'empire_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "profile" : { - "id" : "empire-id-goes-here", - "name" : "Lacuna Expanse Corp", - "planet_count" : 1, - "status_message" : "Looking for Essentia." - "description" : "We are the original inhabitants of the Lacuna Expanse.", - "medals" : { - "building1" : { - "name" : "Built Level 1 Building", - "image" : "building1", - "date" : "01 31 2010 13:09:05 +0600", - "note" : null + "status" : { get_status() } + } + */ + }, + edit_profile: { + description: + 'Edits properties of an empire. Returns the get_own_profile method. See also the get_own_profile and view_public_profile methods.', + parameters: { + session_id: { type: 'string', optional: false }, + profile: { type: 'object', optional: false }, + }, + returns: { type: 'object' }, + }, + view_public_profile: { + description: "Provides a list of the data that's publicly known about this empire.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'empire_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "profile" : { + "id" : "empire-id-goes-here", + "name" : "Lacuna Expanse Corp", + "planet_count" : 1, + "status_message" : "Looking for Essentia." + "description" : "We are the original inhabitants of the Lacuna Expanse.", + "medals" : { + "building1" : { + "name" : "Built Level 1 Building", + "image" : "building1", + "date" : "01 31 2010 13:09:05 +0600", + "note" : null }, ... }, @@ -5181,20 +5131,20 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { get_status() } } */ - }, - find: { - description: - 'Find an empire by name. Returns a hash reference containing empire ids and empire names.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'name', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - /* + }, + find: { + description: + 'Find an empire by name. Returns a hash reference containing empire ids and empire names.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'name', type: 'string', optional: false }, + ], + returns: { type: 'object' }, + /* { "empires" : { "id-goes-here" : "Lacuna Expanse Corp", @@ -5203,36 +5153,36 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { get_status() } } */ - }, - set_status_message: { - description: - 'Sets the empire status message. Similar to what you might put on your Facebook wall, or in a tweet, but about your empire.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_boosts: { - description: - 'Shows the dates at which boosts have expired or will expire. Boosts are subsidies applied to various resources using essentia.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + set_status_message: { + description: + 'Sets the empire status message. Similar to what you might put on your Facebook wall, or in a tweet, but about your empire.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_boosts: { + description: + 'Shows the dates at which boosts have expired or will expire. Boosts are subsidies applied to various resources using essentia.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "boosts" : { @@ -5244,414 +5194,412 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { } } */ - }, - boost_food: { - description: - 'Spends 5 essentia, and boosts food production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + boost_food: { + description: + 'Spends 5 essentia, and boosts food production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "food_boost" : "01 31 2010 13:09:05 +0600" } */ - }, - boost_water: { - description: - 'Spends 5 essentia, and boosts water production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + boost_water: { + description: + 'Spends 5 essentia, and boosts water production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "water_boost" : "01 31 2010 13:09:05 +0600" } */ - }, - boost_energy: { - description: - 'Spends 5 essentia, and boosts energy production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + boost_energy: { + description: + 'Spends 5 essentia, and boosts energy production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "energy_boost" : "01 31 2010 13:09:05 +0600" } */ - }, - boost_ore: { - description: - 'Spends 5 essentia, and boosts ore production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + boost_ore: { + description: + 'Spends 5 essentia, and boosts ore production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "ore_boost" : "01 31 2010 13:09:05 +0600" } */ - }, - boost_happiness: { - description: - 'Spends 5 essentia, and boosts happiness production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + boost_happiness: { + description: + 'Spends 5 essentia, and boosts happiness production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "happiness_boost" : "01 31 2010 13:09:05 +0600" } */ - }, - boost_storage: { - description: - 'Spends 5 essentia, and boosts storage (all 5 types) on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + boost_storage: { + description: + 'Spends 5 essentia, and boosts storage (all 5 types) on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { get_status() }, "storage_boost" : "01 31 2010 13:09:05 +0600" } */ - }, - boost_building: { - description: - 'Spends 5 essentia, and boosts building queues on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - boost_spy_training: { - description: - 'Spends 5 essentia, and boosts spy training on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - enable_self_destruct: { - description: - 'Enables a destruction countdown of 24 hours. Sometime after the timer runs out, the empire will vaporize.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - disable_self_destruct: { - description: 'Disables the self distruction countdown.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - send_password_reset_message: { - description: - 'Starts a password recovery process by sending an email with a recovery key.', - parameters: { - empire_id: { type: 'string', optional: true }, - empire_name: { type: 'string', optional: true }, - email: { type: 'string', optional: true }, - }, - returns: { type: 'object' }, - }, - reset_password: { - description: - 'Changes the empire password that has been forgotten.', - parameters: [ - { - name: 'reset_key', - type: 'string', - optional: false, - }, - { - name: 'password1', - type: 'string', - optional: false, - }, - { - name: 'password2', - type: 'string', - optional: false, - }, - { - name: 'api_key', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - change_password: { - description: 'Changes the empire password.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'password1', - type: 'string', - optional: false, - }, - { - name: 'password2', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - redeem_essentia_code: { - description: 'Redeem an essentia code.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'essentia_code', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - update_species: { - description: "Updates the empire's species.", - parameters: { - empire_id: { type: 'string', optional: false }, - deception_affinity: { - type: 'string', - optional: false, - }, - description: { type: 'string', optional: false }, - environmental_affinity: { - type: 'string', - optional: false, - }, - farming_affinity: { - type: 'string', - optional: false, - }, - growth_affinity: { - type: 'string', - optional: false, - }, - management_affinity: { - type: 'string', - optional: false, - }, - manufacturing_affinity: { - type: 'string', - optional: false, - }, - max_orbit: { type: 'string', optional: false }, - min_orbit: { type: 'string', optional: false }, - mining_affinity: { - type: 'string', - optional: false, - }, - name: { type: 'string', optional: false }, - political_affinity: { - type: 'string', - optional: false, - }, - research_affinity: { - type: 'string', - optional: false, - }, - science_affinity: { - type: 'string', - optional: false, - }, - trade_affinity: { type: 'string', optional: false }, - }, - returns: { type: 'string' }, - }, - redefine_species_limits: { - description: - "Defines the extra limits placed upon a user that want's to redefine their species.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - redefine_species: { - description: - 'Allows a user to spend essentia and redefine their species affinities, name, and description. This can only be used after the empire has been founded.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'params', type: 'object', optional: false }, - ], - returns: { type: 'object' }, - }, - view_species_stats: { - description: - "Returns a list of the stats associated with an empire's species as it was originally created.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_species_templates: { - description: - 'Returns a list of species templates that can be used to populate the form for update_species.', - parameters: [], - returns: { type: 'object' }, - }, - invite_friend: { - description: - 'Send an invitation code to a friend so that they can start in the same zone as your empire.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'email', type: 'string', optional: false }, - { name: 'message', type: 'string', optional: true }, - ], - returns: { type: 'object' }, - }, - get_invite_friend_url: { - description: - 'Returns a URL that can be pasted into a blog, forum, or whatever to invite friends.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, + }, + boost_building: { + description: + 'Spends 5 essentia, and boosts building queues on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + boost_spy_training: { + description: + 'Spends 5 essentia, and boosts spy training on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + enable_self_destruct: { + description: + 'Enables a destruction countdown of 24 hours. Sometime after the timer runs out, the empire will vaporize.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + disable_self_destruct: { + description: 'Disables the self distruction countdown.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + send_password_reset_message: { + description: + 'Starts a password recovery process by sending an email with a recovery key.', + parameters: { + empire_id: { type: 'string', optional: true }, + empire_name: { type: 'string', optional: true }, + email: { type: 'string', optional: true }, + }, + returns: { type: 'object' }, + }, + reset_password: { + description: 'Changes the empire password that has been forgotten.', + parameters: [ + { + name: 'reset_key', + type: 'string', + optional: false, + }, + { + name: 'password1', + type: 'string', + optional: false, + }, + { + name: 'password2', + type: 'string', + optional: false, + }, + { + name: 'api_key', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + change_password: { + description: 'Changes the empire password.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'password1', + type: 'string', + optional: false, + }, + { + name: 'password2', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + redeem_essentia_code: { + description: 'Redeem an essentia code.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'essentia_code', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + update_species: { + description: "Updates the empire's species.", + parameters: { + empire_id: { type: 'string', optional: false }, + deception_affinity: { + type: 'string', + optional: false, + }, + description: { type: 'string', optional: false }, + environmental_affinity: { + type: 'string', + optional: false, + }, + farming_affinity: { + type: 'string', + optional: false, + }, + growth_affinity: { + type: 'string', + optional: false, + }, + management_affinity: { + type: 'string', + optional: false, + }, + manufacturing_affinity: { + type: 'string', + optional: false, + }, + max_orbit: { type: 'string', optional: false }, + min_orbit: { type: 'string', optional: false }, + mining_affinity: { + type: 'string', + optional: false, + }, + name: { type: 'string', optional: false }, + political_affinity: { + type: 'string', + optional: false, + }, + research_affinity: { + type: 'string', + optional: false, + }, + science_affinity: { + type: 'string', + optional: false, + }, + trade_affinity: { type: 'string', optional: false }, }, - Captcha: { - SMDVersion: '2.0', - description: 'SMD service demonstration', + returns: { type: 'string' }, + }, + redefine_species_limits: { + description: + "Defines the extra limits placed upon a user that want's to redefine their species.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + redefine_species: { + description: + 'Allows a user to spend essentia and redefine their species affinities, name, and description. This can only be used after the empire has been founded.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'params', type: 'object', optional: false }, + ], + returns: { type: 'object' }, + }, + view_species_stats: { + description: + "Returns a list of the stats associated with an empire's species as it was originally created.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_species_templates: { + description: + 'Returns a list of species templates that can be used to populate the form for update_species.', + parameters: [], + returns: { type: 'object' }, + }, + invite_friend: { + description: + 'Send an invitation code to a friend so that they can start in the same zone as your empire.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'email', type: 'string', optional: false }, + { name: 'message', type: 'string', optional: true }, + ], + returns: { type: 'object' }, + }, + get_invite_friend_url: { + description: + 'Returns a URL that can be pasted into a blog, forum, or whatever to invite friends.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Captcha: { + SMDVersion: '2.0', + description: 'SMD service demonstration', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/captcha', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/captcha', - services: { - fetch: { - description: - 'Retrieves a captcha that is required in order to call the solve method.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - solve: { - description: - "Validates the user's solution against the known solution for the given guid.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'captcha_guid', - type: 'string', - optional: false, - }, - { - name: 'captcha_solution', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - Inbox: { - SMDVersion: '2.0', - description: 'SMD service demonstration', + services: { + fetch: { + description: 'Retrieves a captcha that is required in order to call the solve method.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + solve: { + description: + "Validates the user's solution against the known solution for the given guid.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'captcha_guid', + type: 'string', + optional: false, + }, + { + name: 'captcha_solution', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + Inbox: { + SMDVersion: '2.0', + description: 'SMD service demonstration', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/inbox', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/inbox', - services: { - /* This is the return for all view_* functions + services: { + /* This is the return for all view_* functions { "messages" : [ { @@ -5666,88 +5614,82 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { get_status() } } */ - view_inbox: { - description: - "Displays a list of the messages in the empire's inbox.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'options', type: 'object', optional: true }, - ], - returns: { type: 'object' }, - }, - view_archived: { - description: - "Displays a list of the messages in the empire's archive.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'options', type: 'object', optional: true }, - ], - returns: { type: 'object' }, - }, - view_trashed: { - description: - "Displays a list of the messages in the empire's trash.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'options', type: 'object', optional: true }, - ], - returns: { type: 'object' }, - }, - view_unread: { - description: - "Displays a list of the unread messages in the empire's inbox.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'options', type: 'object', optional: true }, - ], - returns: { type: 'object' }, - }, - view_sent: { - description: - "Displays a list of the messages in the empire's outbox.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'options', type: 'object', optional: true }, - ], - returns: { type: 'object' }, - }, - read_message: { - description: - "Retrieves a message. Marks it read if it hasn't been already.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'message_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + view_inbox: { + description: "Displays a list of the messages in the empire's inbox.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'options', type: 'object', optional: true }, + ], + returns: { type: 'object' }, + }, + view_archived: { + description: "Displays a list of the messages in the empire's archive.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'options', type: 'object', optional: true }, + ], + returns: { type: 'object' }, + }, + view_trashed: { + description: "Displays a list of the messages in the empire's trash.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'options', type: 'object', optional: true }, + ], + returns: { type: 'object' }, + }, + view_unread: { + description: "Displays a list of the unread messages in the empire's inbox.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'options', type: 'object', optional: true }, + ], + returns: { type: 'object' }, + }, + view_sent: { + description: "Displays a list of the messages in the empire's outbox.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'options', type: 'object', optional: true }, + ], + returns: { type: 'object' }, + }, + read_message: { + description: "Retrieves a message. Marks it read if it hasn't been already.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'message_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "message" : { "id" : "id-goes-here", @@ -5766,77 +5708,77 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { status => { get_status() } } */ - }, - archive_messages: { - description: 'Archives a list of messages.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'message_ids', - type: 'array', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + archive_messages: { + description: 'Archives a list of messages.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'message_ids', + type: 'array', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "success" : 1, "status" : { get_status() } } */ - }, - trash_messages: { - description: 'Trashes a list of messages.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'message_ids', - type: 'array', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + trash_messages: { + description: 'Trashes a list of messages.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'message_ids', + type: 'array', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "success" : 1, "status" : { get_status() } } */ - }, - send_message: { - description: 'Sends a message to other players.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'recipients', - type: 'string', - optional: false, - }, - { - name: 'subject', - type: 'string', - optional: false, - }, - { name: 'body', type: 'string', optional: false }, - { name: 'options', type: 'object', optional: true }, - /* + }, + send_message: { + description: 'Sends a message to other players.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'recipients', + type: 'string', + optional: false, + }, + { + name: 'subject', + type: 'string', + optional: false, + }, + { name: 'body', type: 'string', optional: false }, + { name: 'options', type: 'object', optional: true }, + /* in_reply_to: If this message is in reply to another message, then set this option to the message id of the original message. */ - ], - returns: { type: 'object' }, - /* + ], + returns: { type: 'object' }, + /* { "message": { "sent":[], @@ -5844,745 +5786,740 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { }, "status" : { get_status() } } - */ - }, - }, - }, - Map: { - SMDVersion: '2.0', - description: '', - - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/map', - - services: { - check_star_for_incoming_probe: { - description: - 'Retrieves a chunk of the map and returns it as an array of hashes.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'star_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_star: { - description: 'Retrieves a single star', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'star_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* - { - "star" : { - "name" : "Sol", - "color" : "yellow", - "x" : -41, - "y" : 27, - "bodies" : [ # only added if a probe is present - { - same data as get_status() on /body - }, - ... - ] - } - "status" : { ... } - } - */ - }, - get_star_map: { - description: - 'Retrieves a chunk of the star map (lite version).', - parameters: [ - { name: 'args', type: 'object', optional: false }, - ], - returns: { type: 'object' }, - }, - get_stars: { - description: - 'Retrieves a chunk of the map and returns it as an array of hashes.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'x1', type: 'number', optional: false }, - { name: 'y1', type: 'number', optional: false }, - { name: 'x2', type: 'number', optional: false }, - { name: 'y2', type: 'number', optional: false }, - { name: 'z', type: 'number', optional: false }, - ], - returns: { type: 'object' }, - /* - { - "stars" : [ - { - "name" : "Sol", - "can_name" : 1, - "color" : "yellow", - "x" : -41, - "y" : 27, - "z" : 14, - "alignment" : "self-ally" - }. - { - "name" : "X143S", - "can_name" : 0, - "color" : "green", - "x" : -42, - "y" : 27, - "z" : 14, - "alignments" : "unprobed" - } - ], - "status" : {...} - } - */ - }, - get_star_by_name: { - description: 'Retrieves info on a single star.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'name', type: 'string', optional: false }, - ], - returns: { type: 'object' }, - }, - get_star_by_xy: { - description: 'Retrieves info on a single star.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'x', type: 'number', optional: false }, - { name: 'y', type: 'number', optional: false }, - ], - returns: { type: 'object' }, - }, - search_stars: { - description: - 'If you know a partial name of a star you can search for it. Returns up to 25 results. No body data is returned with this search.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'name', type: 'string', optional: false }, - ], - returns: { type: 'number' }, - /* - { - "stars" : [ - { - "name" : "Sol", - "color" : "yellow", - "x" : -41, - "y" : 27 - }, - { - "name" : "Minsol", - "color" : "green", - "x" : -42, - "y" : 27 - } - ], - "status" : { ... } - } - */ - }, - }, - }, - Modules: { - Parliament: { - SMDVersion: '2.0', - description: 'Parliament', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/parliament', - - services: { - view_laws: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_propositions: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_stars_in_jurisdiction: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_bodies_for_star_in_jurisdiction: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'star_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - get_mining_platforms_for_asteroid_in_jurisdiction: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'asteroid_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - cast_vote: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'proposition_id', - type: 'string', - optional: false, - }, - { - name: 'vote', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_writ: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'title', - type: 'string', - optional: false, - }, - { - name: 'description', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_repeal_law: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'law_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_transfer_station_ownership: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'to_empire_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_rename_star: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'star_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_broadcast_on_network19: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_induct_member: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'empire_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - propose_expel_member: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'empire_id', - type: 'string', - optional: false, - }, - { - name: 'message', - type: 'string', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - propose_elect_new_leader: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'to_empire_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_rename_asteroid: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'asteroid_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - - propose_rename_uninhabited: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'planet_id', - type: 'string', - optional: false, - }, - { - name: 'name', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_members_only_mining_rights: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_evict_mining_platform: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'platform_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_members_only_excavation: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_evict_excavator: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'platform_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_members_only_colonization: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_members_only_stations: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - allow_bhg_by_alliance: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'alliance_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_neutralize_bhg: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - propose_fire_bfg: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'body_id', - type: 'string', - optional: false, - }, - { - name: 'reason', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, - }, - PoliceStation: { - SMDVersion: '2.0', - description: 'Police Station', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/policestation', + */ + }, + }, + }, + Map: { + SMDVersion: '2.0', + description: '', - services: { - view_foreign_ships: { - description: - 'Shows you all the foreign ships that are incoming. However, the list is filtered by the stealth of the ship vs the level of the PoliceStation.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/map', + + services: { + check_star_for_incoming_probe: { + description: 'Retrieves a chunk of the map and returns it as an array of hashes.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'star_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_star: { + description: 'Retrieves a single star', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'star_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* + { + "star" : { + "name" : "Sol", + "color" : "yellow", + "x" : -41, + "y" : 27, + "bodies" : [ # only added if a probe is present { - name: 'page_number', - type: 'number', - optional: true, + same data as get_status() on /body }, - ], - returns: { type: 'object' }, - /* + ... + ] + } + "status" : { ... } + } + */ + }, + get_star_map: { + description: 'Retrieves a chunk of the star map (lite version).', + parameters: [{ name: 'args', type: 'object', optional: false }], + returns: { type: 'object' }, + }, + get_stars: { + description: 'Retrieves a chunk of the map and returns it as an array of hashes.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'x1', type: 'number', optional: false }, + { name: 'y1', type: 'number', optional: false }, + { name: 'x2', type: 'number', optional: false }, + { name: 'y2', type: 'number', optional: false }, + { name: 'z', type: 'number', optional: false }, + ], + returns: { type: 'object' }, + /* + { + "stars" : [ + { + "name" : "Sol", + "can_name" : 1, + "color" : "yellow", + "x" : -41, + "y" : 27, + "z" : 14, + "alignment" : "self-ally" + }. + { + "name" : "X143S", + "can_name" : 0, + "color" : "green", + "x" : -42, + "y" : 27, + "z" : 14, + "alignments" : "unprobed" + } + ], + "status" : {...} + } + */ + }, + get_star_by_name: { + description: 'Retrieves info on a single star.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'name', type: 'string', optional: false }, + ], + returns: { type: 'object' }, + }, + get_star_by_xy: { + description: 'Retrieves info on a single star.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'x', type: 'number', optional: false }, + { name: 'y', type: 'number', optional: false }, + ], + returns: { type: 'object' }, + }, + search_stars: { + description: + 'If you know a partial name of a star you can search for it. Returns up to 25 results. No body data is returned with this search.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'name', type: 'string', optional: false }, + ], + returns: { type: 'number' }, + /* + { + "stars" : [ + { + "name" : "Sol", + "color" : "yellow", + "x" : -41, + "y" : 27 + }, + { + "name" : "Minsol", + "color" : "green", + "x" : -42, + "y" : 27 + } + ], + "status" : { ... } + } + */ + }, + }, + }, + Modules: { + Parliament: { + SMDVersion: '2.0', + description: 'Parliament', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/parliament', + + services: { + view_laws: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_propositions: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_stars_in_jurisdiction: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_bodies_for_star_in_jurisdiction: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'star_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + get_mining_platforms_for_asteroid_in_jurisdiction: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'asteroid_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + cast_vote: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'proposition_id', + type: 'string', + optional: false, + }, + { + name: 'vote', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_writ: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'title', + type: 'string', + optional: false, + }, + { + name: 'description', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_repeal_law: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'law_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_transfer_station_ownership: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'to_empire_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_rename_star: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'star_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_broadcast_on_network19: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_induct_member: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'empire_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + propose_expel_member: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'empire_id', + type: 'string', + optional: false, + }, + { + name: 'message', + type: 'string', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + propose_elect_new_leader: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'to_empire_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_rename_asteroid: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'asteroid_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + + propose_rename_uninhabited: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'planet_id', + type: 'string', + optional: false, + }, + { + name: 'name', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_members_only_mining_rights: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_evict_mining_platform: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'platform_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_members_only_excavation: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_evict_excavator: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'platform_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_members_only_colonization: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_members_only_stations: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + allow_bhg_by_alliance: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'alliance_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_neutralize_bhg: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + propose_fire_bfg: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'body_id', + type: 'string', + optional: false, + }, + { + name: 'reason', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + PoliceStation: { + SMDVersion: '2.0', + description: 'Police Station', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/policestation', + + services: { + view_foreign_ships: { + description: + 'Shows you all the foreign ships that are incoming. However, the list is filtered by the stealth of the ship vs the level of the PoliceStation.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "ships" : [ { @@ -6606,172 +6543,171 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "status" : { ... } } */ - }, - view_prisoners: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - execute_prisoner: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'prisoner_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - release_prisoner: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'prisoner_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_foreign_spies: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - }, - }, + }, + view_prisoners: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + execute_prisoner: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, }, - StationCommand: { - SMDVersion: '2.0', - description: 'Station Command', + { + name: 'prisoner_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + release_prisoner: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'prisoner_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_foreign_spies: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + }, + }, + }, + StationCommand: { + SMDVersion: '2.0', + description: 'Station Command', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/stationcommand', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/stationcommand', - services: { - view_plans: { - description: - "Returns a list of all the plans you've collected through various means.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - view_incoming_supply_chains: { - description: '', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'building_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - }, - }, + services: { + view_plans: { + description: + "Returns a list of all the plans you've collected through various means.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + }, + view_incoming_supply_chains: { + description: '', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'building_id', + type: 'string', + optional: false, }, + ], + returns: { type: 'object' }, }, - Stats: { - SMDVersion: '2.0', - description: 'SMD service demonstration', + }, + }, + }, + Stats: { + SMDVersion: '2.0', + description: 'SMD service demonstration', - envelope: 'JSON-RPC-2.0', - transport: 'POST', - target: '/stats', + envelope: 'JSON-RPC-2.0', + transport: 'POST', + target: '/stats', - services: { - credits: { - description: - 'Retrieves a list of the game credits. It is an array of hashes of arrays.', - parameters: [], - returns: { type: 'array' }, - }, + services: { + credits: { + description: + 'Retrieves a list of the game credits. It is an array of hashes of arrays.', + parameters: [], + returns: { type: 'array' }, + }, - empire_rank: { - description: - 'Returns a sorted list of empires ranked according to various stats.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'sort_by', type: 'string', optional: true }, //Defaults to empire_size_rank. Possible values are: empire_size_rank, university_level_rank, offense_success_rate_rank, defense_success_rate_rank, and dirtiest_rank - { - name: 'page_number', - type: 'number', - optional: true, - }, - ], - returns: { type: 'object' }, - /* + empire_rank: { + description: 'Returns a sorted list of empires ranked according to various stats.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'sort_by', type: 'string', optional: true }, //Defaults to empire_size_rank. Possible values are: empire_size_rank, university_level_rank, offense_success_rate_rank, defense_success_rate_rank, and dirtiest_rank + { + name: 'page_number', + type: 'number', + optional: true, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "empires" : [ @@ -6793,29 +6729,28 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { "page_number" : 3 } */ - }, - find_empire_rank: { - description: - 'Search for a particular empire in the empire_rank().', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { - name: 'sort_by', - type: 'string', - optional: false, - }, - { - name: 'empire_name', - type: 'string', - optional: false, - }, //Must be at least 3 characters to search. - ], - returns: { type: 'object' }, - /* + }, + find_empire_rank: { + description: 'Search for a particular empire in the empire_rank().', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { + name: 'sort_by', + type: 'string', + optional: false, + }, + { + name: 'empire_name', + type: 'string', + optional: false, + }, //Must be at least 3 characters to search. + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "empires" : [ @@ -6828,21 +6763,20 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, + }, - colony_rank: { - description: - 'Returns a sorted list of planets ranked according to various stats.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'sort_by', type: 'string', optional: true }, //Defaults to population_rank. Possible values are: population_rank - ], - returns: { type: 'object' }, - /* + colony_rank: { + description: 'Returns a sorted list of planets ranked according to various stats.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'sort_by', type: 'string', optional: true }, //Defaults to population_rank. Possible values are: population_rank + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "colonies" : [ @@ -6860,20 +6794,19 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - spy_rank: { - description: - 'Returns a sorted list of spies ranked according to various stats.', - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - { name: 'sort_by', type: 'string', optional: true }, //Defaults to level_rank. Possible values are: level_rank success_rate_rank and dirtiest_rank - ], - returns: { type: 'object' }, - /* + }, + spy_rank: { + description: 'Returns a sorted list of spies ranked according to various stats.', + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + { name: 'sort_by', type: 'string', optional: true }, //Defaults to level_rank. Possible values are: level_rank success_rate_rank and dirtiest_rank + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "spies" : [ @@ -6891,19 +6824,18 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - weekly_medal_winners: { - description: - "Returns a list of the empires who won this week's weekly medals.", - parameters: [ - { - name: 'session_id', - type: 'string', - optional: false, - }, - ], - returns: { type: 'object' }, - /* + }, + weekly_medal_winners: { + description: "Returns a list of the empires who won this week's weekly medals.", + parameters: [ + { + name: 'session_id', + type: 'string', + optional: false, + }, + ], + returns: { type: 'object' }, + /* { "status" : { ... }, "winners" : [ @@ -6918,12 +6850,12 @@ if (typeof YAHOO.lacuna.SMD == 'undefined' || !YAHOO.lacuna.SMD) { ] } */ - }, - }, - }, - }; + }, + }, + }, + }; - YAHOO.lacuna.SMD = { Services: smd }; - })(); - YAHOO.register('smd', YAHOO.lacuna.SMD, { version: '1', build: '0' }); + YAHOO.lacuna.SMD = { Services: smd }; + })(); + YAHOO.register('smd', YAHOO.lacuna.SMD, { version: '1', build: '0' }); } diff --git a/app/yui/speciesDesigner.js b/app/yui/speciesDesigner.js index 793c47c3..eaa5464d 100644 --- a/app/yui/speciesDesigner.js +++ b/app/yui/speciesDesigner.js @@ -1,870 +1,670 @@ YAHOO.namespace('lacuna'); -if ( - typeof YAHOO.lacuna.SpeciesDesigner == 'undefined' || - !YAHOO.lacuna.SpeciesDesigner -) { - (function() { - var Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Slider = YAHOO.widget.Slider, - Lib = Lacuna.Library; +if (typeof YAHOO.lacuna.SpeciesDesigner == 'undefined' || !YAHOO.lacuna.SpeciesDesigner) { + (function () { + var Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Slider = YAHOO.widget.Slider, + Lib = Lacuna.Library; - var SpeciesDesigner = function(config) { - if ( - typeof config !== 'undefined' && - typeof config.templates !== 'undefined' && - !config.templates - ) { - this.speciesTemplates = []; - } else { - this.speciesTemplates = [ - { - name: 'Average', - description: - 'Not specializing in any area, but without any particular weaknesses.', - min_orbit: 3, - max_orbit: 3, - manufacturing_affinity: 4, - deception_affinity: 4, - research_affinity: 4, - management_affinity: 4, - farming_affinity: 4, - mining_affinity: 4, - science_affinity: 4, - environmental_affinity: 4, - political_affinity: 4, - trade_affinity: 4, - growth_affinity: 4, - }, - { - name: 'Resilient', - description: - 'Resilient and able to colonize most any planet. Somewhat docile, but very quick learners and above average at producing any resource.', - min_orbit: 2, - max_orbit: 7, - manufacturing_affinity: 3, - deception_affinity: 3, - research_affinity: 3, - management_affinity: 5, - farming_affinity: 5, - mining_affinity: 5, - science_affinity: 5, - environmental_affinity: 5, - political_affinity: 1, - trade_affinity: 1, - growth_affinity: 3, - }, - { - name: 'Warmonger', - description: - 'Adept at ship building and espionage. They are bent on domination.', - min_orbit: 4, - max_orbit: 5, - manufacturing_affinity: 4, - deception_affinity: 7, - research_affinity: 2, - management_affinity: 4, - farming_affinity: 2, - mining_affinity: 2, - science_affinity: 7, - environmental_affinity: 2, - political_affinity: 7, - trade_affinity: 1, - growth_affinity: 5, - }, - { - name: 'Viral', - description: - 'Proficient at growing at the most expedient pace like a virus in the Expanse.', - min_orbit: 1, - max_orbit: 7, - manufacturing_affinity: 1, - deception_affinity: 4, - research_affinity: 7, - management_affinity: 7, - farming_affinity: 1, - mining_affinity: 1, - science_affinity: 1, - environmental_affinity: 1, - political_affinity: 7, - trade_affinity: 1, - growth_affinity: 7, - }, - { - name: 'Trader', - description: 'Masters of commerce and ship building.', - min_orbit: 2, - max_orbit: 3, - manufacturing_affinity: 5, - deception_affinity: 4, - research_affinity: 7, - management_affinity: 7, - farming_affinity: 1, - mining_affinity: 1, - science_affinity: 7, - environmental_affinity: 1, - political_affinity: 1, - trade_affinity: 7, - growth_affinity: 2, - }, - ]; - } - }; - SpeciesDesigner.prototype = { - render: function(el) { - el = Dom.get(el); - var container = document.createElement('div'); - this.container = container; - container.innerHTML = this._getHtml(); - - this.elMessage = Sel.query('.speciesMessage', container, true); - this.elName = Sel.query('.speciesName', container, true); - this.elDesc = Sel.query('.speciesDesc', container, true); - this.elTemplates = Sel.query( - '.speciesTemplates', - container, - true - ); - if (this.speciesTemplates.length > 0) { - Event.delegate( - this.elTemplates, - 'click', - function(e, matchedEl) { - Event.stopEvent(e); - this.selectTemplate(matchedEl.TemplateIndex); - }, - '.speciesTemplate', - this, - true - ); + var SpeciesDesigner = function (config) { + if ( + typeof config !== 'undefined' && + typeof config.templates !== 'undefined' && + !config.templates + ) { + this.speciesTemplates = []; + } else { + this.speciesTemplates = [ + { + name: 'Average', + description: 'Not specializing in any area, but without any particular weaknesses.', + min_orbit: 3, + max_orbit: 3, + manufacturing_affinity: 4, + deception_affinity: 4, + research_affinity: 4, + management_affinity: 4, + farming_affinity: 4, + mining_affinity: 4, + science_affinity: 4, + environmental_affinity: 4, + political_affinity: 4, + trade_affinity: 4, + growth_affinity: 4, + }, + { + name: 'Resilient', + description: + 'Resilient and able to colonize most any planet. Somewhat docile, but very quick learners and above average at producing any resource.', + min_orbit: 2, + max_orbit: 7, + manufacturing_affinity: 3, + deception_affinity: 3, + research_affinity: 3, + management_affinity: 5, + farming_affinity: 5, + mining_affinity: 5, + science_affinity: 5, + environmental_affinity: 5, + political_affinity: 1, + trade_affinity: 1, + growth_affinity: 3, + }, + { + name: 'Warmonger', + description: 'Adept at ship building and espionage. They are bent on domination.', + min_orbit: 4, + max_orbit: 5, + manufacturing_affinity: 4, + deception_affinity: 7, + research_affinity: 2, + management_affinity: 4, + farming_affinity: 2, + mining_affinity: 2, + science_affinity: 7, + environmental_affinity: 2, + political_affinity: 7, + trade_affinity: 1, + growth_affinity: 5, + }, + { + name: 'Viral', + description: + 'Proficient at growing at the most expedient pace like a virus in the Expanse.', + min_orbit: 1, + max_orbit: 7, + manufacturing_affinity: 1, + deception_affinity: 4, + research_affinity: 7, + management_affinity: 7, + farming_affinity: 1, + mining_affinity: 1, + science_affinity: 1, + environmental_affinity: 1, + political_affinity: 7, + trade_affinity: 1, + growth_affinity: 7, + }, + { + name: 'Trader', + description: 'Masters of commerce and ship building.', + min_orbit: 2, + max_orbit: 3, + manufacturing_affinity: 5, + deception_affinity: 4, + research_affinity: 7, + management_affinity: 7, + farming_affinity: 1, + mining_affinity: 1, + science_affinity: 7, + environmental_affinity: 1, + political_affinity: 1, + trade_affinity: 7, + growth_affinity: 2, + }, + ]; + } + }; + SpeciesDesigner.prototype = { + render: function (el) { + el = Dom.get(el); + var container = document.createElement('div'); + this.container = container; + container.innerHTML = this._getHtml(); - for (var i = 0; i < this.speciesTemplates.length; i++) { - var template = this.speciesTemplates[i]; - var tButton = document.createElement('button'); - tButton.innerHTML = template.name; - tButton.title = template.description; - tButton.TemplateIndex = i; - Dom.addClass(tButton, 'speciesTemplate'); - this.elTemplates.appendChild(tButton); - } - } else { - Dom.setStyle( - Sel.query('.speciesButtons', container, true), - 'display', - 'none' - ); - } - el.appendChild(container); - this._createSliders(); - this._createTooltips(); - if (this.speciesTemplates.length > 0) { - this.selectTemplate(0); - } + this.elMessage = Sel.query('.speciesMessage', container, true); + this.elName = Sel.query('.speciesName', container, true); + this.elDesc = Sel.query('.speciesDesc', container, true); + this.elTemplates = Sel.query('.speciesTemplates', container, true); + if (this.speciesTemplates.length > 0) { + Event.delegate( + this.elTemplates, + 'click', + function (e, matchedEl) { + Event.stopEvent(e); + this.selectTemplate(matchedEl.TemplateIndex); }, - _createSliders: function() { - this.speciesHO = this._createHabitableOrbits(); - this.speciesConst = this._createHorizSingle( - 'speciesConst', - 'speciesConst_thumb', - 'speciesConst_num' - ); - this.speciesDecep = this._createHorizSingle( - 'speciesDecep', - 'speciesDecep_thumb', - 'speciesDecep_num' - ); - this.speciesResearch = this._createHorizSingle( - 'speciesResearch', - 'speciesResearch_thumb', - 'speciesResearch_num' - ); - this.speciesManagement = this._createHorizSingle( - 'speciesManagement', - 'speciesManagement_thumb', - 'speciesManagement_num' - ); - this.speciesFarming = this._createHorizSingle( - 'speciesFarming', - 'speciesFarming_thumb', - 'speciesFarming_num' - ); - this.speciesMining = this._createHorizSingle( - 'speciesMining', - 'speciesMining_thumb', - 'speciesMining_num' - ); - this.speciesScience = this._createHorizSingle( - 'speciesScience', - 'speciesScience_thumb', - 'speciesScience_num' - ); - this.speciesEnviro = this._createHorizSingle( - 'speciesEnviro', - 'speciesEnviro_thumb', - 'speciesEnviro_num' - ); - this.speciesPolitical = this._createHorizSingle( - 'speciesPolitical', - 'speciesPolitical_thumb', - 'speciesPolitical_num' - ); - this.speciesTrade = this._createHorizSingle( - 'speciesTrade', - 'speciesTrade_thumb', - 'speciesTrade_num' - ); - this.speciesGrowth = this._createHorizSingle( - 'speciesGrowth', - 'speciesGrowth_thumb', - 'speciesGrowth_num' - ); - - this.elTotal = Sel.query( - '.speciesPointTotal', - this.container, - true - ); - this.elTotal.innerHTML = 45; - this.elTotalLine = Sel.query( - '.speciesPointLine', - this.container, - true - ); - - var updateTotal = function() { - var total = this.getSpeciesData().affinity_total; - this.elTotal.innerHTML = total; + '.speciesTemplate', + this, + true + ); - if (total > 45) { - Dom.removeClass(this.elTotalLine, 'speciesPointsValid'); - Dom.removeClass(this.elTotalLine, 'speciesPointsLow'); - Dom.addClass(this.elTotalLine, 'speciesPointsInvalid'); - } else if (total == 45) { - Dom.addClass(this.elTotalLine, 'speciesPointsValid'); - Dom.removeClass(this.elTotalLine, 'speciesPointsLow'); - Dom.removeClass( - this.elTotalLine, - 'speciesPointsInvalid' - ); - } else { - Dom.removeClass(this.elTotalLine, 'speciesPointsValid'); - Dom.addClass(this.elTotalLine, 'speciesPointsLow'); - Dom.removeClass( - this.elTotalLine, - 'speciesPointsInvalid' - ); - } - }; + for (var i = 0; i < this.speciesTemplates.length; i++) { + var template = this.speciesTemplates[i]; + var tButton = document.createElement('button'); + tButton.innerHTML = template.name; + tButton.title = template.description; + tButton.TemplateIndex = i; + Dom.addClass(tButton, 'speciesTemplate'); + this.elTemplates.appendChild(tButton); + } + } else { + Dom.setStyle(Sel.query('.speciesButtons', container, true), 'display', 'none'); + } + el.appendChild(container); + this._createSliders(); + this._createTooltips(); + if (this.speciesTemplates.length > 0) { + this.selectTemplate(0); + } + }, + _createSliders: function () { + this.speciesHO = this._createHabitableOrbits(); + this.speciesConst = this._createHorizSingle( + 'speciesConst', + 'speciesConst_thumb', + 'speciesConst_num' + ); + this.speciesDecep = this._createHorizSingle( + 'speciesDecep', + 'speciesDecep_thumb', + 'speciesDecep_num' + ); + this.speciesResearch = this._createHorizSingle( + 'speciesResearch', + 'speciesResearch_thumb', + 'speciesResearch_num' + ); + this.speciesManagement = this._createHorizSingle( + 'speciesManagement', + 'speciesManagement_thumb', + 'speciesManagement_num' + ); + this.speciesFarming = this._createHorizSingle( + 'speciesFarming', + 'speciesFarming_thumb', + 'speciesFarming_num' + ); + this.speciesMining = this._createHorizSingle( + 'speciesMining', + 'speciesMining_thumb', + 'speciesMining_num' + ); + this.speciesScience = this._createHorizSingle( + 'speciesScience', + 'speciesScience_thumb', + 'speciesScience_num' + ); + this.speciesEnviro = this._createHorizSingle( + 'speciesEnviro', + 'speciesEnviro_thumb', + 'speciesEnviro_num' + ); + this.speciesPolitical = this._createHorizSingle( + 'speciesPolitical', + 'speciesPolitical_thumb', + 'speciesPolitical_num' + ); + this.speciesTrade = this._createHorizSingle( + 'speciesTrade', + 'speciesTrade_thumb', + 'speciesTrade_num' + ); + this.speciesGrowth = this._createHorizSingle( + 'speciesGrowth', + 'speciesGrowth_thumb', + 'speciesGrowth_num' + ); - this.speciesHO.subscribe('change', updateTotal, this, true); - this.speciesConst.subscribe('change', updateTotal, this, true); - this.speciesDecep.subscribe('change', updateTotal, this, true); - this.speciesResearch.subscribe( - 'change', - updateTotal, - this, - true - ); - this.speciesManagement.subscribe( - 'change', - updateTotal, - this, - true - ); - this.speciesFarming.subscribe( - 'change', - updateTotal, - this, - true - ); - this.speciesMining.subscribe('change', updateTotal, this, true); - this.speciesScience.subscribe( - 'change', - updateTotal, - this, - true - ); - this.speciesEnviro.subscribe('change', updateTotal, this, true); - this.speciesPolitical.subscribe( - 'change', - updateTotal, - this, - true - ); - this.speciesTrade.subscribe('change', updateTotal, this, true); - this.speciesGrowth.subscribe('change', updateTotal, this, true); - }, - _createTooltips: function() { - this._affinityTooltip = new YAHOO.widget.Tooltip( - Dom.generateId(), - { - //iframe:true, - zIndex: 1, - container: this.container, - xyoffset: [0, 10], - context: Sel.query( - '.speciesAffinities label', - this.container - ), - } - ); - }, - _createHabitableOrbits: function() { - var range = 180, - tickSize = 30, - from = Sel.query('.speciesHO_from', this.container, true), - to = Sel.query('.speciesHO_to', this.container, true); + this.elTotal = Sel.query('.speciesPointTotal', this.container, true); + this.elTotal.innerHTML = 45; + this.elTotalLine = Sel.query('.speciesPointLine', this.container, true); - // Create the DualSlider - var YW = YAHOO.widget; + var updateTotal = function () { + var total = this.getSpeciesData().affinity_total; + this.elTotal.innerHTML = total; - var elMinThumb = Sel.query( - '.speciesHO_min_thumb', - this.container, - true - ); - elMinThumb.id = Dom.generateId(); - var elMin = Sel.query('.speciesHO_min', this.container, true); - elMin.id = Dom.generateId(); - var elMaxThumb = Sel.query( - '.speciesHO_max_thumb', - this.container, - true - ); - elMaxThumb.id = Dom.generateId(); - var elMax = Sel.query('.speciesHO_max', this.container, true); - elMax.id = Dom.generateId(); - var elSlider = Sel.query('.speciesHO', this.container, true); - elSlider.id = Dom.generateId(); + if (total > 45) { + Dom.removeClass(this.elTotalLine, 'speciesPointsValid'); + Dom.removeClass(this.elTotalLine, 'speciesPointsLow'); + Dom.addClass(this.elTotalLine, 'speciesPointsInvalid'); + } else if (total == 45) { + Dom.addClass(this.elTotalLine, 'speciesPointsValid'); + Dom.removeClass(this.elTotalLine, 'speciesPointsLow'); + Dom.removeClass(this.elTotalLine, 'speciesPointsInvalid'); + } else { + Dom.removeClass(this.elTotalLine, 'speciesPointsValid'); + Dom.addClass(this.elTotalLine, 'speciesPointsLow'); + Dom.removeClass(this.elTotalLine, 'speciesPointsInvalid'); + } + }; - var mint = new YW.SliderThumb( - elMinThumb.id, - elMin.id, - 0, - range, - 0, - 0, - tickSize - ); - var maxt = new YW.SliderThumb( - elMaxThumb.id, - elMax.id, - 0, - range, - 0, - 0, - tickSize - ); + this.speciesHO.subscribe('change', updateTotal, this, true); + this.speciesConst.subscribe('change', updateTotal, this, true); + this.speciesDecep.subscribe('change', updateTotal, this, true); + this.speciesResearch.subscribe('change', updateTotal, this, true); + this.speciesManagement.subscribe('change', updateTotal, this, true); + this.speciesFarming.subscribe('change', updateTotal, this, true); + this.speciesMining.subscribe('change', updateTotal, this, true); + this.speciesScience.subscribe('change', updateTotal, this, true); + this.speciesEnviro.subscribe('change', updateTotal, this, true); + this.speciesPolitical.subscribe('change', updateTotal, this, true); + this.speciesTrade.subscribe('change', updateTotal, this, true); + this.speciesGrowth.subscribe('change', updateTotal, this, true); + }, + _createTooltips: function () { + this._affinityTooltip = new YAHOO.widget.Tooltip(Dom.generateId(), { + //iframe:true, + zIndex: 1, + container: this.container, + xyoffset: [0, 10], + context: Sel.query('.speciesAffinities label', this.container), + }); + }, + _createHabitableOrbits: function () { + var range = 180, + tickSize = 30, + from = Sel.query('.speciesHO_from', this.container, true), + to = Sel.query('.speciesHO_to', this.container, true); - var mins = new YW.Slider( - elSlider.id, - elSlider.id, - mint, - 'horiz' - ); - var maxs = new YW.Slider( - elSlider.id, - elSlider.id, - maxt, - 'horiz' - ); - var slider = new YW.DualSlider(mins, maxs, range, [90, 90]); - var mintSetX = mint.setXConstraint; - mint.setXConstraint = function(iLeft, iRight, iTickSize) { - if (slider.minLock) { - iRight = (slider.minLock - 1) * iTickSize; - } else { - iRight += iTickSize * 1.5; - } - mintSetX.apply(mint, [iLeft, iRight, iTickSize]); - }; - var maxtSetX = maxt.setXConstraint; - maxt.setXConstraint = function(iLeft, iRight, iTickSize) { - if (slider.maxLock) { - iLeft = (1 - slider.maxLock) * iTickSize; - } else { - iLeft += iTickSize; - } - maxtSetX.apply(maxt, [iLeft, iRight, iTickSize]); - }; + // Create the DualSlider + var YW = YAHOO.widget; - // slider.minRange = -15; - // Decorate the DualSlider instance with some new properties and - // methods to maintain the highlight element - YAHOO.lang.augmentObject( - slider, - { - setLocks: function(min, max) { - this.minLock = min; - this.maxLock = max; - var delta = max - min; - Dom.setStyle(this._lock, 'display', 'block'); - Dom.setStyle( - this._lock, - 'left', - min * tickSize - 23 + 'px' - ); - Dom.setStyle( - this._lock, - 'width', - Math.max(delta * tickSize, 0) + 'px' - ); - }, - minLock: undefined, - maxLock: undefined, - _lock: Sel.query('.speciesSlider_lock', elSlider, true), - // The highlight element - _highlight: Sel.query( - '.speciesHO_highlight', - this.container, - true - ), - // A method to update the status and update the highlight - updateHighlight: function() { - var delta = this.maxVal - this.minVal; - Dom.setStyle( - this._highlight, - 'left', - this.minVal - 5 + 'px' - ); - Dom.setStyle( - this._highlight, - 'width', - Math.max(delta + 27, 0) + 'px' - ); - }, - getMinOrbit: function() { - return ( - Math.round((this.minVal - 14) / tickSize) + 1 - ); - }, - getMaxOrbit: function() { - return ( - Math.round((this.maxVal + 14) / tickSize) + 1 - ); - }, - setMinOrbit: function(orbit, skipAnim, force, silent) { - var value = (orbit - 1) * tickSize + 14; - this.setMinValue(value, skipAnim, force, silent); - return orbit; - }, - setMaxOrbit: function(orbit, skipAnim, force, silent) { - var value = (orbit - 1) * tickSize - 14; - this.setMaxValue(value, skipAnim, force, silent); - return orbit; - }, - setOrbits: function( - minOrbit, - maxOrbit, - skipAnim, - force, - silent - ) { - var min = (minOrbit - 1) * tickSize + 14; - var max = (maxOrbit - 1) * tickSize - 14; - this.setValues(min, max, skipAnim, force, silent); - }, - }, - true - ); - // Attach the highlight method to the slider's change event - slider.subscribe( - 'change', - slider.updateHighlight, - slider, - true - ); - //this.Dialog.showEvent.subscribe(slider.updateHighlight,slider,true); - slider.updateHighlight(); + var elMinThumb = Sel.query('.speciesHO_min_thumb', this.container, true); + elMinThumb.id = Dom.generateId(); + var elMin = Sel.query('.speciesHO_min', this.container, true); + elMin.id = Dom.generateId(); + var elMaxThumb = Sel.query('.speciesHO_max_thumb', this.container, true); + elMaxThumb.id = Dom.generateId(); + var elMax = Sel.query('.speciesHO_max', this.container, true); + elMax.id = Dom.generateId(); + var elSlider = Sel.query('.speciesHO', this.container, true); + elSlider.id = Dom.generateId(); - var updateUI = function() { - from.innerHTML = this.getMinOrbit(); - to.innerHTML = this.getMaxOrbit(); - }; - slider.subscribe('ready', updateUI); - slider.subscribe('change', updateUI); + var mint = new YW.SliderThumb(elMinThumb.id, elMin.id, 0, range, 0, 0, tickSize); + var maxt = new YW.SliderThumb(elMaxThumb.id, elMax.id, 0, range, 0, 0, tickSize); - return slider; - }, - _createHorizSingle: function(container, thumb, num) { - var range = 180, - tickSize = 30, - elNum = Sel.query('.' + num, this.container, true); - container = Sel.query('.' + container, this.container, true); - container.id = Dom.generateId(); - thumb = Sel.query('.' + thumb, this.container, true); - thumb.id = Dom.generateId(); - // Create the Slider - var slider = Slider.getHorizSlider( - container.id, - thumb.id, - 0, - range, - tickSize - ); - slider.key = container.id; - YAHOO.lang.augmentObject( - slider, - { - setLock: function(min) { - Dom.setStyle(this._lock, 'display', 'block'); - Dom.setStyle(this._lock, 'left', '0px'); - Dom.setStyle( - this._lock, - 'width', - (min - 1) * tickSize + 8 + 'px' - ); - this.thumb.setXConstraint( - (1 - min) * tickSize, - range, - tickSize - ); - }, - _lock: Sel.query( - '.speciesSlider_lock', - container, - true - ), - getAffinity: function() { - return Math.round(this.getValue() / tickSize + 1); - }, - setAffinity: function( - affinity, - skipAnim, - force, - silent - ) { - var value = (affinity - 1) * tickSize; - this.setValue(value, skipAnim, force, silent); - return affinity; - }, - }, - true - ); - slider.setAffinity(4); - var updateUI = function() { - elNum.innerHTML = this.getAffinity(); - }; - slider.subscribe('ready', updateUI); - slider.subscribe('change', updateUI); + var mins = new YW.Slider(elSlider.id, elSlider.id, mint, 'horiz'); + var maxs = new YW.Slider(elSlider.id, elSlider.id, maxt, 'horiz'); + var slider = new YW.DualSlider(mins, maxs, range, [90, 90]); + var mintSetX = mint.setXConstraint; + mint.setXConstraint = function (iLeft, iRight, iTickSize) { + if (slider.minLock) { + iRight = (slider.minLock - 1) * iTickSize; + } else { + iRight += iTickSize * 1.5; + } + mintSetX.apply(mint, [iLeft, iRight, iTickSize]); + }; + var maxtSetX = maxt.setXConstraint; + maxt.setXConstraint = function (iLeft, iRight, iTickSize) { + if (slider.maxLock) { + iLeft = (1 - slider.maxLock) * iTickSize; + } else { + iLeft += iTickSize; + } + maxtSetX.apply(maxt, [iLeft, iRight, iTickSize]); + }; - return slider; + // slider.minRange = -15; + // Decorate the DualSlider instance with some new properties and + // methods to maintain the highlight element + YAHOO.lang.augmentObject( + slider, + { + setLocks: function (min, max) { + this.minLock = min; + this.maxLock = max; + var delta = max - min; + Dom.setStyle(this._lock, 'display', 'block'); + Dom.setStyle(this._lock, 'left', min * tickSize - 23 + 'px'); + Dom.setStyle(this._lock, 'width', Math.max(delta * tickSize, 0) + 'px'); }, - getSpeciesData: function() { - var data = { - name: this.elName.value, - description: this.elDesc.value.substr(0, 1024), - min_orbit: this.speciesHO.getMinOrbit(), - max_orbit: this.speciesHO.getMaxOrbit(), - manufacturing_affinity: this.speciesConst.getAffinity(), - deception_affinity: this.speciesDecep.getAffinity(), - research_affinity: this.speciesResearch.getAffinity(), - management_affinity: this.speciesManagement.getAffinity(), - farming_affinity: this.speciesFarming.getAffinity(), - mining_affinity: this.speciesMining.getAffinity(), - science_affinity: this.speciesScience.getAffinity(), - environmental_affinity: this.speciesEnviro.getAffinity(), - political_affinity: this.speciesPolitical.getAffinity(), - trade_affinity: this.speciesTrade.getAffinity(), - growth_affinity: this.speciesGrowth.getAffinity(), - }; - data.affinity_total = - data.max_orbit - - data.min_orbit + - 1 + - data.manufacturing_affinity + - data.deception_affinity + - data.research_affinity + - data.management_affinity + - data.farming_affinity + - data.mining_affinity + - data.science_affinity + - data.environmental_affinity + - data.political_affinity + - data.trade_affinity + - data.growth_affinity; - return data; + minLock: undefined, + maxLock: undefined, + _lock: Sel.query('.speciesSlider_lock', elSlider, true), + // The highlight element + _highlight: Sel.query('.speciesHO_highlight', this.container, true), + // A method to update the status and update the highlight + updateHighlight: function () { + var delta = this.maxVal - this.minVal; + Dom.setStyle(this._highlight, 'left', this.minVal - 5 + 'px'); + Dom.setStyle(this._highlight, 'width', Math.max(delta + 27, 0) + 'px'); }, - setSpeciesData: function(data) { - this.elName.value = data.name; - this.elDesc.value = data.description; - this.speciesHO.setOrbits( - data.min_orbit, - data.max_orbit, - true, - true - ); - this.speciesConst.setAffinity( - data.manufacturing_affinity, - true, - true - ); - this.speciesDecep.setAffinity( - data.deception_affinity, - true, - true - ); - this.speciesResearch.setAffinity( - data.research_affinity, - true, - true - ); - this.speciesManagement.setAffinity( - data.management_affinity, - true, - true - ); - this.speciesFarming.setAffinity( - data.farming_affinity, - true, - true - ); - this.speciesMining.setAffinity( - data.mining_affinity, - true, - true - ); - this.speciesScience.setAffinity( - data.science_affinity, - true, - true - ); - this.speciesEnviro.setAffinity( - data.environmental_affinity, - true, - true - ); - this.speciesPolitical.setAffinity( - data.political_affinity, - true, - true - ); - this.speciesTrade.setAffinity(data.trade_affinity, true, true); - this.speciesGrowth.setAffinity( - data.growth_affinity, - true, - true - ); + getMinOrbit: function () { + return Math.round((this.minVal - 14) / tickSize) + 1; }, - setSpeciesLocks: function(data) { - this.speciesHO.setLocks(data.min_orbit, data.max_orbit); - this.speciesGrowth.setLock(data.min_growth); + getMaxOrbit: function () { + return Math.round((this.maxVal + 14) / tickSize) + 1; }, - compareSpeciesData: function(species1, species2) { - return ( - species1.manufacturing_affinity == - species2.manufacturing_affinity && - species1.deception_affinity == - species2.deception_affinity && - species1.research_affinity == species2.research_affinity && - species1.management_affinity == - species2.management_affinity && - species1.farming_affinity == species2.farming_affinity && - species1.mining_affinity == species2.mining_affinity && - species1.science_affinity == species2.science_affinity && - species1.environmental_affinity == - species2.environmental_affinity && - species1.political_affinity == - species2.political_affinity && - species1.trade_affinity == species2.trade_affinity && - species1.growth_affinity == species2.growth_affinity - ); + setMinOrbit: function (orbit, skipAnim, force, silent) { + var value = (orbit - 1) * tickSize + 14; + this.setMinValue(value, skipAnim, force, silent); + return orbit; }, - setExpert: function() { - this._expert = true; + setMaxOrbit: function (orbit, skipAnim, force, silent) { + var value = (orbit - 1) * tickSize - 14; + this.setMaxValue(value, skipAnim, force, silent); + return orbit; }, - clearExpert: function() { - delete this._expert; + setOrbits: function (minOrbit, maxOrbit, skipAnim, force, silent) { + var min = (minOrbit - 1) * tickSize + 14; + var max = (maxOrbit - 1) * tickSize - 14; + this.setValues(min, max, skipAnim, force, silent); }, - needsExpert: function(data) { - return ( - data.manufacturing_affinity == 1 || - data.deception_affinity == 1 || - data.research_affinity == 1 || - data.management_affinity == 1 || - data.farming_affinity == 1 || - data.mining_affinity == 1 || - data.science_affinity == 1 || - data.environmental_affinity == 1 || - data.political_affinity == 1 || - data.trade_affinity == 1 || - data.growth_affinity == 1 - ); - }, - selectTemplate: function(index) { - var data = this.speciesTemplates[index]; - this.setSpeciesData(data); + }, + true + ); + // Attach the highlight method to the slider's change event + slider.subscribe('change', slider.updateHighlight, slider, true); + //this.Dialog.showEvent.subscribe(slider.updateHighlight,slider,true); + slider.updateHighlight(); + + var updateUI = function () { + from.innerHTML = this.getMinOrbit(); + to.innerHTML = this.getMaxOrbit(); + }; + slider.subscribe('ready', updateUI); + slider.subscribe('change', updateUI); + + return slider; + }, + _createHorizSingle: function (container, thumb, num) { + var range = 180, + tickSize = 30, + elNum = Sel.query('.' + num, this.container, true); + container = Sel.query('.' + container, this.container, true); + container.id = Dom.generateId(); + thumb = Sel.query('.' + thumb, this.container, true); + thumb.id = Dom.generateId(); + // Create the Slider + var slider = Slider.getHorizSlider(container.id, thumb.id, 0, range, tickSize); + slider.key = container.id; + YAHOO.lang.augmentObject( + slider, + { + setLock: function (min) { + Dom.setStyle(this._lock, 'display', 'block'); + Dom.setStyle(this._lock, 'left', '0px'); + Dom.setStyle(this._lock, 'width', (min - 1) * tickSize + 8 + 'px'); + this.thumb.setXConstraint((1 - min) * tickSize, range, tickSize); }, - validateSpecies: function(data) { - if (data.affinity_total > 45) { - throw 'You can only have a maximum of 45 points.'; - } else if (data.affinity_total < 45) { - throw 'You must use exactly 45 points.'; - } else if (!this._expert && this.needsExpert(data)) { - if ( - confirm( - "Setting an affinity to 1 is an expert setting, and is not recommended unless you're absolutely sure you know what you're doing. Are you sure you want to continue?" - ) - ) { - this._expert = true; - } else { - return false; - } - } - return true; + _lock: Sel.query('.speciesSlider_lock', container, true), + getAffinity: function () { + return Math.round(this.getValue() / tickSize + 1); }, - _getHtml: function() { - var nameId = Dom.generateId(); - var descId = Dom.generateId(); - return [ - '
                                                                  ', - ' Presets: ', - ' ', - ' ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                  • Affinities:0/45
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                    ', - ' ', - ' ', - '
                                                                    ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                    ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  • ', - '
                                                                    ', - ' ', - '
                                                                    1
                                                                    ', - '
                                                                    ', - '
                                                                  • ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ].join(''); + setAffinity: function (affinity, skipAnim, force, silent) { + var value = (affinity - 1) * tickSize; + this.setValue(value, skipAnim, force, silent); + return affinity; }, + }, + true + ); + slider.setAffinity(4); + var updateUI = function () { + elNum.innerHTML = this.getAffinity(); + }; + slider.subscribe('ready', updateUI); + slider.subscribe('change', updateUI); + + return slider; + }, + getSpeciesData: function () { + var data = { + name: this.elName.value, + description: this.elDesc.value.substr(0, 1024), + min_orbit: this.speciesHO.getMinOrbit(), + max_orbit: this.speciesHO.getMaxOrbit(), + manufacturing_affinity: this.speciesConst.getAffinity(), + deception_affinity: this.speciesDecep.getAffinity(), + research_affinity: this.speciesResearch.getAffinity(), + management_affinity: this.speciesManagement.getAffinity(), + farming_affinity: this.speciesFarming.getAffinity(), + mining_affinity: this.speciesMining.getAffinity(), + science_affinity: this.speciesScience.getAffinity(), + environmental_affinity: this.speciesEnviro.getAffinity(), + political_affinity: this.speciesPolitical.getAffinity(), + trade_affinity: this.speciesTrade.getAffinity(), + growth_affinity: this.speciesGrowth.getAffinity(), }; - //YAHOO.lang.augmentProto(SpeciesDesigner, Util.EventProvider); + data.affinity_total = + data.max_orbit - + data.min_orbit + + 1 + + data.manufacturing_affinity + + data.deception_affinity + + data.research_affinity + + data.management_affinity + + data.farming_affinity + + data.mining_affinity + + data.science_affinity + + data.environmental_affinity + + data.political_affinity + + data.trade_affinity + + data.growth_affinity; + return data; + }, + setSpeciesData: function (data) { + this.elName.value = data.name; + this.elDesc.value = data.description; + this.speciesHO.setOrbits(data.min_orbit, data.max_orbit, true, true); + this.speciesConst.setAffinity(data.manufacturing_affinity, true, true); + this.speciesDecep.setAffinity(data.deception_affinity, true, true); + this.speciesResearch.setAffinity(data.research_affinity, true, true); + this.speciesManagement.setAffinity(data.management_affinity, true, true); + this.speciesFarming.setAffinity(data.farming_affinity, true, true); + this.speciesMining.setAffinity(data.mining_affinity, true, true); + this.speciesScience.setAffinity(data.science_affinity, true, true); + this.speciesEnviro.setAffinity(data.environmental_affinity, true, true); + this.speciesPolitical.setAffinity(data.political_affinity, true, true); + this.speciesTrade.setAffinity(data.trade_affinity, true, true); + this.speciesGrowth.setAffinity(data.growth_affinity, true, true); + }, + setSpeciesLocks: function (data) { + this.speciesHO.setLocks(data.min_orbit, data.max_orbit); + this.speciesGrowth.setLock(data.min_growth); + }, + compareSpeciesData: function (species1, species2) { + return ( + species1.manufacturing_affinity == species2.manufacturing_affinity && + species1.deception_affinity == species2.deception_affinity && + species1.research_affinity == species2.research_affinity && + species1.management_affinity == species2.management_affinity && + species1.farming_affinity == species2.farming_affinity && + species1.mining_affinity == species2.mining_affinity && + species1.science_affinity == species2.science_affinity && + species1.environmental_affinity == species2.environmental_affinity && + species1.political_affinity == species2.political_affinity && + species1.trade_affinity == species2.trade_affinity && + species1.growth_affinity == species2.growth_affinity + ); + }, + setExpert: function () { + this._expert = true; + }, + clearExpert: function () { + delete this._expert; + }, + needsExpert: function (data) { + return ( + data.manufacturing_affinity == 1 || + data.deception_affinity == 1 || + data.research_affinity == 1 || + data.management_affinity == 1 || + data.farming_affinity == 1 || + data.mining_affinity == 1 || + data.science_affinity == 1 || + data.environmental_affinity == 1 || + data.political_affinity == 1 || + data.trade_affinity == 1 || + data.growth_affinity == 1 + ); + }, + selectTemplate: function (index) { + var data = this.speciesTemplates[index]; + this.setSpeciesData(data); + }, + validateSpecies: function (data) { + if (data.affinity_total > 45) { + throw 'You can only have a maximum of 45 points.'; + } else if (data.affinity_total < 45) { + throw 'You must use exactly 45 points.'; + } else if (!this._expert && this.needsExpert(data)) { + if ( + confirm( + "Setting an affinity to 1 is an expert setting, and is not recommended unless you're absolutely sure you know what you're doing. Are you sure you want to continue?" + ) + ) { + this._expert = true; + } else { + return false; + } + } + return true; + }, + _getHtml: function () { + var nameId = Dom.generateId(); + var descId = Dom.generateId(); + return [ + '
                                                                  ', + ' Presets: ', + ' ', + ' ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                  • Affinities:0/45
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                    ', + ' ', + ' ', + '
                                                                    ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                    ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  • ', + '
                                                                    ', + ' ', + '
                                                                    1
                                                                    ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ].join(''); + }, + }; + //YAHOO.lang.augmentProto(SpeciesDesigner, Util.EventProvider); - Lacuna.SpeciesDesigner = SpeciesDesigner; - })(); - YAHOO.register('speciesDesigner', YAHOO.lacuna.SpeciesDesigner, { - version: '1', - build: '0', - }); + Lacuna.SpeciesDesigner = SpeciesDesigner; + })(); + YAHOO.register('speciesDesigner', YAHOO.lacuna.SpeciesDesigner, { + version: '1', + build: '0', + }); } diff --git a/app/yui/stats.js b/app/yui/stats.js index 26c99204..6bc9928a 100644 --- a/app/yui/stats.js +++ b/app/yui/stats.js @@ -7,236 +7,216 @@ import MenuStore from 'app/stores/menu'; YAHOO.namespace('lacuna'); if (typeof YAHOO.lacuna.Stats == 'undefined' || !YAHOO.lacuna.Stats) { - (function () { - var Lang = YAHOO.lang, - Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Sel = Util.Selector, - Lacuna = YAHOO.lacuna, - Game = Lacuna.Game, - Lib = Lacuna.Library; - - var Stats = function () {}; - Stats.prototype = { - build: _.once(function () { - this.id = 'stats'; - - var container = document.createElement('div'); - container.id = this.id; - Dom.addClass(container, Lib.Styles.HIDDEN); - container.innerHTML = this._getHtml(); - document.body.insertBefore(container, document.body.firstChild); - - this.Panel = new YAHOO.widget.Panel(this.id, { - constraintoviewport: true, - visible: false, - draggable: true, - effect: Game.GetContainerEffect(), - underlay: false, - close: true, - width: '800px', - zIndex: 9999, - }); - this.Panel.renderEvent.subscribe( - function () { - Dom.removeClass(this.id, Lib.Styles.HIDDEN); - this.tabView = new YAHOO.widget.TabView('statsTabs'); - this.tabView.set('activeIndex', 0); - - //subscribe after adding so active doesn't fire - this.tabView.getTab(1).subscribe( - 'activeChange', - function (e) { - if (e.newValue) { - this.AllianceStats(); - } - }, - this, - true - ); - this.tabView.getTab(2).subscribe( - 'activeChange', - function (e) { - if (e.newValue) { - this.ColonyStats(); - } - }, - this, - true - ); - this.tabView.getTab(3).subscribe( - 'activeChange', - function (e) { - if (e.newValue) { - this.SpyStats(); - } - }, - this, - true - ); - this.tabView.getTab(4).subscribe( - 'activeChange', - function (e) { - if (e.newValue) { - this.WeeklyMedalStats(); - } - }, - this, - true - ); - this.tabView.getTab(5).subscribe( - 'activeChange', - function (e) { - if (e.newValue) { - this.getServerStats(); - } - }, - this, - true - ); - - this.generalTabView = new YAHOO.widget.TabView('statsGeneralTabs', { - orientation: 'left', - }); - this.generalTabView.set('activeIndex', 0); - - this.statsGeneralBodies = Dom.get('statsGeneralBodies'); - this.statsGeneralBuildings = Dom.get('statsGeneralBuildings'); - this.statsGeneralEmpires = Dom.get('statsGeneralEmpires'); - this.statsGeneralOrbits = Dom.get('statsGeneralOrbits'); - this.statsGeneralShips = Dom.get('statsGeneralShips'); - this.statsGeneralSpies = Dom.get('statsGeneralSpies'); - this.statsGeneralStars = Dom.get('statsGeneralStars'); - this.statsGeneralGlyphs = Dom.get('statsGeneralGlyphs'); - }, - this, - true - ); - - // Let the React component know that we're going away now. - this.Panel.hideEvent.subscribe(() => StatsWindowStore.hide()); - - this.Panel.render(); - Game.OverlayManager.register(this.Panel); - }), - _getHtml: function () { - return [ - '
                                                                  Universe Stats
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ' ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ' ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - '
                                                                  ', - ].join(''); - }, - - getServerStats: function () { - MenuStore.showLoader(); - Util.Connect.asyncRequest('GET', constants.RPC_BASE + 'server_overview.json', { - success: function (o) { - YAHOO.log(o, 'info', 'Stats.populateServerStats.success'); - MenuStore.hideLoader(); - try { - this._serverOverview = Lang.JSON.parse(o.responseText); - this.populateServerStats(); - } catch (ex) { - YAHOO.log(ex); - } - }, - scope: this, - }); - }, - populateServerStats: function () { - var data = this._serverOverview; - - Event.purgeElement(this.statsGeneralBodies); - Event.purgeElement(this.statsGeneralBuildings); - Event.purgeElement(this.statsGeneralOrbits); - Event.purgeElement(this.statsGeneralShips); - - this.statsGeneralBodies.innerHTML = this._getBodiesHtml(); - this.statsGeneralBuildings.innerHTML = this._getBuildingsHtml(); - this.statsGeneralEmpires.innerHTML = this._getEmpiresHtml(); - this.statsGeneralOrbits.innerHTML = this._getOrbitsHtml(); - this.statsGeneralShips.innerHTML = this._getShipsHtml(); - this.statsGeneralSpies.innerHTML = this._getSpiesHtml(); - this.statsGeneralStars.innerHTML = this._getStarsHtml(); - this.statsGeneralGlyphs.innerHTML = this._getGlyphsHtml(); - - Event.delegate( - this.statsGeneralBodies, - 'click', - this.expander, - 'label.statsSubHeader' - ); - Event.delegate( - this.statsGeneralBuildings, - 'click', - this.expander, - 'label.statsSubHeader' - ); - Event.delegate( - this.statsGeneralOrbits, - 'click', - this.expander, - 'label.statsSubHeader' - ); - Event.delegate( - this.statsGeneralShips, - 'click', - this.expander, - 'label.statsSubHeader' - ); - - /*var r = Raphael("raphaelHolder"), + (function () { + var Lang = YAHOO.lang, + Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Sel = Util.Selector, + Lacuna = YAHOO.lacuna, + Game = Lacuna.Game, + Lib = Lacuna.Library; + + var Stats = function () {}; + Stats.prototype = { + build: _.once(function () { + this.id = 'stats'; + + var container = document.createElement('div'); + container.id = this.id; + Dom.addClass(container, Lib.Styles.HIDDEN); + container.innerHTML = this._getHtml(); + document.body.insertBefore(container, document.body.firstChild); + + this.Panel = new YAHOO.widget.Panel(this.id, { + constraintoviewport: true, + visible: false, + draggable: true, + effect: Game.GetContainerEffect(), + underlay: false, + close: true, + width: '800px', + zIndex: 9999, + }); + this.Panel.renderEvent.subscribe( + function () { + Dom.removeClass(this.id, Lib.Styles.HIDDEN); + this.tabView = new YAHOO.widget.TabView('statsTabs'); + this.tabView.set('activeIndex', 0); + + //subscribe after adding so active doesn't fire + this.tabView.getTab(1).subscribe( + 'activeChange', + function (e) { + if (e.newValue) { + this.AllianceStats(); + } + }, + this, + true + ); + this.tabView.getTab(2).subscribe( + 'activeChange', + function (e) { + if (e.newValue) { + this.ColonyStats(); + } + }, + this, + true + ); + this.tabView.getTab(3).subscribe( + 'activeChange', + function (e) { + if (e.newValue) { + this.SpyStats(); + } + }, + this, + true + ); + this.tabView.getTab(4).subscribe( + 'activeChange', + function (e) { + if (e.newValue) { + this.WeeklyMedalStats(); + } + }, + this, + true + ); + this.tabView.getTab(5).subscribe( + 'activeChange', + function (e) { + if (e.newValue) { + this.getServerStats(); + } + }, + this, + true + ); + + this.generalTabView = new YAHOO.widget.TabView('statsGeneralTabs', { + orientation: 'left', + }); + this.generalTabView.set('activeIndex', 0); + + this.statsGeneralBodies = Dom.get('statsGeneralBodies'); + this.statsGeneralBuildings = Dom.get('statsGeneralBuildings'); + this.statsGeneralEmpires = Dom.get('statsGeneralEmpires'); + this.statsGeneralOrbits = Dom.get('statsGeneralOrbits'); + this.statsGeneralShips = Dom.get('statsGeneralShips'); + this.statsGeneralSpies = Dom.get('statsGeneralSpies'); + this.statsGeneralStars = Dom.get('statsGeneralStars'); + this.statsGeneralGlyphs = Dom.get('statsGeneralGlyphs'); + }, + this, + true + ); + + // Let the React component know that we're going away now. + this.Panel.hideEvent.subscribe(() => StatsWindowStore.hide()); + + this.Panel.render(); + Game.OverlayManager.register(this.Panel); + }), + _getHtml: function () { + return [ + '
                                                                  Universe Stats
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ' ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ' ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + '
                                                                  ', + ].join(''); + }, + + getServerStats: function () { + MenuStore.showLoader(); + Util.Connect.asyncRequest('GET', constants.RPC_BASE + 'server_overview.json', { + success: function (o) { + YAHOO.log(o, 'info', 'Stats.populateServerStats.success'); + MenuStore.hideLoader(); + try { + this._serverOverview = Lang.JSON.parse(o.responseText); + this.populateServerStats(); + } catch (ex) { + YAHOO.log(ex); + } + }, + scope: this, + }); + }, + populateServerStats: function () { + var data = this._serverOverview; + + Event.purgeElement(this.statsGeneralBodies); + Event.purgeElement(this.statsGeneralBuildings); + Event.purgeElement(this.statsGeneralOrbits); + Event.purgeElement(this.statsGeneralShips); + + this.statsGeneralBodies.innerHTML = this._getBodiesHtml(); + this.statsGeneralBuildings.innerHTML = this._getBuildingsHtml(); + this.statsGeneralEmpires.innerHTML = this._getEmpiresHtml(); + this.statsGeneralOrbits.innerHTML = this._getOrbitsHtml(); + this.statsGeneralShips.innerHTML = this._getShipsHtml(); + this.statsGeneralSpies.innerHTML = this._getSpiesHtml(); + this.statsGeneralStars.innerHTML = this._getStarsHtml(); + this.statsGeneralGlyphs.innerHTML = this._getGlyphsHtml(); + + Event.delegate(this.statsGeneralBodies, 'click', this.expander, 'label.statsSubHeader'); + Event.delegate(this.statsGeneralBuildings, 'click', this.expander, 'label.statsSubHeader'); + Event.delegate(this.statsGeneralOrbits, 'click', this.expander, 'label.statsSubHeader'); + Event.delegate(this.statsGeneralShips, 'click', this.expander, 'label.statsSubHeader'); + + /*var r = Raphael("raphaelHolder"), fin = function () { this.flag = r.g.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this); }, @@ -255,1623 +235,1543 @@ if (typeof YAHOO.lacuna.Stats == 'undefined' || !YAHOO.lacuna.Stats) { ["Orbit 1 Bodies", "Orbit 2 Bodies", "Orbit 3 Bodies", "Orbit 4 Bodies", "Orbit 5 Bodies", "Orbit 6 Bodies", "Orbit 7 Bodies", "Orbit 8 Bodies"], ["Orbit 1 Inhabited", "Orbit 2 Inhabited", "Orbit 3 Inhabited", "Orbit 4 Inhabited", "Orbit 5 Inhabited", "Orbit 6 Inhabited", "Orbit 7 Inhabited", "Orbit 8 Inhabited"] ],true);*/ + }, + expander: function (e, matchedEl, container) { + var ul = Sel.query('ul', matchedEl.parentNode, true); + Dom.setStyle(ul, 'display', Dom.getStyle(ul, 'display') == 'none' ? '' : 'none'); + }, + _getBodiesHtml: function () { + var data = this._serverOverview.bodies; + return [ + '
                                                                    ', + '
                                                                  • ', + Lib.formatNumber(data.count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.colony_count), + '
                                                                  • ', + '
                                                                  • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data.types.asteroids.count), + '
                                                                      • ', + '
                                                                      • ', + data.types.asteroids.average_orbit, + '
                                                                      • ', + '
                                                                      • ', + data.types.asteroids.average_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.asteroids.largest_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.asteroids.smallest_size, + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data.types.gas_giants.count), + '
                                                                      • ', + '
                                                                      • ', + data.types.gas_giants.average_orbit, + '
                                                                      • ', + '
                                                                      • ', + data.types.gas_giants.average_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.gas_giants.largest_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.gas_giants.smallest_size, + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data.types.habitables.count), + '
                                                                      • ', + '
                                                                      • ', + data.types.habitables.average_orbit, + '
                                                                      • ', + '
                                                                      • ', + data.types.habitables.average_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.habitables.largest_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.habitables.smallest_size, + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data.types.stations.count), + '
                                                                      • ', + '
                                                                      • ', + data.types.stations.average_orbit, + '
                                                                      • ', + '
                                                                      • ', + data.types.stations.average_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.stations.largest_size, + '
                                                                      • ', + '
                                                                      • ', + data.types.stations.smallest_size, + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    ', + '
                                                                  • ', + '
                                                                  ', + ].join(''); + }, + _getBuildingsHtml: function () { + var data = this._serverOverview.buildings, + output = [ + '
                                                                    ', + '
                                                                  • ', + Lib.formatNumber(data.count), + '
                                                                  • ', + '
                                                                    • ', + ]; + + var btArr = []; + for (var bt in data.types) { + if (data.types.hasOwnProperty(bt)) { + btArr[btArr.length] = bt; + } + } + btArr.sort(); + + for (var b = 0, bLen = btArr.length; b < bLen; b++) { + var key = btArr[b]; + output.push( + [ + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data.types[key].count), + '
                                                                      • ', + '
                                                                      • ', + data.types[key].average_level, + '
                                                                      • ', + '
                                                                      • ', + data.types[key].highest_level, + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + ].join('') + ); + } + + output.push('
                                                                  '); + return output.join(''); + }, + _getEmpiresHtml: function () { + var data = this._serverOverview.empires; + return [ + '
                                                                    ', + '
                                                                  • ', + Lib.formatNumber(data.count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.active_this_week_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.active_today_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.currently_active_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_university_level), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_university_level), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.essentia_using_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.isolationist_count), + '
                                                                  • ', + '
                                                                  ', + ].join(''); + }, + _getOrbitsHtml: function () { + var data = this._serverOverview.orbits; + + return [ + '
                                                                    ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['1'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['1'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['2'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['2'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['3'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['3'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['4'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['4'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['5'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['5'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['6'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['6'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['7'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['7'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data['8'].bodies), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data['8'].inhabited), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + '
                                                                  ', + ].join(''); + }, + _getShipsHtml: function () { + var data = this._serverOverview.ships, + output = [ + '
                                                                    ', + '
                                                                  • ', + Lib.formatNumber(data.count), + '
                                                                  • ', + '
                                                                    • ', + ]; + + for (var bt in data.types) { + if (data.types.hasOwnProperty(bt)) { + output.push( + [ + '
                                                                    • ', + '
                                                                        ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].count), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].smallest_hold_size), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].average_hold_size), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].largest_hold_size), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].slowest_speed), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].average_speed), + '
                                                                      • ', + '
                                                                      • ', + Lib.formatNumber(data.types[bt].fastest_speed), + '
                                                                      • ', + '
                                                                      ', + '
                                                                    • ', + ].join('') + ); + } + } + + output.push('
                                                                  '); + return output.join(''); + }, + _getSpiesHtml: function () { + var data = this._serverOverview.spies; + return [ + '
                                                                    ', + '
                                                                  • ', + Lib.formatNumber(data.count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_defense), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_defense), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_offense), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_offense), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_intel), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_intel), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_mayhem), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_mayhem), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_politics), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_politics), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.average_theft), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.highest_theft), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.idle_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.travelling_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.countering_espionage_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.security_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.propaganda_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.training_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.extra_training_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.gathering_intelligence_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.hacking_networks_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.inciting_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.sabotaging_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.stealing_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.extraction_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.antipersonal_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.infiltrating_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.in_prison_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.for_sale_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.unconscious_count), + '
                                                                  • ', + '
                                                                  ', + ].join(''); + }, + _getStarsHtml: function () { + var data = this._serverOverview.stars; + return [ + '
                                                                    ', + '
                                                                  • ', + Lib.formatNumber(data.count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.seized_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.probed_count), + '
                                                                  • ', + '
                                                                  • ', + Lib.formatNumber(data.probes_count), + '
                                                                  • ', + '
                                                                  ', + ].join(''); + }, + _getGlyphsHtml: function () { + var data = this._serverOverview.glyphs, + output = ['
                                                                    ']; + var glyphs = new Array(); + var i = 0; + for (var bt in data.types) { + glyphs[i] = { type: bt, count: data.types[bt] }; + i++; + } + glyphs.sort(function (a, b) { + return a.count - b.count; + }); + for (var i = 0; i < glyphs.length; i++) { + output.push( + [ + '
                                                                  • ', + Lib.formatNumber(glyphs[i].count), + '
                                                                  • ', + ].join('') + ); + } + return output.join(''); + }, + + formatPercent: function (el, oRecord, oColumn, oData) { + el.innerHTML = Util.Number.format(Math.round(oData * 100), { + thousandsSeparator: ',', + suffix: '%', + }); + }, + EmpireStats: function () { + if (this.EmpireTable) { + this.EmpireTable.requery(); + } else { + this.EmpireFindCreate(); + + this.EmpireColumns = [ + { + key: 'rank', + label: 'Rank', + formatter: function (el, oRecord, oColumn, oData) { + var oState = this.getState(); + el.innerHTML = Math.floor(oState.pagination.recordOffset + this.rankCounter++); + }, }, - expander: function (e, matchedEl, container) { - var ul = Sel.query('ul', matchedEl.parentNode, true); - Dom.setStyle(ul, 'display', Dom.getStyle(ul, 'display') == 'none' ? '' : 'none'); + { key: 'empire_name', label: 'Empire' }, + { key: 'alliance_name', label: 'Alliance' }, + { + key: 'colony_count', + label: 'Colonies', + formatter: 'number', }, - _getBodiesHtml: function () { - var data = this._serverOverview.bodies; - return [ - '
                                                                      ', - '
                                                                    • ', - Lib.formatNumber(data.count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.colony_count), - '
                                                                    • ', - '
                                                                    • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data.types.asteroids.count), - '
                                                                        • ', - '
                                                                        • ', - data.types.asteroids.average_orbit, - '
                                                                        • ', - '
                                                                        • ', - data.types.asteroids.average_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.asteroids.largest_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.asteroids.smallest_size, - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data.types.gas_giants.count), - '
                                                                        • ', - '
                                                                        • ', - data.types.gas_giants.average_orbit, - '
                                                                        • ', - '
                                                                        • ', - data.types.gas_giants.average_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.gas_giants.largest_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.gas_giants.smallest_size, - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data.types.habitables.count), - '
                                                                        • ', - '
                                                                        • ', - data.types.habitables.average_orbit, - '
                                                                        • ', - '
                                                                        • ', - data.types.habitables.average_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.habitables.largest_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.habitables.smallest_size, - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data.types.stations.count), - '
                                                                        • ', - '
                                                                        • ', - data.types.stations.average_orbit, - '
                                                                        • ', - '
                                                                        • ', - data.types.stations.average_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.stations.largest_size, - '
                                                                        • ', - '
                                                                        • ', - data.types.stations.smallest_size, - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      ', - '
                                                                    • ', - '
                                                                    ', - ].join(''); + { + key: 'population', + label: 'Pop', + formatter: 'number', }, - _getBuildingsHtml: function () { - var data = this._serverOverview.buildings, - output = [ - '
                                                                      ', - '
                                                                    • ', - Lib.formatNumber(data.count), - '
                                                                    • ', - '
                                                                      • ', - ]; - - var btArr = []; - for (var bt in data.types) { - if (data.types.hasOwnProperty(bt)) { - btArr[btArr.length] = bt; - } - } - btArr.sort(); - - for (var b = 0, bLen = btArr.length; b < bLen; b++) { - var key = btArr[b]; - output.push( - [ - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data.types[key].count), - '
                                                                        • ', - '
                                                                        • ', - data.types[key].average_level, - '
                                                                        • ', - '
                                                                        • ', - data.types[key].highest_level, - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - ].join('') - ); - } - - output.push('
                                                                    '); - return output.join(''); + { + key: 'empire_size', + label: 'Empire Size', + formatter: 'number', + sortable: true, }, - _getEmpiresHtml: function () { - var data = this._serverOverview.empires; - return [ - '
                                                                      ', - '
                                                                    • ', - Lib.formatNumber(data.count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.active_this_week_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.active_today_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.currently_active_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_university_level), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_university_level), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.essentia_using_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.isolationist_count), - '
                                                                    • ', - '
                                                                    ', - ].join(''); + { + key: 'building_count', + label: 'Buildings', + formatter: 'number', }, - _getOrbitsHtml: function () { - var data = this._serverOverview.orbits; - - return [ - '
                                                                      ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['1'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['1'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['2'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['2'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['3'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['3'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['4'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['4'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['5'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['5'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['6'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['6'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['7'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['7'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data['8'].bodies), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data['8'].inhabited), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - '
                                                                    ', - ].join(''); + { + key: 'average_building_level', + label: 'Avg Bld', + formatter: 'number', }, - _getShipsHtml: function () { - var data = this._serverOverview.ships, - output = [ - '
                                                                      ', - '
                                                                    • ', - Lib.formatNumber(data.count), - '
                                                                    • ', - '
                                                                      • ', - ]; - - for (var bt in data.types) { - if (data.types.hasOwnProperty(bt)) { - output.push( - [ - '
                                                                      • ', - '
                                                                          ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].count), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].smallest_hold_size), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].average_hold_size), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].largest_hold_size), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].slowest_speed), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].average_speed), - '
                                                                        • ', - '
                                                                        • ', - Lib.formatNumber(data.types[bt].fastest_speed), - '
                                                                        • ', - '
                                                                        ', - '
                                                                      • ', - ].join('') - ); - } - } - - output.push('
                                                                    '); - return output.join(''); + { + key: 'offense_success_rate', + label: 'Offense', + formatter: this.formatPercent, + sortable: true, }, - _getSpiesHtml: function () { - var data = this._serverOverview.spies; - return [ - '
                                                                      ', - '
                                                                    • ', - Lib.formatNumber(data.count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_defense), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_defense), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_offense), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_offense), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_intel), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_intel), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_mayhem), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_mayhem), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_politics), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_politics), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.average_theft), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.highest_theft), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.idle_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.travelling_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.countering_espionage_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.security_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.propaganda_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.training_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.extra_training_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.gathering_intelligence_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.hacking_networks_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.inciting_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.sabotaging_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.stealing_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.extraction_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.antipersonal_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.infiltrating_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.in_prison_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.for_sale_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.unconscious_count), - '
                                                                    • ', - '
                                                                    ', - ].join(''); + { + key: 'defense_success_rate', + label: 'Defense', + formatter: this.formatPercent, + sortable: true, }, - _getStarsHtml: function () { - var data = this._serverOverview.stars; - return [ - '
                                                                      ', - '
                                                                    • ', - Lib.formatNumber(data.count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.seized_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.probed_count), - '
                                                                    • ', - '
                                                                    • ', - Lib.formatNumber(data.probes_count), - '
                                                                    • ', - '
                                                                    ', - ].join(''); + { + key: 'dirtiest', + label: 'Dirtiest', + formatter: 'number', + sortable: true, }, - _getGlyphsHtml: function () { - var data = this._serverOverview.glyphs, - output = ['
                                                                      ']; - var glyphs = new Array(); - var i = 0; - for (var bt in data.types) { - glyphs[i] = { type: bt, count: data.types[bt] }; - i++; - } - glyphs.sort(function (a, b) { - return a.count - b.count; - }); - for (var i = 0; i < glyphs.length; i++) { - output.push( - [ - '
                                                                    • ', - Lib.formatNumber(glyphs[i].count), - '
                                                                    • ', - ].join('') - ); - } - return output.join(''); + ]; + + this.EmpireData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + this.EmpireData.connMethodPost = 'POST'; + this.EmpireData.maxCacheEntries = 2; + this.EmpireData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + this.EmpireData.responseSchema = { + resultsList: 'result.empires', + fields: [ + 'empire_id', + 'empire_name', + 'alliance_id', + 'alliance_name', + { key: 'colony_count', parser: 'number' }, + { key: 'population', parser: 'number' }, + { key: 'empire_size', parser: 'number' }, + { key: 'building_count', parser: 'number' }, + { key: 'average_building_level', parser: 'number' }, + { key: 'offense_success_rate', parser: 'number' }, + { key: 'defense_success_rate', parser: 'number' }, + { key: 'dirtiest', parser: 'number' }, + ], + metaFields: { + totalRecords: 'result.total_empires', // Access to value in the server response + pageNumber: 'result.page_number', }, + }; + + var eHt = Game.GetSize().h - 115; + if (eHt > 375) { + eHt = 375; + } + this.EmpireTable = new YAHOO.widget.ScrollingDataTable( + 'statsEmpireTable', + this.EmpireColumns, + this.EmpireData, + { + width: '100%', + height: eHt + 'px', + initialRequest: Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'empire_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), 'empire_size_rank'], + }), + dynamicData: true, + sortedBy: { + key: 'empire_size', + dir: YAHOO.widget.DataTable.CLASS_DSC, + }, + paginator: new YAHOO.widget.Paginator({ + rowsPerPage: 25, + containers: 'statsEmpirePaginator', + }), + selectionMode: 'single', + } + ); + this.EmpireTable.rankCounter = 1; + // Subscribe to events for row selection + this.EmpireTable.subscribe('rowMouseoverEvent', this.EmpireTable.onEventHighlightRow); + this.EmpireTable.subscribe('rowMouseoutEvent', this.EmpireTable.onEventUnhighlightRow); + this.EmpireTable.subscribe('rowClickEvent', this.EmpireTable.onEventSelectRow); + this.EmpireTable.subscribe('cellMouseoverEvent', this.EmpireTable.onEventHighlightCell); + this.EmpireTable.subscribe('cellHighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name' || oArgs.key == 'alliance_name') { + Dom.setStyle(oArgs.el, 'cursor', 'help'); + } + }); + this.EmpireTable.subscribe('cellMouseoutEvent', this.EmpireTable.onEventUnhighlightCell); + this.EmpireTable.subscribe('cellUnhighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name' || oArgs.key == 'alliance_name') { + Dom.setStyle(oArgs.el, 'cursor', 'auto'); + } + }); + this.EmpireTable.subscribe('cellClickEvent', function (ev) { + var target = Event.getTarget(ev), + column = this.getColumn(target), + record; + if (column.key == 'empire_name') { + record = this.getRecord(target); + Lacuna.Info.Empire.Load(record.getData('empire_id')); + } else if (column.key == 'alliance_name') { + record = this.getRecord(target); + Lacuna.Info.Alliance.Load(record.getData('alliance_id')); + } + }); + this.EmpireTable.subscribe('postRenderEvent', function () { + var els = this.getSelectedTrEls(); + if (els && els.length > 0) { + this._elBdContainer.scrollTop = els[els.length - 1].offsetTop; + } + }); + + this.EmpireTable.handleDataReturnPayload = function (oRequest, oResponse, oPayload) { + oPayload.totalRecords = oResponse.meta.totalRecords; + var pn = oResponse.meta.pageNumber - 1; + oPayload.pagination = { + rowsPerPage: 25, + recordOffset: pn * 25, + }; + return oPayload; + }; + this.EmpireTable.requery = function (page) { + // Get the current state + var oState = this.getState(); + + if (Lang.isNumber(page)) { + oState.pagination.recordOffset = (page - 1) * 25; + oState.pagination.page = page; + } + + // Get the request for the new state + var request = this.get('generateRequest')(oState, this); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + this.EmpireTable.find = function (id, page) { + // Get the current state + var oState = this.getState(), + sort = oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey(); + + oState.pagination.recordOffset = (page - 1) * 25; + oState.pagination.page = page; + + this.rankCounter = 1; + this.selectedEmpireId = id; + + var request = Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'empire_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), sort + '_rank', page], + }); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + //overriding generateRequest to send the correct column name back + this.EmpireTable.set('generateRequest', function (oState, oSelf) { + // Set defaults + oState = oState || { pagination: null, sortedBy: null }; + var sort = encodeURIComponent( + oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey() + ), + dir = + oState.sortedBy && oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC + ? 'desc' + : 'asc', + page = oState.pagination ? oState.pagination.page : 1; + + oSelf.rankCounter = 1; + delete oSelf.selectedEmpireId; + + return Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'empire_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), sort + '_rank', page], + }); + }); + this.EmpireTable.set('formatRow', function (elTr, oRecord) { + if (this.selectedEmpireId && oRecord.getData('empire_id') == this.selectedEmpireId) { + this.selectRow(oRecord); + } + return true; + }); + } + }, + EmpireFindCreate: function () { + var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + dataSource.connMethodPost = 'POST'; + dataSource.maxCacheEntries = 2; + dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + dataSource.responseSchema = { + resultsList: 'result.empires', + fields: ['empire_name', 'empire_id', 'page_number'], + }; - formatPercent: function (el, oRecord, oColumn, oData) { - el.innerHTML = Util.Number.format(Math.round(oData * 100), { - thousandsSeparator: ',', - suffix: '%', - }); + var oTextboxList = new YAHOO.lacuna.TextboxList('statsEmpireFind', dataSource, { + //config options + maxResultsDisplayed: 10, + minQueryLength: 3, + multiSelect: false, + forceSelection: true, + formatResultLabelKey: 'empire_name', + formatResultColumnKeys: ['empire_name'], + useIndicator: true, + }); + oTextboxList.generateRequest = function (sQuery) { + var state = Lacuna.Stats.EmpireTable.getState(), + s = Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'find_empire_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), state.sortedBy + '_rank', decodeURIComponent(sQuery)], + }); + return s; + }; + oTextboxList.itemSelectEvent.subscribe(function (e, oArgs) { + oArgs[0]._elTextbox.value = ''; + var data = oArgs[2]; + Lacuna.Stats.EmpireTable.find(data.empire_id, data.page_number); + }); + + this.empireFind = oTextboxList; + }, + AllianceStats: function () { + if (this.AllianceTable) { + this.AllianceTable.requery(); + } else { + this.AllianceFindCreate(); + + this.AllianceColumns = [ + { + key: 'rank', + label: 'Rank', + formatter: function (el, oRecord, oColumn, oData) { + var oState = this.getState(); + el.innerHTML = Math.floor(oState.pagination.recordOffset + this.rankCounter++); + }, }, - EmpireStats: function () { - if (this.EmpireTable) { - this.EmpireTable.requery(); - } else { - this.EmpireFindCreate(); - - this.EmpireColumns = [ - { - key: 'rank', - label: 'Rank', - formatter: function (el, oRecord, oColumn, oData) { - var oState = this.getState(); - el.innerHTML = Math.floor( - oState.pagination.recordOffset + this.rankCounter++ - ); - }, - }, - { key: 'empire_name', label: 'Empire' }, - { key: 'alliance_name', label: 'Alliance' }, - { - key: 'colony_count', - label: 'Colonies', - formatter: 'number', - }, - { - key: 'population', - label: 'Pop', - formatter: 'number', - }, - { - key: 'empire_size', - label: 'Empire Size', - formatter: 'number', - sortable: true, - }, - { - key: 'building_count', - label: 'Buildings', - formatter: 'number', - }, - { - key: 'average_building_level', - label: 'Avg Bld', - formatter: 'number', - }, - { - key: 'offense_success_rate', - label: 'Offense', - formatter: this.formatPercent, - sortable: true, - }, - { - key: 'defense_success_rate', - label: 'Defense', - formatter: this.formatPercent, - sortable: true, - }, - { - key: 'dirtiest', - label: 'Dirtiest', - formatter: 'number', - sortable: true, - }, - ]; - - this.EmpireData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - this.EmpireData.connMethodPost = 'POST'; - this.EmpireData.maxCacheEntries = 2; - this.EmpireData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - this.EmpireData.responseSchema = { - resultsList: 'result.empires', - fields: [ - 'empire_id', - 'empire_name', - 'alliance_id', - 'alliance_name', - { key: 'colony_count', parser: 'number' }, - { key: 'population', parser: 'number' }, - { key: 'empire_size', parser: 'number' }, - { key: 'building_count', parser: 'number' }, - { key: 'average_building_level', parser: 'number' }, - { key: 'offense_success_rate', parser: 'number' }, - { key: 'defense_success_rate', parser: 'number' }, - { key: 'dirtiest', parser: 'number' }, - ], - metaFields: { - totalRecords: 'result.total_empires', // Access to value in the server response - pageNumber: 'result.page_number', - }, - }; - - var eHt = Game.GetSize().h - 115; - if (eHt > 375) { - eHt = 375; - } - this.EmpireTable = new YAHOO.widget.ScrollingDataTable( - 'statsEmpireTable', - this.EmpireColumns, - this.EmpireData, - { - width: '100%', - height: eHt + 'px', - initialRequest: Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'empire_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), 'empire_size_rank'], - }), - dynamicData: true, - sortedBy: { - key: 'empire_size', - dir: YAHOO.widget.DataTable.CLASS_DSC, - }, - paginator: new YAHOO.widget.Paginator({ - rowsPerPage: 25, - containers: 'statsEmpirePaginator', - }), - selectionMode: 'single', - } - ); - this.EmpireTable.rankCounter = 1; - // Subscribe to events for row selection - this.EmpireTable.subscribe( - 'rowMouseoverEvent', - this.EmpireTable.onEventHighlightRow - ); - this.EmpireTable.subscribe( - 'rowMouseoutEvent', - this.EmpireTable.onEventUnhighlightRow - ); - this.EmpireTable.subscribe('rowClickEvent', this.EmpireTable.onEventSelectRow); - this.EmpireTable.subscribe( - 'cellMouseoverEvent', - this.EmpireTable.onEventHighlightCell - ); - this.EmpireTable.subscribe('cellHighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name' || oArgs.key == 'alliance_name') { - Dom.setStyle(oArgs.el, 'cursor', 'help'); - } - }); - this.EmpireTable.subscribe( - 'cellMouseoutEvent', - this.EmpireTable.onEventUnhighlightCell - ); - this.EmpireTable.subscribe('cellUnhighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name' || oArgs.key == 'alliance_name') { - Dom.setStyle(oArgs.el, 'cursor', 'auto'); - } - }); - this.EmpireTable.subscribe('cellClickEvent', function (ev) { - var target = Event.getTarget(ev), - column = this.getColumn(target), - record; - if (column.key == 'empire_name') { - record = this.getRecord(target); - Lacuna.Info.Empire.Load(record.getData('empire_id')); - } else if (column.key == 'alliance_name') { - record = this.getRecord(target); - Lacuna.Info.Alliance.Load(record.getData('alliance_id')); - } - }); - this.EmpireTable.subscribe('postRenderEvent', function () { - var els = this.getSelectedTrEls(); - if (els && els.length > 0) { - this._elBdContainer.scrollTop = els[els.length - 1].offsetTop; - } - }); - - this.EmpireTable.handleDataReturnPayload = function ( - oRequest, - oResponse, - oPayload - ) { - oPayload.totalRecords = oResponse.meta.totalRecords; - var pn = oResponse.meta.pageNumber - 1; - oPayload.pagination = { - rowsPerPage: 25, - recordOffset: pn * 25, - }; - return oPayload; - }; - this.EmpireTable.requery = function (page) { - // Get the current state - var oState = this.getState(); - - if (Lang.isNumber(page)) { - oState.pagination.recordOffset = (page - 1) * 25; - oState.pagination.page = page; - } - - // Get the request for the new state - var request = this.get('generateRequest')(oState, this); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - this.EmpireTable.find = function (id, page) { - // Get the current state - var oState = this.getState(), - sort = oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey(); - - oState.pagination.recordOffset = (page - 1) * 25; - oState.pagination.page = page; - - this.rankCounter = 1; - this.selectedEmpireId = id; - - var request = Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'empire_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), sort + '_rank', page], - }); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - //overriding generateRequest to send the correct column name back - this.EmpireTable.set('generateRequest', function (oState, oSelf) { - // Set defaults - oState = oState || { pagination: null, sortedBy: null }; - var sort = encodeURIComponent( - oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey() - ), - dir = - oState.sortedBy && - oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC - ? 'desc' - : 'asc', - page = oState.pagination ? oState.pagination.page : 1; - - oSelf.rankCounter = 1; - delete oSelf.selectedEmpireId; - - return Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'empire_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), sort + '_rank', page], - }); - }); - this.EmpireTable.set('formatRow', function (elTr, oRecord) { - if ( - this.selectedEmpireId && - oRecord.getData('empire_id') == this.selectedEmpireId - ) { - this.selectRow(oRecord); - } - return true; - }); - } + { key: 'alliance_name', label: 'Alliance' }, + { + key: 'member_count', + label: 'Members', + formatter: 'number', }, - EmpireFindCreate: function () { - var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - dataSource.connMethodPost = 'POST'; - dataSource.maxCacheEntries = 2; - dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - dataSource.responseSchema = { - resultsList: 'result.empires', - fields: ['empire_name', 'empire_id', 'page_number'], - }; - - var oTextboxList = new YAHOO.lacuna.TextboxList('statsEmpireFind', dataSource, { - //config options - maxResultsDisplayed: 10, - minQueryLength: 3, - multiSelect: false, - forceSelection: true, - formatResultLabelKey: 'empire_name', - formatResultColumnKeys: ['empire_name'], - useIndicator: true, - }); - oTextboxList.generateRequest = function (sQuery) { - var state = Lacuna.Stats.EmpireTable.getState(), - s = Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'find_empire_rank', - jsonrpc: '2.0', - params: [ - Game.GetSession(''), - state.sortedBy + '_rank', - decodeURIComponent(sQuery), - ], - }); - return s; - }; - oTextboxList.itemSelectEvent.subscribe(function (e, oArgs) { - oArgs[0]._elTextbox.value = ''; - var data = oArgs[2]; - Lacuna.Stats.EmpireTable.find(data.empire_id, data.page_number); - }); - - this.empireFind = oTextboxList; + { + key: 'colony_count', + label: 'Colonies', + formatter: 'number', }, - AllianceStats: function () { - if (this.AllianceTable) { - this.AllianceTable.requery(); - } else { - this.AllianceFindCreate(); - - this.AllianceColumns = [ - { - key: 'rank', - label: 'Rank', - formatter: function (el, oRecord, oColumn, oData) { - var oState = this.getState(); - el.innerHTML = Math.floor( - oState.pagination.recordOffset + this.rankCounter++ - ); - }, - }, - { key: 'alliance_name', label: 'Alliance' }, - { - key: 'member_count', - label: 'Members', - formatter: 'number', - }, - { - key: 'colony_count', - label: 'Colonies', - formatter: 'number', - }, - { - key: 'population', - label: 'Pop', - formatter: 'number', - sortable: true, - }, - { - key: 'influence', - label: 'Influence', - formatter: 'number', - sortable: true, - }, - { - key: 'space_station_count', - label: 'Stations', - formatter: 'number', - sortable: true, - }, - { - key: 'average_empire_size', - label: 'Avg Emp', - formatter: 'number', - sortable: true, - }, - { - key: 'building_count', - label: 'Buildings', - formatter: 'number', - }, - { - key: 'average_building_level', - label: 'Avg Bld', - formatter: 'number', - }, - { - key: 'offense_success_rate', - label: 'Offense', - formatter: this.formatPercent, - sortable: true, - }, - { - key: 'defense_success_rate', - label: 'Defense', - formatter: this.formatPercent, - sortable: true, - }, - { - key: 'dirtiest', - label: 'Dirtiest', - formatter: 'number', - sortable: true, - }, - ]; - - this.AllianceData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - this.AllianceData.connMethodPost = 'POST'; - this.AllianceData.maxCacheEntries = 2; - this.AllianceData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - this.AllianceData.responseSchema = { - resultsList: 'result.alliances', - fields: [ - 'alliance_id', - 'alliance_name', - { key: 'member_count', parser: 'number' }, - { key: 'space_station_count', parser: 'number' }, - { key: 'influence', parser: 'number' }, - { key: 'colony_count', parser: 'number' }, - { key: 'population', parser: 'number' }, - { key: 'average_empire_size', parser: 'number' }, - { key: 'building_count', parser: 'number' }, - { key: 'average_building_level', parser: 'number' }, - { key: 'offense_success_rate', parser: 'number' }, - { key: 'defense_success_rate', parser: 'number' }, - { key: 'dirtiest', parser: 'number' }, - ], - metaFields: { - totalRecords: 'result.total_alliances', // Access to value in the server response - pageNumber: 'result.page_number', - }, - }; - - var aHt = Game.GetSize().h - 115; - if (aHt > 375) { - aHt = 375; - } - this.AllianceTable = new YAHOO.widget.ScrollingDataTable( - 'statsAllianceTable', - this.AllianceColumns, - this.AllianceData, - { - width: '100%', - height: aHt + 'px', - initialRequest: Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'alliance_rank', - jsonrpc: '2.0', - params: [Game.GetSession('')], - }), - dynamicData: true, - sortedBy: { - key: 'influence', - dir: YAHOO.widget.DataTable.CLASS_DSC, - }, - paginator: new YAHOO.widget.Paginator({ - rowsPerPage: 25, - containers: 'statsAlliancePaginator', - }), - selectionMode: 'single', - } - ); - this.AllianceTable.rankCounter = 1; - // Subscribe to events for row selection - this.AllianceTable.subscribe( - 'rowMouseoverEvent', - this.AllianceTable.onEventHighlightRow - ); - this.AllianceTable.subscribe( - 'rowMouseoutEvent', - this.AllianceTable.onEventUnhighlightRow - ); - this.AllianceTable.subscribe( - 'rowClickEvent', - this.AllianceTable.onEventSelectRow - ); - this.AllianceTable.subscribe( - 'cellMouseoverEvent', - this.AllianceTable.onEventHighlightCell - ); - this.AllianceTable.subscribe('cellHighlightEvent', function (oArgs) { - if (oArgs.key == 'alliance_name') { - Dom.setStyle(oArgs.el, 'cursor', 'help'); - } - }); - this.AllianceTable.subscribe( - 'cellMouseoutEvent', - this.AllianceTable.onEventUnhighlightCell - ); - this.AllianceTable.subscribe('cellUnhighlightEvent', function (oArgs) { - if (oArgs.key == 'alliance_name') { - Dom.setStyle(oArgs.el, 'cursor', 'auto'); - } - }); - this.AllianceTable.subscribe('cellClickEvent', function (ev) { - var target = Event.getTarget(ev), - column = this.getColumn(target); - if (column.key == 'alliance_name') { - var record = this.getRecord(target); - Lacuna.Info.Alliance.Load(record.getData('alliance_id')); - } - }); - this.AllianceTable.subscribe('postRenderEvent', function () { - var els = this.getSelectedTrEls(); - if (els && els.length > 0) { - this._elBdContainer.scrollTop = els[els.length - 1].offsetTop; - } - }); - - this.AllianceTable.handleDataReturnPayload = function ( - oRequest, - oResponse, - oPayload - ) { - oPayload.totalRecords = oResponse.meta.totalRecords; - var pn = oResponse.meta.pageNumber - 1; - oPayload.pagination = { - rowsPerPage: 25, - recordOffset: pn * 25, - }; - return oPayload; - }; - this.AllianceTable.requery = function (page) { - // Get the current state - var oState = this.getState(); - - if (Lang.isNumber(page)) { - oState.pagination.recordOffset = (page - 1) * 25; - oState.pagination.page = page; - } - - // Get the request for the new state - var request = this.get('generateRequest')(oState, this); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - this.AllianceTable.find = function (id, page) { - // Get the current state - var oState = this.getState(), - sort = oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey(); - - oState.pagination.recordOffset = (page - 1) * 25; - oState.pagination.page = page; - - this.rankCounter = 1; - this.selectedAllianceId = id; - - var request = Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'alliance_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), sort + '_rank', page], - }); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - //overriding generateRequest to send the correct column name back - this.AllianceTable.set('generateRequest', function (oState, oSelf) { - // Set defaults - oState = oState || { pagination: null, sortedBy: null }; - var sort = encodeURIComponent( - oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey() - ), - dir = - oState.sortedBy && - oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC - ? 'desc' - : 'asc', - page = oState.pagination ? oState.pagination.page : 1; - - oSelf.rankCounter = 1; - delete oSelf.selectedAllianceId; - - return Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'alliance_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), sort + '_rank', page], - }); - }); - this.AllianceTable.set('formatRow', function (elTr, oRecord) { - if ( - this.selectedAllianceId && - oRecord.getData('alliance_id') == this.selectedAllianceId - ) { - this.selectRow(oRecord); - } - return true; - }); - } + { + key: 'population', + label: 'Pop', + formatter: 'number', + sortable: true, }, - AllianceFindCreate: function () { - var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - dataSource.connMethodPost = 'POST'; - dataSource.maxCacheEntries = 2; - dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - dataSource.responseSchema = { - resultsList: 'result.alliances', - fields: ['alliance_name', 'alliance_id', 'page_number'], - }; - - var oTextboxList = new YAHOO.lacuna.TextboxList('statsAllianceFind', dataSource, { - //config options - maxResultsDisplayed: 10, - minQueryLength: 3, - multiSelect: false, - forceSelection: true, - formatResultLabelKey: 'alliance_name', - formatResultColumnKeys: ['alliance_name'], - useIndicator: true, - }); - oTextboxList.generateRequest = function (sQuery) { - var state = Lacuna.Stats.AllianceTable.getState(), - s = Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'find_alliance_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), state.sortedBy + '_rank', sQuery], - }); - return s.replace(/%20/g, ' '); - }; - oTextboxList.itemSelectEvent.subscribe(function (e, oArgs) { - oArgs[0]._elTextbox.value = ''; - var data = oArgs[2]; - Lacuna.Stats.AllianceTable.find(data.alliance_id, data.page_number); - }); - - this.allianceFind = oTextboxList; + { + key: 'influence', + label: 'Influence', + formatter: 'number', + sortable: true, }, - ColonyStats: function () { - if (this.ColonyTable) { - this.ColonyTable.requery(); - } else { - this.ColonyColumns = [ - { - key: 'rank', - label: 'Rank', - formatter: function (el, oRecord, oColumn, oData) { - el.innerHTML = this.rankCounter++; - }, - }, - { key: 'empire_name', label: 'Empire' }, - { key: 'planet_name', label: 'Colony' }, - { key: 'population', label: 'Pop', sortable: true }, - { key: 'building_count', label: 'Buildings' }, - { key: 'average_building_level', label: 'Avg Bld Lvl' }, - { - key: 'highest_building_level', - label: 'High Bld Lvl', - }, - ]; - - this.ColonyData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - this.ColonyData.connMethodPost = 'POST'; - this.ColonyData.maxCacheEntries = 2; - this.ColonyData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - this.ColonyData.responseSchema = { - resultsList: 'result.colonies', - fields: [ - 'empire_id', - 'empire_name', - { key: 'planet_id', parser: 'number' }, - { key: 'planet_name' }, - { key: 'population', parser: 'number' }, - { key: 'building_count', parser: 'number' }, - { key: 'average_building_level', parser: 'number' }, - { key: 'highest_building_level', parser: 'number' }, - ], - }; - - var cHt = Game.GetSize().h - 115; - if (cHt > 410) { - cHt = 410; - } - this.ColonyTable = new YAHOO.widget.ScrollingDataTable( - 'statsColonyTable', - this.ColonyColumns, - this.ColonyData, - { - width: '100%', - height: cHt + 'px', - initialRequest: Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'colony_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), 'population'], - }), - dynamicData: true, - sortedBy: { - key: 'population', - dir: YAHOO.widget.DataTable.CLASS_DSC, - }, - selectionMode: 'single', - } - ); - this.ColonyTable.rankCounter = 1; - // Subscribe to events for row selection - this.ColonyTable.subscribe( - 'rowMouseoverEvent', - this.ColonyTable.onEventHighlightRow - ); - this.ColonyTable.subscribe( - 'rowMouseoutEvent', - this.ColonyTable.onEventUnhighlightRow - ); - this.ColonyTable.subscribe('rowClickEvent', this.ColonyTable.onEventSelectRow); - this.ColonyTable.subscribe( - 'cellMouseoverEvent', - this.ColonyTable.onEventHighlightCell - ); - this.ColonyTable.subscribe('cellHighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name') { - Dom.setStyle(oArgs.el, 'cursor', 'help'); - } - }); - this.ColonyTable.subscribe( - 'cellMouseoutEvent', - this.ColonyTable.onEventUnhighlightCell - ); - this.ColonyTable.subscribe('cellUnhighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name') { - Dom.setStyle(oArgs.el, 'cursor', 'auto'); - } - }); - this.ColonyTable.subscribe('cellClickEvent', function (ev) { - var target = Event.getTarget(ev), - column = this.getColumn(target); - if (column.key == 'empire_name') { - var record = this.getRecord(target); - Lacuna.Info.Empire.Load(record.getData('empire_id')); - } - }); - - this.ColonyTable.requery = function () { - // Get the current state - var oState = this.getState(); - - // Reset record offset, if paginated - if (oState.pagination) { - oState.pagination.recordOffset = 0; - } - - // Get the request for the new state - var request = this.get('generateRequest')(oState, this); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - //overriding generateRequest to send the correct column name back - this.ColonyTable.set('generateRequest', function (oState, oSelf) { - // Set defaults - oState = oState || { pagination: null, sortedBy: null }; - var sort = encodeURIComponent( - oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey() - ), - dir = - oState.sortedBy && - oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC - ? 'desc' - : 'asc', - page = oState.pagination ? oState.pagination.page : 1; - - oSelf.rankCounter = 1; - - return Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'colony_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), sort + '_rank'], - }); - }); - } + { + key: 'space_station_count', + label: 'Stations', + formatter: 'number', + sortable: true, }, - SpyStats: function () { - if (this.SpyTable) { - this.SpyTable.requery(); - } else { - this.SpyColumns = [ - { - key: 'rank', - label: 'Rank', - formatter: function (el, oRecord, oColumn, oData) { - el.innerHTML = this.rankCounter++; - }, - }, - { key: 'empire_name', label: 'Empire' }, - { key: 'spy_name', label: 'Spy' }, - { - key: 'age', - label: 'Age', - formatter: function (el, oRecord, oColumn, oData) { - el.innerHTML = Lib.formatTime(oData); - }, - }, - { key: 'level', label: 'Level', sortable: true }, - { - key: 'success_rate', - label: 'Success Rate', - formatter: this.formatPercent, - sortable: true, - }, - { key: 'dirtiest', label: 'Dirtiest', sortable: true }, - ]; - - this.SpyData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - this.SpyData.connMethodPost = 'POST'; - this.SpyData.maxCacheEntries = 2; - this.SpyData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - this.SpyData.responseSchema = { - resultsList: 'result.spies', - fields: [ - 'empire_id', - 'empire_name', - { key: 'spy_id', parser: 'number' }, - 'spy_name', - { key: 'age', parser: 'number' }, - { key: 'level', parser: 'number' }, - { key: 'success_rate', parser: 'number' }, - { key: 'dirtiest', parser: 'number' }, - ], - }; - - var sHt = Game.GetSize().h - 115; - if (sHt > 410) { - sHt = 410; - } - this.SpyTable = new YAHOO.widget.ScrollingDataTable( - 'statsSpyTable', - this.SpyColumns, - this.SpyData, - { - width: '100%', - height: sHt + 'px', - initialRequest: Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'spy_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), 'level'], - }), - dynamicData: true, - sortedBy: { - key: 'level', - dir: YAHOO.widget.DataTable.CLASS_DSC, - }, - selectionMode: 'single', - } - ); - this.SpyTable.rankCounter = 1; - // Subscribe to events for row selection - this.SpyTable.subscribe('rowMouseoverEvent', this.SpyTable.onEventHighlightRow); - this.SpyTable.subscribe( - 'rowMouseoutEvent', - this.SpyTable.onEventUnhighlightRow - ); - this.SpyTable.subscribe('rowClickEvent', this.SpyTable.onEventSelectRow); - this.SpyTable.subscribe( - 'cellMouseoverEvent', - this.SpyTable.onEventHighlightCell - ); - this.SpyTable.subscribe('cellHighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name') { - Dom.setStyle(oArgs.el, 'cursor', 'help'); - } - }); - this.SpyTable.subscribe( - 'cellMouseoutEvent', - this.SpyTable.onEventUnhighlightCell - ); - this.SpyTable.subscribe('cellUnhighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name') { - Dom.setStyle(oArgs.el, 'cursor', 'auto'); - } - }); - this.SpyTable.subscribe('cellClickEvent', function (ev) { - var target = Event.getTarget(ev), - column = this.getColumn(target); - if (column.key == 'empire_name') { - var record = this.getRecord(target); - Lacuna.Info.Empire.Load(record.getData('empire_id')); - } - }); - - this.SpyTable.requery = function () { - // Get the current state - var oState = this.getState(); - - // Reset record offset, if paginated - if (oState.pagination) { - oState.pagination.recordOffset = 0; - } - - // Get the request for the new state - var request = this.get('generateRequest')(oState, this); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - //overriding generateRequest to send the correct column name back - this.SpyTable.set('generateRequest', function (oState, oSelf) { - // Set defaults - oState = oState || { pagination: null, sortedBy: null }; - var sort = encodeURIComponent( - oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey() - ), - dir = - oState.sortedBy && - oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC - ? 'desc' - : 'asc', - page = oState.pagination ? oState.pagination.page : 1; - - oSelf.rankCounter = 1; - - return Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'spy_rank', - jsonrpc: '2.0', - params: [Game.GetSession(''), sort + '_rank'], - }); - }); - } + { + key: 'average_empire_size', + label: 'Avg Emp', + formatter: 'number', + sortable: true, }, - WeeklyMedalStats: function () { - if (this.WeeklyMedalTable) { - this.WeeklyMedalTable.requery(); - } else { - this.WeeklyMedalColumns = [ - { key: 'empire_name', label: 'Empire' }, - { key: 'medal_name', label: 'Medal Name' }, - { key: 'times_earned', label: 'Times Earned' }, - { - key: 'medal_image', - label: 'Medal', - formatter: function (elLiner, oRecord, oColumn, oData) { - var name = oRecord.getData('medal_name'); - elLiner.innerHTML = [ - '',
-                                    name,
-                                    '', - ].join(''); - }, - }, - ]; - - this.WeeklyMedalData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); - this.WeeklyMedalData.connMethodPost = 'POST'; - this.WeeklyMedalData.maxCacheEntries = 2; - this.WeeklyMedalData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; - this.WeeklyMedalData.responseSchema = { - resultsList: 'result.winners', - fields: [ - 'empire_id', - 'empire_name', - 'medal_name', - 'medal_image', - { key: 'times_earned', parser: 'number' }, - ], - metaFields: { - totalRecords: 'result.total_spies', // Access to value in the server response - }, - }; - - var wHt = Game.GetSize().h - 115; - if (wHt > 410) { - wHt = 410; - } - this.WeeklyMedalTable = new YAHOO.widget.ScrollingDataTable( - 'statsWeeklyMedalTable', - this.WeeklyMedalColumns, - this.WeeklyMedalData, - { - width: '100%', - height: wHt + 'px', - initialRequest: Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'weekly_medal_winners', - jsonrpc: '2.0', - params: [Game.GetSession('')], - }), - dynamicData: true, - selectionMode: 'single', - } - ); - // Subscribe to events for row selection - this.WeeklyMedalTable.subscribe( - 'rowMouseoverEvent', - this.WeeklyMedalTable.onEventHighlightRow - ); - this.WeeklyMedalTable.subscribe( - 'rowMouseoutEvent', - this.WeeklyMedalTable.onEventUnhighlightRow - ); - this.WeeklyMedalTable.subscribe( - 'rowClickEvent', - this.WeeklyMedalTable.onEventSelectRow - ); - this.WeeklyMedalTable.subscribe( - 'cellMouseoverEvent', - this.WeeklyMedalTable.onEventHighlightCell - ); - this.WeeklyMedalTable.subscribe('cellHighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name') { - Dom.setStyle(oArgs.el, 'cursor', 'help'); - } - }); - this.WeeklyMedalTable.subscribe( - 'cellMouseoutEvent', - this.WeeklyMedalTable.onEventUnhighlightCell - ); - this.WeeklyMedalTable.subscribe('cellUnhighlightEvent', function (oArgs) { - if (oArgs.key == 'empire_name') { - Dom.setStyle(oArgs.el, 'cursor', 'auto'); - } - }); - this.WeeklyMedalTable.subscribe('cellClickEvent', function (ev) { - var target = Event.getTarget(ev), - column = this.getColumn(target); - if (column.key == 'empire_name') { - var record = this.getRecord(target); - Lacuna.Info.Empire.Load(record.getData('empire_id')); - } - }); - - this.WeeklyMedalTable.requery = function () { - // Get the current state - var oState = this.getState(); - - // Reset record offset, if paginated - if (oState.pagination) { - oState.pagination.recordOffset = 0; - } - - // Get the request for the new state - var request = this.get('generateRequest')(oState, this); - - // Purge selections - this.unselectAllRows(); - this.unselectAllCells(); - - // Get the new data from the server - var callback = { - success: this.onDataReturnSetRows, - failure: this.onDataReturnSetRows, - argument: oState, // Pass along the new state to the callback - scope: this, - }; - this._oDataSource.sendRequest(request, callback); - }; - //overriding generateRequest to send the correct column name back - this.WeeklyMedalTable.set('generateRequest', function (oState, oSelf) { - // Set defaults - oState = oState || { pagination: null, sortedBy: null }; - var sort = encodeURIComponent( - oState.sortedBy - ? oState.sortedBy.key - : oSelf.getColumnSet().keys[0].getKey() - ), - dir = - oState.sortedBy && - oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC - ? 'desc' - : 'asc', - page = oState.pagination ? oState.pagination.page : 1; - - return Lang.JSON.stringify({ - id: YAHOO.rpc.Service._requestId++, - method: 'weekly_medal_winners', - jsonrpc: '2.0', - params: [Game.GetSession('')], - }); - }); - } + { + key: 'building_count', + label: 'Buildings', + formatter: 'number', }, - - show: function () { - Lacuna.Stats.build(); - //this is called out of scope so make sure to pass the correct scope in - Lacuna.Stats.EmpireStats(); - Game.OverlayManager.hideAll(); - - var oHt = Game.GetSize().h - 40; - if (oHt > 450) { - oHt = 450; - } - var sHt = oHt - 10; - Dom.setStyle(Dom.get('oHt'), 'height', oHt + 'px'); - Dom.setStyle(Dom.get('sHt'), 'height', sHt + 'px'); - - Lacuna.Stats.Panel.show(); - Lacuna.Stats.Panel.center(); + { + key: 'average_building_level', + label: 'Avg Bld', + formatter: 'number', }, - hide: function () { - this.Panel.hide(); + { + key: 'offense_success_rate', + label: 'Offense', + formatter: this.formatPercent, + sortable: true, }, - Reset: function () { - if (this.AllianceTable) { - this.AllianceTable.requery(1); - } - if (this.EmpireTable) { - this.EmpireTable.requery(1); - } + { + key: 'defense_success_rate', + label: 'Defense', + formatter: this.formatPercent, + sortable: true, + }, + { + key: 'dirtiest', + label: 'Dirtiest', + formatter: 'number', + sortable: true, + }, + ]; + + this.AllianceData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + this.AllianceData.connMethodPost = 'POST'; + this.AllianceData.maxCacheEntries = 2; + this.AllianceData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + this.AllianceData.responseSchema = { + resultsList: 'result.alliances', + fields: [ + 'alliance_id', + 'alliance_name', + { key: 'member_count', parser: 'number' }, + { key: 'space_station_count', parser: 'number' }, + { key: 'influence', parser: 'number' }, + { key: 'colony_count', parser: 'number' }, + { key: 'population', parser: 'number' }, + { key: 'average_empire_size', parser: 'number' }, + { key: 'building_count', parser: 'number' }, + { key: 'average_building_level', parser: 'number' }, + { key: 'offense_success_rate', parser: 'number' }, + { key: 'defense_success_rate', parser: 'number' }, + { key: 'dirtiest', parser: 'number' }, + ], + metaFields: { + totalRecords: 'result.total_alliances', // Access to value in the server response + pageNumber: 'result.page_number', }, + }; + + var aHt = Game.GetSize().h - 115; + if (aHt > 375) { + aHt = 375; + } + this.AllianceTable = new YAHOO.widget.ScrollingDataTable( + 'statsAllianceTable', + this.AllianceColumns, + this.AllianceData, + { + width: '100%', + height: aHt + 'px', + initialRequest: Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'alliance_rank', + jsonrpc: '2.0', + params: [Game.GetSession('')], + }), + dynamicData: true, + sortedBy: { + key: 'influence', + dir: YAHOO.widget.DataTable.CLASS_DSC, + }, + paginator: new YAHOO.widget.Paginator({ + rowsPerPage: 25, + containers: 'statsAlliancePaginator', + }), + selectionMode: 'single', + } + ); + this.AllianceTable.rankCounter = 1; + // Subscribe to events for row selection + this.AllianceTable.subscribe('rowMouseoverEvent', this.AllianceTable.onEventHighlightRow); + this.AllianceTable.subscribe( + 'rowMouseoutEvent', + this.AllianceTable.onEventUnhighlightRow + ); + this.AllianceTable.subscribe('rowClickEvent', this.AllianceTable.onEventSelectRow); + this.AllianceTable.subscribe( + 'cellMouseoverEvent', + this.AllianceTable.onEventHighlightCell + ); + this.AllianceTable.subscribe('cellHighlightEvent', function (oArgs) { + if (oArgs.key == 'alliance_name') { + Dom.setStyle(oArgs.el, 'cursor', 'help'); + } + }); + this.AllianceTable.subscribe( + 'cellMouseoutEvent', + this.AllianceTable.onEventUnhighlightCell + ); + this.AllianceTable.subscribe('cellUnhighlightEvent', function (oArgs) { + if (oArgs.key == 'alliance_name') { + Dom.setStyle(oArgs.el, 'cursor', 'auto'); + } + }); + this.AllianceTable.subscribe('cellClickEvent', function (ev) { + var target = Event.getTarget(ev), + column = this.getColumn(target); + if (column.key == 'alliance_name') { + var record = this.getRecord(target); + Lacuna.Info.Alliance.Load(record.getData('alliance_id')); + } + }); + this.AllianceTable.subscribe('postRenderEvent', function () { + var els = this.getSelectedTrEls(); + if (els && els.length > 0) { + this._elBdContainer.scrollTop = els[els.length - 1].offsetTop; + } + }); + + this.AllianceTable.handleDataReturnPayload = function (oRequest, oResponse, oPayload) { + oPayload.totalRecords = oResponse.meta.totalRecords; + var pn = oResponse.meta.pageNumber - 1; + oPayload.pagination = { + rowsPerPage: 25, + recordOffset: pn * 25, + }; + return oPayload; + }; + this.AllianceTable.requery = function (page) { + // Get the current state + var oState = this.getState(); + + if (Lang.isNumber(page)) { + oState.pagination.recordOffset = (page - 1) * 25; + oState.pagination.page = page; + } + + // Get the request for the new state + var request = this.get('generateRequest')(oState, this); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + this.AllianceTable.find = function (id, page) { + // Get the current state + var oState = this.getState(), + sort = oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey(); + + oState.pagination.recordOffset = (page - 1) * 25; + oState.pagination.page = page; + + this.rankCounter = 1; + this.selectedAllianceId = id; + + var request = Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'alliance_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), sort + '_rank', page], + }); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + //overriding generateRequest to send the correct column name back + this.AllianceTable.set('generateRequest', function (oState, oSelf) { + // Set defaults + oState = oState || { pagination: null, sortedBy: null }; + var sort = encodeURIComponent( + oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey() + ), + dir = + oState.sortedBy && oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC + ? 'desc' + : 'asc', + page = oState.pagination ? oState.pagination.page : 1; + + oSelf.rankCounter = 1; + delete oSelf.selectedAllianceId; + + return Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'alliance_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), sort + '_rank', page], + }); + }); + this.AllianceTable.set('formatRow', function (elTr, oRecord) { + if ( + this.selectedAllianceId && + oRecord.getData('alliance_id') == this.selectedAllianceId + ) { + this.selectRow(oRecord); + } + return true; + }); + } + }, + AllianceFindCreate: function () { + var dataSource = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + dataSource.connMethodPost = 'POST'; + dataSource.maxCacheEntries = 2; + dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + dataSource.responseSchema = { + resultsList: 'result.alliances', + fields: ['alliance_name', 'alliance_id', 'page_number'], }; - Lacuna.Stats = new Stats(); - })(); - YAHOO.register('stats', YAHOO.lacuna.Stats, { version: '1', build: '0' }); + var oTextboxList = new YAHOO.lacuna.TextboxList('statsAllianceFind', dataSource, { + //config options + maxResultsDisplayed: 10, + minQueryLength: 3, + multiSelect: false, + forceSelection: true, + formatResultLabelKey: 'alliance_name', + formatResultColumnKeys: ['alliance_name'], + useIndicator: true, + }); + oTextboxList.generateRequest = function (sQuery) { + var state = Lacuna.Stats.AllianceTable.getState(), + s = Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'find_alliance_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), state.sortedBy + '_rank', sQuery], + }); + return s.replace(/%20/g, ' '); + }; + oTextboxList.itemSelectEvent.subscribe(function (e, oArgs) { + oArgs[0]._elTextbox.value = ''; + var data = oArgs[2]; + Lacuna.Stats.AllianceTable.find(data.alliance_id, data.page_number); + }); + + this.allianceFind = oTextboxList; + }, + ColonyStats: function () { + if (this.ColonyTable) { + this.ColonyTable.requery(); + } else { + this.ColonyColumns = [ + { + key: 'rank', + label: 'Rank', + formatter: function (el, oRecord, oColumn, oData) { + el.innerHTML = this.rankCounter++; + }, + }, + { key: 'empire_name', label: 'Empire' }, + { key: 'planet_name', label: 'Colony' }, + { key: 'population', label: 'Pop', sortable: true }, + { key: 'building_count', label: 'Buildings' }, + { key: 'average_building_level', label: 'Avg Bld Lvl' }, + { + key: 'highest_building_level', + label: 'High Bld Lvl', + }, + ]; + + this.ColonyData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + this.ColonyData.connMethodPost = 'POST'; + this.ColonyData.maxCacheEntries = 2; + this.ColonyData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + this.ColonyData.responseSchema = { + resultsList: 'result.colonies', + fields: [ + 'empire_id', + 'empire_name', + { key: 'planet_id', parser: 'number' }, + { key: 'planet_name' }, + { key: 'population', parser: 'number' }, + { key: 'building_count', parser: 'number' }, + { key: 'average_building_level', parser: 'number' }, + { key: 'highest_building_level', parser: 'number' }, + ], + }; + + var cHt = Game.GetSize().h - 115; + if (cHt > 410) { + cHt = 410; + } + this.ColonyTable = new YAHOO.widget.ScrollingDataTable( + 'statsColonyTable', + this.ColonyColumns, + this.ColonyData, + { + width: '100%', + height: cHt + 'px', + initialRequest: Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'colony_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), 'population'], + }), + dynamicData: true, + sortedBy: { + key: 'population', + dir: YAHOO.widget.DataTable.CLASS_DSC, + }, + selectionMode: 'single', + } + ); + this.ColonyTable.rankCounter = 1; + // Subscribe to events for row selection + this.ColonyTable.subscribe('rowMouseoverEvent', this.ColonyTable.onEventHighlightRow); + this.ColonyTable.subscribe('rowMouseoutEvent', this.ColonyTable.onEventUnhighlightRow); + this.ColonyTable.subscribe('rowClickEvent', this.ColonyTable.onEventSelectRow); + this.ColonyTable.subscribe('cellMouseoverEvent', this.ColonyTable.onEventHighlightCell); + this.ColonyTable.subscribe('cellHighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name') { + Dom.setStyle(oArgs.el, 'cursor', 'help'); + } + }); + this.ColonyTable.subscribe('cellMouseoutEvent', this.ColonyTable.onEventUnhighlightCell); + this.ColonyTable.subscribe('cellUnhighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name') { + Dom.setStyle(oArgs.el, 'cursor', 'auto'); + } + }); + this.ColonyTable.subscribe('cellClickEvent', function (ev) { + var target = Event.getTarget(ev), + column = this.getColumn(target); + if (column.key == 'empire_name') { + var record = this.getRecord(target); + Lacuna.Info.Empire.Load(record.getData('empire_id')); + } + }); + + this.ColonyTable.requery = function () { + // Get the current state + var oState = this.getState(); + + // Reset record offset, if paginated + if (oState.pagination) { + oState.pagination.recordOffset = 0; + } + + // Get the request for the new state + var request = this.get('generateRequest')(oState, this); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + //overriding generateRequest to send the correct column name back + this.ColonyTable.set('generateRequest', function (oState, oSelf) { + // Set defaults + oState = oState || { pagination: null, sortedBy: null }; + var sort = encodeURIComponent( + oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey() + ), + dir = + oState.sortedBy && oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC + ? 'desc' + : 'asc', + page = oState.pagination ? oState.pagination.page : 1; + + oSelf.rankCounter = 1; + + return Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'colony_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), sort + '_rank'], + }); + }); + } + }, + SpyStats: function () { + if (this.SpyTable) { + this.SpyTable.requery(); + } else { + this.SpyColumns = [ + { + key: 'rank', + label: 'Rank', + formatter: function (el, oRecord, oColumn, oData) { + el.innerHTML = this.rankCounter++; + }, + }, + { key: 'empire_name', label: 'Empire' }, + { key: 'spy_name', label: 'Spy' }, + { + key: 'age', + label: 'Age', + formatter: function (el, oRecord, oColumn, oData) { + el.innerHTML = Lib.formatTime(oData); + }, + }, + { key: 'level', label: 'Level', sortable: true }, + { + key: 'success_rate', + label: 'Success Rate', + formatter: this.formatPercent, + sortable: true, + }, + { key: 'dirtiest', label: 'Dirtiest', sortable: true }, + ]; + + this.SpyData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + this.SpyData.connMethodPost = 'POST'; + this.SpyData.maxCacheEntries = 2; + this.SpyData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + this.SpyData.responseSchema = { + resultsList: 'result.spies', + fields: [ + 'empire_id', + 'empire_name', + { key: 'spy_id', parser: 'number' }, + 'spy_name', + { key: 'age', parser: 'number' }, + { key: 'level', parser: 'number' }, + { key: 'success_rate', parser: 'number' }, + { key: 'dirtiest', parser: 'number' }, + ], + }; + + var sHt = Game.GetSize().h - 115; + if (sHt > 410) { + sHt = 410; + } + this.SpyTable = new YAHOO.widget.ScrollingDataTable( + 'statsSpyTable', + this.SpyColumns, + this.SpyData, + { + width: '100%', + height: sHt + 'px', + initialRequest: Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'spy_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), 'level'], + }), + dynamicData: true, + sortedBy: { + key: 'level', + dir: YAHOO.widget.DataTable.CLASS_DSC, + }, + selectionMode: 'single', + } + ); + this.SpyTable.rankCounter = 1; + // Subscribe to events for row selection + this.SpyTable.subscribe('rowMouseoverEvent', this.SpyTable.onEventHighlightRow); + this.SpyTable.subscribe('rowMouseoutEvent', this.SpyTable.onEventUnhighlightRow); + this.SpyTable.subscribe('rowClickEvent', this.SpyTable.onEventSelectRow); + this.SpyTable.subscribe('cellMouseoverEvent', this.SpyTable.onEventHighlightCell); + this.SpyTable.subscribe('cellHighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name') { + Dom.setStyle(oArgs.el, 'cursor', 'help'); + } + }); + this.SpyTable.subscribe('cellMouseoutEvent', this.SpyTable.onEventUnhighlightCell); + this.SpyTable.subscribe('cellUnhighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name') { + Dom.setStyle(oArgs.el, 'cursor', 'auto'); + } + }); + this.SpyTable.subscribe('cellClickEvent', function (ev) { + var target = Event.getTarget(ev), + column = this.getColumn(target); + if (column.key == 'empire_name') { + var record = this.getRecord(target); + Lacuna.Info.Empire.Load(record.getData('empire_id')); + } + }); + + this.SpyTable.requery = function () { + // Get the current state + var oState = this.getState(); + + // Reset record offset, if paginated + if (oState.pagination) { + oState.pagination.recordOffset = 0; + } + + // Get the request for the new state + var request = this.get('generateRequest')(oState, this); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + //overriding generateRequest to send the correct column name back + this.SpyTable.set('generateRequest', function (oState, oSelf) { + // Set defaults + oState = oState || { pagination: null, sortedBy: null }; + var sort = encodeURIComponent( + oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey() + ), + dir = + oState.sortedBy && oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC + ? 'desc' + : 'asc', + page = oState.pagination ? oState.pagination.page : 1; + + oSelf.rankCounter = 1; + + return Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'spy_rank', + jsonrpc: '2.0', + params: [Game.GetSession(''), sort + '_rank'], + }); + }); + } + }, + WeeklyMedalStats: function () { + if (this.WeeklyMedalTable) { + this.WeeklyMedalTable.requery(); + } else { + this.WeeklyMedalColumns = [ + { key: 'empire_name', label: 'Empire' }, + { key: 'medal_name', label: 'Medal Name' }, + { key: 'times_earned', label: 'Times Earned' }, + { + key: 'medal_image', + label: 'Medal', + formatter: function (elLiner, oRecord, oColumn, oData) { + var name = oRecord.getData('medal_name'); + elLiner.innerHTML = [ + '',
+                  name,
+                  '', + ].join(''); + }, + }, + ]; + + this.WeeklyMedalData = new Util.XHRDataSource(constants.RPC_BASE + 'stats'); + this.WeeklyMedalData.connMethodPost = 'POST'; + this.WeeklyMedalData.maxCacheEntries = 2; + this.WeeklyMedalData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; + this.WeeklyMedalData.responseSchema = { + resultsList: 'result.winners', + fields: [ + 'empire_id', + 'empire_name', + 'medal_name', + 'medal_image', + { key: 'times_earned', parser: 'number' }, + ], + metaFields: { + totalRecords: 'result.total_spies', // Access to value in the server response + }, + }; + + var wHt = Game.GetSize().h - 115; + if (wHt > 410) { + wHt = 410; + } + this.WeeklyMedalTable = new YAHOO.widget.ScrollingDataTable( + 'statsWeeklyMedalTable', + this.WeeklyMedalColumns, + this.WeeklyMedalData, + { + width: '100%', + height: wHt + 'px', + initialRequest: Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'weekly_medal_winners', + jsonrpc: '2.0', + params: [Game.GetSession('')], + }), + dynamicData: true, + selectionMode: 'single', + } + ); + // Subscribe to events for row selection + this.WeeklyMedalTable.subscribe( + 'rowMouseoverEvent', + this.WeeklyMedalTable.onEventHighlightRow + ); + this.WeeklyMedalTable.subscribe( + 'rowMouseoutEvent', + this.WeeklyMedalTable.onEventUnhighlightRow + ); + this.WeeklyMedalTable.subscribe('rowClickEvent', this.WeeklyMedalTable.onEventSelectRow); + this.WeeklyMedalTable.subscribe( + 'cellMouseoverEvent', + this.WeeklyMedalTable.onEventHighlightCell + ); + this.WeeklyMedalTable.subscribe('cellHighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name') { + Dom.setStyle(oArgs.el, 'cursor', 'help'); + } + }); + this.WeeklyMedalTable.subscribe( + 'cellMouseoutEvent', + this.WeeklyMedalTable.onEventUnhighlightCell + ); + this.WeeklyMedalTable.subscribe('cellUnhighlightEvent', function (oArgs) { + if (oArgs.key == 'empire_name') { + Dom.setStyle(oArgs.el, 'cursor', 'auto'); + } + }); + this.WeeklyMedalTable.subscribe('cellClickEvent', function (ev) { + var target = Event.getTarget(ev), + column = this.getColumn(target); + if (column.key == 'empire_name') { + var record = this.getRecord(target); + Lacuna.Info.Empire.Load(record.getData('empire_id')); + } + }); + + this.WeeklyMedalTable.requery = function () { + // Get the current state + var oState = this.getState(); + + // Reset record offset, if paginated + if (oState.pagination) { + oState.pagination.recordOffset = 0; + } + + // Get the request for the new state + var request = this.get('generateRequest')(oState, this); + + // Purge selections + this.unselectAllRows(); + this.unselectAllCells(); + + // Get the new data from the server + var callback = { + success: this.onDataReturnSetRows, + failure: this.onDataReturnSetRows, + argument: oState, // Pass along the new state to the callback + scope: this, + }; + this._oDataSource.sendRequest(request, callback); + }; + //overriding generateRequest to send the correct column name back + this.WeeklyMedalTable.set('generateRequest', function (oState, oSelf) { + // Set defaults + oState = oState || { pagination: null, sortedBy: null }; + var sort = encodeURIComponent( + oState.sortedBy ? oState.sortedBy.key : oSelf.getColumnSet().keys[0].getKey() + ), + dir = + oState.sortedBy && oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC + ? 'desc' + : 'asc', + page = oState.pagination ? oState.pagination.page : 1; + + return Lang.JSON.stringify({ + id: YAHOO.rpc.Service._requestId++, + method: 'weekly_medal_winners', + jsonrpc: '2.0', + params: [Game.GetSession('')], + }); + }); + } + }, + + show: function () { + Lacuna.Stats.build(); + //this is called out of scope so make sure to pass the correct scope in + Lacuna.Stats.EmpireStats(); + Game.OverlayManager.hideAll(); + + var oHt = Game.GetSize().h - 40; + if (oHt > 450) { + oHt = 450; + } + var sHt = oHt - 10; + Dom.setStyle(Dom.get('oHt'), 'height', oHt + 'px'); + Dom.setStyle(Dom.get('sHt'), 'height', sHt + 'px'); + + Lacuna.Stats.Panel.show(); + Lacuna.Stats.Panel.center(); + }, + hide: function () { + this.Panel.hide(); + }, + Reset: function () { + if (this.AllianceTable) { + this.AllianceTable.requery(1); + } + if (this.EmpireTable) { + this.EmpireTable.requery(1); + } + }, + }; + + Lacuna.Stats = new Stats(); + })(); + YAHOO.register('stats', YAHOO.lacuna.Stats, { version: '1', build: '0' }); } diff --git a/app/yui/textboxList.js b/app/yui/textboxList.js index c54de660..c2b4fc34 100644 --- a/app/yui/textboxList.js +++ b/app/yui/textboxList.js @@ -1,832 +1,727 @@ YAHOO.namespace('lacuna'); //only load this once -if ( - typeof YAHOO.lacuna.TextboxList == 'undefined' || - !YAHOO.lacuna.TextboxList -) { - // enclose everything in an anonymous function ... - (function() { - // ... so that variables that you declare inside are local to the function and invisible outside - var Util = YAHOO.util, - Dom = Util.Dom, - Event = Util.Event, - Lang = YAHOO.lang, - Lib = YAHOO.lacuna.Library, - CSS_PREFIX = 'TextboxList'; - - var TBL = function(elInput, oDataSource, oConfigs) { - if (!oConfigs) { - oConfigs = {}; +if (typeof YAHOO.lacuna.TextboxList == 'undefined' || !YAHOO.lacuna.TextboxList) { + // enclose everything in an anonymous function ... + (function () { + // ... so that variables that you declare inside are local to the function and invisible outside + var Util = YAHOO.util, + Dom = Util.Dom, + Event = Util.Event, + Lang = YAHOO.lang, + Lib = YAHOO.lacuna.Library, + CSS_PREFIX = 'TextboxList'; + + var TBL = function (elInput, oDataSource, oConfigs) { + if (!oConfigs) { + oConfigs = {}; + } + oConfigs.useShadow = oConfigs.useShadow || false; + oConfigs.useIFrame = oConfigs.useIFrame || true; + oConfigs.animVert = oConfigs.animVert || false; + oConfigs.minQueryLength = oConfigs.minQueryLength || 0; //if null set to zero so we can submit blank request for dropdown display. + oConfigs.resultTypeList = oConfigs.resultTypeList || false; //if false use object literal insted of array in formatResults first arg + oConfigs.formatResultLabelKey = + oConfigs.formatResultLabelKey || + oDataSource.responseSchema.fields[0].key || + oDataSource.responseSchema.fields[0]; + oConfigs.formatResultColumnKeys = oConfigs.formatResultColumnKeys || [ + oDataSource.responseSchema.fields[0].key || oDataSource.responseSchema.fields[0], + ]; //used to show correct columns in drop down + oConfigs._pageNum = 1; //private var to remember what page we're on to use the "Next" option + + // Validate input element and get idPrefix from it's id + var idPrefix; + if (Dom.inDocument(elInput)) { + if (YAHOO.lang.isString(elInput)) { + idPrefix = elInput; + elInput = document.getElementById(elInput); //get dom object + } else { + idPrefix = elInput.id; + } + } else { + return; + } + + //setup dom structure + //Dom.setStyle(elInput, "display", "none"); //hide starting input and use it for storage and form submits + var tblInput = Dom.get(elInput), //document.createElement("input"), + tblContainer = document.createElement('div'), + tblAC = document.createElement('div'), + ddIcon, + tblListContainer, + tblList, + tblListInputLine, + tblIndicator; + + //set needed id's + tblContainer.id = idPrefix + 'Tbl'; //TextboxList + //tblInput.id = idPrefix + "TblInput"; //TextboxListInput + tblAC.id = idPrefix + 'TblAutoComplete'; //TextboxListAutoComplete + //append to dom and keep references + tblContainer = Dom.insertAfter(tblContainer, tblInput); //insert our container after the input passed in + Dom.addClass(tblContainer, CSS_PREFIX); //add the control class to the Container + //remove elInput from dom so we can reinsert it in our structure + tblInput = tblInput.parentNode.removeChild(tblInput); + //check if we're single or multi select + if (oConfigs.multiSelect) { + tblListContainer = document.createElement('div'); + tblList = document.createElement('ul'); + tblListInputLine = document.createElement('li'); + + //Dom.addClass(tblContainer, CSS_PREFIX + "Multi"); //add the control class to the Container + tblListContainer = tblContainer.appendChild(tblListContainer); //append our list to our textbox container + Dom.addClass(tblListContainer, CSS_PREFIX + 'Container'); //add the class to the List Container + tblList = tblListContainer.appendChild(tblList); //append our list to our container + Dom.addClass(tblList, CSS_PREFIX + 'Bits'); //add the control class to the List + tblListInputLine = tblList.appendChild(tblListInputLine); //append the LI to the list + Dom.addClass(tblListInputLine, CSS_PREFIX + 'Bit'); //add the control class to the LI + tblInput = tblListInputLine.appendChild(tblInput); //append our input to the LI + Dom.addClass(tblInput, CSS_PREFIX + 'Input'); //add the control class to the Input + } else { + tblInput = tblContainer.appendChild(tblInput); //append our input to the LI + Dom.addClass(tblInput, CSS_PREFIX + 'InputSingle'); //add the control class to the Input + } + if (!oConfigs.multiSelect && oConfigs.minQueryLength == 0) { + ddIcon = document.createElement('div'); + ddIcon = Dom.insertAfter(ddIcon, tblInput); + Dom.addClass(ddIcon, CSS_PREFIX + 'Icon'); + } + if (oConfigs.useIndicator) { + //create indicator span for image next to input control + tblIndicator = document.createElement('span'); + tblIndicator.innerHTML = [ + 'Loading...', + ].join(''); + Dom.setStyle(tblIndicator, 'display', 'none'); + Dom.addClass(tblIndicator, CSS_PREFIX + 'Indicator'); + if (oConfigs.multiSelect) { + tblIndicator = Dom.insertAfter(tblIndicator, tblInput); + } else { + Dom.addClass(tblIndicator, CSS_PREFIX + 'IndicatorSingle'); + tblIndicator = Dom.insertBefore(tblIndicator, tblInput); + } + } + tblAC = tblContainer.appendChild(tblAC); //append our AutoComplete div to our container + Dom.addClass(tblAC, CSS_PREFIX + 'AutoComplete'); //add the control class to the AutoComplete + + //call AutoComplete's constructor + TBL.superclass.constructor.call(this, tblInput, tblAC, oDataSource, oConfigs); + //setup extra events + this.dirtyEvent = new Util.CustomEvent('dirty', this); + this.selectSingleEvent = new Util.CustomEvent('selectSingle', this); + this.beforeDeleteEvent = new Util.CustomEvent('beforeDelete', this); + + //assign private vars + this._elTblListContainer = tblListContainer; + this._elTblContainer = tblContainer; + this._elTblList = tblList; + this._elTblIndicator = tblIndicator; + this._elTblIcon = ddIcon; + this._elTblListInputLine = this.multiSelect ? tblListInputLine : undefined; + this._oTblSelections = {}; //remember what our selections are + this._oTblSingleSelection = null; + this._sOrigSingleSelection = ''; + this._aOrigSelections = []; //remember what our original selections were for dirty check + //setup click events if min query is 0 + var oSelf = this; + if (this.minQueryLength == 0) { + if (!this.multiSelect) { + Event.addListener(ddIcon, 'click', oSelf._onListTextboxClick, oSelf); + } + Event.addListener(tblInput, 'click', oSelf._onListTextboxClick, oSelf); + } + //correctly hide the container when mousing out + var mouseEnter = function () { + Event.on(this._elContent, 'mouseleave', mouseLeave, this, true); + }, + mouseLeave = function () { + Event.removeListener(this._elContent, 'mouseleave', mouseLeave); + this._toggleContainer(false); + }; + Event.on(this._elContent, 'mouseenter', mouseEnter, oSelf, true); + //always add this listener + Event.addListener(tblListContainer, 'click', oSelf._onListContainerClick, oSelf); + + //if we're using indicator add events to hide and show it + if (this.useIndicator) { + this.dataRequestEvent.subscribe(function (oSelf, sQuery, oRequest) { + this.showIndicator(); + }); + this.dataErrorEvent.subscribe(function (oSelf, sQuery) { + this.hideIndicator(); + }); + this.dataReturnEvent.subscribe(function (oSelf, sQuery, oRequest) { + this.hideIndicator(); + }); + } + }; + + // now we are actually doing the inheritance part. + Lang.extend(TBL, YAHOO.widget.AutoComplete, { + // the third argument to extend are extra prototypes for the new function + formatResult: function (oResultData, sQuery, sResultMatch) { + var sKey = sResultMatch, // the entire result key which is the "name" param in the result set + sKeyQuery = sKey.substr(0, sQuery.length), // the query itself + sKeyRemainder = sKey.substr(sQuery.length), // the rest of the result + aMarkup = [], + val, + key, + col = 1; + for (var k = 0; k < this.formatResultColumnKeys.length; k++) { + key = this.formatResultColumnKeys[k]; + aMarkup[aMarkup.length] = "
                                                                      ', - ].join(''); - Dom.setStyle(tblIndicator, 'display', 'none'); - Dom.addClass(tblIndicator, CSS_PREFIX + 'Indicator'); - if (oConfigs.multiSelect) { - tblIndicator = Dom.insertAfter(tblIndicator, tblInput); - } else { - Dom.addClass(tblIndicator, CSS_PREFIX + 'IndicatorSingle'); - tblIndicator = Dom.insertBefore(tblIndicator, tblInput); - } - } - tblAC = tblContainer.appendChild(tblAC); //append our AutoComplete div to our container - Dom.addClass(tblAC, CSS_PREFIX + 'AutoComplete'); //add the control class to the AutoComplete - - //call AutoComplete's constructor - TBL.superclass.constructor.call( - this, - tblInput, - tblAC, - oDataSource, - oConfigs - ); - //setup extra events - this.dirtyEvent = new Util.CustomEvent('dirty', this); - this.selectSingleEvent = new Util.CustomEvent('selectSingle', this); - this.beforeDeleteEvent = new Util.CustomEvent('beforeDelete', this); - - //assign private vars - this._elTblListContainer = tblListContainer; - this._elTblContainer = tblContainer; - this._elTblList = tblList; - this._elTblIndicator = tblIndicator; - this._elTblIcon = ddIcon; - this._elTblListInputLine = this.multiSelect - ? tblListInputLine - : undefined; - this._oTblSelections = {}; //remember what our selections are - this._oTblSingleSelection = null; - this._sOrigSingleSelection = ''; - this._aOrigSelections = []; //remember what our original selections were for dirty check - //setup click events if min query is 0 - var oSelf = this; - if (this.minQueryLength == 0) { - if (!this.multiSelect) { - Event.addListener( - ddIcon, - 'click', - oSelf._onListTextboxClick, - oSelf - ); - } - Event.addListener( - tblInput, - 'click', - oSelf._onListTextboxClick, - oSelf - ); + } + } else { + this._oTblSingleSelection = null; + this._sOrigSingleSelection = ''; + this._elTextbox.value = ''; + } + }, + /** + * _singleRequest getter + */ + IsSingleRequest: function () { + return this._singleRequest; + }, + handleResponseSingle: function (sQuery, oResponse, oPayload) { + if (this instanceof YAHOO.widget.AutoComplete && this._sName) { + //focus textbox + this._focus(); + //container won't show since it's a single request + this._populateList(sQuery, oResponse, oPayload); + + //get all list items + var elListItem, + allListItemEls = this._elList.childNodes, + queue = oPayload && oPayload.queue ? oPayload.queue : null; + if (queue) { + for (var i = 0; i < allListItemEls.length; i++) { + elListItem = allListItemEls[i]; + if ( + elListItem._oResultData && + queue.indexOf(String(elListItem._oResultData.Id)) >= 0 + ) { + this._selectItem(elListItem); + } } - //correctly hide the container when mousing out - var mouseEnter = function() { - Event.on( - this._elContent, - 'mouseleave', - mouseLeave, - this, - true - ); - }, - mouseLeave = function() { - Event.removeListener( - this._elContent, - 'mouseleave', - mouseLeave - ); - this._toggleContainer(false); - }; - Event.on(this._elContent, 'mouseenter', mouseEnter, oSelf, true); - //always add this listener - Event.addListener( - tblListContainer, - 'click', - oSelf._onListContainerClick, - oSelf - ); - - //if we're using indicator add events to hide and show it - if (this.useIndicator) { - this.dataRequestEvent.subscribe(function( - oSelf, - sQuery, - oRequest - ) { - this.showIndicator(); - }); - this.dataErrorEvent.subscribe(function(oSelf, sQuery) { - this.hideIndicator(); - }); - this.dataReturnEvent.subscribe(function( - oSelf, - sQuery, - oRequest - ) { - this.hideIndicator(); - }); - } - }; - - // now we are actually doing the inheritance part. - Lang.extend(TBL, YAHOO.widget.AutoComplete, { - // the third argument to extend are extra prototypes for the new function - formatResult: function(oResultData, sQuery, sResultMatch) { - var sKey = sResultMatch, // the entire result key which is the "name" param in the result set - sKeyQuery = sKey.substr(0, sQuery.length), // the query itself - sKeyRemainder = sKey.substr(sQuery.length), // the rest of the result - aMarkup = [], - val, - key, - col = 1; - for (var k = 0; k < this.formatResultColumnKeys.length; k++) { - key = this.formatResultColumnKeys[k]; - aMarkup[aMarkup.length] = "
                                                                      0) { + // Reset focus for a new interaction + this._bFocused = null; + //set single request flags + this._singleRequest = true; + this.dataSource._singleRequest = true; + //get request + var sRequest = this.generateRequest(''); + //if indicator show it + if (this.useIndicator) { + this.showIndicator(); + } + //send + this.dataSource.sendRequest(sRequest, { + success: this.handleResponseSingle, + failure: this.handleResponseSingle, + scope: this, + argument: { + query: '', + queue: keys, }, - handleResponseSingle: function(sQuery, oResponse, oPayload) { - if (this instanceof YAHOO.widget.AutoComplete && this._sName) { - //focus textbox - this._focus(); - //container won't show since it's a single request - this._populateList(sQuery, oResponse, oPayload); - - //get all list items - var elListItem, - allListItemEls = this._elList.childNodes, - queue = - oPayload && oPayload.queue ? oPayload.queue : null; - if (queue) { - for (var i = 0; i < allListItemEls.length; i++) { - elListItem = allListItemEls[i]; - if ( - elListItem._oResultData && - queue.indexOf( - String(elListItem._oResultData.Id) - ) >= 0 - ) { - this._selectItem(elListItem); - } - } - } else { - //get first - elListItem = allListItemEls[0]; - //select it - this._selectItem(elListItem); - } - - //remove single response flag - this._singleRequest = null; - this.dataSource._singleRequest = null; - - //if indicator hide it - if (this.useIndicator) { - this.hideIndicator(); - } - //done with single select - this.selectSingleEvent.fire(); - } - }, - /** - * Selects single value. Must override generateRequest to properly handle key unless the key is the what is the normally queried text - */ - Select: function(key) { - if (key) { - // Reset focus for a new interaction - this._bFocused = null; - //set single request flags - this._singleRequest = true; - this.dataSource._singleRequest = true; - //get request - var sRequest = this.generateRequest(key); - //if indicator show it - if (this.useIndicator) { - this.showIndicator(); - } - //send - this.dataSource.sendRequest(sRequest, { - success: this.handleResponseSingle, - failure: this.handleResponseSingle, - scope: this, - argument: { - query: key, - }, - }); - } - }, - Queue: function(keys) { - if (Lang.isArray(keys) && keys.length > 0) { - // Reset focus for a new interaction - this._bFocused = null; - //set single request flags - this._singleRequest = true; - this.dataSource._singleRequest = true; - //get request - var sRequest = this.generateRequest(''); - //if indicator show it - if (this.useIndicator) { - this.showIndicator(); - } - //send - this.dataSource.sendRequest(sRequest, { - success: this.handleResponseSingle, - failure: this.handleResponseSingle, - scope: this, - argument: { - query: '', - queue: keys, - }, - }); - } - }, - /** - * overload populateList to handle single Select and use formatResultLabelKey instead of the first schema field - */ - _populateList: function(sQuery, oResponse, oPayload) { - // Clear previous timeout - if (this._nTypeAheadDelayID != -1) { - clearTimeout(this._nTypeAheadDelayID); - } - - sQuery = oPayload && oPayload.query ? oPayload.query : sQuery; - - // Pass data through abstract method for any transformations - var ok = this.doBeforeLoadData(sQuery, oResponse, oPayload); - - // Data is ok - if (ok && !oResponse.error) { - this.dataReturnEvent.fire(this, sQuery, oResponse.results); - - // Continue only if instance is still focused (i.e., user hasn't already moved on) - // Null indicates initialized state, which is ok too - //if(this._bFocused || (this._bFocused === null)) { - - //TODO: is this still necessary? - /*var isOpera = (YAHOO.env.ua.opera); + }); + } + }, + /** + * overload populateList to handle single Select and use formatResultLabelKey instead of the first schema field + */ + _populateList: function (sQuery, oResponse, oPayload) { + // Clear previous timeout + if (this._nTypeAheadDelayID != -1) { + clearTimeout(this._nTypeAheadDelayID); + } + + sQuery = oPayload && oPayload.query ? oPayload.query : sQuery; + + // Pass data through abstract method for any transformations + var ok = this.doBeforeLoadData(sQuery, oResponse, oPayload); + + // Data is ok + if (ok && !oResponse.error) { + this.dataReturnEvent.fire(this, sQuery, oResponse.results); + + // Continue only if instance is still focused (i.e., user hasn't already moved on) + // Null indicates initialized state, which is ok too + //if(this._bFocused || (this._bFocused === null)) { + + //TODO: is this still necessary? + /*var isOpera = (YAHOO.env.ua.opera); var contentStyle = this._elContent.style; contentStyle.width = (!isOpera) ? null : ""; contentStyle.height = (!isOpera) ? null : "";*/ - // Store state for this interaction - var sCurQuery = decodeURIComponent(sQuery); - this._sCurQuery = sCurQuery; - this._bItemSelected = false; - - var allResults = oResponse.results, - nItemsToShow = Math.min( - allResults.length, - this.maxResultsDisplayed - ), - sMatchKey = this.dataSource.responseSchema.fields - ? this.formatResultLabelKey - : 0; - - if (nItemsToShow > 0) { - // Make sure container and helpers are ready to go - if ( - !this._elList || - this._elList.childNodes.length < nItemsToShow - ) { - this._initListEl(); - } - this._initContainerHelperEls(); - - var allListItemEls = this._elList.childNodes; - // Fill items with data from the bottom up - for (var i = nItemsToShow - 1; i >= 0; i--) { - var elListItem = allListItemEls[i], - oResult = allResults[i]; - - // Backward compatibility - if (this.resultTypeList) { - // Results need to be converted back to an array - var aResult = []; - // Match key is first - aResult[0] = YAHOO.lang.isString(oResult) - ? oResult - : oResult[sMatchKey] || oResult[this.key]; - // Add additional data to the result array - var fields = this.dataSource.responseSchema - .fields; - if ( - YAHOO.lang.isArray(fields) && - fields.length > 1 - ) { - for ( - var k = 1, len = fields.length; - k < len; - k++ - ) { - aResult[aResult.length] = - oResult[fields[k].key || fields[k]]; - } - } - // No specific fields defined, so pass along entire data object - else { - // Already an array - if (YAHOO.lang.isArray(oResult)) { - aResult = oResult; - } - // Simple string - else if (YAHOO.lang.isString(oResult)) { - aResult = [oResult]; - } - // Object - else { - aResult[1] = oResult; - } - } - oResult = aResult; - } - - // The matching value, including backward compatibility for array format and safety net - elListItem._sResultMatch = YAHOO.lang.isString( - oResult - ) - ? oResult - : YAHOO.lang.isArray(oResult) - ? oResult[0] - : oResult[sMatchKey] || ''; - elListItem._oResultData = oResult; // Additional data - elListItem.innerHTML = this.formatResult( - oResult, - sCurQuery, - elListItem._sResultMatch - ); - elListItem.style.display = ''; - } - - // Clear out extraneous items - if (nItemsToShow < allListItemEls.length) { - var extraListItem; - for ( - var j = allListItemEls.length - 1; - j >= nItemsToShow; - j-- - ) { - extraListItem = allListItemEls[j]; - extraListItem.style.display = 'none'; - } - } - - this._nDisplayedItems = nItemsToShow; - - this.containerPopulateEvent.fire( - this, - sQuery, - allResults - ); - - // Highlight the first item - if (this.autoHighlight) { - var elFirstListItem = this._elList.firstChild; - this._toggleHighlight(elFirstListItem, 'to'); - this.itemArrowToEvent.fire(this, elFirstListItem); - this._typeAhead(elFirstListItem, sQuery); - } - // Unhighlight any previous time - else { - this._toggleHighlight(this._elCurListItem, 'from'); - } - - // If not a single request toggle container - if (!this._singleRequest) { - // Expand the container - ok = this.doBeforeExpandContainer( - this._elTextbox, - this._elContainer, - sQuery, - allResults - ); - this._toggleContainer(ok); - } - } else { - this._toggleContainer(false); - } - - return; + // Store state for this interaction + var sCurQuery = decodeURIComponent(sQuery); + this._sCurQuery = sCurQuery; + this._bItemSelected = false; + + var allResults = oResponse.results, + nItemsToShow = Math.min(allResults.length, this.maxResultsDisplayed), + sMatchKey = this.dataSource.responseSchema.fields ? this.formatResultLabelKey : 0; + + if (nItemsToShow > 0) { + // Make sure container and helpers are ready to go + if (!this._elList || this._elList.childNodes.length < nItemsToShow) { + this._initListEl(); + } + this._initContainerHelperEls(); + + var allListItemEls = this._elList.childNodes; + // Fill items with data from the bottom up + for (var i = nItemsToShow - 1; i >= 0; i--) { + var elListItem = allListItemEls[i], + oResult = allResults[i]; + + // Backward compatibility + if (this.resultTypeList) { + // Results need to be converted back to an array + var aResult = []; + // Match key is first + aResult[0] = YAHOO.lang.isString(oResult) + ? oResult + : oResult[sMatchKey] || oResult[this.key]; + // Add additional data to the result array + var fields = this.dataSource.responseSchema.fields; + if (YAHOO.lang.isArray(fields) && fields.length > 1) { + for (var k = 1, len = fields.length; k < len; k++) { + aResult[aResult.length] = oResult[fields[k].key || fields[k]]; + } } - // Error + // No specific fields defined, so pass along entire data object else { - this.dataErrorEvent.fire(this, sQuery); - } - }, - /** - * Enabled and disable the field - */ - disable: function() { - this.getInputEl().disabled = true; - this.disabled = true; - Dom.addClass(this.getInputEl(), CSS_PREFIX + 'Disabled'); - Dom.addClass(this._elTblContainer, CSS_PREFIX + 'Disabled'); - Dom.addClass(this._elTblListContainer, CSS_PREFIX + 'Disabled'); - for (var bitKey in this._oTblSelections) { - var bit = this._oTblSelections[bitKey]; - Dom.addClass(bit, CSS_PREFIX + 'Disabled'); - } - if (this._elTblIcon) { - Dom.setStyle(this._elTblIcon, 'display', 'none'); + // Already an array + if (YAHOO.lang.isArray(oResult)) { + aResult = oResult; + } + // Simple string + else if (YAHOO.lang.isString(oResult)) { + aResult = [oResult]; + } + // Object + else { + aResult[1] = oResult; + } } - }, - enable: function() { - this.getInputEl().disabled = false; - this.disabled = undefined; - Dom.removeClass(this.getInputEl(), CSS_PREFIX + 'Disabled'); - Dom.removeClass(this._elTblContainer, CSS_PREFIX + 'Disabled'); - Dom.removeClass( - this._elTblListContainer, - CSS_PREFIX + 'Disabled' - ); - for (var bitKey in this._oTblSelections) { - var bit = this._oTblSelections[bitKey]; - Dom.removeClass(bit, CSS_PREFIX + 'Disabled'); - } - if (this._elTblIcon) { - Dom.setStyle(this._elTblIcon, 'display', ''); - } - }, - /** - * validity handlers - **/ - setValid: function(isValid) { - this._isValid = isValid; - if (isValid) { - Dom.removeClass(this._elTblContainer, CSS_PREFIX + 'Error'); - } else { - Dom.addClass(this._elTblContainer, CSS_PREFIX + 'Error'); - } - }, - isValid: function() { - return this._isValid; - }, - /** - * show and hide animated indicator gif - */ - showIndicator: function() { - Dom.setStyle(this._elTblIndicator, 'display', ''); - }, - hideIndicator: function() { - Dom.setStyle(this._elTblIndicator, 'display', 'none'); - }, - /** - * private functions to handle selection update and bit creation for multi select and pass through for single select - */ - _createDataObject: function(data) { - var oData = {}; - oData.Object = data; //store actual data structure for possible later use - oData.Value = data ? data[this.formatResultLabelKey] : null; - return oData; - }, - _createBit: function(oData) { - var elTblListInputLine = this._elTblListInputLine, - oSelf = this; - var bit; - //add bit if it doesn't exist already - if (!this._oTblSelections[oData.Value]) { - bit = document.createElement('li'); - bit.Object = oData.Object; //store actual data structure for possible later use - bit._value = oData.Value; - var bitText = document.createTextNode(bit._value); - var bitDelete = document.createElement('a'); - bitDelete.href = '#'; - bit = Dom.insertBefore(bit, elTblListInputLine); - Event.addListener( - bit, - 'click', - oSelf._onListRemoveBitClick, - oSelf - ); - Dom.addClass(bit, CSS_PREFIX + 'Bit'); - Dom.addClass(bit, CSS_PREFIX + 'BitBox'); - //add text - bit.appendChild(bitText); - //add delete - bitDelete = bit.appendChild(bitDelete); - Dom.addClass(bitDelete, CSS_PREFIX + 'BitBoxDelete'); - } - return bit; - }, - _updateValue: function(elListItem) { - if (this.multiSelect) { - if (!this.suppressInputUpdate) { - var elTextbox = this._elTextbox, - data = elListItem._oResultData; - // clear input field - elTextbox.value = ''; - //create bit from data - var oData = this._createDataObject(data); - var bit = this._createBit(oData); - return bit; - } - } else { - TBL.superclass._updateValue.call(this, elListItem); - } - }, - _selectItem: function(elListItem) { - if ( - elListItem && - elListItem !== null && - elListItem._oResultData - ) { - if (this.multiSelect) { - this._bItemSelected = true; - var newBit = this._updateValue(elListItem); - this._clearInterval(); - if (newBit) { - var newVal = newBit._value; - this._sPastSelections = newVal; - this._oTblSelections[newVal] = newBit; - this._updateDirty(); - this.itemSelectEvent.fire( - this, - elListItem, - elListItem._oResultData - ); - } - this._toggleContainer(false); - } else { - var oData = this._createDataObject( - elListItem._oResultData - ); - this._oTblSingleSelection = oData; - TBL.superclass._selectItem.call(this, elListItem); - this._updateDirty(); - } - //remove focus so enter key doesn't submit - this._elTextbox.blur(); - } - }, - //click event catch - _onListTextboxClick: function(v, oSelf) { - if (!this.disabled) { - Event.stopEvent(v); //stop event from bubbling to container - oSelf._sendQuery(''); //must pass empty string as query - } - }, - _onListContainerClick: function(v, oSelf) { - if (!this.disabled) { - if (oSelf.minQueryLength == 0) { - oSelf._elTextbox.focus(); - oSelf._sendQuery(''); - } else { - oSelf._elTextbox.focus(); - } - } - }, - _onListRemoveBitClick: function(v, oSelf) { - if (oSelf._elTblList && !oSelf.disabled) { - var eventTarget = Event.getTarget(v); //stop event from bubbling to container - Event.stopEvent(v); - //if this is a bit... - if (Dom.hasClass(eventTarget, 'TextboxListBitBoxDelete')) { - var target = eventTarget.parentNode; //get target should return the delete link so we want it's parent - if (target) { - //double check delete - if (oSelf.beforeDeleteEvent.fire(target)) { - delete oSelf._oTblSelections[target._value]; - oSelf._elTblList.removeChild(target); - oSelf._updateDirty(); - } - } - } - } - }, - _updateDirty: function() { - //only update dirty if it's not a select - if (!this._singleRequest) { - var isDirty; - if (this.multiSelect) { - var cur = this._oTblSelections, - orig = this._aOrigSelections; - - for (var s = 0; s < orig.length; s++) { - if (!cur[orig[s]]) { - isDirty = true; - break; - } - } - //if we're not dirty yet loop current selection and count to see if we have more selected than original - if (!isDirty) { - var curNum = 0; - for (var key in cur) { - //if the key actually has a value count it - if (cur[key]) { - curNum++; - } - } - if (curNum != orig.length) { - isDirty = true; - } - } - } else { - isDirty = - this._sOrigSingleSelection != - this._oTblSingleSelection.Value; - } - //if it changes reset validity - if (isDirty) { - this.setValid(true); - } - this.dirtyEvent.fire(isDirty); + oResult = aResult; + } + + // The matching value, including backward compatibility for array format and safety net + elListItem._sResultMatch = YAHOO.lang.isString(oResult) + ? oResult + : YAHOO.lang.isArray(oResult) + ? oResult[0] + : oResult[sMatchKey] || ''; + elListItem._oResultData = oResult; // Additional data + elListItem.innerHTML = this.formatResult( + oResult, + sCurQuery, + elListItem._sResultMatch + ); + elListItem.style.display = ''; + } + + // Clear out extraneous items + if (nItemsToShow < allListItemEls.length) { + var extraListItem; + for (var j = allListItemEls.length - 1; j >= nItemsToShow; j--) { + extraListItem = allListItemEls[j]; + extraListItem.style.display = 'none'; + } + } + + this._nDisplayedItems = nItemsToShow; + + this.containerPopulateEvent.fire(this, sQuery, allResults); + + // Highlight the first item + if (this.autoHighlight) { + var elFirstListItem = this._elList.firstChild; + this._toggleHighlight(elFirstListItem, 'to'); + this.itemArrowToEvent.fire(this, elFirstListItem); + this._typeAhead(elFirstListItem, sQuery); + } + // Unhighlight any previous time + else { + this._toggleHighlight(this._elCurListItem, 'from'); + } + + // If not a single request toggle container + if (!this._singleRequest) { + // Expand the container + ok = this.doBeforeExpandContainer( + this._elTextbox, + this._elContainer, + sQuery, + allResults + ); + this._toggleContainer(ok); + } + } else { + this._toggleContainer(false); + } + + return; + } + // Error + else { + this.dataErrorEvent.fire(this, sQuery); + } + }, + /** + * Enabled and disable the field + */ + disable: function () { + this.getInputEl().disabled = true; + this.disabled = true; + Dom.addClass(this.getInputEl(), CSS_PREFIX + 'Disabled'); + Dom.addClass(this._elTblContainer, CSS_PREFIX + 'Disabled'); + Dom.addClass(this._elTblListContainer, CSS_PREFIX + 'Disabled'); + for (var bitKey in this._oTblSelections) { + var bit = this._oTblSelections[bitKey]; + Dom.addClass(bit, CSS_PREFIX + 'Disabled'); + } + if (this._elTblIcon) { + Dom.setStyle(this._elTblIcon, 'display', 'none'); + } + }, + enable: function () { + this.getInputEl().disabled = false; + this.disabled = undefined; + Dom.removeClass(this.getInputEl(), CSS_PREFIX + 'Disabled'); + Dom.removeClass(this._elTblContainer, CSS_PREFIX + 'Disabled'); + Dom.removeClass(this._elTblListContainer, CSS_PREFIX + 'Disabled'); + for (var bitKey in this._oTblSelections) { + var bit = this._oTblSelections[bitKey]; + Dom.removeClass(bit, CSS_PREFIX + 'Disabled'); + } + if (this._elTblIcon) { + Dom.setStyle(this._elTblIcon, 'display', ''); + } + }, + /** + * validity handlers + **/ + setValid: function (isValid) { + this._isValid = isValid; + if (isValid) { + Dom.removeClass(this._elTblContainer, CSS_PREFIX + 'Error'); + } else { + Dom.addClass(this._elTblContainer, CSS_PREFIX + 'Error'); + } + }, + isValid: function () { + return this._isValid; + }, + /** + * show and hide animated indicator gif + */ + showIndicator: function () { + Dom.setStyle(this._elTblIndicator, 'display', ''); + }, + hideIndicator: function () { + Dom.setStyle(this._elTblIndicator, 'display', 'none'); + }, + /** + * private functions to handle selection update and bit creation for multi select and pass through for single select + */ + _createDataObject: function (data) { + var oData = {}; + oData.Object = data; //store actual data structure for possible later use + oData.Value = data ? data[this.formatResultLabelKey] : null; + return oData; + }, + _createBit: function (oData) { + var elTblListInputLine = this._elTblListInputLine, + oSelf = this; + var bit; + //add bit if it doesn't exist already + if (!this._oTblSelections[oData.Value]) { + bit = document.createElement('li'); + bit.Object = oData.Object; //store actual data structure for possible later use + bit._value = oData.Value; + var bitText = document.createTextNode(bit._value); + var bitDelete = document.createElement('a'); + bitDelete.href = '#'; + bit = Dom.insertBefore(bit, elTblListInputLine); + Event.addListener(bit, 'click', oSelf._onListRemoveBitClick, oSelf); + Dom.addClass(bit, CSS_PREFIX + 'Bit'); + Dom.addClass(bit, CSS_PREFIX + 'BitBox'); + //add text + bit.appendChild(bitText); + //add delete + bitDelete = bit.appendChild(bitDelete); + Dom.addClass(bitDelete, CSS_PREFIX + 'BitBoxDelete'); + } + return bit; + }, + _updateValue: function (elListItem) { + if (this.multiSelect) { + if (!this.suppressInputUpdate) { + var elTextbox = this._elTextbox, + data = elListItem._oResultData; + // clear input field + elTextbox.value = ''; + //create bit from data + var oData = this._createDataObject(data); + var bit = this._createBit(oData); + return bit; + } + } else { + TBL.superclass._updateValue.call(this, elListItem); + } + }, + _selectItem: function (elListItem) { + if (elListItem && elListItem !== null && elListItem._oResultData) { + if (this.multiSelect) { + this._bItemSelected = true; + var newBit = this._updateValue(elListItem); + this._clearInterval(); + if (newBit) { + var newVal = newBit._value; + this._sPastSelections = newVal; + this._oTblSelections[newVal] = newBit; + this._updateDirty(); + this.itemSelectEvent.fire(this, elListItem, elListItem._oResultData); + } + this._toggleContainer(false); + } else { + var oData = this._createDataObject(elListItem._oResultData); + this._oTblSingleSelection = oData; + TBL.superclass._selectItem.call(this, elListItem); + this._updateDirty(); + } + //remove focus so enter key doesn't submit + this._elTextbox.blur(); + } + }, + //click event catch + _onListTextboxClick: function (v, oSelf) { + if (!this.disabled) { + Event.stopEvent(v); //stop event from bubbling to container + oSelf._sendQuery(''); //must pass empty string as query + } + }, + _onListContainerClick: function (v, oSelf) { + if (!this.disabled) { + if (oSelf.minQueryLength == 0) { + oSelf._elTextbox.focus(); + oSelf._sendQuery(''); + } else { + oSelf._elTextbox.focus(); + } + } + }, + _onListRemoveBitClick: function (v, oSelf) { + if (oSelf._elTblList && !oSelf.disabled) { + var eventTarget = Event.getTarget(v); //stop event from bubbling to container + Event.stopEvent(v); + //if this is a bit... + if (Dom.hasClass(eventTarget, 'TextboxListBitBoxDelete')) { + var target = eventTarget.parentNode; //get target should return the delete link so we want it's parent + if (target) { + //double check delete + if (oSelf.beforeDeleteEvent.fire(target)) { + delete oSelf._oTblSelections[target._value]; + oSelf._elTblList.removeChild(target); + oSelf._updateDirty(); + } + } + } + } + }, + _updateDirty: function () { + //only update dirty if it's not a select + if (!this._singleRequest) { + var isDirty; + if (this.multiSelect) { + var cur = this._oTblSelections, + orig = this._aOrigSelections; + + for (var s = 0; s < orig.length; s++) { + if (!cur[orig[s]]) { + isDirty = true; + break; + } + } + //if we're not dirty yet loop current selection and count to see if we have more selected than original + if (!isDirty) { + var curNum = 0; + for (var key in cur) { + //if the key actually has a value count it + if (cur[key]) { + curNum++; } - }, - }); + } + if (curNum != orig.length) { + isDirty = true; + } + } + } else { + isDirty = this._sOrigSingleSelection != this._oTblSingleSelection.Value; + } + //if it changes reset validity + if (isDirty) { + this.setValid(true); + } + this.dirtyEvent.fire(isDirty); + } + }, + }); - // Copy static members to class - Lang.augmentObject(TBL, YAHOO.widget.AutoComplete); - Lang.augmentObject(TBL, { - dirtyEvent: null, - selectSingleEvent: null, - beforeDeleteEvent: null, - }); - //assign to global - YAHOO.lacuna.TextboxList = TBL; - })(); - - // Important to register it - YAHOO.register('textboxList', YAHOO.lacuna.TextboxList, { - version: '1.0.0', - build: '1', + // Copy static members to class + Lang.augmentObject(TBL, YAHOO.widget.AutoComplete); + Lang.augmentObject(TBL, { + dirtyEvent: null, + selectSingleEvent: null, + beforeDeleteEvent: null, }); + //assign to global + YAHOO.lacuna.TextboxList = TBL; + })(); + + // Important to register it + YAHOO.register('textboxList', YAHOO.lacuna.TextboxList, { + version: '1.0.0', + build: '1', + }); } diff --git a/environment.d.ts b/environment.d.ts index 09840a25..d5b23ce2 100644 --- a/environment.d.ts +++ b/environment.d.ts @@ -1,11 +1,11 @@ declare global { namespace NodeJS { interface ProcessEnv { - KA_ASSETS_URL: string; - KA_SERVER_URL: string; - KA_WS_SERVER_URL: string; + KA_ASSETS_URL: string; + KA_SERVER_URL: string; + KA_WS_SERVER_URL: string; } } } -export {} +export {}; diff --git a/gulp-tasks/browserify.js b/gulp-tasks/browserify.js index 99621990..b6ffd0f0 100644 --- a/gulp-tasks/browserify.js +++ b/gulp-tasks/browserify.js @@ -11,72 +11,72 @@ import ansi from 'ansi-colors'; const __dirname = dirname(fileURLToPath(import.meta.url)); function handleBundle(b, options) { - return b - .bundle() - .on('error', function (err) { - console.error(ansi.red('Compile error:'), err.message); - }) - .pipe(fs.createWriteStream(path.join(options.rootDir, 'bundle.js'))); + return b + .bundle() + .on('error', function (err) { + console.error(ansi.red('Compile error:'), err.message); + }) + .pipe(fs.createWriteStream(path.join(options.rootDir, 'bundle.js'))); } function getConfigJson(name) { - const jsonPath = path.join(__dirname, '..', 'config', name + '.json'); + const jsonPath = path.join(__dirname, '..', 'config', name + '.json'); - if (fs.existsSync(jsonPath)) { - return JSON.parse(fs.readFileSync(jsonPath)); - } else { - throw 'Unknown KA_ENV: ' + name; - } + if (fs.existsSync(jsonPath)) { + return JSON.parse(fs.readFileSync(jsonPath)); + } else { + throw 'Unknown KA_ENV: ' + name; + } } function loadConfig(env) { - console.log('Loading config: ' + env); - var config = _.merge( - {}, - { NODE_ENV: 'production' }, - getConfigJson('default'), - env !== 'default' ? getConfigJson(env) : {} - ); - console.log('Building with config: ', config); - return config; + console.log('Loading config: ' + env); + var config = _.merge( + {}, + { NODE_ENV: 'production' }, + getConfigJson('default'), + env !== 'default' ? getConfigJson(env) : {} + ); + console.log('Building with config: ', config); + return config; } export default function (options) { - const plugins = [tsify]; + const plugins = [tsify]; - if (options.watch) { - plugins.push(watchify); - } + if (options.watch) { + plugins.push(watchify); + } - var b = browserify(['./app/load.ts'], { - extensions: ['.jsx', '.tsx'], - paths: [path.join(options.rootDir)], - ignoreMissing: true, + var b = browserify(['./app/load.ts'], { + extensions: ['.jsx', '.tsx'], + paths: [path.join(options.rootDir)], + ignoreMissing: true, - // watchify options - cache: {}, - packageCache: {}, - plugin: plugins, - }); + // watchify options + cache: {}, + packageCache: {}, + plugin: plugins, + }); - // This transforms all the .jsx files into JavaScript. - b.transform('babelify'); - b.transform('envify', loadConfig(options.env || process.env.KA_ENV || 'default')); - b.transform('browserify-css', { - global: true, - }); + // This transforms all the .jsx files into JavaScript. + b.transform('babelify'); + b.transform('envify', loadConfig(options.env || process.env.KA_ENV || 'default')); + b.transform('browserify-css', { + global: true, + }); - // Watchify emits 'update' events when a file has been changed and the build should run again. - if (options.watch) { - b.on('update', function () { - console.log('Something changed - rebuilding.'); - handleBundle(b, options); - }); + // Watchify emits 'update' events when a file has been changed and the build should run again. + if (options.watch) { + b.on('update', function () { + console.log('Something changed - rebuilding.'); + handleBundle(b, options); + }); - b.on('log', function (msg) { - console.log(msg); - }); - } + b.on('log', function (msg) { + console.log(msg); + }); + } - return handleBundle(b, options); + return handleBundle(b, options); } diff --git a/gulp-tasks/clean.js b/gulp-tasks/clean.js index 9935ba27..ff07ded3 100644 --- a/gulp-tasks/clean.js +++ b/gulp-tasks/clean.js @@ -1,7 +1,7 @@ import del from 'del'; -export default function() { - var files = ['lacuna/*.js', 'lacuna/*.css']; +export default function () { + var files = ['lacuna/*.js', 'lacuna/*.css']; - return del(files); + return del(files); } diff --git a/gulp-tasks/server.js b/gulp-tasks/server.js index 5b405c91..92725545 100644 --- a/gulp-tasks/server.js +++ b/gulp-tasks/server.js @@ -4,15 +4,15 @@ import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); -export default function(done) { - var app = express(); - var port = process.env.PORT || 80; - var dir = path.join(__dirname, '..'); - console.log('Servering static files from', dir); - app.use(express.static(dir)); +export default function (done) { + var app = express(); + var port = process.env.PORT || 80; + var dir = path.join(__dirname, '..'); + console.log('Servering static files from', dir); + app.use(express.static(dir)); - app.listen(port, function() { - console.log(`Listening on http://localhost:${port}/ for requests.`); - done(); - }); + app.listen(port, function () { + console.log(`Listening on http://localhost:${port}/ for requests.`); + done(); + }); } diff --git a/index.html b/index.html index c12f5615..47e1e9be 100644 --- a/index.html +++ b/index.html @@ -2,33 +2,33 @@ - - Kenó Antigen - - - - - -
                                                                      - Kenó Antigen requires Javascript to run. Please enable and reload the page. -
                                                                      - - - - - + + Kenó Antigen + + + + + +
                                                                      + Kenó Antigen requires Javascript to run. Please enable and reload the page. +
                                                                      + + + + + diff --git a/package.json b/package.json index 66dbd36c..3756e3bd 100644 --- a/package.json +++ b/package.json @@ -1,77 +1,77 @@ { - "name": "ka-web", - "version": "0.0.1", - "description": "Web client for the open source game Kenó Antigen.", - "type": "module", - "main": "app/load.js", - "private": true, - "repository": { - "type": "git", - "url": "https://github.com/Kantigen/ka-web" - }, - "author": "Lacuna Expanse Corp, Kenó Antigen Community & Open Source Contributors", - "contributors": [ - "Nathan McCallum (https://github.com/1vasari)", - "Darin McBride (https://github.com/dmcbride)" - ], - "bugs": { - "url": "https://github.com/Kantigen/ka-web/issues" - }, - "scripts": { - "lint": "eslint . --ext .js,.jsx,.ts,.tsx", - "format": "prettier --write app/**/*.ts app/**/*.tsx app/yui/*.js", - "dev": "gulp devWithServer", - "build": "gulp build", - "clean": "gulp clean" - }, - "homepage": "https://github.com/Kantigen/ka-web", - "dependencies": { - "classnames": "^2.3.1", - "create-react-class": "^15.6.3", - "fingerprintjs2": "^2.1.0", - "fomantic-ui": "^2.8.8", - "jquery": "^3.5.0", - "lodash": "^4.17.15", - "mobx": "^6.3.7", - "mobx-react": "^7.2.1", - "moment": "^2.24.0", - "prop-types": "^15.7.2", - "react": "^17.x.x", - "react-dom": "^17.x.x", - "react-draggable": "^4.0.3", - "react-tabs": "^4.0.0", - "react-tooltip": "^4.x.x", - "validator": "^13.0.0", - "vex-js": "^4.1.0" - }, - "devDependencies": { - "@babel/core": "^7.16.0", - "@babel/preset-env": "^7.16.0", - "@babel/preset-react": "^7.16.0", - "@babel/preset-typescript": "^7.16.7", - "@types/jquery": "^3.5.14", - "@types/lodash": "^4.14.182", - "@types/node": "^17.0.24", - "@types/react": "^17.x.x", - "@types/react-dom": "^17.x.x", - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.21.0", - "ansi-colors": "^4.1.1", - "babel-eslint": "^10.0.3", - "babelify": "^10.0.0", - "browserify": "^17.0.0", - "browserify-css": "^0.15.0", - "del": "^6.0.0", - "envify": "^4.1.0", - "eslint": "^8.14.0", - "eslint-config-airbnb": "^19.0.4", - "express": "^4.17.1", - "gulp": "^4.x.x", - "gulp-typescript": "^6.0.0-alpha.1", - "prettier": "^2.0.0", - "tsify": "^5.0.4", - "typescript": "^4.6.4", - "vinyl-source-stream": "^2.0.0", - "watchify": "^4.0.0" - } + "name": "ka-web", + "version": "0.0.1", + "description": "Web client for the open source game Kenó Antigen.", + "type": "module", + "main": "app/load.js", + "private": true, + "repository": { + "type": "git", + "url": "https://github.com/Kantigen/ka-web" + }, + "author": "Lacuna Expanse Corp, Kenó Antigen Community & Open Source Contributors", + "contributors": [ + "Nathan McCallum (https://github.com/1vasari)", + "Darin McBride (https://github.com/dmcbride)" + ], + "bugs": { + "url": "https://github.com/Kantigen/ka-web/issues" + }, + "scripts": { + "lint": "eslint . --ext .js,.jsx,.ts,.tsx", + "format": "prettier --write app/**/*.ts app/**/*.tsx app/yui/*.js app/components/**/*.jsx gulp-tasks/**/*.js", + "dev": "gulp devWithServer", + "build": "gulp build", + "clean": "gulp clean" + }, + "homepage": "https://github.com/Kantigen/ka-web", + "dependencies": { + "classnames": "^2.3.1", + "create-react-class": "^15.6.3", + "fingerprintjs2": "^2.1.0", + "fomantic-ui": "^2.8.8", + "jquery": "^3.5.0", + "lodash": "^4.17.15", + "mobx": "^6.3.7", + "mobx-react": "^7.2.1", + "moment": "^2.24.0", + "prop-types": "^15.7.2", + "react": "^17.x.x", + "react-dom": "^17.x.x", + "react-draggable": "^4.0.3", + "react-tabs": "^4.0.0", + "react-tooltip": "^4.x.x", + "validator": "^13.0.0", + "vex-js": "^4.1.0" + }, + "devDependencies": { + "@babel/core": "^7.16.0", + "@babel/preset-env": "^7.16.0", + "@babel/preset-react": "^7.16.0", + "@babel/preset-typescript": "^7.16.7", + "@types/jquery": "^3.5.14", + "@types/lodash": "^4.14.182", + "@types/node": "^17.0.24", + "@types/react": "^17.x.x", + "@types/react-dom": "^17.x.x", + "@typescript-eslint/eslint-plugin": "^5.21.0", + "@typescript-eslint/parser": "^5.21.0", + "ansi-colors": "^4.1.1", + "babel-eslint": "^10.0.3", + "babelify": "^10.0.0", + "browserify": "^17.0.0", + "browserify-css": "^0.15.0", + "del": "^6.0.0", + "envify": "^4.1.0", + "eslint": "^8.14.0", + "eslint-config-airbnb": "^19.0.4", + "express": "^4.17.1", + "gulp": "^4.x.x", + "gulp-typescript": "^6.0.0-alpha.1", + "prettier": "^2.0.0", + "tsify": "^5.0.4", + "typescript": "^4.6.4", + "vinyl-source-stream": "^2.0.0", + "watchify": "^4.0.0" + } } diff --git a/run-ka-web-background.sh b/run-ka-web-background.sh index 64117e47..70910479 100755 --- a/run-ka-web-background.sh +++ b/run-ka-web-background.sh @@ -1,11 +1,11 @@ docker run -d \ - -p ${KA_CLIENT_LISTEN:-0.0.0.0}:${KA_CLIENT_PORT:-8080}:80 \ - -v ${PWD}/app:/src/app \ - -v ${PWD}/gulp-tasks:/src/gulp-tasks \ - -v ${PWD}/index.html:/src/index.html \ - -v ${PWD}/app/css/styles.css:/src/lacuna/styles.css \ - -v ${PWD}/app/load.js:/src/lacuna/load.js \ - --name=ka-web \ - --network kaserver_default \ - -e DEBUG=express:* \ - kenoantigen/ka-web gulp dev-with-server + -p ${KA_CLIENT_LISTEN:-0.0.0.0}:${KA_CLIENT_PORT:-8080}:80 \ + -v ${PWD}/app:/src/app \ + -v ${PWD}/gulp-tasks:/src/gulp-tasks \ + -v ${PWD}/index.html:/src/index.html \ + -v ${PWD}/app/css/styles.css:/src/lacuna/styles.css \ + -v ${PWD}/app/load.js:/src/lacuna/load.js \ + --name=ka-web \ + --network kaserver_default \ + -e DEBUG=express:* \ + kenoantigen/ka-web gulp dev-with-server diff --git a/run-ka-web.sh b/run-ka-web.sh index ec3265c8..0578893b 100755 --- a/run-ka-web.sh +++ b/run-ka-web.sh @@ -1,13 +1,13 @@ docker run -it --rm \ - -p ${KA_CLIENT_LISTEN:-0.0.0.0}:${KA_CLIENT_PORT:-8080}:80 \ - -v ${PWD}/app:/src/app \ - -v ${PWD}/gulp-tasks:/src/gulp-tasks \ - -v ${PWD}/index.html:/src/index.html \ - -v ${PWD}/app/css/styles.css:/src/lacuna/styles.css \ - -v ${PWD}/app/load.js:/src/lacuna/load.js \ - -v ${PWD}/app/vendor-css:/src/app/vendor-css \ - -v ${PWD}/app/vendor-js:/src/app/vendor-js \ - --name=ka-web \ - --network kaserver_default \ - -e DEBUG=express:* \ - kenoantigen/ka-web /bin/bash + -p ${KA_CLIENT_LISTEN:-0.0.0.0}:${KA_CLIENT_PORT:-8080}:80 \ + -v ${PWD}/app:/src/app \ + -v ${PWD}/gulp-tasks:/src/gulp-tasks \ + -v ${PWD}/index.html:/src/index.html \ + -v ${PWD}/app/css/styles.css:/src/lacuna/styles.css \ + -v ${PWD}/app/load.js:/src/lacuna/load.js \ + -v ${PWD}/app/vendor-css:/src/app/vendor-css \ + -v ${PWD}/app/vendor-js:/src/app/vendor-js \ + --name=ka-web \ + --network kaserver_default \ + -e DEBUG=express:* \ + kenoantigen/ka-web /bin/bash diff --git a/tsconfig.json b/tsconfig.json index 0f3d83b6..311addea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,14 @@ { - "compilerOptions": { - "target": "ES2015", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "noEmitOnError": false, - "jsx": "react", - "baseUrl": ".", - "allowSyntheticDefaultImports": true - } + "compilerOptions": { + "target": "ES2015", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "noEmitOnError": false, + "jsx": "react", + "baseUrl": ".", + "allowSyntheticDefaultImports": true + } } -- 2.51.2