from mower.utils.scene import Scene
from mower.utils.solver import BaseSolver

from .utils import edge

# 商店


@edge(Scene.SHOP_OTHERS, Scene.SHOP_CREDIT)
@edge(Scene.SHOP_TOKEN, Scene.SHOP_CREDIT)
def shop_credit(solver: BaseSolver):
    solver.switch_shop("credit")


@edge(Scene.SHOP_OTHERS, Scene.SHOP_TOKEN)
@edge(Scene.SHOP_CREDIT, Scene.SHOP_TOKEN)
def shop_token(solver: BaseSolver):
    solver.switch_shop("token")


@edge(Scene.SHOP_CREDIT_CONFIRM, Scene.SHOP_CREDIT)
@edge(Scene.SHOP_UNLOCK_SCHEDULE, Scene.SHOP_CREDIT)
def shop_back(solver: BaseSolver):
    solver.back()


@edge(Scene.SHOP_TRADE_TOKEN, Scene.SHOP_TOKEN)
def trade_cancel(solver: BaseSolver):
    solver.tap_element("shop/trade_token_dialog", x_rate=0)
