package com.gh.common.chain

import android.content.Context
import com.gh.common.simulator.NewSimulatorGameManager
import com.gh.common.simulator.SimulatorGameManager
import com.gh.gamecenter.feature.entity.GameEntity

class UpdateNewSimulatorHandler: DownloadChainHandler() {

    override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
        if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
            if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
                NewSimulatorGameManager.showUpdateNewsSimulator(context, gameEntity) {
                    if (hasNext()) {
                        getNext()?.handleRequest(context, gameEntity, asVGame)
                    } else {
                        processEndCallback?.invoke(asVGame, null)
                    }
                }
            } else {
                if (hasNext()) {
                    getNext()?.handleRequest(context, gameEntity, asVGame)
                }
            }
        } else {
            if (hasNext()) {
                getNext()?.handleRequest(context, gameEntity, asVGame)
            }
        }
    }
}