Skip to content

Commit

Permalink
Best Reversal now adapts to the user's chosen move notation
Browse files Browse the repository at this point in the history
  • Loading branch information
D4RKONION committed Dec 4, 2021
1 parent c498890 commit 686f41b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
25 changes: 21 additions & 4 deletions src/js/components/FrameDataSubHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import CharacterPortrait from "./CharacterPortrait";
import { useEffect, useState } from "react";
import GAME_DETAILS from "../constants/GameDetails";
import { GameName, PlayerData } from "../types";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { setModalVisibility } from "../actions";
import { renameData } from "../utils";
import { dataDisplaySettingsSelector, frameDataSelector } from "../selectors";

type FrameDataSubHeaderProps = {
charName: PlayerData["name"],
Expand All @@ -16,8 +18,17 @@ type FrameDataSubHeaderProps = {

const FrameDataSubHeader = ({ charName, charStats, activeGame }: FrameDataSubHeaderProps) => {

const [statCategory, setStatCategory] = useState("The Basics")
const dispatch = useDispatch()
const [statCategory, setStatCategory] = useState("The Basics");

const dispatch = useDispatch();


const frameData = useSelector(frameDataSelector);
const dataDisplaySettings = useSelector(dataDisplaySettingsSelector);
const moveNotation =
dataDisplaySettings.moveNameType === "common"
? "cmnName"
: dataDisplaySettings.inputNotationType

const labelObj = {}
Object.keys(GAME_DETAILS[activeGame].statsPoints).map(keyName => labelObj[keyName] = keyName)
Expand Down Expand Up @@ -52,7 +63,13 @@ const FrameDataSubHeader = ({ charName, charStats, activeGame }: FrameDataSubHea
Object.keys(dataRowObj).map(statKey =>
charStats[statKey] && charStats[statKey] !== "~" &&
<IonCol key={`stat-entry-${statKey}`} className="stat-entry">
<h2>{charStats[statKey]}</h2>
<h2>
{
statKey === "bestReversal" && frameData[charName] && frameData[charName].moves.normal[charStats[statKey]]
? frameData[charName].moves.normal[charStats[statKey]][moveNotation]
: charStats[statKey]
}
</h2>
<p>{dataRowObj[statKey]}</p>
</IonCol>
)
Expand Down
1 change: 1 addition & 0 deletions src/js/constants/VersionLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const VERSION_LOGS = {
"3.4.2": {
"New Features": [
"Added more stats to GGST characters, removed blank stats from characters",
"Best Reversal now adapts to the user's chosen move notation"
],
"Bug Fixes": [
"Web: Fixed a crash when changing games while a game unique stat was selected",
Expand Down
17 changes: 15 additions & 2 deletions src/js/pages/CharacterStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GAME_DETAILS from '../constants/GameDetails'
import '../../style/components/DetailCards.scss';
import PageHeader from '../components/PageHeader';
import SubHeader from '../components/SubHeader';
import { activeGameSelector, activePlayerSelector, selectedCharactersSelector } from '../selectors';
import { activeGameSelector, activePlayerSelector, dataDisplaySettingsSelector, frameDataSelector, selectedCharactersSelector } from '../selectors';


const CharacterStats = () => {
Expand All @@ -16,6 +16,13 @@ const CharacterStats = () => {
const activeCharName = selectedCharacters[activePlayer].name;
const charStatsData = selectedCharacters[activePlayer].stats;

const frameData = useSelector(frameDataSelector);
const dataDisplaySettings = useSelector(dataDisplaySettingsSelector);
const moveNotation =
dataDisplaySettings.moveNameType === "common"
? "cmnName"
: dataDisplaySettings.inputNotationType


const statsPoints = GAME_DETAILS[activeGame].statsPoints;

Expand Down Expand Up @@ -51,7 +58,13 @@ const CharacterStats = () => {
{Object.entries(dataRow).map(([dataId, headerObj]) =>
<div key={dataId} className="col">
<h2>{headerObj}</h2>
<p>{charStatsData[dataId]}</p>
<p>
{
dataId === "bestReversal" && frameData[activeCharName] && frameData[activeCharName].moves.normal[charStatsData[dataId]]
? frameData[activeCharName].moves.normal[charStatsData[dataId]][moveNotation]
: charStatsData[dataId]
}
</p>
</div>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/style/components/FrameDataSubHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
border-radius: 6px;
margin: 4px 0;
padding: 18px 0;
align-items: center;

.stat-entry {
text-align: center;
Expand Down

0 comments on commit 686f41b

Please sign in to comment.