from core.Config import Config
from core.Monitor import Monitor
from bots.battleground.battlegroundAgent import BattlegroundAgent
from bots.fishing.FishingAgent import FishingAgent
from bots.fighting.FightingAgent import FightingAgent
from bots.idling.IdlingAgent import IdlingAgent
from core.Player import Player, PLAYER_STATE

class MainAgent:
  def __init__(self, configName = "config ") -> None:
    self.config = Config(configName)
    self.monitor = Monitor(self.config)
    self.playerAgent = Player(self.monitor, self.config)
    self.idlingBot = IdlingAgent(self.monitor, self.playerAgent)
    self.fightingAgent = FightingAgent(self.monitor, self.playerAgent)
    self.fishingBot = FishingAgent(self.monitor, self.playerAgent)
    self.bgFarming = BattlegroundAgent(self.monitor, self.playerAgent)
    self.monitor.startScreenCaptureThread()
    # Start idling agent at the construction of the mainAgent for now
    self.idlingBot.run()

  def startFishBot(self):
    self.playerAgent.changeState(PLAYER_STATE.FISHING)
    self.fishingBot.run()

  def startBgBot(self):
    self.playerAgent.changeState(PLAYER_STATE.BG_FARMING)
    self.bgFarming.run()
  
  def toggleFightingAgent(self):
    if (self.fightingAgent is True):
      self.fightingAgent.stopFighting()
    else:
      self.fightingAgent.run()


