candyapplecorn

level masker

Apr 19th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /*
  2. Copyright (c) 2017 candyapplecorn
  3.  
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10.  
  11. The above copyright notice and this permission notice shall be included in all
  12. copies or substantial portions of the Software.
  13.  
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. SOFTWARE.
  21. */
  22. // Let's call this suggested item "Level Masker".
  23. // By adding this code to the PLAYER entity and the
  24. // logic responsible for generating enemies, we can
  25. // achieve a lure-like effect.
  26.  
  27. // Of course Mackan would have to add a new item to the
  28. // #!items shop and give it a cost, his discretion the price
  29.  
  30. // when a player uses "Level Masker":
  31. class player{
  32.     constructor(){
  33.         this.mask = {
  34.             maxLimit: 5, // ARBITRARY. Could add a game mechanic to increase this as well!
  35.             used: 0,
  36.             level = null,
  37.             timeout: null
  38.         }
  39.         this.level = API_CALL_RETRIEVE_PLAYER_INFO_FROM_DATABASE()
  40.         // the player already has a level, idc how it's obtained        
  41.         //... idk what else code you have
  42.     }
  43.     // ...
  44.     maskLevel(){
  45.         // Error check: is the player attempting to exceed the maximum # of
  46.         // "Level Masker" items he/she may?
  47.         if (this.mask.used >= this.mask.maxLimit)
  48.             return "You're all tweaked out on Level Masker, " +
  49.                    "it would be a bad dangerous to use more."
  50.  
  51.  
  52.         // 1: increment the masksUsed counter, which
  53.         // is used for calculating power of generated enemy
  54.         this.mask.used++
  55.  
  56.         // 1.5: calculate the player's fake, "masked" level
  57.         // 1 "Level Masker" used? player's masked/fake level is 25
  58.         // 2 "Level Masker" used? player's level is 25% higher
  59.         // 3 used? 50% higher, 4 used? 75% higher, 5 used? 100% higher
  60.         switch (this.mask.used){
  61.             case 1:
  62.                 this.mask.level = 25;
  63.                 break;
  64.             default:
  65.                 this.mask.level = (this.mask.used - 1) * 0.25 * this.level;
  66.         }
  67.  
  68.         // 2: clear the player's timeout if it exists
  69.         if (this.mask.timeout)
  70.             clearTimeout(this.mask.timeout)
  71.  
  72.         // 3: Set a timeout that will reset used to 0 in an hour.
  73.         this.mask.timeout = setTimeout(() => { this.mask.used = 0 }, 1000 * 60 * 60)        
  74.     }
  75.     // snippet - Mackan I don't have your source code anyways
  76. }
  77.  
  78. // In the code that spawns an enemy for the player to fight:
  79. // There's some code that calculates the max level for an enemy
  80. // IDK what the code is BUTTTT......
  81. function generateEnemy(player){
  82.     var maximumEnemyLevel,
  83.         minimumEnemyLevel = player.level
  84.  
  85.     if (player.mask.used == 0)
  86.         CALCULATE_ENEMY_NORMALLY_AS_BEFORE_THIS_SUGGESTION(),
  87.         maximumEnemyLevel = player.level // I think this is how it works right??
  88.     else
  89.         maximumEnemyLevel = player.mask.level,
  90.         minimumEnemyLevel = player.mask.level / 2     /* AGAIN, is ARBITRARY */
  91.  
  92.     // proceed as normal
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment