diff --git a/sapai/data.py b/sapai/data.py index 82600a3..fa506fb 100644 --- a/sapai/data.py +++ b/sapai/data.py @@ -246,7 +246,7 @@ "unicodeCodePoint": "🦫", }, "tier": 1, - "baseAttack": 2, + "baseAttack": 3, "baseHealth": 2, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { @@ -837,7 +837,7 @@ "unicodeCodePoint": "🦆", }, "tier": 1, - "baseAttack": 1, + "baseAttack": 2, "baseHealth": 3, "packs": ["StandardPack"], "level1Ability": { @@ -953,7 +953,7 @@ }, "tier": 1, "baseAttack": 2, - "baseHealth": 3, + "baseHealth": 2, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "Level-up: Give all friends +1/+1", @@ -1535,7 +1535,7 @@ "baseHealth": 2, "packs": ["StandardPack"], "level1Ability": { - "description": "Buy: Give a random friend +1/+1", + "description": "Buy: Give one random friend +1/+1", "trigger": "Buy", "triggeredBy": {"kind": "Self"}, "effect": { @@ -1547,26 +1547,26 @@ }, }, "level2Ability": { - "description": "Buy: Give a random friend +2/+2", + "description": "Buy: Give two random friend +1/+1", "trigger": "Buy", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", - "target": {"kind": "RandomFriend", "n": 1}, - "attackAmount": 2, - "healthAmount": 2, + "target": {"kind": "RandomFriend", "n": 2}, + "attackAmount": 1, + "healthAmount": 1, "untilEndOfBattle": False, }, }, "level3Ability": { - "description": "Buy: Give a random friend +3/+3", + "description": "Buy: Give three random friend +1/+1", "trigger": "Buy", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", - "target": {"kind": "RandomFriend", "n": 1}, - "attackAmount": 3, - "healthAmount": 3, + "target": {"kind": "RandomFriend", "n": 3}, + "attackAmount": 1, + "healthAmount": 1, "untilEndOfBattle": False, }, }, @@ -1648,7 +1648,7 @@ "unicodeCodePoint": "🐖", }, "tier": 1, - "baseAttack": 3, + "baseAttack": 4, "baseHealth": 1, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { @@ -1937,11 +1937,11 @@ }, "tier": 2, "baseAttack": 3, - "baseHealth": 3, + "baseHealth": 1, "packs": ["StandardPack"], "level1Ability": { - "description": "Buy: Copy Health from the most healthy friend", - "trigger": "Buy", + "description": "Start of battle: copy 50% of health from most healthy friend", + "trigger": "StartOfBattle", "triggeredBy": {"kind": "Player"}, "effect": { "kind": "TransferStats", @@ -1949,11 +1949,12 @@ "copyHealth": True, "from": {"kind": "HighestHealthFriend"}, "to": {"kind": "Self"}, + "percentage": 50, }, }, "level2Ability": { - "description": "Buy: Copy Health from the most healthy friend", - "trigger": "Buy", + "description": "Start of battle: copy 100% of health from most healthy friend", + "trigger": "StartOfBattle", "triggeredBy": {"kind": "Player"}, "effect": { "kind": "TransferStats", @@ -1961,11 +1962,12 @@ "copyHealth": True, "from": {"kind": "HighestHealthFriend"}, "to": {"kind": "Self"}, + "percentage": 100, }, }, "level3Ability": { - "description": "Buy: Copy Health from the most healthy friend", - "trigger": "Buy", + "description": "Start of battle: copy 150% of health from most healthy friend", + "trigger": "StartOfBattle", "triggeredBy": {"kind": "Player"}, "effect": { "kind": "TransferStats", @@ -1973,6 +1975,7 @@ "copyHealth": True, "from": {"kind": "HighestHealthFriend"}, "to": {"kind": "Self"}, + "percentage": 150, }, }, "probabilities": [ @@ -2153,8 +2156,8 @@ "unicodeCodePoint": "🐕", }, "tier": 3, - "baseAttack": 2, - "baseHealth": 2, + "baseAttack": 3, + "baseHealth": 3, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "Friend summoned: Gain +1 Attack or +1 Health.", @@ -2550,8 +2553,8 @@ "unicodeCodePoint": "🦩", }, "tier": 2, - "baseAttack": 3, - "baseHealth": 1, + "baseAttack": 4, + "baseHealth": 2, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "Faint: Give the two friends behind +1/+1.", @@ -2886,40 +2889,37 @@ "baseHealth": 5, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { - "description": "Hurt: Gain 50% more Attack. Works 1 time(s) per turn.", + "description": "Hurt: Gain 4 attack.", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, - "amount": {"attackPercent": 50}, + "attackAmount": 4, "untilEndOfBattle": False, }, - "maxTriggers": 1, }, "level2Ability": { - "description": "Hurt: Gain 50% more Attack. Works 2 time(s) per turn.", + "description": "Hurt: Gain 8 attack.", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, - "amount": {"attackPercent": 50}, + "attackAmount": 8, "untilEndOfBattle": False, }, - "maxTriggers": 2, }, "level3Ability": { - "description": "Hurt: Gain 50% more Attack. Works 3 time(s) per turn.", + "description": "Hurt: Gain 12 attack.", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, - "amount": {"attackPercent": 50}, + "attackAmount": 12, "untilEndOfBattle": False, }, - "maxTriggers": 3, }, "probabilities": [ { @@ -3813,7 +3813,7 @@ }, "tier": 3, "baseAttack": 5, - "baseHealth": 4, + "baseHealth": 3, "packs": ["StandardPack"], "level1Ability": { "description": "Faint: Deal Attack damage to adjacent animals", @@ -3822,7 +3822,7 @@ "effect": { "kind": "DealDamage", "target": {"kind": "AdjacentAnimals"}, - "amount": {"attackDamagePercent": 100}, + "amount": {"attackDamagePercent": 50}, }, }, "level2Ability": { @@ -3842,7 +3842,7 @@ "effect": { "kind": "DealDamage", "target": {"kind": "AdjacentAnimals"}, - "amount": {"attackDamagePercent": 100}, + "amount": {"attackDamagePercent": 150}, }, }, "probabilities": [ @@ -4152,40 +4152,40 @@ }, "tier": 3, "baseAttack": 2, - "baseHealth": 5, + "baseHealth": 6, "packs": ["StandardPack"], "level1Ability": { - "description": "Hurt: Give friend behind +1/+2", + "description": "Hurt: Give friend behind +2/+2", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "FriendBehind", "n": 1}, - "attackAmount": 1, + "attackAmount": 2, "healthAmount": 2, "untilEndOfBattle": False, }, }, "level2Ability": { - "description": "Hurt: Give friend behind +2/+4", + "description": "Hurt: Give friend behind +4/+4", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "FriendBehind", "n": 1}, - "attackAmount": 2, + "attackAmount": 4, "healthAmount": 4, "untilEndOfBattle": False, }, }, "level3Ability": { - "description": "Hurt: Give friend behind +3/+6", + "description": "Hurt: Give friend behind +6/+6", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "FriendBehind", "n": 1}, - "attackAmount": 3, + "attackAmount": 6, "healthAmount": 6, "untilEndOfBattle": False, }, @@ -4356,7 +4356,7 @@ }, "tier": 3, "baseAttack": 2, - "baseHealth": 5, + "baseHealth": 4, "packs": ["StandardPack"], "level1Ability": { "description": "End turn: Give friend ahead +1/+1", @@ -4665,10 +4665,10 @@ }, "tier": 3, "baseAttack": 1, - "baseHealth": 4, + "baseHealth": 3, "packs": ["StandardPack"], "level1Ability": { - "description": "Friend ahead attacks: Gain Melon Armor and +2 attack", + "description": "Friend ahead attacks: Gain Melon Armor and +1 attack", "trigger": "Faint", "triggeredBy": {"kind": "FriendAhead", "n": 1}, "effect": { @@ -4682,14 +4682,14 @@ { "kind": "ModifyStats", "target": {"kind": "Self"}, - "attackAmount": 2, + "attackAmount": 1, "untilEndOfBattle": False, }, ], }, }, "level2Ability": { - "description": "Friend ahead attacks: Gain Melon Armor and +4 attack", + "description": "Friend ahead attacks: Gain Melon Armor and +2 attack", "trigger": "Faint", "triggeredBy": {"kind": "FriendAhead", "n": 1}, "effect": { @@ -4703,14 +4703,14 @@ { "kind": "ModifyStats", "target": {"kind": "Self"}, - "attackAmount": 4, + "attackAmount": 2, "untilEndOfBattle": False, }, ], }, }, "level3Ability": { - "description": "Friend ahead attacks: Gain Melon Armor and +6 attack", + "description": "Friend ahead attacks: Gain Melon Armor and +3 attack", "trigger": "Faint", "triggeredBy": {"kind": "FriendAhead", "n": 1}, "effect": { @@ -4724,7 +4724,7 @@ { "kind": "ModifyStats", "target": {"kind": "Self"}, - "attackAmount": 6, + "attackAmount": 3, "untilEndOfBattle": False, }, ], @@ -4897,7 +4897,7 @@ "unicodeCodePoint": "🐇", }, "tier": 3, - "baseAttack": 3, + "baseAttack": 1, "baseHealth": 2, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { @@ -5674,8 +5674,8 @@ "unicodeCodePoint": "🦬", }, "tier": 4, - "baseAttack": 6, - "baseHealth": 6, + "baseAttack": 4, + "baseHealth": 4, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "End turn: Gain +2/+2 if there is at least one Lvl. 3 friend.", @@ -6144,38 +6144,38 @@ "baseHealth": 7, "packs": ["StandardPack"], "level1Ability": { - "description": "Knock out: Gain +2/+2.", + "description": "Knock out: Gain +3/+3.", "trigger": "KnockOut", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, - "attackAmount": 2, - "healthAmount": 2, + "attackAmount": 3, + "healthAmount": 3, "untilEndOfBattle": False, }, }, "level2Ability": { - "description": "Knock out: Gain +4/+4.", + "description": "Knock out: Gain +6/+6.", "trigger": "KnockOut", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, - "attackAmount": 4, - "healthAmount": 4, + "attackAmount": 6, + "healthAmount": 6, "untilEndOfBattle": False, }, }, "level3Ability": { - "description": "Knock out: Gain +6/+6.", + "description": "Knock out: Gain +9/+9.", "trigger": "KnockOut", "triggeredBy": {"kind": "Self"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, - "attackAmount": 6, - "healthAmount": 6, + "attackAmount": 9, + "healthAmount": 9, "untilEndOfBattle": False, }, }, @@ -6417,7 +6417,7 @@ "baseHealth": 2, "packs": ["StandardPack"], "level1Ability": { - "description": "End turn: Give right-most friend +3/+3", + "description": "End turn: Give right-most friend +2/+3", "trigger": "EndOfTurn", "triggeredBy": {"kind": "Player"}, "effect": { @@ -6429,7 +6429,7 @@ }, }, "level2Ability": { - "description": "End turn: Give right-most friend +6/+6", + "description": "End turn: Give right-most friend +4/+6", "trigger": "EndOfTurn", "triggeredBy": {"kind": "Player"}, "effect": { @@ -6441,7 +6441,7 @@ }, }, "level3Ability": { - "description": "End turn: Give right-most friend +9/+9", + "description": "End turn: Give right-most friend +6/+9", "trigger": "EndOfTurn", "triggeredBy": {"kind": "Player"}, "effect": { @@ -6772,7 +6772,7 @@ }, "tier": 4, "baseAttack": 3, - "baseHealth": 6, + "baseHealth": 5, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "Start of battle: Reduce the highest Health enemy by 33%.", @@ -6893,7 +6893,7 @@ }, "tier": 4, "baseAttack": 2, - "baseHealth": 2, + "baseHealth": 5, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "Start of turn: Discount shop food by 1 gold", @@ -7001,8 +7001,8 @@ "unicodeCodePoint": "🪱", }, "tier": 4, - "baseAttack": 2, - "baseHealth": 2, + "baseAttack": 3, + "baseHealth": 3, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { "description": "Eats shop food: Gain +1/+1", @@ -7584,7 +7584,7 @@ "unicodeCodePoint": "🦜", }, "tier": 4, - "baseAttack": 5, + "baseAttack": 4, "baseHealth": 3, "packs": ["StandardPack"], "level1Ability": { @@ -7926,38 +7926,38 @@ "baseHealth": 4, "packs": ["StandardPack"], "level1Ability": { - "description": "Friend faints: Gain +2/+1.", + "description": "Friend faints: Gain +2/+2.", "trigger": "Faint", "triggeredBy": {"kind": "EachFriend"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, "attackAmount": 2, - "healthAmount": 1, + "healthAmount": 2, "untilEndOfBattle": False, }, }, "level2Ability": { - "description": "Friend faints: Gain +4/+2.", + "description": "Friend faints: Gain +4/+4.", "trigger": "Faint", "triggeredBy": {"kind": "EachFriend"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, "attackAmount": 4, - "healthAmount": 2, + "healthAmount": 4, "untilEndOfBattle": False, }, }, "level3Ability": { - "description": "Friend faints: Gain +6/+3.", + "description": "Friend faints: Gain +6/+6.", "trigger": "Faint", "triggeredBy": {"kind": "EachFriend"}, "effect": { "kind": "ModifyStats", "target": {"kind": "Self"}, "attackAmount": 6, - "healthAmount": 3, + "healthAmount": 6, "untilEndOfBattle": False, }, }, @@ -8134,7 +8134,7 @@ "unicodeCodePoint": "🐗", }, "tier": 6, - "baseAttack": 8, + "baseAttack": 10, "baseHealth": 6, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { @@ -8387,7 +8387,7 @@ "baseHealth": 9, "packs": ["StandardPack", "ExpansionPack1"], "level1Ability": { - "description": "Hurt: Gain Coconut Shield.", + "description": "Hurt: Gain Coconut Shield. Works 1 time per turn.", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { @@ -8398,7 +8398,7 @@ "maxTriggers": 1, }, "level2Ability": { - "description": "Hurt: Gain Coconut Shield.", + "description": "Hurt: Gain Coconut Shield. Works 2 times per turn.", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { @@ -8406,10 +8406,10 @@ "status": "status-coconut-shield", "to": {"kind": "Self"}, }, - "maxTriggers": 1, + "maxTriggers": 2, }, "level3Ability": { - "description": "Hurt: Gain Coconut Shield.", + "description": "Hurt: Gain Coconut Shield. Works 3 times per turn.", "trigger": "Hurt", "triggeredBy": {"kind": "Self"}, "effect": { @@ -8417,7 +8417,7 @@ "status": "status-coconut-shield", "to": {"kind": "Self"}, }, - "maxTriggers": 1, + "maxTriggers": 3, }, "probabilities": [ { diff --git a/sapai/effects.py b/sapai/effects.py index 14e4c69..e177558 100644 --- a/sapai/effects.py +++ b/sapai/effects.py @@ -1074,9 +1074,9 @@ def TransferStats(apet, apet_idx, teams, te=None, te_idx=[], fixed_targets=[]): ### that have this ability temp_from = temp_from[0][0] if copy_attack: - apet._attack = temp_from.attack + apet._attack = int(temp_from.attack * percentage) if copy_health: - apet._health = temp_from.health + apet._health = int(temp_from.health * percentage) return target, possible diff --git a/sapai/status.py b/sapai/status.py index e3607be..c0f9ea9 100644 --- a/sapai/status.py +++ b/sapai/status.py @@ -19,7 +19,7 @@ def apply_coconut_shield(value): def apply_bone_attack(value): if value > 0: - return value + 5 + return value + 4 else: return 0 diff --git a/sapai/teams.py b/sapai/teams.py index e8a58cd..4952528 100644 --- a/sapai/teams.py +++ b/sapai/teams.py @@ -29,7 +29,7 @@ def __init__( super().__init__(slots, 5, slot_class=TeamSlot) self._battle = battle self.seed_state = seed_state - self.team = [TeamSlot(seed_state=self.seed_state) for x in range(self.nslots)] + self.slots = [TeamSlot(seed_state=self.seed_state) for x in range(self.nslots)] for iter_idx, obj in enumerate(slots): self[iter_idx] = obj self[iter_idx]._pet.team = self @@ -121,40 +121,40 @@ def move_backward(self): def remove(self, obj): if type(obj) == int: - self.team[obj] = TeamSlot(seed_state=self.seed_state) + self.slots[obj] = TeamSlot(seed_state=self.seed_state) elif type(obj).__name__ == "TeamSlot": found = False - for iter_idx, temp_slot in enumerate(self.team): + for iter_idx, temp_slot in enumerate(self.slots): if temp_slot == obj: found_idx = iter_idx found = True if not found: raise Exception("Remove {} not found".format(obj)) - self.team[found_idx] = TeamSlot(seed_state=self.seed_state) + self.slots[found_idx] = TeamSlot(seed_state=self.seed_state) elif type(obj).__name__ == "Pet": found = False - for iter_idx, temp_slot in enumerate(self.team): + for iter_idx, temp_slot in enumerate(self.slots): temp_pet = temp_slot.pet if temp_pet == obj: found_idx = iter_idx found = True if not found: raise Exception("Remove {} not found".format(obj)) - self.team[found_idx] = TeamSlot(seed_state=self.seed_state) + self.slots[found_idx] = TeamSlot(seed_state=self.seed_state) else: raise Exception("Object of type {} not recognized".format(type(obj))) def check_friend(self, obj): if type(obj).__name__ == "TeamSlot": found = False - for iter_idx, temp_slot in enumerate(self.team): + for iter_idx, temp_slot in enumerate(self.slots): if temp_slot == obj: found_idx = iter_idx found = True return found elif type(obj).__name__ == "Pet": found = False - for iter_idx, temp_slot in enumerate(self.team): + for iter_idx, temp_slot in enumerate(self.slots): temp_pet = temp_slot.pet if temp_pet == obj: found_idx = iter_idx @@ -166,7 +166,7 @@ def check_friend(self, obj): def get_idx(self, obj): if type(obj).__name__ == "TeamSlot": found = False - for iter_idx, temp_slot in enumerate(self.team): + for iter_idx, temp_slot in enumerate(self.slots): if temp_slot == obj: found_idx = iter_idx found = True @@ -175,7 +175,7 @@ def get_idx(self, obj): return found_idx elif type(obj).__name__ == "Pet": found = False - for iter_idx, temp_slot in enumerate(self.team): + for iter_idx, temp_slot in enumerate(self.slots): temp_pet = temp_slot.pet if temp_pet == obj: found_idx = iter_idx @@ -233,7 +233,7 @@ def get_behind(self, obj, n=1): chosen = [] for temp_idx in fidx: if temp_idx > pet_idx: - chosen.append(self.team[temp_idx]) + chosen.append(self.slots[temp_idx]) return chosen[0:n] def get_empty(self): @@ -246,15 +246,15 @@ def get_empty(self): def append(self, obj): obj = TeamSlot(obj, seed_state=self.seed_state) n = len(self) - if n == len(self.team): + if n == len(self.slots): raise Exception("Attempted to append to a full team") empty_idx = self.get_empty() if len(empty_idx) == 0: raise Exception("This should not be possible") - self.team[empty_idx[0]] = obj + self.slots[empty_idx[0]] = obj def check_lvl3(self): - for slot in self.team: + for slot in self.slots: if slot.empty: continue if slot.pet.level == 3: @@ -266,25 +266,25 @@ def battle(self): return self._battle def __iter__(self): - yield from self.team + yield from self.slots def __len__(self): count = 0 - for temp_slot in self.team: + for temp_slot in self.slots: if not temp_slot.empty: count += 1 return count def __getitem__(self, idx): - return self.team[idx] + return self.slots[idx] def __setitem__(self, idx, obj): if type(obj).__name__ == "Pet": - self.team[idx] = TeamSlot(obj, seed_state=self.seed_state) + self.slots[idx] = TeamSlot(obj, seed_state=self.seed_state) elif type(obj).__name__ == "TeamSlot": - self.team[idx] = obj + self.slots[idx] = obj elif type(obj) == str or type(obj) == numpy.str_: - self.team[idx] = TeamSlot(obj, seed_state=self.seed_state) + self.slots[idx] = TeamSlot(obj, seed_state=self.seed_state) else: raise Exception( "Tried setting a team slot with type {}".format(type(obj).__name__) @@ -292,7 +292,7 @@ def __setitem__(self, idx, obj): def __repr__(self): repr_str = "" - for iter_idx, slot in enumerate(self.team): + for iter_idx, slot in enumerate(self.slots): repr_str += "{}: {} \n ".format(iter_idx, slot) return repr_str @@ -311,7 +311,7 @@ def state(self): state_dict = { "type": "Team", "battle": self.battle, - "team": [x.state for x in self.team], + "team": [x.state for x in self.slots], "pack": self.pack, } return state_dict diff --git a/tests/test_battles.py b/tests/test_battles.py index 58a30ba..b8ef8c6 100644 --- a/tests/test_battles.py +++ b/tests/test_battles.py @@ -6,6 +6,7 @@ from sapai import * from sapai.battle import Battle from sapai.graph import graph_battle +from sapai.compress import * class TestBattles(unittest.TestCase): @@ -144,7 +145,8 @@ def test_horse_in_battle(self): test_battle = Battle(team1, team2) result = test_battle.battle() - self.assertEqual(result, 2) + self.assertEqual(test_battle.t0.empty, [0, 1, 2, 3, 4]) + self.assertEqual(test_battle.t1[0].health, 1) def test_horse_with_bee_in_battle(self): cricket = Pet("cricket") @@ -387,5 +389,15 @@ def test_rat_summons_at_front(self): result = test_battle.battle() self.assertEqual(result, 0) + def test_peacock(self): + ### Check that peacock attack is correct after battle + + ### Check peacock attack after elephant for all three levels + + ### Check peacock after headgehog on both teams + + ### Implement later with others + pass + # %% diff --git a/tests/test_effects.py b/tests/test_effects.py index 040a16d..d44ceb1 100644 --- a/tests/test_effects.py +++ b/tests/test_effects.py @@ -184,17 +184,6 @@ def test_weak(self): attack_phase = get_attack(fish, t3[0].pet) self.assertEqual(attack_phase[1], 9) # 6/8 + 3 - def test_peacock(self): - peacock = Pet("peacock") - peacock._hurt = True - t = Team([peacock]) - peacock.hurt_trigger(Team()) - self.assertEqual(peacock.attack, 3) - # same turn, therefore should not activate again: - peacock._hurt = True - peacock.hurt_trigger(Team()) - self.assertEqual(peacock.attack, 3) - def test_hatching_chick_level_3(self): hc = Pet("hatching-chick") hc.level = 3 diff --git a/tests/test_pet_triggers.py b/tests/test_pet_triggers.py index 212cb3e..a31cba0 100644 --- a/tests/test_pet_triggers.py +++ b/tests/test_pet_triggers.py @@ -1,3 +1,4 @@ +#%% import unittest import numpy as np from torch import seed @@ -164,7 +165,7 @@ def test_buy_friend_triggers_self(self): self.print_pet_list(test_pet_list) # Buy friend as self - test_bool_list = [True, True, True, False, False, True, False, False] + test_bool_list = [True, False, True, False, False, True, False, False] for iter_idx, pet in enumerate(test_pet_list): activated_bool, targets, possible = pet.buy_friend_trigger(pet) if pet.name == "pet-snail": @@ -395,6 +396,7 @@ def test_start_of_battle_triggers(self): test_pet_names = [ "mosquito", "bat", + "crab", "whale", "dolphin", "skunk", @@ -496,13 +498,13 @@ def test_knockout_triggers(self): def test_dragon_ability(self): player = Player(shop=Shop(["ant"]), team=Team([Pet("fish"), Pet("dragon")])) self.assertEqual(player.team[0].attack, 2) - self.assertEqual(player.team[0].health, 3) + self.assertEqual(player.team[0].health, 2) self.assertEqual(player.team[1].attack, 6) self.assertEqual(player.team[1].health, 8) player.buy_pet(0) self.assertEqual(player.team[0].attack, 3) - self.assertEqual(player.team[0].health, 4) + self.assertEqual(player.team[0].health, 3) self.assertEqual(player.team[1].attack, 6) self.assertEqual(player.team[1].health, 8) @@ -530,23 +532,30 @@ def test_dodo(self): ) def test_crab(self): - dragon = Pet("dragon") - player = Player(shop=Shop(["crab"]), team=Team([dragon])) - player.buy_pet(0) - self.assertEqual(player.team[1].pet.health, dragon.health) + t = Team(["crab", "dragon"]) + activated_bool, targets, possible = t[0].obj.sob_trigger(t) + self.assertEqual(t[0].health, 4) + + t[0].obj.level = 2 + activated_bool, targets, possible = t[0].obj.sob_trigger(t) + self.assertEqual(t[0].health, 8) + + t[0].obj.level = 3 + activated_bool, targets, possible = t[0].obj.sob_trigger(t) + self.assertEqual(t[0].health, 12) def test_horse(self): player = Player(shop=Shop(["fish"]), team=Team([Pet("horse")])) player.buy_pet(0) self.assertEqual(player.team[1].attack, 3) - self.assertEqual(player.team[1].health, 3) + self.assertEqual(player.team[1].health, 2) player.end_turn() player.start_turn() self.assertEqual(player.team[1].attack, 2) - self.assertEqual(player.team[1].health, 3) + self.assertEqual(player.team[1].health, 2) def test_cupcake_cat(self): player = Player(shop=Shop(["cupcake"]), team=Team([Pet("cat")])) @@ -566,19 +575,19 @@ def test_ant_pill_in_shop(self): shop=Shop(["sleeping-pill"]), team=Team([Pet("ant"), Pet("beaver")]) ) player.buy_food(0, 0) - self.assertEqual(player.team[1].attack, 4) + self.assertEqual(player.team[1].attack, 5) self.assertEqual(player.team[1].health, 3) def test_beaver_sell(self): player = Player(team=Team([Pet("beaver"), Pet("fish"), Pet("fish")])) player.sell(0) - self.assertEqual(player.team[1].health, 4) - self.assertEqual(player.team[2].health, 4) + self.assertEqual(player.team[1].health, 3) + self.assertEqual(player.team[2].health, 3) def test_beaver_sell_only_one_other_pet_on_team(self): player = Player(team=Team([Pet("fish"), Pet("beaver")])) player.sell(1) - self.assertEqual(player.team[0].health, 4) + self.assertEqual(player.team[0].health, 3) def test_cricket_pill_in_shop(self): player = Player(shop=Shop(["sleeping-pill"]), team=Team([Pet("cricket")])) @@ -601,15 +610,15 @@ def test_fish_combine(self): ) player.buy_combine(0, 0) self.assertEqual(player.team[0].pet.level, 2) - self.assertEqual(player.team[1].attack, 3) + self.assertEqual(player.team[1].attack, 4) self.assertEqual(player.team[1].health, 3) - self.assertEqual(player.team[2].attack, 3) + self.assertEqual(player.team[2].attack, 4) self.assertEqual(player.team[2].health, 3) def test_otter(self): player = Player(shop=Shop(["otter"]), team=Team([Pet("beaver")])) player.buy_pet(0) - self.assertEqual(player.team[0].attack, 3) + self.assertEqual(player.team[0].attack, 4) self.assertEqual(player.team[0].health, 3) self.assertEqual(player.team[1].attack, 1) self.assertEqual(player.team[1].health, 2) @@ -622,11 +631,35 @@ def test_buy_otter_on_empty_team(self): def test_buy_otter_on_level_up(self): otter = Pet("otter") - otter.experience = 1 player = Player(shop=Shop(["otter"]), team=Team([otter, Pet("beaver")])) player.buy_combine(0, 0) self.assertEqual(player.team[1].attack, 4) - self.assertEqual(player.team[1].health, 4) + self.assertEqual(player.team[1].health, 3) + + otter = Pet("otter") + otter.experience = 1 + player = Player( + shop=Shop(["otter"]), team=Team([otter, Pet("beaver"), Pet("fish")]) + ) + player.buy_combine(0, 0) + self.assertEqual(player.team[1].attack, 4) + self.assertEqual(player.team[1].health, 3) + self.assertEqual(player.team[2].attack, 3) + self.assertEqual(player.team[2].health, 3) + + otter = Pet("otter") + otter.experience = 4 + player = Player( + shop=Shop(["otter"]), + team=Team([otter, Pet("beaver"), Pet("fish"), Pet("ant")]), + ) + player.buy_combine(0, 0) + self.assertEqual(player.team[1].attack, 4) + self.assertEqual(player.team[1].health, 3) + self.assertEqual(player.team[2].attack, 3) + self.assertEqual(player.team[2].health, 3) + self.assertEqual(player.team[3].attack, 3) + self.assertEqual(player.team[3].health, 2) def test_pig(self): player = Player(team=Team([Pet("pig")])) @@ -710,3 +743,102 @@ def test_zombie_fly_location(self): self.assertEqual( player.team[0].pet.name, "pet-zombie-fly" ) # zombie fly spawned in front of fly, not on fainted target location + + def test_flamingo(self): + t = Team(["flamingo", "dragon", "dragon", "dragon"]) + t[0].obj.level = 1 + pet = t[0].obj + te_idx = [0, 0] + t[0].obj.faint_trigger(pet, te_idx) + self.assertEqual(t[1].attack, 6 + 1) + self.assertEqual(t[1].health, 8 + 1) + self.assertEqual(t[2].attack, 6 + 1) + self.assertEqual(t[2].health, 8 + 1) + self.assertEqual(t[3].attack, 6) + self.assertEqual(t[3].health, 8) + + t = Team(["flamingo", "dragon", "dragon", "dragon"]) + t[0].obj.level = 2 + pet = t[0].obj + te_idx = [0, 0] + t[0].obj.faint_trigger(pet, te_idx) + self.assertEqual(t[1].attack, 6 + 2) + self.assertEqual(t[1].health, 8 + 2) + self.assertEqual(t[2].attack, 6 + 2) + self.assertEqual(t[2].health, 8 + 2) + self.assertEqual(t[3].attack, 6) + self.assertEqual(t[3].health, 8) + + t = Team(["flamingo", "dragon", "dragon", "dragon"]) + t[0].obj.level = 3 + pet = t[0].obj + te_idx = [0, 0] + t[0].obj.faint_trigger(pet, te_idx) + self.assertEqual(t[1].attack, 6 + 3) + self.assertEqual(t[1].health, 8 + 3) + self.assertEqual(t[2].attack, 6 + 3) + self.assertEqual(t[2].health, 8 + 3) + self.assertEqual(t[3].attack, 6) + self.assertEqual(t[3].health, 8) + + def test_peacock(self): + t = Team(["peacock"]) + enemy = Team(["fish"]) + t[0].obj.level = 1 + t[0].obj.hurt(1) + t[0].obj.hurt_trigger(enemy) + self.assertEqual(t[0].attack, 6) + + t = Team(["peacock"]) + enemy = Team(["fish"]) + t[0].obj.level = 2 + t[0].obj.hurt(1) + t[0].obj.hurt_trigger(enemy) + self.assertEqual(t[0].attack, 10) + + t = Team(["peacock"]) + enemy = Team(["fish"]) + t[0].obj.level = 3 + t[0].obj.hurt(1) + t[0].obj.hurt_trigger(enemy) + self.assertEqual(t[0].attack, 14) + + def test_badger(self): + t = Team(["badger", "dragon"]) + pet = t[0].obj + ally = t[1].obj + other_team = Team(["fish"]) + enemy = other_team[0].obj + t[0].obj.level = 1 + t[0].obj.hurt(3) + t[0].obj.faint_trigger(t[0].obj, [0, 0], other_team) + self.assertEqual(pet.health, 0) + self.assertEqual(ally.health, 8 - 2) + self.assertEqual(enemy.health, 2 - 2) + + t = Team(["badger", "dragon"]) + pet = t[0].obj + ally = t[1].obj + other_team = Team(["fish"]) + enemy = other_team[0].obj + t[0].obj.level = 2 + t[0].obj.hurt(3) + t[0].obj.faint_trigger(t[0].obj, [0, 0], other_team) + self.assertEqual(pet.health, 0) + self.assertEqual(ally.health, 8 - 5) + self.assertEqual(enemy.health, 2 - 5) + + t = Team(["badger", "dragon"]) + pet = t[0].obj + ally = t[1].obj + other_team = Team(["fish"]) + enemy = other_team[0].obj + t[0].obj.level = 3 + t[0].obj.hurt(3) + t[0].obj.faint_trigger(t[0].obj, [0, 0], other_team) + self.assertEqual(pet.health, 0) + self.assertEqual(ally.health, 8 - 7) + self.assertEqual(enemy.health, 2 - 7) + + +# %% diff --git a/tests/test_shop.py b/tests/test_shop.py index f7cf278..b90a89d 100644 --- a/tests/test_shop.py +++ b/tests/test_shop.py @@ -81,20 +81,20 @@ def test_cupcake(self): player = Player(shop=Shop(["cupcake"]), team=Team([Pet("fish")])) player.buy_food(0, 0) - self.assertEqual(player.team[0].attack, 5) - self.assertEqual(player.team[0].health, 6) + self.assertEqual(player.team[0].attack, 5) # fish 2/2 + self.assertEqual(player.team[0].health, 5) player.end_turn() player.start_turn() self.assertEqual(player.team[0].attack, 2) - self.assertEqual(player.team[0].health, 3) + self.assertEqual(player.team[0].health, 2) def test_apple(self): player = Player(shop=Shop(["apple"]), team=Team([Pet("beaver")])) player.buy_food(0, 0) - self.assertEqual(player.team[0].attack, 3) + self.assertEqual(player.team[0].attack, 4) self.assertEqual(player.team[0].health, 3) def test_shop_levelup_from_combine(self): @@ -116,7 +116,7 @@ def test_buy_multi_target_food(self): player.buy_food(0) self.assertEqual(player.team[0].attack, 4) # 3 + sushi self.assertEqual(player.team[0].health, 10) # 8 + sushi + rabbit - self.assertEqual(player.team[1].attack, 5) # 3 + sushi + seal + self.assertEqual(player.team[1].attack, 3) # 1 + sushi + seal self.assertEqual(player.team[1].health, 5) # 2 + sushi + seal + rabbit self.assertEqual(player.team[2].attack, 4) # 1 + sushi + seal + ladybug self.assertEqual( @@ -133,7 +133,7 @@ def test_buy_chocolate(self): self.assertEqual(player.team[0].pet.experience, 1) self.assertEqual(player.team[0].attack, 3) # 3 self.assertEqual(player.team[0].health, 9) # 8 + rabbit - self.assertEqual(player.team[1].attack, 4) # 3 + seal + self.assertEqual(player.team[1].attack, 2) # 1 + seal self.assertEqual(player.team[1].health, 3) # 2 + seal self.assertEqual(player.team[2].attack, 3) # 1 + seal + ladybug self.assertEqual(player.team[2].health, 5) # 3 + seal + ladybug @@ -143,7 +143,7 @@ def test_buy_apple(self): player.buy_food(0, 0) self.assertEqual(player.team[0].attack, 4) # 3 + apple self.assertEqual(player.team[0].health, 10) # 8 + apple + rabbit - self.assertEqual(player.team[1].attack, 4) # 3 + seal + self.assertEqual(player.team[1].attack, 2) # 1 + seal self.assertEqual(player.team[1].health, 3) # 2 + seal self.assertEqual(player.team[2].attack, 3) # 1 + seal + ladybug self.assertEqual(player.team[2].health, 5) # 3 + seal + ladybug @@ -152,19 +152,19 @@ def test_chicken(self): state = np.random.RandomState(seed=1).get_state() player = Player(shop=Shop(["fish", "fish"], seed_state=state), team=["chicken"]) player.buy_pet(0) - self.assertEqual(player.shop[0].obj.attack, 3) - self.assertEqual(player.shop[0].obj.health, 4) + self.assertEqual(player.shop[0].obj.attack, 3) # fish 2/2 + self.assertEqual(player.shop[0].obj.health, 3) ### check result after 1 roll player.roll() - self.assertEqual(player.shop[0].obj.attack, 2) # duck 1/3 + self.assertEqual(player.shop[0].obj.attack, 3) # duck 2/3 self.assertEqual(player.shop[0].obj.health, 4) ### check result in a new turn player.end_turn() player.start_turn() - self.assertEqual(player.shop[0].obj.attack, 3) # mosquito 2/1 + self.assertEqual(player.shop[0].obj.attack, 3) # mosquito 2/2 self.assertEqual(player.shop[0].obj.health, 3) def test_canned_food(self): @@ -175,12 +175,12 @@ def test_canned_food(self): player.buy_food(1) ### check immediate result - self.assertEqual(player.shop[0].obj.attack, 4) - self.assertEqual(player.shop[0].obj.health, 4) + self.assertEqual(player.shop[0].obj.attack, 4) # fish 2/2 + self.assertEqual(player.shop[0].obj.health, 3) ### check result after 1 roll player.roll() - self.assertEqual(player.shop[0].obj.attack, 3) # duck 2/2 + self.assertEqual(player.shop[0].obj.attack, 4) # duck 2/3 self.assertEqual(player.shop[0].obj.health, 4) ### check result in a new turn