Ejemplo n.º 1
0
def test_get_active_minion():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    
    minionBoard.activeMinion = minionA
    
    assert(minionBoard.get_active_minion() == minionA)
Ejemplo n.º 2
0
def test_add_minion_to_right_empty_minion_list():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    
    minionBoard.minions = []
    minionBoard.add_minion_to_right(minionA)
    
    assert(minionBoard.minions == [minionA])
Ejemplo n.º 3
0
    def __init__(self, manager, boardNumber):
        self.manager = manager  # This feels messy but is required for Old Murkeye buff as old murkeye looks at opponents board

        self.boardNumber = boardNumber
        self.minions = MinionBoard(self)
        self.deathrattles = []
        self.staticEffects = []
        self.personalEffects = []

        self.deadMinions = []
        self.usedMinions = []
        self.activeMinionIndex = 0
Ejemplo n.º 4
0
def test_add_minion_to_right():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    
    minionBoard.minions = [minionA, minionB]
    minionBoard.add_minion_to_right(minionC)
    
    assert(minionBoard.minions == [minionA, minionB, minionC])
Ejemplo n.º 5
0
def test_add_minion_with_reference():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    
    newMinion = MagicMock()
    
    minionBoard.minions = [minionA, minionB, minionC]
    minionBoard.add_minion_with_reference(newMinion, minionB)
    
    assert(minionBoard.minions == [minionA, minionB, newMinion, minionC])
Ejemplo n.º 6
0
def test_set_next_active_minion_simple():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionA.name = "MinionA"
    
    minionB = MagicMock()
    minionB.name = "MinionB"
    
    minionBoard.minions = [minionA, minionB]
    
    minionBoard.set_next_active_minion()
    
    assert(minionBoard.activeMinion == minionA)
    assert(minionBoard.boardSnapshot == [minionA, minionB])
Ejemplo n.º 7
0
def test_set_next_active_minion_multiple_active_children():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    minionD = MagicMock()
    
    childB1 = MagicMock()
    childB2 = MagicMock()
    childB3 = MagicMock()
    
    childB1.parentMinions = [minionB]
    childB2.parentMinions = [minionB]
    childB3.parentMinions = [minionB]
    
    minionBoard.minions = [minionA, childB1, childB2, childB3, minionC, minionD]
    minionBoard.boardSnapshot = [minionA, minionB, minionC, minionD]
    minionBoard.activeMinion = minionB
    
    minionBoard.set_next_active_minion()
    
    assert(minionBoard.activeMinion == childB1)
    assert(minionBoard.boardSnapshot == [minionA, childB1, childB2, childB3, minionC, minionD])
Ejemplo n.º 8
0
def test_set_next_active_minion_all_children():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    minionD = MagicMock()
    
    childA1 = MagicMock()
    childB1 = MagicMock()
    childC1 = MagicMock()
    
    childA1.parentMinions = [minionA]
    childB1.parentMinions = [minionB]
    childC1.parentMinions = [minionC]
    
    minionBoard.minions = [childA1, childB1, childC1]
    minionBoard.boardSnapshot = [minionA, minionB, minionC, minionD]
    minionBoard.activeMinion = minionB
    
    minionBoard.set_next_active_minion()
    
    assert(minionBoard.activeMinion == childB1)
    assert(minionBoard.boardSnapshot == [childA1, childB1, childC1])
Ejemplo n.º 9
0
def test_set_next_active_minion_right_minions_children():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    minionD = MagicMock()
    
    childC1 = MagicMock()
    childC2 = MagicMock()
    childC3 = MagicMock()
    
    childC1.parentMinions = [minionC]
    childC2.parentMinions = [minionC]
    childC3.parentMinions = [minionC]
    
    minionBoard.minions = [minionA, childC1, childC2, childC3, minionD]
    minionBoard.boardSnapshot = [minionA, minionB, minionC, minionD]
    minionBoard.activeMinion = minionB
    
    minionBoard.set_next_active_minion()
    
    assert(minionBoard.activeMinion == childC1)
    assert(minionBoard.boardSnapshot == [minionA, childC1, childC2, childC3, minionD])
Ejemplo n.º 10
0
def test_set_next_active_minion_active_minion_dead():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    minionD = MagicMock()

    minionBoard.minions = [minionA, minionC, minionD]
    minionBoard.boardSnapshot = [minionA, minionB, minionC, minionD]
    minionBoard.activeMinion = minionB
    
    minionBoard.set_next_active_minion()
    
    assert(minionBoard.activeMinion == minionC)
    assert(minionBoard.boardSnapshot == [minionA, minionC, minionD])
Ejemplo n.º 11
0
def test_add_minion_with_reference_all_left_minions_dead():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    
    newMinion = MagicMock()
    
    minionBoard.minions = [minionC]
    minionBoard.boardSnapshot = [minionA, minionB, minionC]
    minionBoard.add_minion_with_reference(newMinion, minionB)
    
    assert(minionBoard.minions == [newMinion, minionC])
Ejemplo n.º 12
0
def test_set_next_active_minion_active_children_parent_lives():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    minionD = MagicMock()
    
    childB1 = MagicMock()
    
    childB1.parentMinions = [minionB]
    
    minionBoard.minions = [minionA, minionB, childB1, minionC, minionD]
    minionBoard.boardSnapshot = [minionA, minionB, minionC, minionD]
    minionBoard.activeMinion = minionB
    
    minionBoard.set_next_active_minion()
    
    assert(minionBoard.activeMinion == childB1)
    assert(minionBoard.boardSnapshot ==  [minionA, minionB, childB1, minionC, minionD])
Ejemplo n.º 13
0
def test_add_minion_with_reference_dead_minion_and_child_neighbour():
    masterBoard = MagicMock()
    minionBoard = MinionBoard(masterBoard)
    
    minionA = MagicMock()
    minionB = MagicMock()
    minionC = MagicMock()
    
    childA1 = MagicMock()
    childA2 = MagicMock()
    childA1.parentMinions = [minionA]
    childA2.parentMinions = [minionA]
    
    newMinion = MagicMock()
    
    minionBoard.minions = [childA1, childA2, minionC]
    minionBoard.boardSnapshot = [minionA, minionB, minionC]
    minionBoard.add_minion_with_reference(newMinion, minionB)
    
    assert(minionBoard.minions == [childA1, childA2, newMinion, minionC])
Ejemplo n.º 14
0
class PlayerBoard:
    def __init__(self, manager, boardNumber):
        self.manager = manager  # This feels messy but is required for Old Murkeye buff as old murkeye looks at opponents board

        self.boardNumber = boardNumber
        self.minions = MinionBoard(self)
        self.deathrattles = []
        self.staticEffects = []
        self.personalEffects = []

        self.deadMinions = []
        self.usedMinions = []
        self.activeMinionIndex = 0

    def add_minion_to_right(self, minion):
        """
            Adds a minion to the rightmost position of the board
        """
        return self.minions.add_minion_to_right(minion)

    def add_minion_at_index(self, minion, index):
        """
            Adds a minion at position "index" of the board
        """
        return self.minion.add_minion_at_index(self, minion, index)

    def add_minion_with_reference(self, newMinion, referenceMinion):
        """
            Adds a minion to the right of the reference minion
            If said minion is no longer on the board, adds it to the right of its previous left neighbour, or that minions children
            If no left neighbours remain, adds minion at index 0
        """
        self.minions.add_minion_with_reference(newMinion, referenceMinion)

    def remove_minion(self, minion):
        self.minions.remove(minion)

    def remmove_minion_by_index(self, index):
        self.minions.pop(index)

    def update_minion_data(self):
        self._update_minion_locations()
        self._update_static_effects()
        self._update_personal_effects()
        self._update_deathrattles()
        self._reset_anthems()
        self._update_minion_stats()
        self._update_for_lethal_damage()

    def get_leftmost_minion(self):
        return self.minions[0]

    def get_attackable_targets(self):
        taunts = [x for x in self.minions if x.hasTaunt == True]
        if len(taunts) > 0:
            return taunts
        else:
            return self.minions

    def apply_buff(self, minion, buff):
        minion.buffs.append(buff)

    def _update_for_lethal_damage(self):
        for minion in self.minions:
            if minion.currentHealth <= 0:
                minion.isDead = True

    def _update_minion_locations(self):
        for minion in self.minions:
            minion.location = self.minions.index(minion)

    def _update_static_effects(self):
        """
            Denesting list comprehension in the form [x for y in z for x in y]
            Unpacks all minions static effects into one flat list
            Method uses minion order left to right, preserves effect order in minions themselves
        """
        self.staticEffects = [
            effect for minion in self.minions
            for effect in minion.staticEffects
        ]

    def _update_personal_effects(self):
        """
            Denesting list comprehension in the form [x for y in z for x in y]
            Unpacks all minions personal effects into one flat list
            Method uses minion order left to right, preserves effect order in minions themselves
        """
        self.personalEffects = [
            effect for minion in self.minions
            for effect in minion.personalEffects
        ]

    def _update_deathrattles(self):
        """
            Denesting list comprehension in the form [x for y in z for x in y]
            Unpacks all minions deathrattles into one flat list
            Method uses minion order left to right, preserves effect order in minions themselves
        """
        self.deathrattles = [
            dr for minion in self.minions for dr in minion.deathrattles
        ]

    def _reset_anthems(self):
        for minion in self.minions:
            minion.buffs = [x for x in minion.buffs if x.buffType != "anthem"]

        anthems = [x for x in self.staticEffects if x.effectType == "anthem"]
        for anthem in anthems:
            for minion in self.minions:
                if anthem.condition(minion):
                    self.apply_buff(minion, anthem.get_buff(self.manager))

    def _update_minion_stats(self):
        for minion in self.minions:
            minion.update_stats()