| Total Complexity | 9 |
| Complexity/F | 1.5 |
| Lines of Code | 43 |
| Function Count | 6 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | 'use strict'; |
||
| 2 | |||
| 3 | angular |
||
| 4 | .module('game') |
||
| 5 | .service('generator', ['state', |
||
| 6 | 'data', |
||
| 7 | function(state, data) { |
||
| 8 | this.generatorProduction = function(name, element) { |
||
| 9 | let baseProduction = data.generators[name].power; |
||
| 10 | return upgradedProduction(baseProduction, name, element); |
||
| 11 | }; |
||
| 12 | |||
| 13 | this.tierProduction = function(name, element) { |
||
| 14 | let baseProduction = data.generators[name].power * |
||
| 15 | state.player.elements[element].generators[name]; |
||
| 16 | return upgradedProduction(baseProduction, name, element); |
||
| 17 | }; |
||
| 18 | |||
| 19 | function upgradedProduction(production, name, element) { |
||
| 20 | for (let up in data.generators[name].upgrades) { |
||
| 21 | if (state.player.elements[element].upgrades[data.generators[name].upgrades[up]]) { |
||
| 22 | let power = data.upgrades[data.generators[name].upgrades[up]].power; |
||
| 23 | production = upgradeApply(production, power); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | let exotic = data.elements[element].exotic; |
||
| 27 | production += production * state.player.resources[exotic].number * data.constants.EXOTIC_POWER; |
||
| 28 | return Math.floor(production); |
||
| 29 | } |
||
| 30 | |||
| 31 | function upgradeApply(resource, power) { |
||
| 32 | return resource * power; |
||
| 33 | } |
||
| 34 | |||
| 35 | this.elementProduction = function(element) { |
||
| 36 | let total = 0; |
||
| 37 | for (let tier in data.generators) { |
||
| 38 | total += this.tierProduction(tier, element); |
||
| 39 | } |
||
| 40 | return total; |
||
| 41 | }; |
||
| 42 | } |
||
| 43 | ]); |
||
| 44 |