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 Normal Battle
        result = self.check(True, self.battle_arena("special/battle_30BP.png"), e.START_BATTLE)
        self.flush(self.step())
        if not result: return

        # Step 3 : Normal Battle
        result = self.check(True, self.battle_puyo(), e.PUYO_BATTLE)
        self.flush(self.step())
        if not result: return

        # Step 4 : Battle Result
        result = self.check(True, self.battle_arena_result(), e.CHECK_BATTLE)
        self.flush(self.step())
        if not result: return

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