Browse Source

add range upgrade fix bug

kyleperik 4 months ago
parent
commit
907c72631d
3 changed files with 18 additions and 4 deletions
  1. 2 2
      helpers.js
  2. 3 1
      main.js
  3. 13 1
      setup.js

+ 2 - 2
helpers.js

@@ -80,7 +80,7 @@ function copy(o) {
80 80
  }
81 81
 
82 82
  function upgradeLevelModifier(upgrade_type){
83
-    var level = pc.state.player.upgrades.find(u => u.type = upgrade_type).level;
84
-    var upgrade = game_data.upgrades.find( u => u.type = upgrade_type);
83
+    var level = pc.state.player.upgrades.find(u => u.type === upgrade_type).level;
84
+    var upgrade = game_data.upgrades.find( u => u.type === upgrade_type);
85 85
     return upgrade.bonus.amount(level);
86 86
  }

+ 3 - 1
main.js

@@ -18,6 +18,7 @@ pc.gameLoop(game_data.interval, last => {
18 18
     ));
19 19
 
20 20
     var speed_modifier = upgradeLevelModifier("speed")/100 + 1;
21
+    var range_modifier = upgradeLevelModifier("range");
21 22
 
22 23
     var player = {
23 24
         ...last.player,
@@ -46,7 +47,8 @@ pc.gameLoop(game_data.interval, last => {
46 47
 
47 48
     // setting maxDistance that Rover is allowed to move
48 49
     // roughly screen width;
49
-    var maxDistance = 30000;
50
+    var maxDistance = 60000 * range_modifier;
51
+    console.log(maxDistance);
50 52
     var warnDistance = maxDistance * .9;
51 53
     var currentDistance = Math.pow(player.pos.x,2) + Math.pow(player.pos.y, 2);
52 54
     var warnMessage = {};

+ 13 - 1
setup.js

@@ -256,6 +256,17 @@ const game_data = {
256 256
                 type: "%"
257 257
             }
258 258
         },
259
+        { 
260
+            type: 'range', inputs: (level) => { 
261
+                return [{ 
262
+                    type: 'el_component',
263
+                    amount : level + 5
264
+            }]},
265
+            bonus: {
266
+                amount: (level) => (level),
267
+                type: "x"
268
+            }
269
+        },
259 270
     ],
260 271
     views : ["recipes", "upgrades"],
261 272
     gridfactor: 20,
@@ -280,7 +291,8 @@ var initialState = {
280 291
         vel: { x: 0, y: 0 },
281 292
         upgrades:[
282 293
             { type: 'speed', level: 1, icon: "wheels"},
283
-            { type: 'drill', level: 2, icon: "drill"},
294
+            { type: 'drill', level: 1, icon: "drill"},
295
+            { type: 'range', level: 1, icon: "el_component"},
284 296
         ],
285 297
         topmods: [
286 298
             { type: 'battery', pos: 0 },