-- Puk family mixin
require('scripts/globals/mixins')
-----------------------------------

g_mixins = g_mixins or {}
g_mixins.families = g_mixins.families or {}

g_mixins.families.puk = function(mob)
    mob:addListener('SPAWN', 'PUK_SPAWN', function(puk)
        puk:setMod(xi.mod.WIND_ABSORB, 100)
    end)

    mob:addListener('TAKE_DAMAGE', 'PUK_TAKE_DAMAGE', function(puk, amount, attacker, attackType, damageType)
        local elements =
        {
            { xi.damageType.FIRE,    xi.day.FIRESDAY     },
            { xi.damageType.EARTH,   xi.day.EARTHSDAY    },
            { xi.damageType.WATER,   xi.day.WATERSDAY    },
            { xi.damageType.WIND,    xi.day.WINDSDAY     },
            { xi.damageType.ICE,     xi.day.ICEDAY       },
            { xi.damageType.THUNDER, xi.day.LIGHTNINGDAY },
            { xi.damageType.LIGHT,   xi.day.LIGHTSDAY    },
            { xi.damageType.DARK,    xi.day.DARKSDAY     }
        }

        -- If the element corresponding to the elemental day of the in-game Vana'diel week is used on a Puk, it will get 100% TP instantly.
        for k, v in pairs(elements) do
            if damageType == v[1] and VanadielDayOfTheWeek() == v[2] then
                puk:addTP(1000)
            end
        end
    end)
end

return g_mixins.families.puk
