Site News |
---|
Warning: This wiki contains spoilers. Read at your own risk! Social media: If you would like, please join our Discord server, and/or follow us on Twitter or Tumblr! Engage info: As the game has only recently released, we lack much key information. Please help add any info that you can. |
Module:HeroBattle
From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.
For use on Hero Battle and possibly other locations later on. This module can be used to output Hero Battle data, including the next rerun date, total number of reruns, and the current active Hero Battle.
Only one parameter is used, the name of the relevant Hero Battle:
{{#invoke:HeroBattle|Sophia}}
This outputs:
Rerun 187 times to date
Next rerun: April 9, 2023
local p = {}
--[[
Functions for each Hero Battle. Sophia was the first Hero Battle, on
launch day, so she is number 0; the others follow on up to 11 (Stahl).
Then, call the main functions down below.
]]
function p.Sophia()
hb_number = 0
return p.getHBData(hb_number)
end
function p.Virion()
hb_number = 1
return p.getHBData(hb_number)
end
function p.Hana()
hb_number = 2
return p.getHBData(hb_number)
end
function p.Subaki()
hb_number = 3
return p.getHBData(hb_number)
end
function p.Donnel()
hb_number = 4
return p.getHBData(hb_number)
end
function p.Lissa()
hb_number = 5
return p.getHBData(hb_number)
end
function p.Gunter()
hb_number = 6
return p.getHBData(hb_number)
end
function p.Cecilia()
hb_number = 7
return p.getHBData(hb_number)
end
function p.Felicia()
hb_number = 8
return p.getHBData(hb_number)
end
function p.Wrys()
hb_number = 9
return p.getHBData(hb_number)
end
function p.Olivia()
hb_number = 10
return p.getHBData(hb_number)
end
function p.Stahl()
hb_number = 11
return p.getHBData(hb_number)
end
--[[
This gets the current Hero Battle, by comparing today's date to
Heroes' launch date (2 February, 2017).
]]
function p.getHeroBattle()
launch_day = os.time( { year=2017, month=02, day=02, hour=07 } )
days_since_launch = math.floor(os.difftime( os.time(), launch_day ) / (24*60*60))
curr_hb = days_since_launch % 12
return curr_hb
end
--[[
Produce the Hero Battle data; first get the date of the next rerun,
then count how many reruns we've had so far, then check to see
which Hero Battle is currently active.
]]
function p.getHBData(hb_number)
curr_hb = p.getHeroBattle()
-- Need to wrap around for Hero Battles with an ID number lower than the current one
if( hb_number <= curr_hb ) then
next_rerun_wrap = hb_number + 12
else
next_rerun_wrap = hb_number
end
next_rerun_days_away = next_rerun_wrap - curr_hb
next_rerun = os.date("%B %e, %Y", os.time()+(24*60*60*next_rerun_days_away))
total_reruns = math.floor(os.difftime( os.time(), os.time( { year=2017, month=02, day=02+hb_number } ) ) / (24*60*60)/12)
if( hb_number == curr_hb ) then
is_active = "<b>Currently available</b><br/>"
else
is_active = ""
end
return string.format("Rerun %s times to date<br/>%sNext rerun: %s", total_reruns, is_active, next_rerun)
end
return p