GE Lua Documentation

Press F to search!

reduceCareerRewardsForDefaultStars

Definition


-- @/lua/ge/extensions/gameplay/missions/progress.lua:961

local function reduceCareerRewardsForDefaultStars(mission)
  if career_career.isActive() then
    for key, starCount in pairs(mission.saveData.unlockedStars) do
      if mission.careerSetup.starsActive[key] then
        local list = mission.careerSetup.starRewards[key] or {}
        if starCount then
          local rewardMultiplier = starCount == 0 and 1 or 0.1 --math.max(0.1,(1-(starCount or 0) * 0.2))
          log("D","", string.format("%s - %s reduced to x%0.2f", mission.id, key, rewardMultiplier*100 ))
          for _, reward in ipairs(list) do
            if reward.attributeKey == "money" then
              reward.rewardAmount = (round(reward._originalRewardAmount*rewardMultiplier))
            end
            if reward.attributeKey == "vouchers" and starCount > 0 then
              reward.rewardAmount = 0
            end
          end
        end
      end
    end
  end

  computeStarRewardSums(mission)
end

Callers

@/lua/ge/extensions/gameplay/missions/progress.lua
  --reduce rewards for successive attempts
  M.reduceCareerRewardsForDefaultStars(mission)
@/lua/ge/extensions/gameplay/missions/missions.lua
      mission.saveData = saveData
      gameplay_missions_progress.reduceCareerRewardsForDefaultStars(mission)
    end