Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function forges.open(player, forge_id, time)
- local working_forge = player.forge.working_forge
- if (not working_forge) or working_forge.id ~= forge_id then
- error("trying to open invalid forge")
- end
- if not model.forges.is_ready(player, forge_id, time) then
- error("forge not ready")
- end
- local overdue = model.forges.get_overdue(player, forge_id, time)
- model.stats.inc(player, "melt_" .. forge_id)
- local owned = player.forge.owned_forges[forge_id]
- owned.melts = (owned.melts or 0) + 1
- local upgrade_level = working_forge.upgrade_level
- local bars = data.forges.get_produced_bars(forge_id, upgrade_level)
- local loot_id = model.resources.add_loot(player, "bars", bars)
- local loot = {{type="bars", amount=bars, loot_id=loot_id}}
- analytics.send("Forge.Open", {
- bars = bars,
- forge = forge_id,
- overdue_minutes = math.floor(overdue/60),
- ad_boost_count = working_forge.boost_ad or 0
- })
- player.forge.working_forge = nil
- return loot
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement