Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.getDeviceDataCost = function (device, count) {
- var i, price, lastAffordable;
- if (typeof count === 'undefined') {
- count = $scope.buyMode;
- }
- lastAffordable = 0;
- price = 0;
- if (count === 0) {
- i = 0;
- while (price <= $scope.data) {
- lastAffordable = price;
- price += device.dataCostBase * Math.pow(device.dataCostIncrement - $scope.getDeviceCostReduction(device), device.count + i);
- i += 1;
- }
- price = lastAffordable;
- } else {
- for (i = 0; i < count; i += 1) {
- price += device.dataCostBase * Math.pow(device.dataCostIncrement - $scope.getDeviceCostReduction(device), device.count + i);
- }
- }
- return Math.round(price * 100) / 100;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement