Test Page: Difference between revisions

From :: ChromeRivals Wiki ::
Jump to navigation Jump to search
(Removed redirect to Main Page)
Tags: Removed redirect Reverted
No edit summary
Tag: Manual revert
(179 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- ENCHANT MODULE
{{Test
-- Define your MediaWiki Lua Module:GetEnchants
|WIDTH= 16em
local GetEnchants = {}
|Icon= <span class="TestSpan" title="Item icon">https://download.chromerivals.net/resources/items_images/standard/3737594287.png</span>
 
|IMAGE= {{E15}}<span class="TestSpan" title="Item main image">https://download.chromerivals.net/resources/items_images/big/3738522537.png</span>{{/E15}}
-- Mapping of color IDs to color values
|NAME= {{magenta}}Your mom{{EndColor}} {{yellow}}Shard of Phillon{{/yellow}} {{red}}is so fat{{EndColor}}
local colorMap = {
|TYPE= Missile type
    [1] = "orange",
|GEAR_TYPE= B-Gear
    [2] = "yellow",
|REQUIRED_LEVEL= 105
    [3] = "green",
|ATTACK_POWER= (520 ~ 665) X (2 X 1)
    [4] = "#164459",
|ATTACK_POWER/s=<div class="Script_DefaultShownValue">260 {{lime}}[+15%]{{/lime}}</div><div class="Script_HiddenCalculatedValue">123</div> ~ <div class="Script_DefaultShownValue">333 {{lime}}[+15%]{{/lime}}</div><div class="Script_HiddenCalculatedValue">634</div>
    [5] = "#591639",
|ACCURACY= <div class="Script_DefaultShownValue">90.00% {{lime}}[+15.00%]{{/lime}}</div><div class="Script_HiddenCalculatedValue">70.00%</div>
    [6] = "lime",
|PIERCE= <div class="Script_DefaultShownValue">0.00% {{orange}}[+12.00%]{{/orange}}</div><div class="Script_HiddenCalculatedValue">0.00%</div>
    [7] = "white"  
|RANGE= 4000m
}
|REATTACK_TIME= 4.00s
 
|VALID_ANGLE=
-- Function to fetch Weapon Fixes data from the Cargo table
|SPEED= <div class="Script_DefaultShownValue">200m/s {{orange}}[-26.00%]{{/orange}} {{lime}}[-30.00%]{{/lime}}</div><div class="Script_HiddenCalculatedValue">120m/s</div>
function GetEnchants.getFixes(name, suffix)
|INDUCTION_RATE= 40°/s
    -- Query the Cargo table
|EXPLOSION_RADIUS= 0m
    local cargoTable = mw.ext.cargo.query({
|WEIGHT= 330kg
        tables = "WeaponFixes",
|CRAFT= [[File:Gigantic God Strength Icon.png|Gigantic God Strength|link=]] [[File:A-Type Datacube (Blue).png|A-Type Datacube (Blue)|link=]]
        fields = "Name, NameSuffix, NameColorID, Probability, WF_AttackMin, WF_AttackMax, WF_Accuracy, WF_Reattack, WF_Pierce, WF_Weight, WF_ValidAngle, WF_Range, WF_Overheat",
|Drop= [https://chromerivals.net/game/pedia/item/799624794709438500 Bishop Red]<br>Mob name <br> Other Mob name
        where = string.format("Name = '%s' AND NameSuffix = '%s'", name, suffix)
|Description= A powerful Missile forged by the ancient Phillons.
    })
}}
 
    -- Check if the query was successful
    if not cargoTable or #cargoTable == 0 then
        return nil, "No data found in the Cargo table"
    end
 
    -- Map cargo table data to a Lua table
    local data = cargoTable[1]
 
    -- Calculate the sum of prefix and suffix values for specific parameters
    calculateSum(data, suffix, "WF_AttackMin")
    calculateSum(data, suffix, "WF_AttackMax")
    calculateSum(data, suffix, "WF_Accuracy")
    calculateSum(data, suffix, "WF_Reattack")
    calculateSum(data, suffix, "WF_Pierce")
    calculateSum(data, suffix, "WF_Weight")
    calculateSum(data, suffix, "WF_ValidAngle")
    calculateSum(data, suffix, "WF_Range")
    calculateSum(data, suffix, "WF_Overheat")
 
    -- Return the mapped values
    return data
end
 
-- Function to parse and sum prefix and suffix values for a specific parameter
local function calculateSum(data, suffix, parameter)
    if data[parameter] and suffix[parameter] then
        -- Parse numerical values from strings
        local prefixNum = tonumber(data[parameter]) or 0
        local suffixNum = tonumber(suffix[parameter]) or 0
 
        -- If the parameter is WF_Reattack or WF_Weight, consider them as negative values
        if parameter == "WF_Reattack" or parameter == "WF_Weight" then
            suffixNum = -suffixNum
        end
 
        -- Add prefix and suffix values together
        local sum = prefixNum + suffixNum
 
        -- Store the sum in data
        data[parameter] = sum
    end
end
 
-- Function to get the color value based on the NameColorID
function GetEnchants.getColorPre(nameColorID)
    local colorValue = colorMap[tonumber(nameColorID)]
    if colorValue then
        return string.format('<span color="%s">', colorValue)
    else
        return "" -- Return empty string if color ID is invalid
    end
end
 
-- Function to get the NameColorID for a given Name or NameSuffix
function GetEnchants.getNameColorID(name)
    -- Query the Cargo table to get NameColorID for the given Name or NameSuffix
    local cargoTable = mw.ext.cargo.query({
        tables = "WeaponFixes",
        fields = "NameColorID",
        where = string.format("Name = '%s' OR NameSuffix = '%s'", name, name)
    })
 
    -- Check if the query was successful and if it returned any results
    if cargoTable and #cargoTable > 0 then
        return cargoTable[1].NameColorID
    else
        return nil -- Return nil(nothing) if no data found
    end
end
 
-- Export the Lua module
return GetEnchants

Revision as of 14:56, 9 May 2024