🌟現在、鉄壁 鉄壁ヘッドショットには対応済みです。
鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。

「モジュール:Utility/Library」の版間の差分

提供:Apex Data
ナビゲーションに移動 検索に移動
(HTMLエスケープ用関数の実装)
(一部分に同じ要素をもつ配列をテキスト化する関数を標準化)
65行目: 65行目:
return aw.roundover(num)
return aw.roundover(num)
end
end
end
-- 一部分に同じ要素をもつ配列をテキスト化する関数
local function toRepeatingString(cache, count)
if count > 1 then
return cache .. '×' .. count
else
return cache
end
end
function aw.stringifyRepeatingArray(array, separator)
local cache = array[1]
local count = 0
local output = nil
for _, damage in ipairs(array) do
if cache == damage then
count = count + 1
else
local text = toRepeatingString(cache, count)
if output ~= nil then
output = output .. separator .. text
else
output = text
end
cache = damage
count = 1
end
end
local text = toRepeatingString(cache, count)
if output ~= nil then
output = output .. separator .. text
else
output = text
end
return output
end
end


return aw
return aw

2021年2月7日 (日) 09:38時点における版

このモジュールについての説明文ページを モジュール:Utility/Library/doc に作成できます

local aw = {}

function aw.shallowCopy(obj)
	local typename = type(obj)
	local copy
	if typename == 'table' then
		copy = {}
		for key, value in pairs(obj) do
			copy[key] = value
		end
	else
		copy = obj
	end
    return copy
end

function aw.getAsBoolean(strOrNumOrBool, defaultValue)
	defaultValue = defaultValue or false
	
	local typename = type(strOrNumOrBool)
	if typename == 'boolean' then
		return strOrNumOrBool
	elseif typename == 'number' then
		return strOrNumOrBool ~= 0
	elseif typename == 'string' then
		local str = string.lower(strOrNumOrBool)
		return str == 'true' or str == 't' or str == '1'
	else
		return defaultValue
	end
end

function aw.getAsNumber(strOrNum, defaultValue)
	defaultValue = defaultValue or 0
	
	local typename = type(strOrNum)
	if typename == 'number' then
		return strOrNum
	elseif typename == 'string' then
		return tonumber(strOrNum)
	else
		return defaultValue
	end
end

function aw.escapeHtml(html)
	local result, _ = html
		:gsub('&', '&')
		:gsub('"', '"')
	return result
end

function aw.round(num)
	return math.floor(tonumber(string.format("%.4f", num)) + 0.5)
end

function aw.roundover(num)
	return math.ceil(tonumber(string.format("%.4f", num)) - 0.5)
end

function aw.selectiveRound(num, useRound)
	if useRound or false then
		return aw.round(num)
	else
		return aw.roundover(num)
	end
end

-- 一部分に同じ要素をもつ配列をテキスト化する関数
local function toRepeatingString(cache, count)
	if count > 1 then
		return cache .. '×' .. count
	else
		return cache
	end
end

function aw.stringifyRepeatingArray(array, separator)
	local cache = array[1]
	local count = 0
	local output = nil
	for _, damage in ipairs(array) do
		if cache == damage then
			count = count + 1
		else
			local text = toRepeatingString(cache, count)
			if output ~= nil then
				output = output .. separator .. text
			else
				output = text
			end
			cache = damage
			count = 1
		end
	end
	
	local text = toRepeatingString(cache, count)
	if output ~= nil then
		output = output .. separator .. text
	else
		output = text
	end
	return output
end

return aw