-- [[ mirror formspec :

function selfcare.form.Hygiene(name)
    local plyr = minetest.get_player_by_name(name)

    local s_unedited = selfcare.get(plyr, "smell") or "clean" -- the 'or' prevents crashing
    local s = (s_unedited == "bad") and "bad!" or s_unedited
    local h = selfcare.get(plyr, "hair") or "clean"
    local c = selfcare.get(plyr, "condish") or "soft"
    local t = selfcare.get(plyr, "teeth") or "white"
    local to = selfcare.get(plyr, "tongue") or "pink"
    local b = selfcare.get(plyr, "breath") or "minty"
    local p = tn(selfcare.get(plyr, "pimples")) or 0
    local fs = selfcare.get(plyr, "faceskin") or "clean" -- cleanliness
    local _fs = selfcare.get(plyr, "_faceskin") or "soft" -- dryness
    local pf = selfcare.get(plyr, "perfume") or "not"
    local _t = selfcare.get(plyr, "_teeth") or "nothing"
    local bdr = selfcare.get(plyr, "b_dryness") or "smooth"
    local bdi = selfcare.get(plyr, "b_dirtiness") or "clean"
    local bi = selfcare.get(plyr, "b_itchiness") or "not"

    local p_spelling = (p == 1) and " pimple" or " pimples"

    local form = "size[4.8,3.8]" ..
	"background[4.5,2;0,0;default_aspen_wood.png^[opacity:50;true]" ..
        "label[0,-0.1;You smell "..s.."]" ..
        "label[0,0.3;Your hair's "..h.." and "..c.."]" ..
        "label[0,0.7;Your teeth are "..t..", breath is "..b..",]" ..
        "label[0,1.1;tongue is "..to..", and there's ".._t.."]" ..
        "label[0,1.5;in-between your teeth.]" ..
        "label[0,1.9;You have "..p..p_spelling.."]" ..
        "label[0,2.3;Your face is "..fs.." and ".._fs.."]" ..
        "label[0,2.7;You "..pf.." wearing perfume]" ..
        "label[0,3.1;Your skin is "..bdr..", "..bdi..",]" ..
        "label[0,3.5;and "..bi.." itchy]" ..
        "button_exit[4.4,-0.2;0.6,0.2;exit;x]"

    minetest.show_formspec(name, "self_care:hygiene", form)
    return form
end




-- [[ figuring out what to show on mirror

local function get_overall_health(plyr)
    local to = selfcare.get(plyr, "tongue") or "pink"
    local b = selfcare.get(plyr, "breath") or "minty"
    local p = tn(selfcare.get(plyr, "pimples")) or 0
    local _t = selfcare.get(plyr, "_teeth") or "nothing"
    local bdr = selfcare.get(plyr, "b_dryness") or "smooth"
    local bdi = selfcare.get(plyr, "b_dirtiness") or "clean"
    local bi = selfcare.get(plyr, "b_itchiness") or "not"
    local __bs, __p, __m = 0, 0, 0

-- why do i do this to myself...

	if bdr == "smooth" or bdr == "soft" then __bs = __bs + 12 end
	if bdr == "normal" then __bs = __bs + 9 end
	if bdr == "slightly dry" or bdr == "slightly flaky" then __bs = __bs + 6 end
	if bdr == "flaky" then __bs = __bs + 3 end
	if bdi == "clean" or bdi == "neutral" then __bs = __bs + 10 end
	if bdi == "slightly unclean" or bdi == "slightly dirty" then __bs = __bs + 6 end
	if bdi == "dirty" or bdi == "grimy" then __bs = __bs + 3 end
	if bi == "" then __bs = __bs + 12 end
	if bi == "a bit" then __bs = __bs + 10 end
	if bi == "very" then __bs = __bs + 6 end
	if bi == "irritatingly" then __bs = __bs + 2 end

	if p > 4 then __p = __p + 5 end
	if p > 2 then __p = __p + 13 end
	if p > 0 then __p = __p + 23 end
	if p == 0 then __p = __p + 34 end

	if to == "pink" then __m = __m + 14 end
	if to == "peach" then __m = __m + 10 end
	if to == "yellow" then __m = __m + 5 end
	if _t == "nothing" then __m = __m + 15 end
	if _t == "some dirt" or _t == "build-up" then __m = __m + 11 end
	if _t == "plaque" then __m = __m + 6 end
	if _t == "a plaque colony" then __m = __m + 2 end -- yikes!
	if b == "minty" then __m = __m + 12 end
	if b == "neutral" then __m = __m + 9 end
	if b == "slightly bad" then __m = __m + 7 end
	if b == "bad" then __m = __m + 4 end

	local body = ts_state(__bs, "body")
	local pimples = ts_state(__p, "pimples")
	local mouth = ts_state(__m, "mouth")


	return {pimples = pimples, bskin = body, mouth = mouth}
end