Rob Williams avatar Rob Williams committed c87cafe

enhanced GemPowerView to accept level and target count parameters

Comments (0)

Files changed (3)

web/cdn/analyzer/GemPower.js

 var GemPower = new Class({
     power: function() {
         // one out of every four waves is air, the others are ground
-        return (this.powerAir(this.gem) + 3 * this.powerGround(this.gem)) / 4;
+        return (this.powerAir() + 3 * this.powerGround()) / 4;
     },
 
     powerAir: function() {
-        if (this.gem.kind.isAntiAir) return this.powerBase(this.gem);
+        if (this.gem.kind.isAntiAir) return this.powerBase();
         return 0;
     },
 
     powerBase: function() {
-        return (this.powerMaximum(this.gem) + this.powerMinimum(this.gem)) / 2;
+        return (this.powerMaximum() + this.powerMinimum()) / 2;
     },
 
     powerGround: function() {
-        if (this.gem.kind.isAntiGround) return this.powerBase(this.gem);
+        if (this.gem.kind.isAntiGround) return this.powerBase();
         return 0;
     },
 
         return this.gem.minimum * this.gem.range / this.gem.cooldown * 1000;
     },
 
-    initialize: function(theGem) {
+    initialize: function(theGem, theLevel, theCountTargets) {
         assert.isRequiredType('theGem', theGem, 'Gem', Gem);
         this.gem = theGem;
-        this.id = theGem.id;
+        this.id = GemPower.id(theGem.id, theLevel, theCountTargets);
+        this.level = theLevel;
+        this.countTargets = theCountTargets;
         // Establish direct & indirect navigation
         this.key = GemPower.key(this.id);
         GemPower[this.key] = this;
 });
 
 GemPower.addAll = function() {
+    GemPower.addAllFor(0, 1);
+}
+
+GemPower.addAllFor = function(theLevel, theCountTargets) {
     Gem.getAll().getValues().each(
         function(theGem) {
-            new GemPower(theGem);
+            new GemPower(theGem, theLevel, theCountTargets);
         }
     );
 }
     );
 }
 
+GemPower.id = function(theGemId, theLevel, theCountTargets) {
+    return [theGemId, '-', theLevel, '-', theCountTargets].join(' ');
+}
+
 GemPower.initialize = function() {
     GemPower.all = new Hash();
 }
 
 GemPower.key = function(theId) {
-    return theId.capitalize().replace(/\s/g, '');
+    return theId.capitalize();
 }

web/cdn/analyzer/GemPowerView.js

     iconSource: function() {
         var aBuffer = [];
         aBuffer.push(GemPowerView.source);
-        if (this.gem.isSpecial) {
+        if (this.gemPower.gem.isSpecial) {
             aBuffer.push('specials/');
         }
-        if (this.iconName) {
-            aBuffer.push(this.iconName);
-        } else {
-            aBuffer.push(this.gem.key.toLowerCase());
-        }
+        aBuffer.push(this.iconName);
         aBuffer.push('.jpg');
         return aBuffer.join('');
     },
 
     newIcon: function() {
         return new Element('img', {
-            alt: this.gem.id,
+            alt: this.gemPower.gem.id,
             src: this.iconSource(),
-            title: this.gem.id,
+            title: this.gemPower.gem.id,
             height: this.iconHeight,
             width: this.iconWidth
         });
     },
 
-    initialize: function(theGem) {
-        assert.isRequiredType('theGem', theGem, 'Gem', Gem);
-        this.gem = theGem;
+    initialize: function(theGemPower) {
+        assert.isRequiredType('theGemPower', theGemPower, 'GemPower', GemPower);
+        this.gemPower = theGemPower;
         this.iconHeight = 26;
+        this.iconName = GemView.lookup(this.gemPower.gem).iconName;
         this.iconWidth = 26;
         // Establish direct & indirect navigation
-        this.key = theGem.key;
+        this.key = theGemPower.key;
         GemPowerView[this.key] = this;
         GemPowerView.all.set(this.key, this);
     }
 });
 
 GemPowerView.addAll = function() {
-    Gem.getAll().each(function(theGem) {
-        new GemPowerView(theGem);
+    GemPower.getAll().each(function(theGemPower) {
+        new GemPowerView(theGemPower);
     });
-    GemPowerView.RedCrystalFacet.iconName = 'redfacet';
-    GemPowerView.RoseQuartzCrystal.iconName = 'redquartzcrystal';
 }
 
 GemPowerView.initialize = function() {

web/cdn/analyzer/GemView.js

         assert.isRequiredType('theGem', theGem, 'Gem', Gem);
         this.gem = theGem;
         this.iconHeight = 26;
+        this.iconName = this.gem.key.toLowerCase();
         this.iconWidth = 26;
         // Establish direct & indirect navigation
         this.key = theGem.key;
     GemView.all = new Hash();
     GemView.addAll();
 }
+
+GemView.lookup = function(theGem) {
+    return GemView[theGem.key];
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.