Commits

Rob Williams  committed 9339ec3

refactored to extract GemPower class
tweaked gem data based on playing game

  • Participants
  • Parent commits 4eacc54

Comments (0)

Files changed (6)

File web/cdn/analyzer/Gem.js

         return this.totalWeight;
     },
 
-    power: function() {
-        // one out of every four waves is air, the others are ground
-        return this.powerAir() + 3 * this.powerGround();
-    },
-
-    powerAir: function() {
-        if (this.kind.isAntiAir) return this.powerBase();
-        return 0;
-    },
-
-    powerBase: function() {
-        return (this.powerMaximum() + this.powerMinimum()) / 2.0;
-    },
-
-    powerGround: function() {
-        if (this.kind.isAntiGround) return this.powerBase();
-        return 0;
-    },
-
-    powerMaximum: function() {
-        return this.maximum * this.range / this.cooldown * 1000;
-    },
-
-    powerMinimum: function() {
-        return this.minimum * this.range / this.cooldown * 1000;
-    },
-
     initialize: function(theId, theKind) {
         var aId = (new String(theId)).clean();
         assert.isPresentString('aId', aId);

File web/cdn/analyzer/GemPower.js

+// Integrated with Mootools 1.2.3
+
+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;
+    },
+
+    powerAir: function() {
+        if (this.gem.kind.isAntiAir) return this.powerBase(this.gem);
+        return 0;
+    },
+
+    powerBase: function() {
+        return (this.powerMaximum(this.gem) + this.powerMinimum(this.gem)) / 2;
+    },
+
+    powerGround: function() {
+        if (this.gem.kind.isAntiGround) return this.powerBase(this.gem);
+        return 0;
+    },
+
+    powerMaximum: function() {
+        return this.gem.maximum * this.gem.range / this.gem.cooldown * 1000;
+    },
+
+    powerMinimum: function() {
+        return this.gem.minimum * this.gem.range / this.gem.cooldown * 1000;
+    },
+
+    initialize: function(theGem) {
+        assert.isRequiredType('theGem', theGem, 'Gem', Gem);
+        this.gem = theGem;
+        this.id = theGem.id;
+        GemPower.all.set(this.gem.key, this);
+    }
+});
+
+GemPower.getAll = function() {
+    return GemPower.all;
+}
+
+GemPower.initialize = function() {
+    GemPower.all = new Hash();
+}
+
+GemPower.addAll = function() {
+    Gem.getAll().getValues().each(
+        function(theGem) {
+            new GemPower(theGem);
+        }
+    );
+}

File web/cdn/analyzer/business.js

 var BusinessTier = new Class({
     initialize: function() {
         Gem.initialize();
+        GemPower.initialize();
         BusinessTier.loadData();
     }
 });

File web/cdn/analyzer/data.js

     GemKind.addAll();
     GemQuality.addAll();
     Gem.addAll();
+    GemPower.addAll();
 }
 
 GemKind.addAll = function() {
     new Gem('Paraiba Tourmaline', GemKind.Aquamarine).
         recipe([Gem.PerfectAquamarine, Gem.FlawlessOpal, Gem.FlawedAquamarine, Gem.FlawedEmerald]).
         cools(750).
-        does(122, 10, 400);
+        does(121, 10, 400); // -4 armor within 85.8, 20% chance of 200 frost lasting ?s
     new Gem('Malachite',          GemKind.Emerald   ).
         recipe([Gem.ChippedAquamarine, Gem.ChippedEmerald, Gem.ChippedOpal]).
         cools(500).
     Gem.PerfectTopaz     .does( 86,  75,  75); // multiple targets
 
     Gem.GreatAquamarine.does( 85, 280, 280);
+    Gem.GreatEmerald   .does(128, 250, 250); // slow enemy 50% & poison 50/s for 30s
     Gem.GreatTopaz     .does(100, 250, 250); // multiple targets
 }
 
     new Gem('Asian Jade', GemKind.Aquamarine).
         upgrades(45, Gem.Jade).
         cools(500).
-        does(114, 50, 50);
+        does(114, 50, 50); // poison 10/s for 3s slows 50%
     new Gem('Blood Star', GemKind.Ruby).
         upgrades(30, Gem.StarRuby).
         cools(250).
     new Gem('Egyptian Gold', GemKind.Amethyst).
         upgrades(210, Gem.Gold).
         cools(750).
-        does(114, 160, 190);
+        does(114, 160, 200); // 30% of damage x2, -8 armor
     new Gem('Enchanted Emerald', GemKind.Emerald).
         upgrades(250, Gem.DarkEmerald).
         cools(700).
-        does(100, 100, 200);
+        does(100, 100, 200); // 15% chance of stun for 2s, 15% of damage x4
     new Gem('Great Pink Diamond', GemKind.Diamond).
         upgrades(175, Gem.PinkDiamond).
         cools(650).
     new Gem('Paraiba Tourmaline Facet', GemKind.Aquamarine).
         upgrades(350, Gem.ParaibaTourmaline).
         cools(750).
-        does(125, 30, 420);
+        does(125, 30, 420); // -6 armor within 93, 20% chance of 250 frost nova lasting ?s
     new Gem('Red Crystal Facet', GemKind.Amethyst).
         upgrades(100, Gem.RedCrystal).
         cools(800).
-        does(200, 75, 100);
+        does(200, 75, 100); // -5 armor within 200
     new Gem('Star Yellow Sapphire', GemKind.Sapphire).
         upgrades(180, Gem.YellowSapphire).
         cools(800).
-        does(121, 189, 189);
+        does(121, 189, 189); // slows, splash, 5% more damage within 121
     new Gem('Sterling Silver', GemKind.Sapphire).
         upgrades(25, Gem.Silver).
         cools(1000).
-        does(92, 40, 40);
+        does(92, 40, 40); // slow, splash
     new Gem('Uranium 235', GemKind.Opal).
         upgrades(190, Gem.Uranium238).
         cools(250).
     new Gem('Fire Star', GemKind.Ruby).
         upgrades(290, Gem.BloodStar).
         cools(500).
-        does(85, 101, 100);
+        does(85, 75, 75); // 130/s within 85
     new Gem('Lucky Asian Jade', GemKind.Aquamarine).
         upgrades(250, Gem.AsianJade).
         cools(350).
-        does(121, 55, 55);
+        does(121, 55, 55); // poison 10/s for 4s slows 50%, 1% chance stun
     new Gem('Mighty Malachite', GemKind.Emerald).
         upgrades(280, Gem.VividMalachite).
         cools(550).

File web/cdn/analyzer/presentation.js

         }
     },
 
-    getGemsByPower: function() {
-        return Gem.getAll().getValues().clean().sort(
+    getGemPowers: function() {
+        return GemPower.getAll().getValues().clean().sort(
             function(theLeft, theRight) {
                 // sort by power descending
                 var aLeft = theLeft.power();
         return aReturn;
     },
 
-    newPowerRow: function(theGem) {
+    newPowerRow: function(theGemPower) {
         var aReturn = new Element('tr', {'class': 'power'});
-        aReturn.adopt(GemView[theGem.key].newCell());
-        aReturn.adopt(new Element('td', {text: theGem.power(),  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.powerAir(),  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.powerGround(),  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.powerBase(),  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.powerMinimum(),  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.powerMaximum(),  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.kind.isAntiAir,  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.kind.isAntiGround,  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.range,    'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.minimum,  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.maximum,  'class': 'power'}));
-        aReturn.adopt(new Element('td', {text: theGem.cooldown, 'class': 'power'}));
+        aReturn.adopt(GemView[theGemPower.gem.key].newCell());
+        aReturn.adopt(new Element('td', {text: theGemPower.power(),  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.powerAir(),  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.powerGround(),  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.powerBase(),  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.powerMinimum(),  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.powerMaximum(),  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.gem.kind.isAntiAir,  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.gem.kind.isAntiGround,  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.gem.range,    'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.gem.minimum,  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.gem.maximum,  'class': 'power'}));
+        aReturn.adopt(new Element('td', {text: theGemPower.gem.cooldown, 'class': 'power'}));
         return aReturn;
     },
 
     newPowerTable: function() {
         var aReturn = new Element('table', {'class': 'power'});
-        this.getGemsByPower().each(
-            function(theGem) {
-                aReturn.adopt(this.newPowerRow(theGem));
+        this.getGemPowers().each(
+            function(theGemPower) {
+                aReturn.adopt(this.newPowerRow(theGemPower));
             }, this
         );
         return aReturn;

File web/www/analyzer/analyzer.html

     <script type="text/javascript" src="../../cdn/analyzer/Gem.js"></script>
     <script type="text/javascript" src="../../cdn/analyzer/GemKind.js"></script>
     <script type="text/javascript" src="../../cdn/analyzer/GemQuality.js"></script>
+    <script type="text/javascript" src="../../cdn/analyzer/GemPower.js"></script>
     <script type="text/javascript" src="../../cdn/analyzer/business.js"></script>
     <script type="text/javascript" src="../../cdn/analyzer/data.js"></script>
     <script type="text/javascript" src="../../cdn/analyzer/GemView.js"></script>