экономика
This commit is contained in:
1 parent
296988b199
commit
58ae93f9e6
28 files changed
+6503
-299
No files matched your search
@@ -14,6 +14,12 @@ local Debris = game:GetService("Debris")
|
||||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||||
local Models = require(ReplicatedStorage:WaitForChild("GameModels"))
|
||||
local Guild = require(script.Parent:WaitForChild("Guild"))
|
||||
local Progression = require(script.Parent:WaitForChild("Progression"))
|
||||
local Potions = require(script.Parent:WaitForChild("Potions"))
|
||||
local Market = require(script.Parent:WaitForChild("Market"))
|
||||
local Telemetry = require(script.Parent:WaitForChild("Telemetry"))
|
||||
local PlayerStore = require(script.Parent:WaitForChild("PlayerStore"))
|
||||
local E = Config.Economy
|
||||
|
||||
local remote = ReplicatedStorage:FindFirstChild("GameEvent") or Instance.new("RemoteEvent")
|
||||
remote.Name = "GameEvent"
|
||||
@@ -72,10 +78,13 @@ local SPLASH_SOUND = "rbxasset://sounds/impact_water.mp3"
|
||||
|
||||
---------------------------------------------------------------- данные
|
||||
|
||||
local store = nil
|
||||
local store, marketStore = nil, nil
|
||||
pcall(function()
|
||||
store = DataStoreService:GetDataStore("FishingGame_v2")
|
||||
marketStore = DataStoreService:GetDataStore("FishMarket_v1")
|
||||
end)
|
||||
-- замок сессии: профиль открыт только на одном сервере (без этого возможен дюп между серверами и на рынке)
|
||||
local playerStore = store and PlayerStore.new(store, { staleAfter = 600 }) or nil
|
||||
|
||||
local profiles = {}
|
||||
local loadedOk = {}
|
||||
@@ -88,7 +97,8 @@ local function defaultData()
|
||||
bag = "Pouch", bags = { Pouch = true },
|
||||
items = {}, discovered = {}, claimed = {},
|
||||
chain = { index = 1, step = 1, progress = 0, tier = 0 }, daily = { last = 0, streak = 0 },
|
||||
boostUntil = 0, boostBonus = 0,
|
||||
boostUntil = 0, boostBonus = 0, -- до экономики v2 (переносятся в potions миграцией)
|
||||
potions = { inv = {} }, market = {},
|
||||
totalCaught = 0, nextUid = 1, receipts = {},
|
||||
passes = {}, -- купленные пропуска (Developer Products): [key] = true
|
||||
coinsEarned = 0, robuxSpent = 0, -- для досок лидеров: всего выручено за рыбу и потрачено Robux
|
||||
@@ -98,37 +108,44 @@ local function defaultData()
|
||||
}
|
||||
end
|
||||
|
||||
-- status: "ok" (из хранилища), "offline" (хранилища нет — играем без сохранения), "locked", "error"
|
||||
local function loadData(player)
|
||||
local data = defaultData()
|
||||
if not store then
|
||||
return data, false
|
||||
if not playerStore then
|
||||
data.econ = E.version
|
||||
return data, "offline"
|
||||
end
|
||||
local ok, saved = pcall(function()
|
||||
return store:GetAsync("player_" .. player.UserId)
|
||||
end)
|
||||
if not ok then
|
||||
warn("Не удалось загрузить данные " .. player.Name .. ": " .. tostring(saved))
|
||||
return data, false
|
||||
local status, saved = playerStore:load("player_" .. player.UserId)
|
||||
if status ~= "ok" then
|
||||
warn(("Не удалось загрузить данные %s: %s %s"):format(player.Name, status, tostring(saved)))
|
||||
data.econ = E.version
|
||||
return data, status
|
||||
end
|
||||
if type(saved) == "table" then
|
||||
if type(saved) == "table" and next(saved) ~= nil and saved.level ~= nil then
|
||||
for k, v in pairs(saved) do
|
||||
data[k] = v
|
||||
end
|
||||
else
|
||||
data.econ = E.version -- новый игрок: миграция не нужна
|
||||
end
|
||||
return data, true
|
||||
return data, "ok"
|
||||
end
|
||||
|
||||
local function saveData(player)
|
||||
-- ok; release = true — игрок уходит (снять замок сессии)
|
||||
local function saveData(player, release)
|
||||
local data = profiles[player]
|
||||
if not store or not data or not loadedOk[player] then
|
||||
return
|
||||
if not playerStore or not data or not loadedOk[player] then
|
||||
return false
|
||||
end
|
||||
local ok, err = pcall(function()
|
||||
store:SetAsync("player_" .. player.UserId, data)
|
||||
end)
|
||||
local ok, status, err = playerStore:save("player_" .. player.UserId, data, release)
|
||||
if not ok then
|
||||
warn("Не удалось сохранить данные " .. player.Name .. ": " .. tostring(err))
|
||||
warn(("Не удалось сохранить данные %s: %s %s"):format(player.Name, tostring(status), tostring(err)))
|
||||
if status == "lost" then
|
||||
-- профиль уже открыт другим сервером: дальше этот сервер его не пишет
|
||||
loadedOk[player] = false
|
||||
end
|
||||
end
|
||||
return ok
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- пропуска и события
|
||||
@@ -169,8 +186,9 @@ local function rodLevel(data, rodId)
|
||||
return data.rodLevels[rodId or data.rod] or 0
|
||||
end
|
||||
|
||||
-- удача от действующего зелья (донат «Супер-зелье», перенесённое старое зелье)
|
||||
local function boostActive(data)
|
||||
return data.boostUntil > os.time() and data.boostBonus or 0
|
||||
return Potions.effect(data).luck or 0
|
||||
end
|
||||
|
||||
local function masteryCount(data)
|
||||
@@ -215,6 +233,31 @@ local function notify(player, text, color)
|
||||
remote:FireClient(player, "Notify", text, color or Color3.new(1, 1, 1))
|
||||
end
|
||||
|
||||
-- серебро: все начисления и траты — здесь (телеметрия источников и расходов)
|
||||
local function addCoins(player, data, amount, kind)
|
||||
amount = math.floor(amount)
|
||||
if amount <= 0 then
|
||||
return 0
|
||||
end
|
||||
data.coins += amount
|
||||
Telemetry.silver(player, true, amount, data.coins, kind)
|
||||
return amount
|
||||
end
|
||||
local function spendCoins(player, data, amount, kind, sku)
|
||||
amount = math.floor(amount)
|
||||
if amount < 0 or data.coins < amount then
|
||||
return false
|
||||
end
|
||||
data.coins -= amount
|
||||
Telemetry.silver(player, false, amount, data.coins, kind, sku)
|
||||
return true
|
||||
end
|
||||
|
||||
-- множитель серебряных наград: по самому дальнему открытому миру (1 / 2 / 4)
|
||||
local function tierOf(data)
|
||||
return Config.TierFor(data.level or 1)
|
||||
end
|
||||
|
||||
local function today()
|
||||
return math.floor(os.time() / 86400)
|
||||
end
|
||||
@@ -228,10 +271,6 @@ end
|
||||
|
||||
---------------------------------------------------------------- цепочки заданий
|
||||
|
||||
local function levelMult(data)
|
||||
return 1 + (data.level - 1) * 0.25
|
||||
end
|
||||
|
||||
local function currentChain(data)
|
||||
local c = data.chain
|
||||
local chain = Config.QuestChains[(c.index - 1) % #Config.QuestChains + 1]
|
||||
@@ -242,22 +281,31 @@ local function stepGoal(data, step)
|
||||
local kind = Config.QuestKinds[step[1]]
|
||||
local g = step[2] * (1 + Config.QuestTierGrowth * data.chain.tier)
|
||||
if kind.byLevel then
|
||||
g *= levelMult(data)
|
||||
g *= tierOf(data)
|
||||
end
|
||||
g = math.ceil(g)
|
||||
return kind.max and math.min(g, kind.max) or g
|
||||
end
|
||||
|
||||
-- награда шага: серебро (× tier); опыта карьеры у заданий нет (второе значение — 0 для старого клиента)
|
||||
local function stepReward(data, step, goal)
|
||||
local kind = Config.QuestKinds[step[1]]
|
||||
local m = levelMult(data)
|
||||
return math.max(10, math.floor(kind.coins * goal * m)), math.max(10, math.floor(kind.xp * goal * m))
|
||||
local t = tierOf(data)
|
||||
return math.max(Config.QuestMinCoins * t, math.floor(kind.coins * goal * t)), 0
|
||||
end
|
||||
|
||||
-- бонус цепочки: серебро; зелье — за самую первую цепочку и за каждый пройденный круг
|
||||
local function chainBonus(data)
|
||||
local b = Config.ChainBonus
|
||||
local m = levelMult(data) * (1 + Config.QuestTierGrowth * data.chain.tier)
|
||||
return math.floor(b.coins * m), math.floor(b.xp * m), b.potion and Config.Find(Config.Potions, b.potion)
|
||||
local c = data.chain
|
||||
local coins = math.floor(b.coins * tierOf(data) * (1 + Config.QuestTierGrowth * c.tier))
|
||||
local potionId = nil
|
||||
if c.index == 1 and c.tier == 0 then
|
||||
potionId = b.firstPotion
|
||||
elseif c.index % #Config.QuestChains == 0 then
|
||||
potionId = b.roundPotions[(c.tier % #b.roundPotions) + 1]
|
||||
end
|
||||
return coins, 0, potionId and Potions.def(potionId)
|
||||
end
|
||||
|
||||
local function sendQuests(player)
|
||||
@@ -319,8 +367,15 @@ local function updateStats(player)
|
||||
player:SetAttribute("BagCap", bagCapacity(player, data))
|
||||
player:SetAttribute("BagValue", math.floor(bagValue * sellMult(player)))
|
||||
player:SetAttribute("Luck", math.floor(totalLuck(player, data) * 100 + 0.5))
|
||||
-- зелья: сумка ("Focus:2,Trophy:1") и действующее (id, остаток попыток или секунд)
|
||||
local pDef, pAct = Potions.active(data)
|
||||
player:SetAttribute("PotionInv", Potions.encode(data))
|
||||
player:SetAttribute("PotionActive", pDef and pDef.id or nil)
|
||||
player:SetAttribute("PotionLeft", pAct and math.max(0, math.floor(pAct.left)) or 0)
|
||||
player:SetAttribute("PotionKind", pDef and (pDef.charges and "charges" or "time") or nil)
|
||||
player:SetAttribute("BoostBonus", boostActive(data))
|
||||
player:SetAttribute("BoostLeft", math.max(0, data.boostUntil - os.time()))
|
||||
player:SetAttribute("BoostLeft", (pDef and not pDef.charges) and math.max(0, math.floor(pAct.left)) or 0)
|
||||
player:SetAttribute("MarketInbox", data.market and data.market.inbox and #data.market.inbox or 0)
|
||||
player:SetAttribute("TotalCaught", data.totalCaught)
|
||||
player:SetAttribute("CoinsEarned", data.coinsEarned)
|
||||
-- когда откроется следующая ежедневная награда (0 — уже доступна); по ней сундук в лобби прыгает только для тех,
|
||||
@@ -341,33 +396,43 @@ local function updateStats(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function addXp(player, data, amount)
|
||||
data.xp += amount
|
||||
local leveled = false
|
||||
while data.xp >= Config.XPForLevel(data.level) do
|
||||
data.xp -= Config.XPForLevel(data.level)
|
||||
data.level += 1
|
||||
leveled = true
|
||||
-- опыт карьеры (единственный источник — ручная поимка; source — для телеметрии)
|
||||
local function addXp(player, data, amount, source)
|
||||
if amount <= 0 then
|
||||
return
|
||||
end
|
||||
if leveled then
|
||||
Telemetry.xp(player, source or "Catch", amount)
|
||||
local levels = Progression.addXp(data, amount)
|
||||
for _, lvl in ipairs(levels) do
|
||||
Telemetry.level(player, lvl)
|
||||
end
|
||||
if #levels > 0 then
|
||||
notify(player, "⭐ Уровень " .. data.level .. "!", GOLD)
|
||||
feed("level", { name = player.DisplayName, userId = player.UserId, level = data.level })
|
||||
for _, w in ipairs(Config.Worlds) do
|
||||
if w.level == data.level and not w.soon then
|
||||
if not w.soon and table.find(levels, w.level) then
|
||||
notify(player, "🌍 Открыт: " .. w.icon .. " " .. w.name, w.color)
|
||||
end
|
||||
end
|
||||
if table.find(levels, Config.Market.minLevel) then
|
||||
notify(player, "🏪 Открыт рынок игроков: продавай ценную рыбу другим рыбакам", GOLD)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Guild.init({
|
||||
profiles = profiles, notify = notify, updateStats = updateStats, addXp = addXp, sendInventory = sendInventory,
|
||||
bagCapacity = bagCapacity, isNight = isNight, weather = weather, remote = remote,
|
||||
addCoins = addCoins, spendCoins = spendCoins, tierOf = tierOf,
|
||||
})
|
||||
|
||||
local function applyPotion(data, bonus, duration)
|
||||
data.boostBonus = math.max(boostActive(data), bonus)
|
||||
data.boostUntil = math.max(os.time(), data.boostUntil) + duration
|
||||
-- зелье-награда: в сумку зелий (пить — когда игрок сам решит)
|
||||
local function givePotion(player, data, def)
|
||||
if def and Potions.add(data, def.id, 1) then
|
||||
Telemetry.event(player, "PotionGranted", 1, { def.id })
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- задания: прогресс цепочки
|
||||
@@ -395,20 +460,18 @@ local function questProgress(player, kind, amount, absolute)
|
||||
local goal = stepGoal(data, step)
|
||||
if c.progress >= goal then
|
||||
-- награда сразу, следующий шаг тоже сразу
|
||||
local coins, xp = stepReward(data, step, goal)
|
||||
data.coins += coins
|
||||
addXp(player, data, xp)
|
||||
remote:FireClient(player, "QuestDone", kind, goal, coins, xp)
|
||||
local coins = stepReward(data, step, goal)
|
||||
addCoins(player, data, coins, "Quest")
|
||||
remote:FireClient(player, "QuestDone", kind, goal, coins, 0)
|
||||
c.step += 1
|
||||
c.progress = 0
|
||||
if c.step > #chain.steps then
|
||||
local bCoins, bXp, potion = chainBonus(data)
|
||||
data.coins += bCoins
|
||||
addXp(player, data, bXp)
|
||||
local bCoins, _, potion = chainBonus(data)
|
||||
addCoins(player, data, bCoins, "Chain")
|
||||
if potion then
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
givePotion(player, data, potion)
|
||||
end
|
||||
remote:FireClient(player, "ChainDone", chain.name, bCoins, bXp, potion and potion.name)
|
||||
remote:FireClient(player, "ChainDone", chain.name, bCoins, 0, potion and (potion.icon .. " " .. potion.name .. " — в сумку зелий"))
|
||||
c.index += 1
|
||||
c.step = 1
|
||||
if (c.index - 1) % #Config.QuestChains == 0 then
|
||||
@@ -432,14 +495,12 @@ local function claimDaily(player)
|
||||
end
|
||||
local streak = (data.daily.last == t - 1) and (data.daily.streak % 7 + 1) or 1
|
||||
local r = Config.DailyRewards[streak]
|
||||
local coins = math.floor(r.coins * (1 + (data.level - 1) * 0.2))
|
||||
data.coins += coins
|
||||
local coins = addCoins(player, data, r.coins * tierOf(data), "Daily")
|
||||
local extra = ""
|
||||
if r.potion then
|
||||
local p = Config.Find(Config.Potions, r.potion)
|
||||
if p then
|
||||
applyPotion(data, p.bonus, p.duration)
|
||||
extra = " + " .. p.name
|
||||
local p = Potions.def(r.potion)
|
||||
if givePotion(player, data, p) then
|
||||
extra = " + " .. p.icon .. " " .. p.name
|
||||
end
|
||||
end
|
||||
data.daily = { last = t, streak = streak }
|
||||
@@ -471,19 +532,19 @@ local function claimCollection(player, worldId, rarity)
|
||||
return
|
||||
end
|
||||
end
|
||||
data.claimed[key] = true
|
||||
-- коллекция — исследование: серебро (× tier мира) и мастерство, без опыта карьеры
|
||||
if rarity == "Master" then
|
||||
local coins = Config.MasteryCoins * world.mult
|
||||
data.coins += coins
|
||||
notify(player, ("🏆 «%s» собран! +%d ⚪"):format(world.name, coins), GOLD)
|
||||
data.claimed[key] = true
|
||||
local coins = addCoins(player, data, Config.MasteryCoins * (world.tier or 1), "Collection")
|
||||
notify(player, ("🏆 «%s» собран! +%d ⚪ и +%d%% удачи навсегда"):format(world.name, coins, Config.MasteryLuck * 100), GOLD)
|
||||
else
|
||||
local r = Config.CollectionRewards[rarity]
|
||||
if not r then
|
||||
return
|
||||
end
|
||||
data.coins += r.coins * world.mult
|
||||
addXp(player, data, r.xp * world.mult)
|
||||
notify(player, ("📖 +%d ⚪ +%d XP"):format(r.coins * world.mult, r.xp * world.mult), GREEN)
|
||||
data.claimed[key] = true
|
||||
local coins = addCoins(player, data, r.coins * (world.tier or 1), "Collection")
|
||||
notify(player, ("📖 +%d ⚪"):format(coins), GREEN)
|
||||
end
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
@@ -808,7 +869,9 @@ local function stopFishing(player, tellClient)
|
||||
end
|
||||
end
|
||||
|
||||
-- mods: { bait = наживка из Config.Baits, maxRank = потолок редкости (автоловля) }
|
||||
-- mods: { bait = наживка из Config.Baits, maxRank = потолок редкости (автоловля), potion = Potions.effect }
|
||||
-- Удача смягчается к потолку (Config.EffectiveLuck): лучшее снаряжение даёт больше дорогой рыбы,
|
||||
-- но мифическая не становится обычной, а мутации не чаще × Economy.mutationCap
|
||||
local function rollFish(player, data, worldId, luckMult, mods)
|
||||
local zone = Config.Zones[worldId]
|
||||
if not zone then
|
||||
@@ -816,22 +879,23 @@ local function rollFish(player, data, worldId, luckMult, mods)
|
||||
end
|
||||
mods = mods or {}
|
||||
local bait = mods.bait
|
||||
local pot = mods.potion or {}
|
||||
local base = totalLuck(player, data) + (bait and bait.luck or 0)
|
||||
if bait and bait.nightLuck and isNight() then
|
||||
base += bait.nightLuck - Config.DayNight.nightLuck -- светлячок: ночью +30% вместо обычных +10%
|
||||
end
|
||||
local luck = base * (luckMult or 1)
|
||||
local bonus = luck - 1
|
||||
local beff = Config.EffectiveLuck(luck)
|
||||
local weights, total = {}, 0
|
||||
for i, f in ipairs(zone.fish) do
|
||||
local r = Config.Rarities[f.rarity]
|
||||
local w = r.weight * math.max(0.2, 1 + bonus * (r.rank - 1))
|
||||
if r.rank == 1 then
|
||||
w = r.weight / math.max(1, luck)
|
||||
end
|
||||
local w = Config.RarityWeight(f.rarity, beff)
|
||||
if bait and bait.rareWeight and r.rank >= 3 then
|
||||
w *= bait.rareWeight
|
||||
end
|
||||
if pot.newSpecies and not data.discovered[f.id] then
|
||||
w *= pot.newSpecies -- зелье исследователя: ещё не пойманные виды
|
||||
end
|
||||
if mods.maxRank and r.rank > mods.maxRank then
|
||||
w = 0
|
||||
end
|
||||
@@ -848,13 +912,14 @@ local function rollFish(player, data, worldId, luckMult, mods)
|
||||
end
|
||||
end
|
||||
local mutation = nil
|
||||
local mm = Config.MutationMult(beff, ev("mutation", 1) * (weather().mutation or 1) * (bait and bait.mutation or 1) * (pot.mutation or 1))
|
||||
for _, m in ipairs(Config.Mutations) do
|
||||
if rng:NextNumber() < m.chance * luck * ev("mutation", 1) * (weather().mutation or 1) * (bait and bait.mutation or 1) then
|
||||
if rng:NextNumber() < m.chance * mm then
|
||||
mutation = m
|
||||
break
|
||||
end
|
||||
end
|
||||
local wf = rng:NextNumber() ^ 2.2
|
||||
local wf = rng:NextNumber() ^ (pot.weightCurve or 2.2)
|
||||
local weight = chosen.minW + (chosen.maxW - chosen.minW) * wf
|
||||
return {
|
||||
id = chosen.id,
|
||||
@@ -862,7 +927,6 @@ local function rollFish(player, data, worldId, luckMult, mods)
|
||||
rarity = chosen.rarity,
|
||||
weight = math.floor(weight * 100) / 100,
|
||||
value = math.floor(chosen.price * (0.75 + 0.9 * wf) * (mutation and mutation.mult or 1) + 0.5),
|
||||
xp = chosen.xp * (mutation and 2 or 1),
|
||||
mutation = mutation and mutation.id or nil,
|
||||
world = worldId,
|
||||
}
|
||||
@@ -953,12 +1017,14 @@ local function onCast(player, power)
|
||||
local stats = Config.RodStats(data.rod, rodLevel(data))
|
||||
local perfect = power >= Config.CastPerfect[1] and power <= Config.CastPerfect[2]
|
||||
local bait = Guild.useBait(player, data) -- 1 штука наживки на заброс
|
||||
local fish = rollFish(player, data, world.id, perfect and Config.CastPerfectLuck or 1, { bait = bait })
|
||||
-- зелье: эффект берём на момент заброса, попытку списываем при поклёвке (ниже)
|
||||
local potion = Potions.effect(data)
|
||||
local fish = rollFish(player, data, world.id, perfect and Config.CastPerfectLuck or 1, { bait = bait, potion = potion })
|
||||
if not fish then
|
||||
remote:FireClient(player, "CastFail")
|
||||
return
|
||||
end
|
||||
local s = { stage = "casting", fish = fish, tool = tool, perfect = perfect }
|
||||
local s = { stage = "casting", fish = fish, tool = tool, perfect = perfect, potion = potion }
|
||||
fishing[player] = s
|
||||
-- замах игрок уже сделал, пока держал кнопку (у себя на клиенте); здесь только бросок вперёд
|
||||
local throw = { windup = 0.15, flight = 0.35 + dist * 0.018, arc = 2 + dist * 0.3, perfect = perfect }
|
||||
@@ -983,13 +1049,19 @@ local function onCast(player, power)
|
||||
end
|
||||
s.stage = "waiting"
|
||||
|
||||
local waitTime = rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax) * stats.speed * ev("speed", 1) * (weather().speed or 1) * (bait and bait.speed or 1)
|
||||
-- все ускорения клёва вместе — не больше чем на 25% (Economy.waitFloor), и не короче minBite секунд
|
||||
local waitTime = math.max(E.minBite, rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax)
|
||||
* Config.WaitMult(stats.speed * ev("speed", 1) * (weather().speed or 1) * (bait and bait.speed or 1) * (potion.speed or 1)))
|
||||
task.wait(waitTime)
|
||||
if fishing[player] ~= s then
|
||||
return
|
||||
end
|
||||
s.stage = "bite"
|
||||
s.biteAt = os.clock()
|
||||
-- поклёвка: попытка зелья засчитана (дальше — поймал, сорвалась или ушла; отмена уже не спасает заряд)
|
||||
if potion.id and Potions.consumeAttempt(data, potion.id) then
|
||||
updateStats(player)
|
||||
end
|
||||
if s.bobber and s.bobber.PrimaryPart then
|
||||
local root = s.bobber.PrimaryPart
|
||||
splash(root, 25)
|
||||
@@ -1009,9 +1081,10 @@ local function onCast(player, power)
|
||||
end
|
||||
end)
|
||||
local rank = Config.Rarities[fish.rarity].rank
|
||||
s.hits = Config.HitsNeeded(rank)
|
||||
remote:FireClient(player, "Bite", {
|
||||
speed = 0.55 + 0.22 * (rank - 1),
|
||||
zoneWidth = math.max(0.07, stats.zone - 0.02 * (rank - 1)),
|
||||
zoneWidth = math.max(0.07, stats.zone + (potion.zone or 0) - 0.02 * (rank - 1)),
|
||||
hits = Config.HitsNeeded(rank),
|
||||
misses = Config.MaxMisses,
|
||||
timeout = Config.BiteTimeout,
|
||||
@@ -1039,7 +1112,9 @@ local function onCatch(player, success, misses)
|
||||
if s.tween then
|
||||
s.tween:Cancel()
|
||||
end
|
||||
local failed = success ~= true or os.clock() - s.biteAt > Config.BiteTimeout + 1
|
||||
-- подсечка быстрее, чем физически возможно пройти мини-игру, не засчитывается
|
||||
local reel = os.clock() - s.biteAt
|
||||
local failed = success ~= true or reel > Config.BiteTimeout + 1 or reel < E.reelPerHit * (s.hits or 1)
|
||||
if failed then
|
||||
reelBobber(s.bobber, tool)
|
||||
elseif s.bobber then
|
||||
@@ -1061,19 +1136,27 @@ end
|
||||
-- ctx: { perfect, misses, fromPos, auto }; у автоловли нет серии и бонусов за точность
|
||||
grantFish = function(player, data, fish, ctx)
|
||||
local streak = combo[player] or 0
|
||||
local comboMult = 1
|
||||
local comboBonus = 0
|
||||
if not ctx.auto then
|
||||
-- серия: каждая рыба подряд дороже и даёт больше опыта
|
||||
comboMult = math.min(Config.Combo.max, 1 + Config.Combo.step * streak)
|
||||
fish.value = math.floor(fish.value * comboMult + 0.5)
|
||||
fish.xp = math.floor(fish.xp * comboMult + 0.5)
|
||||
-- серия: каждая рыба подряд чуть дороже (опыт карьеры не меняется)
|
||||
comboBonus = math.min(Config.Combo.max, Config.Combo.step * streak)
|
||||
setCombo(player, streak + 1)
|
||||
end
|
||||
fish.xp = math.floor(fish.xp * Guild.xpMult(data)) -- бонус отдыха: двойной опыт
|
||||
table.insert(data.items, {
|
||||
-- надбавки к цене складываются и ограничены: серия + отдых ≤ valueBonusCap
|
||||
local restBonus = (data.rest or 0) > 0 and E.restSilver or 0
|
||||
local valueMult = 1 + math.min(E.valueBonusCap, comboBonus + restBonus)
|
||||
if ctx.auto then
|
||||
valueMult = E.autoValue
|
||||
end
|
||||
fish.value = math.max(1, math.floor(fish.value * valueMult + 0.5))
|
||||
-- опыт карьеры: фиксированный за ручную поимку в этом мире; автоловля — Economy.autoXP
|
||||
fish.xp = Progression.catchXP(fish.world, { auto = ctx.auto })
|
||||
local item = {
|
||||
uid = data.nextUid, id = fish.id, name = fish.name, rarity = fish.rarity,
|
||||
weight = fish.weight, value = fish.value, mutation = fish.mutation,
|
||||
})
|
||||
}
|
||||
Progression.stamp(item, player.UserId, player.DisplayName, fish.world, os.time())
|
||||
table.insert(data.items, item)
|
||||
data.nextUid += 1
|
||||
data.totalCaught += 1
|
||||
|
||||
@@ -1089,25 +1172,29 @@ grantFish = function(player, data, fish, ctx)
|
||||
rec.best = fish.weight
|
||||
end
|
||||
|
||||
addXp(player, data, fish.xp * (isNew and 2 or 1))
|
||||
-- новый вид и рекорд радуют серебром, коллекцией и карточкой, а не скачком уровня
|
||||
addXp(player, data, fish.xp, ctx.auto and "Auto" or "Catch")
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
if ctx.fromPos then
|
||||
showFishFlight(player, fish, ctx.fromPos)
|
||||
end
|
||||
remote:FireClient(player, "Caught", fish, { new = isNew, record = isRecord, combo = comboMult, streak = ctx.auto and 0 or streak + 1, auto = ctx.auto })
|
||||
remote:FireClient(player, "Caught", fish, { new = isNew, record = isRecord, combo = 1 + comboBonus, rest = restBonus > 0, streak = ctx.auto and 0 or streak + 1, auto = ctx.auto })
|
||||
do
|
||||
local h = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
feedCatch(player, fish, h and Config.WorldAt(h.Position))
|
||||
end
|
||||
|
||||
local rank = Config.Rarities[fish.rarity].rank
|
||||
questProgress(player, "catch", 1)
|
||||
if rank >= 2 then
|
||||
questProgress(player, "uncommon", 1)
|
||||
end
|
||||
if rank >= 3 then
|
||||
questProgress(player, "rare", 1)
|
||||
-- задания засчитывают только ручную ловлю (автоловля — дополнительный доход, не прогресс)
|
||||
if not ctx.auto then
|
||||
questProgress(player, "catch", 1)
|
||||
if rank >= 2 then
|
||||
questProgress(player, "uncommon", 1)
|
||||
end
|
||||
if rank >= 3 then
|
||||
questProgress(player, "rare", 1)
|
||||
end
|
||||
end
|
||||
if not ctx.auto then
|
||||
if ctx.misses == 0 then
|
||||
@@ -1170,7 +1257,9 @@ local function autoFishLoop(player, token)
|
||||
continue
|
||||
end
|
||||
|
||||
local cycleStart = os.clock()
|
||||
local bait = Guild.useBait(player, data)
|
||||
-- зелья автоловля не использует и не тратит
|
||||
local fish = rollFish(player, data, world.id, A.luck, { bait = bait, maxRank = (not Guild.rank(data).autoNoCap) and A.maxRarity or nil })
|
||||
local s = { stage = "casting", fish = fish, tool = tool, auto = true }
|
||||
fishing[player] = s
|
||||
@@ -1191,8 +1280,8 @@ local function autoFishLoop(player, token)
|
||||
end
|
||||
s.stage = "waiting"
|
||||
local stats = Config.RodStats(data.rod, rodLevel(data))
|
||||
local waitTime = rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax) * stats.speed * ev("speed", 1)
|
||||
* (weather().speed or 1) * (bait and bait.speed or 1) * A.slower
|
||||
local waitTime = math.max(E.minBite, rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax)
|
||||
* Config.WaitMult(stats.speed * ev("speed", 1) * (weather().speed or 1) * (bait and bait.speed or 1))) * A.slower
|
||||
local t0, bit = os.clock(), false
|
||||
while fishing[player] == s and autoFishing[player] == token and os.clock() - t0 < waitTime + A.reel do
|
||||
local h = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
@@ -1225,7 +1314,8 @@ local function autoFishLoop(player, token)
|
||||
end
|
||||
gripSequence(tool, { { 85, 0.15 }, { REST_ANGLE, 0.45 } })
|
||||
grantFish(player, data, fish, { auto = true, fromPos = fromPos })
|
||||
task.wait(1.2)
|
||||
-- автоловля не быстрее одной рыбы за Economy.autoMinCycle секунд: не обгоняет ручную ловлю
|
||||
task.wait(math.max(1.2, E.autoMinCycle - (os.clock() - cycleStart)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1301,7 +1391,8 @@ local function sellItems(player, filterUid)
|
||||
local total, count, keep = 0, 0, {}
|
||||
for _, item in ipairs(data.items) do
|
||||
if filterUid == nil or item.uid == filterUid then
|
||||
total += math.floor(item.value * mult)
|
||||
-- купленная на рынке рыба — по базовой цене, без бонусов пропусков и ярмарки (нет перепродажи с наваром)
|
||||
total += item.bought and math.floor(item.value) or math.floor(item.value * mult)
|
||||
count += 1
|
||||
else
|
||||
table.insert(keep, item)
|
||||
@@ -1314,7 +1405,7 @@ local function sellItems(player, filterUid)
|
||||
return
|
||||
end
|
||||
data.items = keep
|
||||
data.coins += total
|
||||
addCoins(player, data, total, "Sell")
|
||||
data.coinsEarned += total
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
@@ -1341,11 +1432,10 @@ local function buy(player, kind, id)
|
||||
return
|
||||
end
|
||||
local cost = Guild.price(data, Config.UpgradeCost(rod, lvl)) -- скидка ранга гильдии
|
||||
if data.coins < cost then
|
||||
if not spendCoins(player, data, cost, "Upgrade", id) then
|
||||
notify(player, "Нужно " .. cost .. " ⚪", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= cost
|
||||
data.rodLevels[id] = lvl + 1
|
||||
if data.rod == id then
|
||||
stopFishing(player, true)
|
||||
@@ -1357,8 +1447,9 @@ local function buy(player, kind, id)
|
||||
return
|
||||
end
|
||||
if kind == "Potion" then
|
||||
local potion = Config.Find(Config.Potions, id)
|
||||
if not potion then
|
||||
-- покупка — в сумку зелий; выпить отдельно (DrinkPotion)
|
||||
local potion = Potions.def(id)
|
||||
if not potion or not potion.price or potion.paid or potion.legacy then
|
||||
return
|
||||
end
|
||||
if potion.level and data.level < potion.level then
|
||||
@@ -1366,14 +1457,14 @@ local function buy(player, kind, id)
|
||||
return
|
||||
end
|
||||
local price = Guild.price(data, potion.price)
|
||||
if data.coins < price then
|
||||
if not spendCoins(player, data, price, "Potion", id) then
|
||||
notify(player, "Нужно " .. price .. " ⚪", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= price
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
Potions.add(data, id, 1)
|
||||
Telemetry.event(player, "PotionBought", 1, { id })
|
||||
updateStats(player)
|
||||
notify(player, ("🍀 +%d%% удачи, %d мин"):format(potion.bonus * 100, potion.duration / 60), GREEN)
|
||||
notify(player, ("%s %s — в сумке зелий"):format(potion.icon, potion.name), GREEN)
|
||||
questProgress(player, "buy", 1)
|
||||
return
|
||||
end
|
||||
@@ -1396,11 +1487,10 @@ local function buy(player, kind, id)
|
||||
return
|
||||
end
|
||||
local price = Guild.price(data, item.price)
|
||||
if data.coins < price then
|
||||
if not spendCoins(player, data, price, kind, id) then
|
||||
notify(player, "Нужно " .. price .. " ⚪", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= price
|
||||
owned[id] = true
|
||||
bought = true
|
||||
notify(player, "✅ " .. item.name, GREEN)
|
||||
@@ -1419,6 +1509,71 @@ local function buy(player, kind, id)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- зелья: выпить
|
||||
|
||||
-- confirm = true — игрок подтвердил замену действующего зелья (его остаток пропадает)
|
||||
local function drinkPotion(player, id, confirm)
|
||||
local data = profiles[player]
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
local ok, code, info = Potions.activate(data, id, confirm == true)
|
||||
local def = Potions.def(id)
|
||||
if ok then
|
||||
Telemetry.event(player, "PotionActivated", 1, { id, code })
|
||||
local left = def.charges and (def.charges .. " попыток") or (math.floor((def.duration or 0) / 60) .. " мин игры")
|
||||
if code == "extended" then
|
||||
notify(player, ("%s %s продлено"):format(def.icon, def.name), GREEN)
|
||||
elseif code == "replaced" and info then
|
||||
local lost = Potions.def(info.lostId)
|
||||
notify(player, ("%s %s: %s. Прежнее зелье (%s) заменено"):format(def.icon, def.name, left, lost and lost.name or "?"), GOLD)
|
||||
else
|
||||
notify(player, ("%s %s: %s"):format(def.icon, def.name, left), GREEN)
|
||||
end
|
||||
updateStats(player)
|
||||
elseif code == "needConfirm" then
|
||||
-- клиент покажет окно подтверждения с остатком текущего зелья
|
||||
remote:FireClient(player, "PotionConfirm", id, info.activeId, info.left)
|
||||
elseif code == "full" then
|
||||
notify(player, "Больше этого зелья сейчас не выпить", RED)
|
||||
elseif code == "none" then
|
||||
notify(player, "Такого зелья нет в сумке", RED)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- рынок игроков
|
||||
|
||||
local marketLedger = nil
|
||||
if marketStore then
|
||||
marketLedger = Market.dataStoreLedger(marketStore)
|
||||
elseif RunService:IsStudio() and Config.Market.studioFakeLedger then
|
||||
marketLedger = Market.memoryLedger() -- в Studio без API: сделки в памяти (профили всё равно не сохраняются)
|
||||
end
|
||||
Market.init({
|
||||
profiles = profiles, ledger = marketLedger,
|
||||
save = function(p)
|
||||
if not playerStore or not loadedOk[p] then
|
||||
-- без хранилища (Studio) сохранять нечего: считаем шаг выполненным
|
||||
return profiles[p] ~= nil and (not playerStore)
|
||||
end
|
||||
return saveData(p)
|
||||
end,
|
||||
notify = notify,
|
||||
changed = function(p)
|
||||
updateStats(p)
|
||||
sendInventory(p)
|
||||
end,
|
||||
send = function(p, payload)
|
||||
remote:FireClient(p, "Market", payload)
|
||||
end,
|
||||
bagCapacity = bagCapacity,
|
||||
telemetry = Telemetry,
|
||||
enabled = function()
|
||||
-- живой сервер без DataStore рынок не открывает (нечем гарантировать сделки)
|
||||
return marketStore ~= nil or RunService:IsStudio()
|
||||
end,
|
||||
})
|
||||
|
||||
---------------------------------------------------------------- телепорт
|
||||
|
||||
local TELEPORT_FADE = 0.3 -- сколько клиент затемняет экран перед переносом
|
||||
@@ -1526,7 +1681,12 @@ end)
|
||||
|
||||
---------------------------------------------------------------- события от клиента
|
||||
|
||||
remote.OnServerEvent:Connect(function(player, action, a, b)
|
||||
local potionCooldown = {}
|
||||
Players.PlayerRemoving:Connect(function(p)
|
||||
potionCooldown[p] = nil
|
||||
end)
|
||||
|
||||
local function onRemote(player, action, a, b)
|
||||
if action == "Cast" then
|
||||
onCast(player, a)
|
||||
elseif action == "Tutorial" then
|
||||
@@ -1578,10 +1738,19 @@ remote.OnServerEvent:Connect(function(player, action, a, b)
|
||||
end
|
||||
elseif action == "AutoFish" then
|
||||
setAutoFish(player, a == true)
|
||||
elseif action == "DrinkPotion" then
|
||||
local t = os.clock()
|
||||
if (potionCooldown[player] or 0) <= t then
|
||||
potionCooldown[player] = t + 0.4
|
||||
drinkPotion(player, a, b)
|
||||
end
|
||||
elseif Market.onAction(player, action, a, b) then
|
||||
return
|
||||
else
|
||||
Guild.onAction(player, action, a, b)
|
||||
end
|
||||
end)
|
||||
end
|
||||
remote.OnServerEvent:Connect(onRemote)
|
||||
|
||||
---------------------------------------------------------------- донат
|
||||
|
||||
@@ -1628,13 +1797,15 @@ MarketplaceService.ProcessReceipt = function(info)
|
||||
end
|
||||
end
|
||||
if product.coins then
|
||||
local coins = math.floor(product.coins * (1 + (data.level - 1) * 0.15))
|
||||
data.coins += coins
|
||||
-- как обещано в описании товара: «больше с уровнем» (формула не менялась в экономике v2)
|
||||
local coins = addCoins(player, data, product.coins * (1 + (data.level - 1) * 0.15), "Product")
|
||||
notify(player, ("Спасибо! +%d ⚪"):format(coins), GOLD)
|
||||
end
|
||||
if product.boost then
|
||||
applyPotion(data, product.boost, product.duration)
|
||||
notify(player, ("🍀 +%d%% удачи, %d мин"):format(product.boost * 100, product.duration / 60), GOLD)
|
||||
if product.potion then
|
||||
local def = Potions.def(product.potion)
|
||||
Potions.add(data, product.potion, 1)
|
||||
Telemetry.event(player, "PotionGranted", 1, { product.potion, "Product" })
|
||||
notify(player, ("%s %s — в сумке зелий. Выпей, когда будешь готов"):format(def.icon, def.name), GOLD)
|
||||
end
|
||||
table.insert(data.receipts, info.PurchaseId)
|
||||
if #data.receipts > 50 then
|
||||
@@ -1703,21 +1874,17 @@ local function finishBoss(won)
|
||||
end
|
||||
local R = Config.Boss.reward
|
||||
local fair = b.max / math.max(1, helpers) -- «честная доля» урона на одного
|
||||
local potion = R.potion and Config.Find(Config.Potions, R.potion)
|
||||
local potion = R.potion and Potions.def(R.potion)
|
||||
for p, d in pairs(b.dmg) do
|
||||
local data = p.Parent and profiles[p]
|
||||
if data then
|
||||
-- серебро × tier мира босса (без множителя уровня), опыта карьеры нет, зелье — в сумку зелий
|
||||
local share = 0.4 + 0.6 * math.min(1, d / fair)
|
||||
local coins = math.floor(R.coins * b.world.mult * share * levelMult(data))
|
||||
local xp = math.floor(R.xp * b.world.mult * share)
|
||||
data.coins += coins
|
||||
addXp(p, data, xp)
|
||||
if potion then
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
end
|
||||
local coins = addCoins(p, data, R.coins * (b.world.tier or 1) * share, "Boss")
|
||||
local gotPotion = givePotion(p, data, potion)
|
||||
Guild.onBossWin(p, data)
|
||||
updateStats(p)
|
||||
remote:FireClient(p, "BossReward", coins, xp, potion and potion.name)
|
||||
remote:FireClient(p, "BossReward", coins, 0, gotPotion and (potion.icon .. " " .. potion.name) or nil)
|
||||
end
|
||||
end
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
@@ -1782,16 +1949,36 @@ local function onPlayerAdded(player)
|
||||
v.Parent = ls
|
||||
end
|
||||
|
||||
local data, ok = loadData(player)
|
||||
local data, status = loadData(player)
|
||||
if not player.Parent then
|
||||
-- ушёл, пока грузились: снять поставленный замок сессии
|
||||
if status == "ok" and playerStore then
|
||||
task.spawn(function()
|
||||
playerStore:save("player_" .. player.UserId, data, true)
|
||||
end)
|
||||
end
|
||||
return
|
||||
end
|
||||
if status == "locked" then
|
||||
player:Kick("Твой прогресс ещё сохраняется на другом сервере. Зайди снова через минуту.")
|
||||
return
|
||||
end
|
||||
loadPasses(player, data)
|
||||
ensureChain(data)
|
||||
Guild.defaults(data)
|
||||
-- экономика v2: перенос старого сохранения (уровень, доля опыта, зелье, id рыбы); повторно не выполняется
|
||||
if Progression.migrate(data, { now = os.time(), userId = player.UserId, name = player.DisplayName }) then
|
||||
Telemetry.event(player, "EconomyMigrated", 1, { tostring(data.migration and data.migration.from), tostring(data.level) })
|
||||
end
|
||||
Potions.ensure(data)
|
||||
Market.ensure(data)
|
||||
Guild.onJoin(player, data)
|
||||
-- рынок: разобрать сделки, прерванные падением сервера (по журналу сделок)
|
||||
if Market.unresolved(data) then
|
||||
Market.recover(player, data)
|
||||
end
|
||||
profiles[player] = data
|
||||
loadedOk[player] = ok
|
||||
loadedOk[player] = status == "ok"
|
||||
local settings = type(data.settings) == "table" and data.settings or {}
|
||||
player:SetAttribute("VolMusic", tonumber(settings.music) or Config.DefaultVolume.music)
|
||||
player:SetAttribute("VolSfx", tonumber(settings.sfx) or Config.DefaultVolume.sfx)
|
||||
@@ -1819,25 +2006,42 @@ for _, p in ipairs(Players:GetPlayers()) do
|
||||
task.spawn(onPlayerAdded, p)
|
||||
end
|
||||
|
||||
Players.PlayerRemoving:Connect(function(player)
|
||||
-- выход: дождаться сделок рынка и снять лоты, затем финальное сохранение со снятием замка сессии
|
||||
local leaving = {}
|
||||
local function finishPlayer(player)
|
||||
if leaving[player] then
|
||||
return
|
||||
end
|
||||
leaving[player] = true
|
||||
stopFishing(player, false)
|
||||
combo[player], comboUntil[player] = nil, nil
|
||||
autoFishing[player] = nil
|
||||
if profiles[player] then
|
||||
Market.onLeave(player, 20)
|
||||
Guild.onLeave(profiles[player])
|
||||
Telemetry.flush(player)
|
||||
end
|
||||
saveData(player)
|
||||
saveData(player, true)
|
||||
profiles[player] = nil
|
||||
loadedOk[player] = nil
|
||||
passes[player] = nil
|
||||
end)
|
||||
leaving[player] = nil
|
||||
end
|
||||
Players.PlayerRemoving:Connect(finishPlayer)
|
||||
|
||||
game:BindToClose(function()
|
||||
-- параллельно: у сервера ~30 секунд, последовательные сохранения могут не успеть
|
||||
local left = 0
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
if profiles[p] then
|
||||
Guild.onLeave(profiles[p])
|
||||
end
|
||||
saveData(p)
|
||||
left += 1
|
||||
task.spawn(function()
|
||||
finishPlayer(p)
|
||||
left -= 1
|
||||
end)
|
||||
end
|
||||
local t0 = os.clock()
|
||||
while left > 0 and os.clock() - t0 < 25 do
|
||||
task.wait(0.1)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -1863,7 +2067,12 @@ task.spawn(function()
|
||||
end
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
local data = profiles[p]
|
||||
if data and data.boostUntil > os.time() - 2 then
|
||||
-- зелья на время тикают, пока игрок в игре
|
||||
local pDef = data and Potions.active(data)
|
||||
if pDef and not pDef.charges then
|
||||
if Potions.tick(data, 1) then
|
||||
notify(p, pDef.icon .. " " .. pDef.name .. " закончилось", Color3.fromRGB(255, 200, 120))
|
||||
end
|
||||
updateStats(p)
|
||||
end
|
||||
-- бонус отдыха тратится, пока игрок рыбачит
|
||||
@@ -1875,10 +2084,60 @@ task.spawn(function()
|
||||
breakCombo(p)
|
||||
end
|
||||
end
|
||||
-- рынок: снять просроченные лоты, разослать изменения
|
||||
if t % 5 == 0 then
|
||||
Market.tick()
|
||||
end
|
||||
if Market.isDirty() then
|
||||
Market.broadcast(Players:GetPlayers())
|
||||
end
|
||||
if t % 60 == 0 then
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
saveData(p)
|
||||
local data = profiles[p]
|
||||
-- сделки, которые журнал не подтвердил при входе, — ещё раз
|
||||
if data and not leaving[p] and Market.unresolved(data) and next(Market._inflight()) == nil then
|
||||
if Market.recover(p, data) then
|
||||
updateStats(p)
|
||||
sendInventory(p)
|
||||
end
|
||||
end
|
||||
task.spawn(saveData, p)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- проверки в Studio
|
||||
-- ServerStorage.EconomyDebug:Invoke("telemetry") / ("profile", player) / ("market")
|
||||
if RunService:IsStudio() then
|
||||
local f = Instance.new("BindableFunction")
|
||||
f.Name = "EconomyDebug"
|
||||
f.OnInvoke = function(op, player, a, b, c)
|
||||
if op == "telemetry" then
|
||||
return Telemetry.summary()
|
||||
elseif op == "profile" then
|
||||
return profiles[player]
|
||||
elseif op == "market" then
|
||||
return Market.snapshot(player)
|
||||
elseif op == "set" then
|
||||
-- профиль приходит через BindableFunction копией: менять поля — только так
|
||||
local data = profiles[player]
|
||||
if data then
|
||||
data[a] = b
|
||||
updateStats(player)
|
||||
end
|
||||
elseif op == "action" then
|
||||
onRemote(player, a, b, c)
|
||||
elseif op == "grant" then
|
||||
-- выдать рыбу как пойманную (для проверок рынка)
|
||||
local data = profiles[player]
|
||||
local f2 = Config.FindFish(a)
|
||||
if data and f2 then
|
||||
local _, zoneId = Config.FindFish(a)
|
||||
grantFish(player, data, { id = f2.id, name = f2.name, rarity = f2.rarity, weight = f2.minW, value = f2.price, mutation = b, world = zoneId }, { auto = true })
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
f.Parent = game:GetService("ServerStorage")
|
||||
end
|
||||
Reference in new issue
Block a user