
from builders.mob_builder import MobBuilder, MobDirector
from handlers.party_handler import PartyHandler
from misc_functions.mob_chances import MobChances
from misc_functions.random_utils import random_choice_from_dict
from screens.encounter_screen import get_encounter_thinking_menu


class Combat:
    """Created by EncounterHandler at the start of CombatEncounter"""
    def __init__(self, party, tile):
        self.party = party
        self.enemies = self.get_mob_party(tile)
        self.grid = self.initialize_grid()

    def initialize_grid(self):
        grid = CombatGrid()
        if self.party.formation is 'Unorganized':
            grid.rows[3].extend(self.party.members)
        else:
            pass
        if self.enemies.formation is 'Unorganized':
            grid.rows[4].extend(self.enemies.members)
        else:
            pass

        return grid

    def get_mob_party(self, tile):
        mp = PartyHandler(self.get_mob(tile))
        return mp

    @staticmethod
    def get_mob(tile):
        mob_chances = MobChances(tile.type, tile.subtype, tile.np)
        mcs = mob_chances.get_mob_chances()
        monster_choice = random_choice_from_dict(mcs)

        mob_builder = MobBuilder(0, monster_choice)
        mob_director = MobDirector()
        mob_director.set_builder(mob_builder)
        mob = mob_director.get_mob()
        return mob

    def destroy(self, entity):
        self.enemies.remove(entity)
        self.grid.remove(entity)


class CombatGrid:
    """Holds combatants in rows, held by Combat"""

    def __init__(self):
        self.rows = [[], [], [], [], [], [], [], []]
        self.x = 4
        self.y = 0

    def remove(self, entity):
        for row in self.rows:
            try:
                row.remove(entity)
            except ValueError:
                pass




903bbfee355b947109b9f3dd95004b284e3a2d4c
<mask token>


class Combat:
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>


class CombatGrid:
    """Holds combatants in rows, held by Combat"""

    def __init__(self):
        self.rows = [[], [], [], [], [], [], [], []]
        self.x = 4
        self.y = 0

    def remove(self, entity):
        for row in self.rows:
            try:
                row.remove(entity)
            except ValueError:
                pass

<mask token>


class Combat:
    <mask token>
    <mask token>
    <mask token>

    def get_mob_party(self, tile):
        mp = PartyHandler(self.get_mob(tile))
        return mp

    @staticmethod
    def get_mob(tile):
        mob_chances = MobChances(tile.type, tile.subtype, tile.np)
        mcs = mob_chances.get_mob_chances()
        monster_choice = random_choice_from_dict(mcs)
        mob_builder = MobBuilder(0, monster_choice)
        mob_director = MobDirector()
        mob_director.set_builder(mob_builder)
        mob = mob_director.get_mob()
        return mob

    def destroy(self, entity):
        self.enemies.remove(entity)
        self.grid.remove(entity)


class CombatGrid:
    """Holds combatants in rows, held by Combat"""

    def __init__(self):
        self.rows = [[], [], [], [], [], [], [], []]
        self.x = 4
        self.y = 0

    def remove(self, entity):
        for row in self.rows:
            try:
                row.remove(entity)
            except ValueError:
                pass

<mask token>


class Combat:
    <mask token>

    def __init__(self, party, tile):
        self.party = party
        self.enemies = self.get_mob_party(tile)
        self.grid = self.initialize_grid()

    def initialize_grid(self):
        grid = CombatGrid()
        if self.party.formation is 'Unorganized':
            grid.rows[3].extend(self.party.members)
        else:
            pass
        if self.enemies.formation is 'Unorganized':
            grid.rows[4].extend(self.enemies.members)
        else:
            pass
        return grid

    def get_mob_party(self, tile):
        mp = PartyHandler(self.get_mob(tile))
        return mp

    @staticmethod
    def get_mob(tile):
        mob_chances = MobChances(tile.type, tile.subtype, tile.np)
        mcs = mob_chances.get_mob_chances()
        monster_choice = random_choice_from_dict(mcs)
        mob_builder = MobBuilder(0, monster_choice)
        mob_director = MobDirector()
        mob_director.set_builder(mob_builder)
        mob = mob_director.get_mob()
        return mob

    def destroy(self, entity):
        self.enemies.remove(entity)
        self.grid.remove(entity)


class CombatGrid:
    """Holds combatants in rows, held by Combat"""

    def __init__(self):
        self.rows = [[], [], [], [], [], [], [], []]
        self.x = 4
        self.y = 0

    def remove(self, entity):
        for row in self.rows:
            try:
                row.remove(entity)
            except ValueError:
                pass

<mask token>


class Combat:
    """Created by EncounterHandler at the start of CombatEncounter"""

    def __init__(self, party, tile):
        self.party = party
        self.enemies = self.get_mob_party(tile)
        self.grid = self.initialize_grid()

    def initialize_grid(self):
        grid = CombatGrid()
        if self.party.formation is 'Unorganized':
            grid.rows[3].extend(self.party.members)
        else:
            pass
        if self.enemies.formation is 'Unorganized':
            grid.rows[4].extend(self.enemies.members)
        else:
            pass
        return grid

    def get_mob_party(self, tile):
        mp = PartyHandler(self.get_mob(tile))
        return mp

    @staticmethod
    def get_mob(tile):
        mob_chances = MobChances(tile.type, tile.subtype, tile.np)
        mcs = mob_chances.get_mob_chances()
        monster_choice = random_choice_from_dict(mcs)
        mob_builder = MobBuilder(0, monster_choice)
        mob_director = MobDirector()
        mob_director.set_builder(mob_builder)
        mob = mob_director.get_mob()
        return mob

    def destroy(self, entity):
        self.enemies.remove(entity)
        self.grid.remove(entity)


class CombatGrid:
    """Holds combatants in rows, held by Combat"""

    def __init__(self):
        self.rows = [[], [], [], [], [], [], [], []]
        self.x = 4
        self.y = 0

    def remove(self, entity):
        for row in self.rows:
            try:
                row.remove(entity)
            except ValueError:
                pass


from builders.mob_builder import MobBuilder, MobDirector
from handlers.party_handler import PartyHandler
from misc_functions.mob_chances import MobChances
from misc_functions.random_utils import random_choice_from_dict
from screens.encounter_screen import get_encounter_thinking_menu


class Combat:
    """Created by EncounterHandler at the start of CombatEncounter"""
    def __init__(self, party, tile):
        self.party = party
        self.enemies = self.get_mob_party(tile)
        self.grid = self.initialize_grid()

    def initialize_grid(self):
        grid = CombatGrid()
        if self.party.formation is 'Unorganized':
            grid.rows[3].extend(self.party.members)
        else:
            pass
        if self.enemies.formation is 'Unorganized':
            grid.rows[4].extend(self.enemies.members)
        else:
            pass

        return grid

    def get_mob_party(self, tile):
        mp = PartyHandler(self.get_mob(tile))
        return mp

    @staticmethod
    def get_mob(tile):
        mob_chances = MobChances(tile.type, tile.subtype, tile.np)
        mcs = mob_chances.get_mob_chances()
        monster_choice = random_choice_from_dict(mcs)

        mob_builder = MobBuilder(0, monster_choice)
        mob_director = MobDirector()
        mob_director.set_builder(mob_builder)
        mob = mob_director.get_mob()
        return mob

    def destroy(self, entity):
        self.enemies.remove(entity)
        self.grid.remove(entity)


class CombatGrid:
    """Holds combatants in rows, held by Combat"""

    def __init__(self):
        self.rows = [[], [], [], [], [], [], [], []]
        self.x = 4
        self.y = 0

    def remove(self, entity):
        for row in self.rows:
            try:
                row.remove(entity)
            except ValueError:
                pass



