From 7cd14f2b586b1114ff228acc3aafe82b9fd1be24 Mon Sep 17 00:00:00 2001 From: Jeff Colombo Date: Sun, 10 Mar 2019 22:08:47 -0400 Subject: [PATCH] begin work showing type coverage --- dist/main-bundle.js | 16 +++++++++++----- src/ts/api/PokemonService.ts | 11 ++++++++++- src/ts/app/PokemonApp.tsx | 1 + src/ts/app/components/MovesExplorer.tsx | 6 ++++++ src/ts/app/components/TypeEffectiveDisplay.tsx | 3 ++- src/ts/app/models/Config.ts | 12 +++++++++++- 6 files changed, 41 insertions(+), 8 deletions(-) diff --git a/dist/main-bundle.js b/dist/main-bundle.js index 5e0cf5c..6b19115 100644 --- a/dist/main-bundle.js +++ b/dist/main-bundle.js @@ -29619,7 +29619,7 @@ function pathToRegexp (path, keys, options) { /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js because of ./node_modules/react-redux/es/index.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/extends.js because of ./node_modules/react-redux/es/index.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js because of ./node_modules/react-redux/es/index.js */ -/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js because of ./node_modules/react-measure/dist/index.esm.js */ +/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js because of ./node_modules/react-redux/es/index.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { @@ -36665,7 +36665,7 @@ function () { return __awaiter(this, void 0, void 0, /*#__PURE__*/ regeneratorRuntime.mark(function _callee() { - var queryParameters, response; + var queryParameters, response, attackTypeEffectiveness; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { @@ -36676,11 +36676,16 @@ function () { case 3: response = _context.sent; + attackTypeEffectiveness = response.attackTypeEffectiveness.map(function (tuple) { + var deserialize = [tuple[0], new Map(tuple[1])]; + return deserialize; + }); return _context.abrupt("return", Object.assign({}, response, { + attackTypeEffectiveness: new Map(attackTypeEffectiveness), combatMoves: new Map(response.combatMoves) })); - case 5: + case 6: case "end": return _context.stop(); } @@ -37156,6 +37161,7 @@ function (_react_1$default$Comp) { quickMoves: leaguePokemon.moves.quick, chargeMoves: leaguePokemon.moves.cinematic, selectedMoves: selectedCombatMoves, + attackTypeEffectiveness: null, combatMoveSelectorsOpen: combatMoveSelectorsOpen, handleToggleDropdownOpen: this.handleToggleDropdownOpen, handleChangeSelectedMove: this.handleChangeSelectedMove @@ -38816,7 +38822,7 @@ function (_react_1$default$Comp) { }), chargeMove2 && chargeMove2Type && react_1.default.createElement(TypeIndicator_1.TypeIndicator, { className: chargeMove2Css, type: chargeMove2Type - })); + }), react_1.default.createElement("div", null, react_1.default.createElement("h4", null, "Type Coverage"))); } }]); @@ -39796,9 +39802,9 @@ function (_react_1$default$Comp) { var typeIndicator; if (value === Pokemon_1.TypeEffectiveness.SUPER_EFFECTIVE || value === Pokemon_1.TypeEffectiveness.NOT_VERY_EFFECTIVE) { + // using `key` because these are later transformed into an array of duplicate elements typeIndicator = react_1.default.createElement(TypeIndicator_1.TypeIndicator, { key: key, - className: "test", type: key }); } else { diff --git a/src/ts/api/PokemonService.ts b/src/ts/api/PokemonService.ts index 0eb1997..f58152a 100644 --- a/src/ts/api/PokemonService.ts +++ b/src/ts/api/PokemonService.ts @@ -2,7 +2,7 @@ import POGOProtos from 'pogo-protos'; import { AjaxRequest } from 'api/AjaxRequest'; -import { IConfig, IConfigJson } from 'app/models/Config'; +import { AttackTypeEffectivenessSerializingTuple, IConfig, IConfigJson } from 'app/models/Config'; import { ILeaguePokemon } from 'app/models/League'; import { IPokemon, TypeEffectiveness } from 'app/models/Pokemon'; @@ -29,8 +29,17 @@ export class PokemonService implements IPokemonService { }; const response : IConfigJson = await this.AjaxRequest.ajaxGet('/dist/db/config.json', queryParameters); + const attackTypeEffectiveness = response.attackTypeEffectiveness.map((tuple) => { + const deserialize : AttackTypeEffectivenessSerializingTuple = [ + tuple[0], + new Map(tuple[1]), + ]; + return deserialize; + }); + return { ...response, + attackTypeEffectiveness: new Map(attackTypeEffectiveness), combatMoves: new Map(response.combatMoves), }; } diff --git a/src/ts/app/PokemonApp.tsx b/src/ts/app/PokemonApp.tsx index 4492ca3..dca6d8e 100644 --- a/src/ts/app/PokemonApp.tsx +++ b/src/ts/app/PokemonApp.tsx @@ -229,6 +229,7 @@ class PokemonApp extends React.Component { quickMoves={ leaguePokemon.moves.quick } chargeMoves={ leaguePokemon.moves.cinematic } selectedMoves={ selectedCombatMoves } + attackTypeEffectiveness={ null } combatMoveSelectorsOpen={ combatMoveSelectorsOpen } handleToggleDropdownOpen={ this.handleToggleDropdownOpen } handleChangeSelectedMove={ this.handleChangeSelectedMove } diff --git a/src/ts/app/components/MovesExplorer.tsx b/src/ts/app/components/MovesExplorer.tsx index 4d9e938..ffa7372 100644 --- a/src/ts/app/components/MovesExplorer.tsx +++ b/src/ts/app/components/MovesExplorer.tsx @@ -2,6 +2,7 @@ import React from 'react'; import classNames from 'classnames'; +import { AttackTypeEffectiveness } from 'app/models/Config'; import { CombatMoveStats, ICombatMoveStats, IPokemonMove } from 'app/models/Pokemon'; import { CombatMoveSelectorsOpen, SelectedCombatMoves } from 'app/types'; @@ -20,6 +21,7 @@ export interface IMovesExplorerProps { chargeMove1 : IPokemonMove | null; chargeMove2 : IPokemonMove | null; }; + attackTypeEffectiveness : AttackTypeEffectiveness | null; combatMoveSelectorsOpen : CombatMoveSelectorsOpen; handleToggleDropdownOpen : (menu : keyof CombatMoveSelectorsOpen, isOpen : boolean) => void; handleChangeSelectedMove : (moves : SelectedCombatMoves) => void; @@ -96,6 +98,10 @@ export class MovesExplorer extends React.Component { { chargeMove2 && chargeMove2Type && } +
+

Type Coverage

+ +
); } diff --git a/src/ts/app/components/TypeEffectiveDisplay.tsx b/src/ts/app/components/TypeEffectiveDisplay.tsx index 3643874..b760caa 100644 --- a/src/ts/app/components/TypeEffectiveDisplay.tsx +++ b/src/ts/app/components/TypeEffectiveDisplay.tsx @@ -51,7 +51,8 @@ export class TypeEffectiveDisplay extends React.Component; + // using `key` because these are later transformed into an array of duplicate elements + typeIndicator = ; } else { typeIndicator = ; } diff --git a/src/ts/app/models/Config.ts b/src/ts/app/models/Config.ts index 7efe5e3..1f169bf 100644 --- a/src/ts/app/models/Config.ts +++ b/src/ts/app/models/Config.ts @@ -1,13 +1,23 @@ import POGOProtos from 'pogo-protos'; -import { CombatMoveStats, ICombatMoveStats, IMaxStats } from 'app/models/Pokemon'; +import { CombatMoveStats, ICombatMoveStats, IMaxStats, TypeEffectiveness } from 'app/models/Pokemon'; + +type TypeEffectivenessByTypeJson = Array<[POGOProtos.Enums.PokemonType, TypeEffectiveness]>; +type AttackTypeEffectivenessJson = Array<[POGOProtos.Enums.PokemonType, TypeEffectivenessByTypeJson]>; export interface IConfigJson { maxPossibleStats : IMaxStats; + attackTypeEffectiveness : AttackTypeEffectivenessJson; combatMoves : Array<[POGOProtos.Enums.PokemonMove, ICombatMoveStats]>; } +export type TypeEffectivenessByType = Map; +export type AttackTypeEffectiveness = Map; + export interface IConfig { maxPossibleStats : IMaxStats; + attackTypeEffectiveness : AttackTypeEffectiveness; combatMoves : CombatMoveStats; } + +export type AttackTypeEffectivenessSerializingTuple = [POGOProtos.Enums.PokemonType, TypeEffectivenessByType];