Skip to content

Commit

Permalink
Sprint times for prestiges are stored properly
Browse files Browse the repository at this point in the history
  • Loading branch information
angarg12 committed Feb 13, 2015
1 parent 0b3ce89 commit cde377f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ <h2>Cash: <span style="font-family:Courier New, Courier, monospace">$<span ng-bi
<h2>Cash multiplier: {{(player.multiplier).toFixed(4)}}</h2>
<h2>Time: {{getSprintTime()}}</h2>
<h2>{{player.sprintTimes}}</h2>
<h2>Goal<sup ng-if="player.prestige > 0">{{player.prestige}}</sup>: <span ng-bind-html="trustedPrettifyNumber(prestigeGoal[player.prestige])"/></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="!player.sprintFinished">
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0" style="width:{{player.currency.div(prestigeGoal[player.prestige])*100}}%" ng-if="!logscale">
{{Math.max(Math.floor((player.currency.div(prestigeGoal[player.prestige]))*1000)/10,0)}}%
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0" style="width:{{player.currency.div(prestigeGoal[currentPrestige])*100}}%" ng-if="!logscale">
{{Math.max(Math.floor((player.currency.div(prestigeGoal[currentPrestige]))*1000)/10,0)}}%
</div>
<div class="progress-bar-log" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0" style="width:{{player.currency.ln().div(prestigeGoal[player.prestige].ln())*100}}%" ng-if="logscale">
{{Math.max(Math.floor((player.currency.ln().div(prestigeGoal[player.prestige].ln()))*1000)/10,0)}}%
<div class="progress-bar-log" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0" style="width:{{player.currency.ln().div(prestigeGoal[currentPrestige].ln())*100}}%" ng-if="logscale">
{{Math.max(Math.floor((player.currency.ln().div(prestigeGoal[currentPrestige].ln()))*1000)/10,0)}}%
</div>
</div>
<div ng-if="player.sprintFinished">
Expand Down
43 changes: 25 additions & 18 deletions js/exponential.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ angular.module('incremental',[])

var startPlayer = {
cashPerClick: new Decimal(1),
multiplier: new Decimal(1),
multiplier: new Decimal(2),
multiplierUpgradeLevel: [],
multiplierUpgradePrice: [],
clickUpgradeLevel: [],
clickUpgradePrice: [],
currency: new Decimal(0),
prestige: 0,
maxPrestige: 0,
version: $scope.version,
sprintFinished: false,
sprintTimes: [],
Expand All @@ -33,6 +33,9 @@ angular.module('incremental',[])
new Decimal("1e50000"),
new Decimal("1e100000"),
new Decimal("1e9000000000000000")];
$scope.currentPrestige = 0;
var timer;
var timerSeconds = 0;

$scope.trustedPrettifyNumber = function(value) {
return $sce.trustAsHtml(prettifyNumber(value));
Expand Down Expand Up @@ -75,7 +78,7 @@ angular.module('incremental',[])
$scope.load = function load() {
$scope.player = JSON.parse(localStorage.getItem("playerStored"));
seconds = localStorage.getItem("timerSeconds");
alert(seconds);

timerSet(seconds);
$scope.player.currency = new Decimal($scope.player.currency);
$scope.player.multiplier = new Decimal($scope.player.multiplier);
Expand All @@ -96,9 +99,10 @@ angular.module('incremental',[])
init();
timerReset();
timerStart();
generatePrestigePlayer($scope.player.prestige);
generatePrestigeUpgrades($scope.player.prestige);
generatePrestigePlayer($scope.player.maxPrestige);
generatePrestigeUpgrades($scope.player.maxPrestige);
localStorage.removeItem("playerStored");
$scope.currentPrestige = 0;
}
$scope.loadPreferences();
}
Expand All @@ -115,7 +119,7 @@ angular.module('incremental',[])

$scope.prestige = function prestige(){
// Save the values of the player that persist between prestiges
newPrestige = $scope.player.prestige+1;
newPrestige = $scope.player.maxPrestige+1;
preferences = $scope.player.preferences;
version = $scope.player.version;
sprintTimes = $scope.player.sprintTimes;
Expand All @@ -128,14 +132,15 @@ angular.module('incremental',[])
timerStart();

// Restore the values
$scope.player.prestige = newPrestige;
$scope.player.maxPrestige = newPrestige;
$scope.player.preferences = preferences;
$scope.player.version = version;
$scope.player.sprintTimes = sprintTimes;

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

function update() {
Expand Down Expand Up @@ -250,13 +255,19 @@ angular.module('incremental',[])
};

function adjustCurrency(currency){
if(currency.comparedTo($scope.prestigeGoal[$scope.player.prestige]) >= 0){
if(currency.comparedTo($scope.prestigeGoal[$scope.player.maxPrestige]) >= 0){
if($scope.player.sprintFinished == false){
$scope.player.sprintFinished = true;
timerStop();
$scope.player.sprintTimes.push(timerSeconds);
if($scope.player.sprintTimes.length < $scope.currentPrestige){
throw new Error("Inconsistent prestige value: "+$scope.currentPrestige);
}else if($scope.player.sprintTimes.length == $scope.currentPrestige){
$scope.player.sprintTimes.push(timerSeconds);
}else if(timerSeconds < $scope.player.sprintTimes[$scope.currentPrestige]){
$scope.player.sprintTimes[$scope.currentPrestige] = timerSeconds;
}
}
currency = $scope.prestigeGoal[$scope.player.prestige];
currency = $scope.prestigeGoal[$scope.player.maxPrestige];
}
return currency;
}
Expand All @@ -271,24 +282,20 @@ angular.module('incremental',[])
}
if(typeof $scope.player === 'undefined'){
init();
generatePrestigePlayer($scope.player.prestige);
generatePrestigePlayer($scope.player.maxPrestige);
}
if(typeof $scope.lastSave === 'undefined'){
$scope.lastSave = "None";
}
versionControl(false);
generatePrestigeUpgrades($scope.player.prestige);
generatePrestigeUpgrades($scope.player.maxPrestige);
$interval(update,1000);
$interval($scope.save,60000);
timerStart();
});

var timer;
var timerSeconds = 0;

function timerSet(seconds){
timerSeconds = seconds;
alert($scope.player.sprintFinished);
if($scope.player.sprintFinished == true){
timerStop();
}
Expand Down

0 comments on commit cde377f

Please sign in to comment.