Skip to content

Commit

Permalink
Sprint replay added
Browse files Browse the repository at this point in the history
  • Loading branch information
angarg12 committed Feb 14, 2015
1 parent 083532d commit 30ca655
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
28 changes: 26 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ <h1>True<sup>xponential</sup></h1>
<h2>Cash: <span style="font-family:Courier New, Courier, monospace">$<span ng-bind-html="trustedPrettifyNumber(player.currency)"/></span></h2>
<h2>Cash multiplier: {{(player.multiplier).toFixed(4)}}</h2>
<h2>Time: {{getSprintTime()}}</h2>
<h2>{{player.sprintTimes}}</h2>
<h2>Goal<sup ng-if="currentPrestige > 0">{{currentPrestige}}</sup>: <span ng-bind-html="trustedPrettifyNumber(prestigeGoal[currentPrestige])"/></h2>
<div class="progress-striped" style="margin-bottom:0;width:80%;">
<div ng-if="!sprintFinished">
Expand Down Expand Up @@ -50,13 +49,38 @@ <h3 ng-if="clickUpgradePower.length > 0">Click power upgrades</h3>
<br>
</div>
<hr>
</div>
<div id="sprints" ng-if="player.maxPrestige > 0">
<h2>Sprints</h2>
<table id="sprintsTable">
<tr>
<td>
Sprint
</td>
<td>
Best time
</td>
</tr>
<tr ng-repeat="sprint in player.sprintTimes">
<td>
{{$index}}
</td>
<td>
{{formatTime(sprint)}}
</td>
<td>
<button id="retry" ng-click="prestige($index)">Retry</button>
</td>
</tr>
</table>
<hr>
</div>
<div id="options">
<h2>Options</h2>
<table id="optionTable">
<tr ng-if="sprintFinished && prestigeGoal.length > player.maxPrestige+1">
<td>
<button id="prestige" ng-click="prestige()">Prestige</button>
<button id="prestige" ng-click="prestige(currentPrestige+1)">Prestige</button>
</td>
</tr>
<tr>
Expand Down
37 changes: 22 additions & 15 deletions js/exponential.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
angular.module('incremental',[])
.controller('IncCtrl',['$scope','$document','$interval', '$sce',function($scope,$document,$interval,$sce) {
$scope.version = '0.8.2';
$scope.version = '0.9';
$scope.Math = window.Math;

const startPlayer = {
cashPerClick: new Decimal(1),
multiplier: new Decimal(10),
multiplier: new Decimal(1),
multiplierUpgradeLevel: [],
multiplierUpgradePrice: [],
clickUpgradeLevel: [],
Expand Down Expand Up @@ -109,8 +109,8 @@ angular.module('incremental',[])
init();
timerReset();
timerStart();
generatePrestigePlayer($scope.player.maxPrestige);
generatePrestigeUpgrades($scope.player.maxPrestige);
generatePrestigePlayer(0);
generatePrestigeUpgrades(0);
localStorage.removeItem("playerStored");
$scope.currentPrestige = 0;
}
Expand All @@ -127,9 +127,12 @@ angular.module('incremental',[])
}
};

$scope.prestige = function prestige(){
$scope.prestige = function prestige(level){
// Save the values of the player that persist between prestiges
newPrestige = $scope.player.maxPrestige+1;
newPrestige = $scope.player.maxPrestige;
if(level > newPrestige){
newPrestige = level;
}
preferences = $scope.player.preferences;
version = $scope.player.version;
sprintTimes = $scope.player.sprintTimes;
Expand All @@ -148,9 +151,9 @@ angular.module('incremental',[])
$scope.player.sprintTimes = sprintTimes;

// Generate the prestige values
generatePrestigePlayer($scope.player.maxPrestige);
generatePrestigeUpgrades($scope.player.maxPrestige);
$scope.currentPrestige++;
generatePrestigePlayer(level);
generatePrestigeUpgrades(level);
$scope.currentPrestige = level;
};

function update() {
Expand All @@ -177,7 +180,7 @@ angular.module('incremental',[])
};

function versionControl(ifImport){
versionComparison = versionCompare($scope.player.version,'0.8');
versionComparison = versionCompare($scope.player.version,'0.9');
if(versionComparison == -1 || versionComparison == false){
if(ifImport){
alert("This save is incompatible with the current version.");
Expand Down Expand Up @@ -293,13 +296,13 @@ angular.module('incremental',[])
}
if(typeof $scope.player === 'undefined'){
init();
generatePrestigePlayer($scope.player.maxPrestige);
generatePrestigePlayer(0);
}
if(typeof $scope.lastSave === 'undefined'){
$scope.lastSave = "None";
}
versionControl(false);
generatePrestigeUpgrades($scope.player.maxPrestige);
generatePrestigeUpgrades($scope.currentPrestige);
$interval(update,1000);
$interval($scope.save,60000);
timerStart();
Expand Down Expand Up @@ -334,10 +337,14 @@ angular.module('incremental',[])
timerSeconds = 0;
}

$scope.formatTime = function formatTime(time){
return padCeroes(parseInt(time/3600))+":"+
padCeroes(parseInt((time%3600)/60))+":"+
padCeroes(time%60);
};

$scope.getSprintTime = function getSprintTime(){
return padCeroes(parseInt(timerSeconds/3600))+":"+
padCeroes(parseInt((timerSeconds%3600)/60))+":"+
padCeroes(timerSeconds%60);
return $scope.formatTime(timerSeconds);
};

function padCeroes(number){
Expand Down

0 comments on commit 30ca655

Please sign in to comment.