import os
import sys
import time

from owanimo.app.error import ERROR as e
from owanimo.script import allegory_special
from owanimo.util import define
from owanimo.util.log import LOG as L

class Allegory(allegory_special.Allegory):
    def __init__(self, runner, profile, player):
        allegory_special.Allegory.__init__(self, runner, profile, player)
        time.sleep(2)

    def before(self):
        L.info("*** Start Allegory   : %s *** " % __file__)
        self.start()

    def test(self):
        # Step 1 : Login
        result = self.check(True, self.login(), e.LOGIN)
        self.flush(self.step())
        if not result: return

        # Step 2 : Select Special Quest
        result = self.check(True,
            self.quest_special_material_highest(), e.SELECT_SP_QUEST)
        self.flush(self.step())
        if not result: return

        # Step 3 : Select Support
        result = self.check(True, self.support(), e.SUPPORT)
        self.flush(self.step())
        if not result: return

        # Step 4 : Normal Quest
        result = self.check(True, self.quest_puyo_all(), e.QUEST)
        self.flush(self.step())
        if not result: return

        # Step 5 : Normal Quest Result
        result = self.check(True, self.quest_result(), e.QUEST_RESULT)
        self.flush(self.step())
        if not result: return

    def after(self):
        L.info("*** End Allegory   : %s *** " % __file__)
        self.stop()
