Module:Weapon

-- -- Get other Required Modules local p = {} local weapons = require( Module:Weapon/Data ) local makeStat = require( Module:Statname )._getStatName local styleCoins = require( Module:Currency )._coins local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local mr = require('Module:RarityTier') local makeRarity, makeRarityLink = mr._getTier, mr._link local onmain = require('Module:Mainonly').on_main local makeStatsList = require("Module:Armor/StatsList") local string = require('Module:String') local color = require('Module:Color')

--Invokes --Gets Input from the Template function p.getWeaponInfo( frame ) local args = getArgs( frame ) local weapon = string.lower(args[1] or (onmain and mw.title.getCurrentTitle.text)) local a = string.lower(args[2])

return frame:preprocess(p._getWeaponInfo( weapon, a )) end

-- Module Access Point function p._getWeaponInfo( weaponName, a ) local weapon = weapons[weaponName] --Error Function if not weapon or not weaponName then return '' end --Local Parameters local ia = weapon.itemAbility local specialEffect = weapon.specialEffect local source = weapon.source local weapontype = weapon.weapontype local rarity = weapon.stats.rarity local all = function if not specialEffect then SE = '' else SE = ' '..specialEffect end if not ia.iaName then Name = '' else Name = ' ' end if not ia.iaDesc then Desc = '' else Desc = ia.iaDesc end if not ia.iaCost then Cost = '' else Cost = ' ' end if not ia.iaCooldown then Cooldown = '' else Cooldown = ' ' end if not ia.iaCooldownAlt then CooldownAlt = '' else CooldownAlt = ' '..ia.iaCooldownAlt end return SE..Name..Desc..Cost..Cooldown..CooldownAlt end --Set Parameters that dont have requested info to empty --Main if not ia then ia = {} end --Weapon Item Ability Description if not ia.iaDesc then ia.iaDesc = '' end --Weapon Item Ability Name if not ia.iaName then ia.iaName = '' end --Weapon Item Ability Mana Cost if not ia.iaCost then ia.iaCost = '' end --Weapon Item Ability Cooldown if not ia.iaCooldown then ia.iaCooldown = '' end --Weapon Item Ability Cooldown alternate text if not ia.iaCooldownAlt then ia.iaCooldownAlt = '' end --Weapon Special Effect if not specialEffect then specialEffect = '' end --Weapon Rarity if not rarity then rarity = '' end --Weapon Source if not source then source = '' end --Get the Weapon Info --Weapon Item Ability Description if a == 'ia desc' or a == 'item ability desc' or a == 'item ability description' or a == 'ia description' then outputInfo = ia.iaDesc --Weapon Item Ability Name elseif a == 'ia name' or a == 'item ability name' then outputInfo = ia.iaName --Weapon Item Ability Mana Cost elseif a == 'ia cost' or a == 'item ability cost' or a == 'ia mana cost' or a == 'item ability mana cost' then outputInfo = ia.iaCost --Weapon Item Ability Cooldown elseif a == 'ia cooldown' or a == 'item ability cooldown' then outputInfo = ia.iaCooldown --Weapon Item Ability Cooldown alternate text elseif a == 'ia cooldown alt' or a == 'item ability cooldown alt' or a == 'ia cd alt' or a == 'item ability cd alt' then outputInfo = ia.iaCooldownAlt --Weapon Special Effect elseif a == 'special effect' or a == 'weapon special effect' or a == 'sp eff' then outputInfo = specialEffect --Weapon Rarity elseif a == 'rarity' or a == 'r' or a == 'weapon rarity' then outputInfo = rarity --Weapon Type elseif a == 'type' or a == 'weapon type' or a == 't'           then outputInfo = weapontype --Weapon Source elseif a == 'source' or a == 'weapon source' or a == 's'           then outputInfo = source elseif a == 'all' or a == 'a' or a == 'load all' then outputInfo = all --Else Return Error else outputInfo = '' end return outputInfo end

--Invokes --Get Inputs from the Template function p.getWeaponStat( frame ) local args = getArgs( frame ) local weapon = string.lower(args[1]) or mw.title.getCurrentTitle.text local stat = string.lower(args[2]) return p._getWeaponStat( weapon, stat ) end

-- module access point function p._getWeaponStat( weaponName, stat ) local weapon = weapons[weaponName] --Error Function if not weapon or not weaponName then return ' Template Error: Bad Argument to #1 "'..weaponName..'" ' end local stats = weapon.stats --Set Nil Stats to 0 --Damage if not stats.dmg then stats.dmg = '0' end --Strength if not stats.str then stats.str = '0' end --Crit Chance if not stats.cc then stats.cc = '0' end --Crit Damage if not stats.cd then stats.cd = '0' end --Attack Speed if not stats.as then stats.as = '0' end --Intelligence if not stats.int then stats.int = '0' end --Speed if not stats.spd then stats.spd = '0' end --Defense if not stats.def then stats.def = '0' end --Health if not stats.hp then stats.hp = '0' end --Fishing Speed if not stats.fs then stats.fs = '0' end --Ferocity if not stats.fer then stats.fer = '0' end --Get Stats from Data Module --Damage if stat == 'dmg' or stat == 'damage' then outputStat = stats.dmg --Strength elseif stat == 'str' or stat == 'strength' then outputStat = stats.str --Crit Chance elseif stat == 'cc' or stat == 'crit chance' or stat == 'crit chnc' then outputStat = stats.cc       --Crit Damage elseif stat == 'cd' or stat == 'crit dmg' or stat == 'crit damage' then outputStat = stats.cd       --Attack Speed elseif stat == 'as' or stat == 'atk spd' or stat == 'attack speed' then outputStat = stats.as       --Intelligence elseif stat == 'int' or stat == 'intel' or stat == 'intelligence' then outputStat = stats.int --Speed elseif stat == 'spd' or stat == 'speed' or stat == 'movement speed' then outputStat = stats.spd --Defense elseif stat == 'def' or stat == 'defence' or stat == 'defense' then outputStat = stats.def --Health elseif stat == 'hp' or stat == 'health' or stat == 'hit points' then outputStat = stats.hp       --Fishing Speed elseif stat == 'fs' or stat == 'fishing speed' then outputStat = stats.fs           	--Strength elseif stat == 'fer' or stat == 'ferocity' then outputStat = stats.fer --Else Return Error else outputStat = string.error('Stat requested is unknown %q', stat) end --Return the Stat return outputStat end

--Invokes --Get Inputs from the Template function p._weaponStatsTable(frame) --local parameters = frame.args local args = getArgs(frame) local weapon = args[1] or args["weapon"] or args["w"] or mw.title.getCurrentTitle.text return frame:preprocess(p.weaponStatsTable(weapon)) end

-- module access point function p.weaponStatsTable(weaponName) local weapon = weapons[weaponName:lower] local stats, specialEffect, weaponType, rarity, ia = weapon.stats, weapon.specialEffect, weapon.type, weapon.stats.rarity, weapon.ia   local wikitable = mw.html.create('table') :addClass('article-table') :css({ ["max-width"]="50%" }) :tag("tr") :tag("th") :wikitext(                   string.centerText({ 'Weapon Stats', string.wrapHtml{ {                               string.makeLink('Module:Weapon/Data', 'v'), ' &bull; ', string.fullUrl('Module:Weapon/Data', { action="edit" }, 'e'), },                           ' ', {                                style={ ["float"]="right"; ["color"]="white"; ["font-size"]="75%"; },                           },                        },                    })                )            :done :done :tag('tr') :tag('td') :wikitext(makeRarityLink(rarity, weaponName)) :wikitext(makeStatsList(stats)) :wikitext(' ', 'Weapon Rarity: ') :wikitext(makeRarityLink(rarity)) :wikitext(' ', 'Weapon Type: ', string.makeLink(weaponType, { , weaponType,  })) :done :done if specialEffect then wikitable :tag('tr') :tag('th') :wikitext('Weapon Special Effect') :done :done :tag('tr') :tag('td') :wikitext(specialEffect) :done :done end if ia then wikitable :tag('tr') :tag('th') :wikitext('Weapon Item Ability') :done :done :tag('tr') :tag('td') :wikitext('') :wikitext(' ', (ia.desc:gsub('\n', ' '))) :done :done if ia.cost or ia.cooldown or ia.cooldownAlt then wikitable :tag('tr') :tag('td') :wikitext(                           (not ia.cooldownAlt and ia.cooldown) and color.makeColor('dark gray', 'Cooldown: ') or ia.cooldownAlt or ,                             (not ia.cooldownAlt and ia.cooldown) and color.makeColor('yellow', ia.cooldown) or ,                            (ia.cooldownAlt or ia.cooldown) and ' ' or ,                            ia.cost and color.makeColor('dark gray', 'Mana Cost: ') or ,                            ia.cost and makeStat('mana', tostring(ia.cost)) or ''                        ) :done :done end end --Return the Table return tostring(wikitable:done) end

-- Finish Module -- return p --''