From ca3629f2558268a27cdcd5896c50f6fa488e8cd1 Mon Sep 17 00:00:00 2001 From: Jeff Colombo Date: Mon, 11 Mar 2019 23:28:08 -0400 Subject: [PATCH] start reporting type coverage --- dist/app.css | 88 +++++++++---------- dist/main-bundle.js | 48 ++++++++-- src/ts/app/actions.ts | 3 +- .../PokemonExplorer/MovesExplorer.tsx | 40 +++++++-- .../PokemonExplorer/PokemonExplorer.tsx | 2 +- 5 files changed, 120 insertions(+), 61 deletions(-) diff --git a/dist/app.css b/dist/app.css index b54db0a..ba6e25c 100644 --- a/dist/app.css +++ b/dist/app.css @@ -396,50 +396,6 @@ .MovesDropdown__legacy__3-s2n { } -.MovesExplorer__wrapper__2y-BK { - font-size: 1em; } - .MovesExplorer__wrapper__2y-BK .title { - color: #fff; - position: absolute; - margin-top: -2em; - margin-bottom: 0; } - -.MovesExplorer__legacy__2PDtp { - background-image: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255, 255, 255, 0.5) 5px, rgba(255, 255, 255, 0.5) 10px); - background-size: 14px 14px; } - -.PokemonDisplay__highlight__h50BA { - color: #fff; - pointer-events: none; } - -.PokemonDisplay__pokemonInfoWrapper__3AW3e { - margin-bottom: 1rem; } - -.PokemonDisplay__pokemonInfoLeftColumn__1vugM { } - -.PokemonDisplay__pokemonInfoRightColumn__27Q49 { } - -.PokemonDisplay__pokemonName__WBKbk { - margin-bottom: 0; } - -.PokemonDisplay__dexHeader__2HVfr { - margin-bottom: 0.25rem; } - -.PokemonDisplay__pokemonTypeWrapper__1rJIA { - display: flex; - justify-content: center; - align-self: stretch; } - -.PokemonDisplay__formHeader__1pr6M { - text-transform: uppercase; - margin-bottom: 0; } - -.PokemonDisplay__pokemonBaseStats__3UJvn { - display: flex; - flex-flow: column nowrap; - align-items: start; - align-self: stretch; } - .TypeEffectiveDisplay__multiplierWrapper__14os7 { position: relative; z-index: 0; @@ -504,6 +460,50 @@ flex-basis: unset; width: 6.75rem; } +.MovesExplorer__wrapper__2y-BK { + font-size: 1em; } + .MovesExplorer__wrapper__2y-BK .title { + color: #fff; + position: absolute; + margin-top: -2em; + margin-bottom: 0; } + +.MovesExplorer__legacy__2PDtp { + background-image: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255, 255, 255, 0.5) 5px, rgba(255, 255, 255, 0.5) 10px); + background-size: 14px 14px; } + +.PokemonDisplay__highlight__h50BA { + color: #fff; + pointer-events: none; } + +.PokemonDisplay__pokemonInfoWrapper__3AW3e { + margin-bottom: 1rem; } + +.PokemonDisplay__pokemonInfoLeftColumn__1vugM { } + +.PokemonDisplay__pokemonInfoRightColumn__27Q49 { } + +.PokemonDisplay__pokemonName__WBKbk { + margin-bottom: 0; } + +.PokemonDisplay__dexHeader__2HVfr { + margin-bottom: 0.25rem; } + +.PokemonDisplay__pokemonTypeWrapper__1rJIA { + display: flex; + justify-content: center; + align-self: stretch; } + +.PokemonDisplay__formHeader__1pr6M { + text-transform: uppercase; + margin-bottom: 0; } + +.PokemonDisplay__pokemonBaseStats__3UJvn { + display: flex; + flex-flow: column nowrap; + align-items: start; + align-self: stretch; } + .PokemonSelectList__wrapper__2LQMY { font-size: 0.8rem; width: 20em; diff --git a/dist/main-bundle.js b/dist/main-bundle.js index b523e17..d32ba06 100644 --- a/dist/main-bundle.js +++ b/dist/main-bundle.js @@ -37133,7 +37133,7 @@ exports.setMaxPossibleStats = function (maxStats) { }; exports.setAttackTypeEffectiveness = function (attackTypeEffectiveness) { - return typesafe_actions_1.action(types_1.PokemonAppActionTypes.SET_COMBAT_MOVE_STATS, { + return typesafe_actions_1.action(types_1.PokemonAppActionTypes.SET_ATTACK_TYPE_EFFECTIVENESS, { attackTypeEffectiveness: attackTypeEffectiveness }); }; @@ -38472,8 +38472,12 @@ var react_1 = __importDefault(__webpack_require__(/*! react */ "./node_modules/r var classnames_1 = __importDefault(__webpack_require__(/*! classnames */ "./node_modules/classnames/index.js")); +var Pokemon_1 = __webpack_require__(/*! app/models/Pokemon */ "./src/ts/app/models/Pokemon.ts"); + var MovesDropdown_1 = __webpack_require__(/*! app/components/PokemonExplorer/MovesDropdown */ "./src/ts/app/components/PokemonExplorer/MovesDropdown.tsx"); +var TypeEffectiveDisplay_1 = __webpack_require__(/*! ./TypeEffectiveDisplay */ "./src/ts/app/components/PokemonExplorer/TypeEffectiveDisplay.tsx"); + var TypeIndicator_1 = __webpack_require__(/*! ./TypeIndicator */ "./src/ts/app/components/PokemonExplorer/TypeIndicator.tsx"); var styles = __importStar(__webpack_require__(/*! app/components/PokemonExplorer/styles/MovesExplorer.scss */ "./src/ts/app/components/PokemonExplorer/styles/MovesExplorer.scss")); @@ -38490,6 +38494,31 @@ function (_react_1$default$Comp) { _this = _possibleConstructorReturn(this, _getPrototypeOf(MovesExplorer).apply(this, arguments)); + _this.calculateTypeCoverage = function () { + var _this$props = _this.props, + selectedMoves = _this$props.selectedMoves, + attackTypeEffectiveness = _this$props.attackTypeEffectiveness; + var calculatedffectiveness = new Map(); + Object.values(selectedMoves).forEach(function (move) { + var moveType = _this.getMoveType(move); + + if (moveType !== null) { + var moveEffectiveness = attackTypeEffectiveness.get(moveType); + + if (typeof moveEffectiveness !== 'undefined') { + moveEffectiveness.forEach(function (effectiveness, type) { + var currentEffectiveness = calculatedffectiveness.get(type); + + if (typeof currentEffectiveness === 'undefined' || Pokemon_1.TypeEffectiveness[effectiveness] > Pokemon_1.TypeEffectiveness[currentEffectiveness]) { + calculatedffectiveness.set(type, effectiveness); + } + }); + } + } + }); + return calculatedffectiveness; + }; + _this.getMoveType = function (move) { var moveStats = null; @@ -38540,11 +38569,11 @@ function (_react_1$default$Comp) { _createClass(MovesExplorer, [{ key: "render", value: function render() { - var _this$props = this.props, - movesById = _this$props.movesById, - quickMoves = _this$props.quickMoves, - chargeMoves = _this$props.chargeMoves, - combatMoveSelectorsOpen = _this$props.combatMoveSelectorsOpen; + var _this$props2 = this.props, + movesById = _this$props2.movesById, + quickMoves = _this$props2.quickMoves, + chargeMoves = _this$props2.chargeMoves, + combatMoveSelectorsOpen = _this$props2.combatMoveSelectorsOpen; var _this$props$selectedM = this.props.selectedMoves, quickMove = _this$props$selectedM.quickMove, chargeMove1 = _this$props$selectedM.chargeMove1, @@ -38591,7 +38620,10 @@ 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"))); + }), react_1.default.createElement("div", null, react_1.default.createElement("h4", null, "Type Coverage"), react_1.default.createElement(TypeEffectiveDisplay_1.TypeEffectiveDisplay, { + pokemonName: "test", + effectiveness: this.calculateTypeCoverage() + }))); } }]); @@ -38873,7 +38905,7 @@ function (_react_1$default$Comp) { _this.props.dispatch(ActionsPokemonExplorer.setCombatMoveSelectorsOpen(combatMoveSelectorsOpen)); - _this.props.toggleInterruption(true); + _this.props.toggleInterruption(isOpen); }; _this.handleOverlayClick = function () { diff --git a/src/ts/app/actions.ts b/src/ts/app/actions.ts index eac40eb..05f5b16 100644 --- a/src/ts/app/actions.ts +++ b/src/ts/app/actions.ts @@ -6,9 +6,10 @@ import { AttackTypeEffectiveness } from 'app/models/Config'; import { CombatMoveStats, IMaxStats } from 'app/models/Pokemon'; export const setIsInterruption = (isInterruption : boolean) => action(PokemonAppActionTypes.SET_IS_INTERRUPTION, { isInterruption }); + export const setMaxPossibleStats = (maxStats : IMaxStats) => action(PokemonAppActionTypes.SET_MAX_STATS, { maxStats }); -export const setAttackTypeEffectiveness = (attackTypeEffectiveness : AttackTypeEffectiveness) => action(PokemonAppActionTypes.SET_COMBAT_MOVE_STATS, { attackTypeEffectiveness }); +export const setAttackTypeEffectiveness = (attackTypeEffectiveness : AttackTypeEffectiveness) => action(PokemonAppActionTypes.SET_ATTACK_TYPE_EFFECTIVENESS, { attackTypeEffectiveness }); export const setCombatMoveStats = (combatMoves : CombatMoveStats) => action(PokemonAppActionTypes.SET_COMBAT_MOVE_STATS, { combatMoves }); diff --git a/src/ts/app/components/PokemonExplorer/MovesExplorer.tsx b/src/ts/app/components/PokemonExplorer/MovesExplorer.tsx index 119ade3..9c5fe27 100644 --- a/src/ts/app/components/PokemonExplorer/MovesExplorer.tsx +++ b/src/ts/app/components/PokemonExplorer/MovesExplorer.tsx @@ -1,13 +1,16 @@ +import POGOProtos from 'pogo-protos'; + import React from 'react'; import classNames from 'classnames'; import { AttackTypeEffectiveness } from 'app/models/Config'; -import { CombatMoveStats, ICombatMoveStats, IPokemonMove } from 'app/models/Pokemon'; +import { CombatMoveStats, ICombatMoveStats, IPokemonMove, TypeEffectiveness } from 'app/models/Pokemon'; import { CombatMoveSelectorsOpen, SelectedCombatMoves } from 'app/components/PokemonExplorer/types'; import { MovesDropdown } from 'app/components/PokemonExplorer/MovesDropdown'; +import { TypeEffectiveDisplay } from './TypeEffectiveDisplay'; import { TypeIndicator } from './TypeIndicator'; import * as styles from 'app/components/PokemonExplorer/styles/MovesExplorer.scss'; @@ -16,11 +19,7 @@ export interface IMovesExplorerProps { movesById : CombatMoveStats; quickMoves : Array; chargeMoves : Array; - selectedMoves : { - quickMove : IPokemonMove | null; - chargeMove1 : IPokemonMove | null; - chargeMove2 : IPokemonMove | null; - }; + selectedMoves : SelectedCombatMoves; attackTypeEffectiveness : AttackTypeEffectiveness; combatMoveSelectorsOpen : CombatMoveSelectorsOpen; handleToggleDropdownOpen : (menu : keyof CombatMoveSelectorsOpen, isOpen : boolean) => void; @@ -100,12 +99,39 @@ export class MovesExplorer extends React.Component { }

Type Coverage

- +
); } + private readonly calculateTypeCoverage = () => { + const { + selectedMoves, + attackTypeEffectiveness, + } = this.props; + const calculatedffectiveness : Map = new Map(); + Object.values(selectedMoves).forEach((move) => { + const moveType = this.getMoveType(move); + if (moveType !== null) { + const moveEffectiveness = attackTypeEffectiveness.get(moveType); + if (typeof moveEffectiveness !== 'undefined') { + moveEffectiveness.forEach((effectiveness, type) => { + const currentEffectiveness = calculatedffectiveness.get(type); + if (typeof currentEffectiveness === 'undefined' || TypeEffectiveness[effectiveness] > TypeEffectiveness[currentEffectiveness]) { + calculatedffectiveness.set(type, effectiveness); + } + }); + } + } + }); + + return calculatedffectiveness; + } + private readonly getMoveType = (move : IPokemonMove | null) => { let moveStats : ICombatMoveStats | null = null; if (move !== null) { diff --git a/src/ts/app/components/PokemonExplorer/PokemonExplorer.tsx b/src/ts/app/components/PokemonExplorer/PokemonExplorer.tsx index 4f9aad4..9366d8b 100644 --- a/src/ts/app/components/PokemonExplorer/PokemonExplorer.tsx +++ b/src/ts/app/components/PokemonExplorer/PokemonExplorer.tsx @@ -181,7 +181,7 @@ class PokemonExplorer extends React.Component {