From c8774d5b014a0220477d8fa6293f94dca4ff9072 Mon Sep 17 00:00:00 2001 From: Craig Wright Date: Mon, 7 Aug 2017 12:54:52 -0700 Subject: [PATCH] Iss #32 Previous balance and script processing. --- app/components/EpisodeUserStats.jsx | 3 ++- app/components/Event.jsx | 2 +- scripts/lib.jsx | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/components/EpisodeUserStats.jsx b/app/components/EpisodeUserStats.jsx index 8e978ea..5927cd2 100644 --- a/app/components/EpisodeUserStats.jsx +++ b/app/components/EpisodeUserStats.jsx @@ -20,7 +20,7 @@ export class EpisodeUserStats extends React.Component {
- Result + Previous Balance
{ toCurrencyString(previousBalance) } @@ -62,6 +62,7 @@ export class EpisodeUserStats extends React.Component { function mapStateToProps(state, props) { const { episodeId } = props; const userId = props.userId || getKey(state.login, 'uid', null); + const episode = getKey(state.episodes, episodeId, {}); const results = getKey(state.leaderboard, `${episode.season}.${userId}.episodes.${episodeId}`, {}); return { diff --git a/app/components/Event.jsx b/app/components/Event.jsx index 39b3d97..dcbe520 100644 --- a/app/components/Event.jsx +++ b/app/components/Event.jsx @@ -32,7 +32,7 @@ export class Event extends React.Component { { episode.resolved && userId ? - : + :
} diff --git a/scripts/lib.jsx b/scripts/lib.jsx index 102a27a..cc238e4 100644 --- a/scripts/lib.jsx +++ b/scripts/lib.jsx @@ -99,11 +99,13 @@ function processUserWagers(user, episodes, bets) { } } let cheated = (balance - costOfPlay < 0); + let previousBalance = balance; let balanceBeforeWinnings = balance - costOfPlay; balance = balance - costOfPlay + totalWinnings; episodesSummary[episode.id] = { cheated, balance, + previousBalance, balanceBeforeWinnings, winnings: episodeWinnings, losses: episodeLosses