Module:Sandbox/Hubianzhen/BTD6 rewards
Documentation for this module may be created at Module:Sandbox/Hubianzhen/BTD6 rewards/doc
local p = {}
local cg = mw.ext.cargo
local tower_names = {
DartMonkey = 'Dart Monkey',
BoomerangMonkey = 'Boomerang Monkey',
BombShooter = 'Bomb Shooter',
TackShooter = 'Tack Shooter',
IceMonkey = 'Ice Monkey',
GlueGunner = 'Glue Gunner',
SniperMonkey = 'Sniper Monkey',
MonkeySub = 'Monkey Sub',
MonkeyBuccaneer = 'Monkey Buccaneer',
MonkeyAce = 'Monkey Ace',
HeliPilot = 'Heli Pilot',
MortarMonkey = 'Mortar Monkey',
DartlingGunner = 'Dartling Gunner',
WizardMonkey = 'Wizard Monkey',
SuperMonkey = 'Super Monkey',
NinjaMonkey = 'Ninja Monkey',
Alchemist = 'Alchemist',
Druid = 'Druid',
Mermonkey = 'Mermonkey',
BananaFarm = 'Banana Farm',
SpikeFactory = 'Spike Factory',
MonkeyVillage = 'Monkey Village',
EngineerMonkey = 'Engineer Monkey',
BeastHandler = 'Beast Handler'
}
local towers = {
DartMonkey = '000-DartMonkey.png|x20px|link=Dart Monkey (BTD6)]] Dart Monkey',
BoomerangMonkey = '000-BoomerangMonkey.png|x20px|link=Boomerang Monkey (BTD6)]] Boomerang Monkey',
BombShooter = '000-BombShooter.png|x20px|link=Bomb Shooter (BTD6)]] Bomb Shooter',
TackShooter = '000-TackShooter.png|x20px|link=Tack Shooter (BTD6)]] Tack Shooter',
IceMonkey = '000-IceMonkey.png|x20px|link=Ice Monkey (BTD6)]] Ice Monkey',
GlueGunner = '000-GlueGunner.png|x20px|link=Glue Gunner (BTD6)]] Glue Gunner',
SniperMonkey = '000-SniperMonkey.png|x20px|link=Sniper Monkey (BTD6)]] Sniper Monkey',
MonkeySub = '000-MonkeySub.png|x20px|link=Monkey Sub (BTD6)]] Monkey Sub',
MonkeyBuccaneer = '000-MonkeyBuccaneer.png|x20px|link=Monkey Buccaneer (BTD6)]] Monkey Buccaneer',
MonkeyAce = '000-MonkeyAce.png|x20px|link=Monkey Ace (BTD6)]] Monkey Ace',
HeliPilot = '000-HeliPilot.png|x20px|link=Heli Pilot (BTD6)]] Heli Pilot',
MortarMonkey = '000-MortarMonkey.png|x20px|link=Mortar Monkey (BTD6)]] Mortar Monkey',
DartlingGunner = '000-DartlingGunner.png|x20px|link=Dartling Gunner (BTD6)]] Dartling Gunner',
WizardMonkey = '000-WIzard.png|x20px|link=Wizard Monkey (BTD6)]] Wizard Monkey',
SuperMonkey = '000-SuperMonkey.png|x20px|link=Super Monkey (BTD6)]] Super Monkey',
NinjaMonkey = '000-NinjaMonkey.png|x20px|link=Ninja Monkey (BTD6)]] Ninja Monkey',
Alchemist = '000-Alchemist.png|x20px|link=Alchemist (BTD6)]] Alchemist',
Druid = '000-Druid.png|x20px|link=Druid (BTD6)]] Druid',
Mermonkey = '000-Mermonkey.png|x20px|link=Mermonkey (BTD6)]] Mermonkey',
BananaFarm = '000-BananaFarm.png|x20px|link=Banana Farm (BTD6)]] Banana Farm',
SpikeFactory = '000-SpikeFactory.png|x20px|link=Spike Factory (BTD6)]] Spike Factory',
MonkeyVillage = '000-MonkeyVillage.png|x20px|link=Monkey Village (BTD6)]] Monkey Village',
EngineerMonkey = '000-EngineerMonkey.png|x20px|link=Engineer Monkey (BTD6)]] Engineer Monkey',
BeastHandler = '000-BeastHandler.png|x20px|link=Beast Handler (BTD6)]] Beast Handler'
}
local insta_towers = {
DartMonkey = '000-DartMonkeyInsta.png|x20px|link=Dart Monkey (BTD6)',
BoomerangMonkey = '000-BoomerangMonkeyInsta.png|x20px|link=Boomerang Monkey (BTD6)',
BombShooter = '000-BombShooterInsta.png|x20px|link=Bomb Shooter (BTD6)',
TackShooter = '000-TackShooterInsta.png|x20px|link=Tack Shooter (BTD6)',
IceMonkey = '000-IceMonkeyInsta.png|x20px|link=Ice Monkey (BTD6)',
GlueGunner = '000-GlueGunnerInsta.png|x20px|link=Glue Gunner (BTD6)',
SniperMonkey = '000-SniperMonkeyInsta.png|x20px|link=Sniper Monkey (BTD6)',
MonkeySub = '000-MonkeySubInsta.png|x20px|link=Monkey Sub (BTD6)',
MonkeyBuccaneer = '000-MonkeyBuccaneerInsta.png|x20px|link=Monkey Buccaneer (BTD6)',
MonkeyAce = '000-MonkeyAceInsta.png|x20px|link=Monkey Ace (BTD6)',
HeliPilot = '000-HeliPilotInsta.png|x20px|link=Heli Pilot (BTD6)',
MortarMonkey = '000-MortarMonkeyInsta.png|x20px|link=Mortar Monkey (BTD6)',
DartlingGunner = '000-DartlingGunnerInsta.png|x20px|link=Dartling Gunner (BTD6)',
WizardMonkey = '000-WIzardInsta.png|x20px|link=Wizard Monkey (BTD6)',
SuperMonkey = '000-SuperMonkeyInsta.png|x20px|link=Super Monkey (BTD6)',
NinjaMonkey = '000-NinjaMonkeyInsta.png|x20px|link=Ninja Monkey (BTD6)',
Alchemist = '000-AlchemistInsta.png|x20px|link=Alchemist (BTD6)',
Druid = '000-DruidInsta.png|x20px|link=Druid (BTD6)',
Mermonkey = '000-MermonkeyInsta.png|x20px|link=Mermonkey (BTD6)',
BananaFarm = '000-BananaFarmInsta.png|x20px|link=Banana Farm (BTD6)',
SpikeFactory = '000-SpikeFactoryInsta.png|x20px|link=Spike Factory (BTD6)',
MonkeyVillage = '000-MonkeyVillageInsta.png|x20px|link=Monkey Village (BTD6)',
EngineerMonkey = '000-EngineerMonkeyInsta.png|x20px|link=Engineer Monkey (BTD6)',
BeastHandler = '000-BeastHandlerInsta.png|x20px|link=Beast Handler (BTD6)'
}
local reward_for_type = {
['FullTowerUnlock'] = function(value)
return string.format('[[File:BTD6 %s', towers[value])
end,
['InstaMonkey'] = function(value)
local delimiter = string.find(value, ',')
return string.format('[[File:BTD6 %s]] %s-%s-%s', insta_towers[string.sub(value, 1, delimiter - 1)],
string.sub(value, delimiter + 1, delimiter + 1),
string.sub(value, delimiter + 2, delimiter + 2),
string.sub(value, delimiter + 3, delimiter + 3)
)
end,
['RandomInstaMonkey'] = function(value)
local values = {}
for v in string.gmatch(value, '([^,]+)') do
table.insert(values, v)
end
local tier = values[1]
local amt = values[2]
local tower = tower_names[values[3]]
-- tier 0
if values[1] == "0" then
if #values == 3 then
-- random tier 0 of a specific tower
return string.format('[[File:BTD6 InstaRandomTier1.png|x20px|Tier 0 %s Insta Monkey|link=Insta Monkey]] %s ×%s', tower, tower, amt)
else
-- random tier 0
return string.format('[[File:BTD6 InstaRandomTier1.png|x20px|Tier 0 Insta Monkey|link=Insta Monkey]] ×%s', amt)
end
else
if #values == 3 then
-- random tier X of a specific tower
return string.format('[[File:BTD6 InstaRandomTier%s.png|x20px|Tier %s %s Insta Monkey|link=Insta Monkey]] %s ×%s', tier, tier, tower, tower, amt)
else
-- random tier X
return string.format('[[File:BTD6 InstaRandomTier%s.png|x20px|Tier %s Insta Monkey|link=Insta Monkey]] ×%s', tier, tier, amt)
end
end
end,
}
function p.parse(text)
local reward_text = {}
-- split text by '#'
for reward in string.gmatch(text, '([^#]+)') do
-- split reward by ':'
local delimiter = string.find(reward, ':')
if delimiter ~= nil then
table.insert(reward_text, reward_for_type[string.sub(reward, 1, delimiter - 1)](string.sub(reward, delimiter + 1, string.len(reward))))
--[[if string.sub(reward, 1, delimiter - 1) == 'TrophyStoreItem' and source ~= nil then
cg.store('btd6_cosmetic_sources', {
name = source,
item = string.sub(reward, delimiter + 1, string.len(reward))
})
end]]--
else
table.insert(reward_text, reward_for_type[reward]())
end
end
return table.concat(reward_text, ', ')
end
function p.main(frame)
return p.parse(frame.args[1])
end
return p