finish market system for real

This commit is contained in:
ErikasKontenis
2022-04-11 17:10:46 +03:00
parent 944af32a8c
commit 09ddca2a61
7 changed files with 1991 additions and 23 deletions

View File

@@ -998,3 +998,22 @@ end
function Guild.removeMember(self, player)
return player:getGuild() == self and player:setGuild(nil)
end
function getCombatName(combat)
local combats = {
[COMBAT_PHYSICALDAMAGE] = 'physical',
[COMBAT_ENERGYDAMAGE] = 'energy',
[COMBAT_EARTHDAMAGE] = 'earth',
[COMBAT_FIREDAMAGE] = 'fire',
[COMBAT_UNDEFINEDDAMAGE] = 'undefined',
[COMBAT_LIFEDRAIN] = 'lifedrain',
[COMBAT_MANADRAIN] = 'manadrain',
[COMBAT_HEALING] = 'healing',
[COMBAT_DROWNDAMAGE] = 'drown',
--[COMBAT_ICEDAMAGE] = 'ice',
--[COMBAT_HOLYDAMAGE] = 'holy',
--[COMBAT_DEATHDAMAGE] = 'death'
}
return combats[combat]
end

View File

@@ -157,3 +157,59 @@ function Game.setStorageValue(key, value)
db.query("INSERT INTO `global_storage` (`key`, `value`) VALUES (" .. key .. ", " .. value .. ");")
end
end
do
local cdShort = {"d", "h", "m", "s"}
local cdLong = {" day", " hour", " minute", " second"}
local function getTimeUnitGrammar(amount, unitID, isLong)
return isLong and string.format("%s%s", cdLong[unitID], amount ~= 1 and "s" or "") or cdShort[unitID]
end
function Game.getCountdownString(duration, longVersion, hideZero)
if duration < 0 then
return "expired"
end
local days = math.floor(duration / 86400)
local hours = math.floor((duration % 86400) / 3600)
local minutes = math.floor((duration % 3600) / 60)
local seconds = math.floor(duration % 60)
local response = {}
if hideZero then
if days > 0 then
response[#response + 1] = days .. getTimeUnitGrammar(days, 1, longVersion)
end
if hours > 0 then
response[#response + 1] = hours .. getTimeUnitGrammar(hours, 2, longVersion)
end
if minutes > 0 then
response[#response + 1] = minutes .. getTimeUnitGrammar(minutes, 3, longVersion)
end
if seconds > 0 then
response[#response + 1] = seconds .. getTimeUnitGrammar(seconds, 4, longVersion)
end
else
if days > 0 then
response[#response + 1] = days .. getTimeUnitGrammar(days, 1, longVersion)
response[#response + 1] = hours .. getTimeUnitGrammar(hours, 2, longVersion)
response[#response + 1] = minutes .. getTimeUnitGrammar(minutes, 3, longVersion)
response[#response + 1] = seconds .. getTimeUnitGrammar(seconds, 4, longVersion)
elseif hours > 0 then
response[#response + 1] = hours .. getTimeUnitGrammar(hours, 2, longVersion)
response[#response + 1] = minutes .. getTimeUnitGrammar(minutes, 3, longVersion)
response[#response + 1] = seconds .. getTimeUnitGrammar(seconds, 4, longVersion)
elseif minutes > 0 then
response[#response + 1] = minutes .. getTimeUnitGrammar(minutes, 3, longVersion)
response[#response + 1] = seconds .. getTimeUnitGrammar(seconds, 4, longVersion)
elseif seconds >= 0 then
response[#response + 1] = seconds .. getTimeUnitGrammar(seconds, 4, longVersion)
end
end
return table.concat(response, " ")
end
end