Skip to content

Commit

Permalink
Merge pull request #319 from ORNL-AMO/issue-279-d
Browse files Browse the repository at this point in the history
Issue 279 - Use carbon savings per tonne stat
  • Loading branch information
nbintertech authored Apr 2, 2024
2 parents a30233a + f6709a2 commit 7f56711
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,10 @@ export class App extends React.PureComponent<unknown, AppState> {
});
const carbonSavingsPercentFormatted: string = (endYearStats.carbonSavingsPercent * 100).toFixed(2);
const gameTotalNetCostFormatted: string = noDecimalsFormatter.format(endYearStats.gameTotalSpending);
const carbonSavingsKgFormatted: string = noDecimalsFormatter.format(endYearStats.carbonSavingsPerKg);

const carbonSavingsPerTonne = endYearStats.carbonSavingsPerKg / 1000;
const carbonSavingsPerTonneFormatted: string = noDecimalsFormatter.format(carbonSavingsPerTonne);

const projectedFinancedSpendingFormatted: string = noDecimalsFormatter.format(projectedFinancedSpending);
const gameCurrentAndProjectedSpendingFormatted: string = noDecimalsFormatter.format(projectedFinancedSpending + endYearStats.gameTotalSpending);
const costPerCarbonSavingsFormatted: string = endYearStats.costPerCarbonSavings !== undefined ? Intl.NumberFormat('en-US', {
Expand All @@ -659,7 +662,7 @@ export class App extends React.PureComponent<unknown, AppState> {
// todo add NAN / undefined defensives
let endGameResults: EndGameResults = {
carbonSavingsPercent: carbonSavingsPercentFormatted,
carbonSavingsKg: carbonSavingsKgFormatted,
carbonSavingsPerTonne: carbonSavingsPerTonneFormatted,
gameTotalSpending: gameTotalNetCostFormatted,
projectedFinancedSpending: projectedFinancedSpendingFormatted,
gameCurrentAndProjectedSpending: gameCurrentAndProjectedSpendingFormatted,
Expand Down
8 changes: 4 additions & 4 deletions src/components/WinGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class WinGame extends React.Component<WinGameProps> {
<span>In the game, you spent
<UnderlineSpan text={`$${this.props.endGameResults.gameTotalSpending}`}
animationClass='animate-underline-emphasis'></UnderlineSpan>
on GHG reduction measures.
on GHG reduction measures
</span>

</div>,
Expand All @@ -86,7 +86,7 @@ export default class WinGame extends React.Component<WinGameProps> {
className='slide-stat-div child-stat-div'>
{this.props.endGameResults.projectedFinancedSpending ?
<span>In the years after the game, you will spend <UnderlineSpan text={`$${this.props.endGameResults.projectedFinancedSpending}`}
animationClass='animate-underline-emphasis'></UnderlineSpan> on financed and power purchase agreement projects.
animationClass='animate-underline-emphasis'></UnderlineSpan> on financed and power purchase agreement projects
</span>
:
<></>
Expand All @@ -108,7 +108,7 @@ export default class WinGame extends React.Component<WinGameProps> {
<UnderlineSpan text={`$${this.props.endGameResults.gameCurrentAndProjectedSpending}`}
animationClass='animate-underline-emphasis'></UnderlineSpan>
and you will have reduced your GHG emissions by
<UnderlineSpan text={`${this.props.endGameResults.carbonSavingsKg} kg/yr`} animationClass='animate-underline-emphasis'></UnderlineSpan>
<UnderlineSpan text={`${this.props.endGameResults.carbonSavingsPerTonne} tonne/yr`} animationClass='animate-underline-emphasis'></UnderlineSpan>
</span>
</div>,
<div
Expand All @@ -130,7 +130,7 @@ export default class WinGame extends React.Component<WinGameProps> {
<div
key={'slide4c'}
className='slide-stat-div'>
Overall, You reduced your GHG emissions by {this.props.endGameResults.carbonSavingsPercent}%
Overall, you reduced your GHG emissions by {this.props.endGameResults.carbonSavingsPercent}%
</div>,
<div
key={'slide4b'}
Expand Down
2 changes: 1 addition & 1 deletion src/trackedStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface TrackedStats {
export interface EndGameResults {
carbonSavingsPercent: string,
gameTotalSpending: string,
carbonSavingsKg: string,
carbonSavingsPerTonne: string,
projectedFinancedSpending: string,
gameCurrentAndProjectedSpending: string,
costPerCarbonSavings: string,
Expand Down

0 comments on commit 7f56711

Please sign in to comment.