#!/usr/bin/env python

from evennia import CmdSet

from commands.command import Command
from utils.scoring import Scores


class CmdScore(Command):
    """
    Display your score.

    Usage:

      score

    The more things you do in this game, the better your scorecard.
    """
    key = "score"
    aliases = ["scorecard"]

    def func(self):
        """
        Implements the score command.
        """
        def checked(tick):
            return " |g✔|n " if score & tick.value else " |r-|n "

        score = self.caller.attributes.get('score', 0)
        total = len([1 for tick in list(Scores) if score & tick.value])

        msg = "Your scorecard is:|/" + "|/".join([
            checked(Scores.jump) + "Jumped in a puddle",
            checked(Scores.moss_sit) + "Sat on some moss",
            checked(Scores.throw_stick) + "Thrown a stick",
            checked(Scores.catch_fish) + "Caught a fish",
            checked(Scores.feed_bhb) + "Fed Big Hairy Beast",
            checked(Scores.eat_candy) + "Eaten a candy",
            checked(Scores.get_cocktail) + "Got a cocktail",
            checked(Scores.finish_cocktail) + "Finished a cocktail",
            checked(Scores.make_tea) + "Made a pot of tea",
            checked(Scores.read_a_book) + "Read a book from Dabbler's library",
            checked(Scores.blow_horn) + "Called on the Mist Horn",
            checked(Scores.get_pipe) + "Received a smoking pipe",
            checked(Scores.get_blue_medal) + "Found the Blue Medal",
            checked(Scores.make_potion) + "Made a potion",
        ]) + f"|/Total: {total}"

        self.caller.msg(msg)
