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 (X) or Tumblr! |
Module:GhbRotation
From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.
For use on Grand Hero Battle and possibly other locations later on. This module can be used to output Grand Hero Battle data, including the first rerun date, the next rerun date, total number of reruns, and the current active Grand Hero Battle.
The only function, main
, takes three parameters, each of them corresponding to a year, a month number, and a day of a month, where the full date represents the first rerun date of a Grand Hero Battle.
{{#invoke:GhbRotation|main|2018|02|10}}
This outputs:
Script error: The function "main" does not exist.
local p = {}
--[[
Functions for each Grand Hero Battle. Lloyd was the first rotation GHB, on
9 February 2018, so he is number 0; the others follow on up to 6 (Ursula).
Then, call the main functions down below.
]]
function p.Lloyd()
return p.getGHBData(0)
end
function p.Michalis()
return p.getGHBData(1)
end
function p.Xander()
return p.getGHBData(2)
end
function p.Narcian()
return p.getGHBData(3)
end
function p.Navarre()
return p.getGHBData(4)
end
function p.RobinF()
return p.getGHBData(5)
end
function p.Ursula()
return p.getGHBData(6)
end
--[[
This gets the current Grand Hero Battle, by comparing today's date to
the rotation start date (8 February, 2018).
]]
function p.getGrandHeroBattle()
start_day = os.time( { year=2018, month=02, day=08, hour=07 } )
days_since_start = math.floor(os.difftime( os.time(), start_day ) / (24*60*60))
curr_ghb = days_since_start % 7
return curr_ghb
end
--[[
Produce the Grand 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 Grand Hero Battle is currently active.
]]
function p.getGHBData(ghb_number)
curr_ghb = p.getGrandHeroBattle()
-- Need to wrap around for Hero Battles with an ID number lower than the current one
if( ghb_number <= curr_ghb ) then
next_rerun_wrap = ghb_number + 7
else
next_rerun_wrap = ghb_number
end
next_rerun_days_away = next_rerun_wrap - curr_ghb
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=2018, month=02, day=08+ghb_number } ) ) / (24*60*60)/7)
if( ghb_number == curr_ghb ) then
is_active = "<b>Currently available</b><br/>"
else
is_active = ""
end
return string.format("Rerun in rotation %s times to date<br/>%sNext rerun: %s", total_reruns, is_active, next_rerun)
end
return p