diff --git a/app/components/building/information.tsx b/app/components/building/information.tsx index 95d793e8..7dc75d2c 100644 --- a/app/components/building/information.tsx +++ b/app/components/building/information.tsx @@ -1,4 +1,5 @@ import React from 'react'; +//@ts-expect-error import resources from 'app/json/resources'; import BodyRPCStore from 'app/stores/rpc/body'; import environment from 'app/environment'; diff --git a/app/components/building/productionTab.tsx b/app/components/building/productionTab.tsx index a0407050..8a8037e9 100644 --- a/app/components/building/productionTab.tsx +++ b/app/components/building/productionTab.tsx @@ -7,7 +7,6 @@ import _ from 'lodash'; import BodyRPCStore from 'app/stores/rpc/body'; import ActionButton from 'app/components/building/actionButton'; -import ResourceCost from 'app/components/building/resourceCost'; import ResourceLine from 'app/components/building/resourceLine'; import { Building } from 'app/interfaces'; @@ -23,35 +22,29 @@ class ProductionTab extends React.Component { onDemolishClick() { const 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) - ); + vex.confirm(`Are you sure you want to demolish your ${name}?`, () => { + // GenericBuildingRPCActions.requestGenericBuildingRPCDemolish(this.props.building.url, { + // building_id: this.props.building.id, + // }); + }); } onDowngradeClick() { const name = `${this.props.building.name} to level ${this.props.building.level - 1}`; - vex.confirm( - `Are you sure you want to downgrade your ${name}?`, - _.bind(function () { - GenericBuildingRPCActions.requestGenericBuildingRPCDowngrade( - this.props.building.url, - this.props.building.id - ); - }, this) - ); + vex.confirm(`Are you sure you want to downgrade your ${name}?`, () => { + // GenericBuildingRPCActions.requestGenericBuildingRPCDowngrade( + // this.props.building.url, + // this.props.building.id + // ); + }); } onUpgradeClick() { - GenericBuildingRPCActions.requestGenericBuildingRPCUpgrade( - this.props.building.url, - this.props.building.id - ); + // GenericBuildingRPCActions.requestGenericBuildingRPCUpgrade( + // this.props.building.url, + // this.props.building.id + // ); } render() { diff --git a/app/components/errorBoundary.tsx b/app/components/errorBoundary.tsx index 29c474fb..6cb3ac21 100644 --- a/app/components/errorBoundary.tsx +++ b/app/components/errorBoundary.tsx @@ -36,6 +36,7 @@ class ErrorBoundary extends React.Component { { text: 'Close', handler() { + //@ts-expect-error this.hide(); }, }, diff --git a/app/components/essentia.tsx b/app/components/essentia.tsx index 83770ce6..e9a27063 100644 --- a/app/components/essentia.tsx +++ b/app/components/essentia.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import EmpireRPCStore from 'app/stores/rpc/empire'; import BoostsTab from 'app/components/essentia/boostsTab'; import GetEssentiaTab from 'app/components/essentia/getEssentiaTab'; @@ -13,12 +12,7 @@ class Essentia extends React.Component { tabs={[ { title: 'Boosts', - component: () => ( - - ), + component: () => , }, { title: 'Get More Essentia', diff --git a/app/components/essentia/boost.jsx b/app/components/essentia/boost.tsx similarity index 52% rename from app/components/essentia/boost.jsx rename to app/components/essentia/boost.tsx index d6e15a18..34d6de49 100644 --- a/app/components/essentia/boost.jsx +++ b/app/components/essentia/boost.tsx @@ -1,64 +1,45 @@ import * as vex from 'app/vex'; -import PropTypes from 'prop-types'; - import React from 'react'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import validator from 'validator'; import EmpireRPCStore from 'app/stores/rpc/empire'; import * as util from 'app/util'; +import Icon from 'app/components/menu/icon'; +import { IconStyle } from 'app/interfaces/menu/icons'; -class Boost extends React.Component { - static propTypes = { - type: PropTypes.string.isRequired, - iconName: PropTypes.string.isRequired, - description: PropTypes.string.isRequired, - ms: PropTypes.number.isRequired, - }; +type Props = { + type: string; + iconStyle: IconStyle; + description: string; + ms: number; +}; - static defaultProps = { - type: '', - iconName: '', - description: '', - ms: 0, - }; +class Boost extends React.Component { + weeks = React.createRef(); - handleBoost = () => { + handleBoost() { const { type } = this.props; - const weeks = this.refs.weeks.value; + const weeks = this.weeks?.current?.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; - } - if (weeks * 5 > EmpireRPCStore.essentia) { - vex.alert('Insufficient Essentia.'); - return; - } - EmpireRPCActions.requestEmpireRPCBoost({ type, weeks }); - }; + console.log(`Boosting ${type} for ${weeks} weeks`); - renderButton = () => { - const iconClassName = classnames('icon', this.props.iconName); - - return ( -
- - Boost -
- ); - }; + // 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; + // } + // if (weeks * 5 > EmpireRPCStore.essentia) { + // vex.alert('Insufficient Essentia.'); + // return; + // } + // EmpireRPCActions.requestEmpireRPCBoost({ type, weeks }); + } tagClassNames() { if (this.props.ms > 0) { @@ -84,7 +65,7 @@ class Boost extends React.Component { - {this.renderButton()} +
this.handleBoost()} + title={this.props.description} + > + + Boost +
{this.props.ms > 0 ? (
{util.formatMillisecondTime(this.props.ms)}
diff --git a/app/components/essentia/boostsTab.jsx b/app/components/essentia/boostsTab.tsx similarity index 87% rename from app/components/essentia/boostsTab.jsx rename to app/components/essentia/boostsTab.tsx index 601759a9..b68ca591 100644 --- a/app/components/essentia/boostsTab.jsx +++ b/app/components/essentia/boostsTab.tsx @@ -18,7 +18,7 @@ class BoostsTab extends React.Component {
Essentia -
{EmpireRPCStore.exact_essentia}
+
{EmpireRPCStore.exactEssentia}
Boost Cost @@ -32,25 +32,25 @@ class BoostsTab extends React.Component {
@@ -59,25 +59,25 @@ class BoostsTab extends React.Component {
diff --git a/app/components/essentia/getEssentiaTab.jsx b/app/components/essentia/getEssentiaTab.tsx similarity index 95% rename from app/components/essentia/getEssentiaTab.jsx rename to app/components/essentia/getEssentiaTab.tsx index e4169572..2e7989e5 100644 --- a/app/components/essentia/getEssentiaTab.jsx +++ b/app/components/essentia/getEssentiaTab.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import { observer } from 'mobx-react'; import * as vex from 'app/vex'; import WindowsStore from 'app/stores/windows'; @@ -64,4 +63,4 @@ class GetEssentiaTab extends React.Component { } } -export default observer(GetEssentiaTab); +export default GetEssentiaTab; diff --git a/app/components/essentiavein.tsx b/app/components/essentiavein.tsx index 13841f01..14bac452 100644 --- a/app/components/essentiavein.tsx +++ b/app/components/essentiavein.tsx @@ -8,14 +8,9 @@ import ProductionTab from 'app/components/building/productionTab'; import withBuildingData from 'app/hocs/withBuildingData'; import { Tabber } from 'app/components/tabber'; -import { Building, BuildingWindowOptions } from 'app/interfaces'; +import { BuildingComponentProps } from 'app/interfaces'; -type Props = { - options: BuildingWindowOptions; - building: Building; -}; - -class EssentiaVein extends React.Component { +class EssentiaVein extends React.Component { render() { return ( <> diff --git a/app/components/genericBuilding.tsx b/app/components/genericBuilding.tsx index 41eedb8c..66851978 100644 --- a/app/components/genericBuilding.tsx +++ b/app/components/genericBuilding.tsx @@ -7,14 +7,9 @@ import ProductionTab from 'app/components/building/productionTab'; import { Tabber } from 'app/components/tabber'; -import { WindowOptions, Building } from 'app/interfaces'; +import { BuildingComponentProps } from 'app/interfaces'; -type Props = { - options: WindowOptions; - building: Building; -}; - -class GenericBuilding extends React.Component { +class GenericBuilding extends React.Component { render() { return ( <> diff --git a/app/components/menu/leftSidebar.tsx b/app/components/menu/leftSidebar.tsx index 8e354257..ed059649 100644 --- a/app/components/menu/leftSidebar.tsx +++ b/app/components/menu/leftSidebar.tsx @@ -12,6 +12,7 @@ declare const YAHOO: any; class LeftSidebar extends React.Component { componentDidMount() { + //@ts-expect-error $('#left-sidebar').sidebar({ context: $('#sidebarContainer'), duration: 300, @@ -23,6 +24,7 @@ class LeftSidebar extends React.Component { } componentDidUpdate() { + //@ts-expect-error $('#left-sidebar').sidebar(MenuStore.leftSidebarShown ? 'show' : 'hide'); } diff --git a/app/components/menu/panel.tsx b/app/components/menu/panel.tsx index 82508ce4..3c0eea8b 100644 --- a/app/components/menu/panel.tsx +++ b/app/components/menu/panel.tsx @@ -40,7 +40,7 @@ class Panel extends React.Component { render() { return ( - +
{ panelHeight={this.props.window.config.height} >
- +
diff --git a/app/components/menu/rightSidebar.tsx b/app/components/menu/rightSidebar.tsx index 74b20053..26cdaf8e 100644 --- a/app/components/menu/rightSidebar.tsx +++ b/app/components/menu/rightSidebar.tsx @@ -9,6 +9,7 @@ import MenuStore from 'app/stores/menu'; class RightSidebar extends React.Component { componentDidMount() { + //@ts-expect-error $('#right-sidebar').sidebar({ context: $('#sidebarContainer'), duration: 300, @@ -20,6 +21,7 @@ class RightSidebar extends React.Component { } componentDidUpdate() { + //@ts-expect-error $('#right-sidebar').sidebar(MenuStore.rightSidebarShown ? 'show' : 'hide'); } diff --git a/app/components/menu/rightSidebar/bodiesAccordion.tsx b/app/components/menu/rightSidebar/bodiesAccordion.tsx index 22d69270..4cee0609 100644 --- a/app/components/menu/rightSidebar/bodiesAccordion.tsx +++ b/app/components/menu/rightSidebar/bodiesAccordion.tsx @@ -48,7 +48,7 @@ class BodiesAccordion extends React.Component { items.push( diff --git a/app/components/rearrangeBuildings/rearrangeBuildings.tsx b/app/components/rearrangeBuildings/rearrangeBuildings.tsx index a31e6d78..3f8336e2 100644 --- a/app/components/rearrangeBuildings/rearrangeBuildings.tsx +++ b/app/components/rearrangeBuildings/rearrangeBuildings.tsx @@ -10,17 +10,13 @@ import WindowsStore from 'app/stores/windows'; import RearrangeBuildingsService from 'app/services/rearrangeBuildings'; import RearrangeBuildingsHelper from 'app/helpers/rearrangeBuildings'; -type Props = { - building: Building; -}; - type State = { matrix: Matrix; selected: SelectedBuilding; }; -class RearrangeBuildings extends React.Component { - constructor(props: Props) { +class RearrangeBuildings extends React.Component { + constructor(props: any) { super(props); this.state = { matrix: [], diff --git a/app/components/tabber.tsx b/app/components/tabber.tsx index ed5f00bc..30fda651 100644 --- a/app/components/tabber.tsx +++ b/app/components/tabber.tsx @@ -2,14 +2,12 @@ import React from 'react'; import * as ReactTabs from 'react-tabs'; import _ from 'lodash'; -interface ITab { - title: string; - component: Function; - shouldRender?: boolean; -} - type Props = { - tabs: Array; + tabs: Array<{ + title: string; + component: Function; + shouldRender?: boolean; + }>; }; class Tabber extends React.Component { diff --git a/app/game.tsx b/app/game.tsx index 7eb658d6..81236f92 100644 --- a/app/game.tsx +++ b/app/game.tsx @@ -10,6 +10,7 @@ import TickerStore from 'app/stores/ticker'; import WindowsStore from 'app/stores/windows'; import environment from 'app/environment'; +//@ts-expect-error import resources from 'app/json/resources'; import { Empire } from 'app/client'; @@ -53,6 +54,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { MenuStore.showLoader(); + //@ts-expect-error Game.escListener = new Util.KeyListener( document, { @@ -92,12 +94,15 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { } if (query.reset_password) { Game.InitLogin(); + //@ts-expect-error Game.LoginDialog.resetPassword(query.reset_password); return; } if (query.facebook_uid) { Game.InitLogin(); + //@ts-expect-error Game.LoginDialog.initEmpireCreator(); + //@ts-expect-error Game.EmpireCreator.facebookReturn( query.facebook_uid, query.facebook_token, @@ -110,7 +115,9 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { SessionStore.update(query.session_id); } else if (query.empire_id) { Game.InitLogin(); + //@ts-expect-error Game.LoginDialog.initEmpireCreator(); + //@ts-expect-error Game.SpeciesCreator.show(query.empire_id); return; } else if (!session) { @@ -158,6 +165,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { { text: 'Close', handler() { + //@ts-expect-error this.hide(); }, }, @@ -197,6 +205,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { { text: 'View Tutorial', handler() { + //@ts-expect-error this.hide(); Lacuna.Messaging.showMessage(result.welcome_message_id); }, @@ -205,6 +214,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { { text: 'Skip Tutorial', handler() { + //@ts-expect-error this.hide(); }, }, @@ -230,6 +240,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { // init event subscribtions if we need to Game.InitEvents(); // enable esc handler + //@ts-expect-error Game.escListener.enable(); document.title = `KA - ${EmpireRPCStore.name}`; @@ -251,12 +262,16 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { Event.on(window, 'resize', () => { // taken from YUI Overlay if (YAHOO.env.ua.ie) { + //@ts-expect-error if (!window.resizeEnd) { + //@ts-expect-error window.resizeEnd = -1; } + //@ts-expect-error clearTimeout(window.resizeEnd); + //@ts-expect-error window.resizeEnd = setTimeout(() => { Lacuna.Game.Resize(); }, 100); @@ -266,12 +281,13 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { }); } }, - InitServices(smd) { + InitServices(smd: any) { const serviceOut = {}; for (const sKey in smd) { if (smd.hasOwnProperty(sKey)) { const oSmd = smd[sKey]; if (oSmd.services) { + //@ts-expect-error serviceOut[sKey] = new YAHOO.rpc.Service( oSmd, { @@ -287,6 +303,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { environment.getServerUrl() ); } else { + //@ts-expect-error serviceOut[sKey] = Game.InitServices(oSmd); } } @@ -303,7 +320,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { func(params, opts); }; const opts = { - failure(o) { + failure(o: any) { const self = this; const failure = function (silent: boolean) { if (Lang.isFunction(origOpts.failure)) { @@ -322,6 +339,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { }; YAHOO.lang.augmentObject(opts, origOpts); if (!('timeout' in opts)) { + //@ts-expect-error opts.timeout = Game.Timeout; } method(params, opts); @@ -348,12 +366,15 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { const dialog = new YAHOO.widget.SimpleDialog(container, config); dialog.renderEvent.subscribe(function () { if (afterRender) { + //@ts-expect-error afterRender.call(this); } + //@ts-expect-error this.show(); }); dialog.hideEvent.subscribe(function () { if (afterHide) { + //@ts-expect-error afterHide.call(this); } // let the current process complete before destroying @@ -374,6 +395,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { SetSession(session: string) { if (session) { Game.SetCookie('session', session); + //@ts-expect-error Game._session = session; } else { Game.RemoveCookie('session'); @@ -382,6 +404,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { }, GetSize() { const content = document.getElementById('content'); + //@ts-expect-error const width = content.offsetWidth; const height = document.documentElement.clientHeight; @@ -446,6 +469,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { Reset() { // disable esc handler + //@ts-expect-error Game.escListener.disable(); document.title = 'Kenó Antigen'; @@ -470,6 +494,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { }; if (expiresDate) { + //@ts-expect-error opts.expires = expiresDate; } @@ -528,14 +553,18 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { let el = document.createElement(TAGNAMES[eventName] || 'div'); eventName = `on${eventName}`; if (eventName in cache) { + //@ts-expect-error return cache[eventName]; } let isSupported = eventName in el; if (!isSupported) { el.setAttribute(eventName, 'return;'); + //@ts-expect-error isSupported = typeof el[eventName] === 'function'; } + //@ts-expect-error cache[eventName] = isSupported; + //@ts-expect-error el = null; return isSupported; } @@ -556,6 +585,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { xDelta /= 120; yDelta /= 120; } + //@ts-expect-error fn.call(this, e, xDelta, yDelta, o); }, obj, @@ -573,6 +603,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { const xAxis = e.axis === e.HORIZONTAL_AXIS; const xDelta = xAxis ? -e.detail : 0; const yDelta = xAxis ? 0 : -e.detail; + //@ts-expect-error fn.call(this, e, xDelta, yDelta, o); }, obj, @@ -589,6 +620,7 @@ if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) { // this event gets 'lines' const xDelta = xAxis ? -e.detail * pixelsPerLine : 0; const yDelta = xAxis ? 0 : -e.detail * pixelsPerLine; + //@ts-expect-error fn.call(this, e, xDelta, yDelta, o); }, obj, diff --git a/app/hocs/withBuildingData.tsx b/app/hocs/withBuildingData.tsx index 7a70fc0d..9822f369 100644 --- a/app/hocs/withBuildingData.tsx +++ b/app/hocs/withBuildingData.tsx @@ -1,13 +1,22 @@ import React from 'react'; import server from 'app/server'; -import { BuildingWindowOptions, BuildingsViewResponse, Building } from 'app/interfaces'; +import { + BuildingWindowOptions, + BuildingsViewResponse, + Building, + BuildingComponentProps, +} from 'app/interfaces'; type Props = { options: BuildingWindowOptions; }; -const withBuildingData = (WrappedComponent: React.ReactNode): React.Component => - class extends React.Component<{ options: BuildingWindowOptions }, { building: Building }> { +type State = { + building: Building; +}; + +const withBuildingData = (WrappedComponent: React.ComponentType) => + class extends React.Component { constructor(props: any) { super(props); this.state = { @@ -30,6 +39,7 @@ const withBuildingData = (WrappedComponent: React.ReactNode): React.Component; config: WindowConfig; } @@ -300,3 +312,14 @@ export type WindowType = | 'register' | 'serverClock' | 'starPanel'; + +export interface BuildingComponentProps { + options: BuildingWindowOptions; + building: Building; +} + +export interface StatusBlock { + empire?: EmpireGetStatusResponse['empire']; + body?: any; + server?: any; +} diff --git a/app/interfaces/menu/icons.ts b/app/interfaces/menu/icons.ts index dd005832..11f71252 100644 --- a/app/interfaces/menu/icons.ts +++ b/app/interfaces/menu/icons.ts @@ -11,8 +11,10 @@ export type IconStyle = | 'ore' | 'planet_side' | 'plots' + | 'spy' | 'star_map' | 'stats' + | 'storage' | 'time' | 'waste' | 'water'; diff --git a/app/server.ts b/app/server.ts index 22a49269..424a0a5c 100644 --- a/app/server.ts +++ b/app/server.ts @@ -11,6 +11,7 @@ import SessionStore from 'app/stores/session'; import WindowsStore from 'app/stores/windows'; import environment from 'app/environment'; +import { StatusBlock } from 'app/interfaces'; interface ServerRequest { module: string; @@ -143,7 +144,7 @@ export const call = function (obj: ServerRequest): void { // Split the status message into server, body, empire // and call the corresponding actions // -export const splitStatus = function (status: any): void { +export const splitStatus = function (status: StatusBlock): void { if (status.server) { const serverStatus = util.fixNumbers(_.cloneDeep(status.server)); ServerRPCStore.update(serverStatus); diff --git a/app/services/stats.ts b/app/services/stats.ts index 22cf1bdf..9cb39e3f 100644 --- a/app/services/stats.ts +++ b/app/services/stats.ts @@ -7,6 +7,7 @@ class StatsService { module: 'stats', method: 'credits', params: [], + addSession: true, success: (result: any) => { CreditsRPCStore.update(result); }, diff --git a/app/shims/yahoo.ts b/app/shims/yahoo.ts index 87b5ed29..383e7454 100644 --- a/app/shims/yahoo.ts +++ b/app/shims/yahoo.ts @@ -32,5 +32,6 @@ import 'app/vendor-js/yui2/build/grids/grids.css'; import 'app/vendor-js/yui2/build/reset-fonts-grids/reset-fonts-grids.css'; import 'app/vendor-js/yui2/build/yahoo/yahoo'; +//@ts-expect-error const { YAHOO } = window; export default YAHOO; diff --git a/app/stores/menu.ts b/app/stores/menu.ts index b0dc927d..e022f128 100644 --- a/app/stores/menu.ts +++ b/app/stores/menu.ts @@ -12,7 +12,7 @@ class MenuStore { rightSidebarShown = false; - loaderShwon = false; + loaderShown = false; mapMode: MapMode = PLANET_MAP_MODE; @@ -65,11 +65,11 @@ class MenuStore { } showLoader() { - this.loaderShwon = true; + this.loaderShown = true; } hideLoader() { - this.loaderShwon = false; + this.loaderShown = false; } } diff --git a/app/stores/rpc/empire.ts b/app/stores/rpc/empire.ts index ef9041e6..0ee262b3 100644 --- a/app/stores/rpc/empire.ts +++ b/app/stores/rpc/empire.ts @@ -2,9 +2,10 @@ import { makeAutoObservable } from 'mobx'; import _ from 'lodash'; import { int, serverDateToMs } from 'app/util'; import ServerRPCStore from 'app/stores/rpc/server'; +import { EmpireGetStatusResponse } from 'app/interfaces'; class EmpireRPCStore { - bodies = { + bodies: EmpireGetStatusResponse['empire']['bodies'] = { colonies: [], mystations: [], ourstations: [], @@ -65,7 +66,7 @@ class EmpireRPCStore { } } - update(empire: any) { + update(empire: EmpireGetStatusResponse['empire']) { this.has_new_messages = empire.has_new_messages; this.home_planet_id = empire.home_planet_id; this.id = empire.id; @@ -85,9 +86,9 @@ class EmpireRPCStore { // 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); - this.essentia = int(empire.essentia); + this.self_destruct_active = empire.self_destruct_active; + this.exactEssentia = empire.essentia; + this.essentia = empire.essentia; if (empire.self_destruct_active) { this.self_destruct_ms = serverDateToMs(empire.self_destruct_date) - ServerRPCStore.serverTimeMoment.valueOf(); @@ -103,7 +104,7 @@ class EmpireRPCStore { this.bodies.colonies = []; this.bodies.mystations = []; this.bodies.ourstations = []; - this.bodies.babies = []; + this.bodies.babies = {}; this.colonies = []; this.essentia = 0; this.exactEssentia = 0; diff --git a/app/util.ts b/app/util.ts index 6328a066..cd481dbe 100644 --- a/app/util.ts +++ b/app/util.ts @@ -159,7 +159,7 @@ const handleObj = function (obj: any): any { return obj; }; -export const fixNumbers = function (data: any) { +export const fixNumbers = function (data: any): any { return _.mapValues(data, handleObj); }; diff --git a/package-lock.json b/package-lock.json index cca14c8d..55d32ad8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,7 @@ "@types/node": "^17.0.24", "@types/react": "^18.x.x", "@types/react-dom": "^18.x.x", + "@types/validator": "^13.7.3", "@typescript-eslint/eslint-plugin": "^5.21.0", "@typescript-eslint/parser": "^5.21.0", "concurrently": "^7.1.0", @@ -1702,6 +1703,12 @@ "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==", "dev": true }, + "node_modules/@types/validator": { + "version": "13.7.3", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.3.tgz", + "integrity": "sha512-DNviAE5OUcZ5s+XEQHRhERLg8fOp8gSgvyJ4aaFASx5wwaObm+PBwTIMXiOFm1QrSee5oYwEAYb7LMzX2O88gA==", + "dev": true + }, "node_modules/@types/vinyl": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.6.tgz", @@ -18463,6 +18470,12 @@ "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==", "dev": true }, + "@types/validator": { + "version": "13.7.3", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.3.tgz", + "integrity": "sha512-DNviAE5OUcZ5s+XEQHRhERLg8fOp8gSgvyJ4aaFASx5wwaObm+PBwTIMXiOFm1QrSee5oYwEAYb7LMzX2O88gA==", + "dev": true + }, "@types/vinyl": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.6.tgz", diff --git a/package.json b/package.json index ad6ac247..fea26f7c 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,9 @@ "scripts": { "lint": "eslint . --ext .ts,.tsx", "format": "prettier --write app/**/*.ts app/**/*.tsx app/yui/**/*.js app/components/**/*.jsx stubs/**/*.js", + "compile": "tsc --noEmit", "dev": "concurrently \"npm run serve:app\" \"npm run serve:stubs\" \"npm run serve:assets\"", - "test": "jest", + "test": "npm run compile && jest", "test:watch": "jest --watch", "test:coverage": "jest --coverage", "build": "vite build && ln -s ../Lacuna-Assets ./dist/Lacuna-Assets", @@ -61,6 +62,7 @@ "@types/node": "^17.0.24", "@types/react": "^18.x.x", "@types/react-dom": "^18.x.x", + "@types/validator": "^13.7.3", "@typescript-eslint/eslint-plugin": "^5.21.0", "@typescript-eslint/parser": "^5.21.0", "concurrently": "^7.1.0", diff --git a/stubs/src/empire.js b/stubs/src/empire.js index 31d919b4..d8c950c2 100644 --- a/stubs/src/empire.js +++ b/stubs/src/empire.js @@ -103,7 +103,7 @@ const Empire = { ], babies: { 'Taylor Swift': { - planets: [ + bodies: [ { id: 500, name: 'Red',