mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-13 14:24:55 +02:00
finish market system for real
This commit is contained in:
@@ -327,7 +327,6 @@ function Player:onLookInMarket(itemType)
|
||||
end
|
||||
|
||||
if duration > 0 then
|
||||
-- TODO!!!!!!!!!!!!!
|
||||
response:addString(Game.getCountdownString(duration, true, true))
|
||||
else
|
||||
response:addU16(0)
|
||||
@@ -427,7 +426,7 @@ function Player:onLookInMarket(itemType)
|
||||
|
||||
-- speed
|
||||
if abilities.speed ~= 0 then
|
||||
skillBoosts[#skillBoosts + 1] = string.format("speed %+d", math.floor(abilities.speed / 2))
|
||||
skillBoosts[#skillBoosts + 1] = string.format("speed %+d", abilities.speed)
|
||||
end
|
||||
|
||||
-- skills
|
||||
@@ -465,16 +464,7 @@ function Player:onLookInMarket(itemType)
|
||||
|
||||
-- weight
|
||||
response:addString(string.format("%0.2f", itemType:getWeight() / 100))
|
||||
|
||||
-- to do
|
||||
response:addU16(0) -- Imbuement Slots
|
||||
response:addU16(0) -- Magic Shield Capacity
|
||||
response:addU16(0) -- Cleave
|
||||
response:addU16(0) -- Damage Reflection
|
||||
response:addU16(0) -- Perfect Shot
|
||||
response:addU16(0) -- Classification
|
||||
response:addU16(0) -- Tier
|
||||
|
||||
|
||||
-- buy stats
|
||||
do
|
||||
local stats = itemType:getMarketBuyStatistics()
|
||||
|
@@ -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
|
@@ -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
|
||||
|
Reference in New Issue
Block a user