def choose_target_enemy(self, all_targets): if len(all_targets) == 0: raise Exception("No targets") targets = self.prune_targets(all_targets, False) if len(targets) == 0: return Util.rand_el(all_targets) if not self.current_trade: return Util.rand_prefer_minion(targets) # raise Exception("No current trade") for target in targets: if self.current_trade.opp_minion == target: return target # raise Exception("Could not find target {}".format(target)) return Util.rand_prefer_minion(targets)
def raw_plays_without_coin(self): res = [] def valid_card(card): saved_mana = card.player.mana card.player.mana = self.mana usable = card.can_use(card.player, card.player.game) card.player.mana = saved_mana return usable possible = [card for card in filter(valid_card, self.cards)] if self.possible_is_pointless_coin(possible): possible = [] if self.mana >= 2 and self.allow_hero_power: possible.append(HeroPowerCard()) if len(possible) == 0: return [[]] for card in possible: rest = self.cards[0:99999] if card.name == 'Hero Power': f_plays = PossiblePlays(rest, self.mana - card.mana_cost(card.player), allow_hero_power=False).raw_plays() else: rest.remove(card) f_plays = PossiblePlays( rest, self.mana - card.mana_cost(card.player), allow_hero_power=self.allow_hero_power).raw_plays() for following_play in f_plays: combined = [card] + following_play res.append(combined) res = Util.uniq_by_sorted(res) return res
def raw_plays_without_coin(self): res = [] possible = [ card for card in filter(lambda card: card.mana <= self.mana, self.cards) ] if self.possible_is_pointless_coin(possible): possible = [] if self.mana >= 2 and self.allow_hero_power: possible.append(HeroPowerCard()) if len(possible) == 0: return [[]] for card in possible: rest = self.cards[0:99999] if card.name == 'Hero Power': f_plays = PossiblePlays(rest, self.mana - card.mana, allow_hero_power=False).raw_plays() else: rest.remove(card) f_plays = PossiblePlays( rest, self.mana - card.mana, allow_hero_power=self.allow_hero_power).raw_plays() for following_play in f_plays: combined = [card] + following_play res.append(combined) res = Util.uniq_by_sorted(res) return res
def choose_target_friendly(self, targets): pruned = self.prune_targets(targets, True) if len(pruned) == 0: return Util.rand_el(targets) return Util.rand_el(pruned)
def cards_without_coin(self): return Util.filter_out_one(self.cards, lambda c: c.name == "The Coin")
def sorted_mana(self): return Util.reverse_sorted(map(lambda c: c.mana_cost(), self.cards))