Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Iss #32 Previous balance and script processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Wright committed Aug 7, 2017
1 parent 16a6ce7 commit c8774d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/components/EpisodeUserStats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class EpisodeUserStats extends React.Component {
<div className="results row ">
<div className="result balance small-3 columns">
<div className="title">
Result
Previous Balance
</div>
<div className="body">
{ toCurrencyString(previousBalance) }
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/components/Event.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Event extends React.Component {
<Episode { ...episode }/>
{
episode.resolved && userId ?
<EpisodeUserStats episodeId={ episode.id }/> :
<EpisodeUserStats userId={ userId } episodeId={ episode.id }/> :
<div className="noresults"/>
}
<BetsList episodeId={ episode.id } userId={ userId } context={ context }/>
Expand Down
2 changes: 2 additions & 0 deletions scripts/lib.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c8774d5

Please sign in to comment.