daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function User:recalcSkills()
  2.     -- USER SKILLS
  3.     self.skillCache.data = util.copy(self.skills)
  4.     local skills = self.skillCache.data
  5.  
  6.     -- BASE SKILLS
  7.     for skillId, value in pairs(content.userSettings.skills) do
  8.         skills[skillId] = (skills[skillId] or 0) + value
  9.     end
  10.  
  11.     -- ITEMS SKILLS
  12.     for id, itemUser in pairs(self.items or {}) do
  13.         local itemContent = content.items[id]
  14.         for skillId, value in pairs((itemContent or {}).commonSkills or {}) do
  15.             skills[skillId] = (skills[skillId] or 0) + value
  16.         end
  17.     end
  18.  
  19.     local absoluteSkills = {
  20.         -- EXAMPLE = { time = 23423423, value = 123 }
  21.     }
  22.  
  23.     -- TECHNOLOGIES
  24.     for id, technologyUser in pairs(self.technology or {}) do
  25.         if technologyUser.status == User.QUEST_STATUS_FINISHED then
  26.             local technologyContent = content.technology[id]
  27.             for skillId, value in pairs(technologyContent.skills or {}) do
  28.                 skills[skillId] = (skills[skillId] or 0) + value
  29.             end
  30.  
  31.             for skillId, value in pairs(technologyContent.absoluteSkills or {}) do
  32.                 if technologyUser.studyTime > ((absoluteSkills[skillId] or {}).time or 0) then
  33.                     absoluteSkills[skillId] = { time = technologyUser.studyTime, value = value }
  34.                 end
  35.             end
  36.         end
  37.     end
  38.  
  39.  
  40.     -- PSI SKILLS
  41.     for id, level in pairs(self.psiCapsule or {}) do
  42.         local psiCapsule = content.psiCapsule[id]
  43.         for skillId, value in pairs((psiCapsule.levels[level] or {}).skills or {}) do
  44.             skills[skillId] = (skills[skillId] or 0) + value
  45.         end
  46.     end
  47.  
  48.     -- ARMOR
  49.     local itemSkills = self:itemSkillsGet(self.slots.armor or 0)
  50.     for skillId, value in pairs(itemSkills) do
  51.         if skillId ~= 'LEVEL' then
  52.             skills[skillId] = (skills[skillId] or 0) + value
  53.         end
  54.     end
  55.  
  56.     -- PREMIUM
  57.     if self:premiumGet() then
  58.         for skillId, value in pairs(content.premiumSettings.skills) do
  59.             skills[skillId] = (skills[skillId] or 0) + value
  60.         end
  61.     end
  62.  
  63.     -- LEVEL
  64.     local levelContent = content.levels[self.skills.LEVEL] or {}
  65.     for skillId, value in pairs(levelContent.skills or {}) do
  66.         skills[skillId] = (skills[skillId] or 0) + value
  67.     end
  68.  
  69.     -- сумама по абсолютным скилам
  70.     for skillId, skill in pairs(absoluteSkills) do
  71.         skills[skillId] = (skills[skillId] or 0) + skill.value
  72.     end
  73.  
  74.  
  75.     self.skillCache.expired = false
  76. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top