<commit_before>package com.hearthsim.test.groovy.card

import com.hearthsim.card.minion.concrete.AnubarAmbusher
import com.hearthsim.card.minion.concrete.BloodfenRaptor
import com.hearthsim.card.minion.concrete.DarkCultist
import com.hearthsim.card.minion.concrete.RiverCrocolisk
import com.hearthsim.card.spellcard.concrete.Fireball
import com.hearthsim.model.BoardModel
import com.hearthsim.test.helpers.BoardModelBuilder
import com.hearthsim.util.tree.HearthTreeNode
import com.hearthsim.util.tree.RandomEffectNode

import static com.hearthsim.model.PlayerSide.CURRENT_PLAYER
import static com.hearthsim.model.PlayerSide.WAITING_PLAYER
import static org.junit.Assert.*

class AnubarAmbusherSpec extends CardSpec {

    HearthTreeNode root
    BoardModel startingBoard

    def setup() {

        startingBoard = new BoardModelBuilder().make {
            currentPlayer {
                field([[minion:AnubarAmbusher]])
                mana(10)
            }
        }

        root = new HearthTreeNode(startingBoard)
    }

    def "dying with no deathrattle targets"() {
        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 1, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
            }
        }
    }

    def "does not bounce enemies"() {
        startingBoard.placeMinion(WAITING_PLAYER, new BloodfenRaptor(), 0)

        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 1, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
            }
        }
    }

    def "dying with 1 deathrattle target"() {
        startingBoard.placeMinion(CURRENT_PLAYER, new BloodfenRaptor(), 0)

        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 2, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(1)
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
                addCardToHand(BloodfenRaptor)
            }
        }
    }

    def "dying with 2 deathrattle target"() {
        startingBoard.placeMinion(CURRENT_PLAYER, new BloodfenRaptor(), 0)
        startingBoard.placeMinion(CURRENT_PLAYER, new RiverCrocolisk(), 1)

        def copiedBoard = startingBoard.deepCopy()<commit_msg>Add test covering bouncing into a full hand<commit_after>package com.hearthsim.test.groovy.card

import com.hearthsim.card.minion.concrete.AnubarAmbusher
import com.hearthsim.card.minion.concrete.BloodfenRaptor
import com.hearthsim.card.minion.concrete.DarkCultist
import com.hearthsim.card.minion.concrete.RiverCrocolisk
import com.hearthsim.card.spellcard.concrete.Fireball
import com.hearthsim.card.spellcard.concrete.TheCoin
import com.hearthsim.model.BoardModel
import com.hearthsim.test.helpers.BoardModelBuilder
import com.hearthsim.util.tree.HearthTreeNode
import com.hearthsim.util.tree.RandomEffectNode

import static com.hearthsim.model.PlayerSide.CURRENT_PLAYER
import static com.hearthsim.model.PlayerSide.WAITING_PLAYER
import static org.junit.Assert.*

class AnubarAmbusherSpec extends CardSpec {

    HearthTreeNode root
    BoardModel startingBoard

    def setup() {

        startingBoard = new BoardModelBuilder().make {
            currentPlayer {
                field([[minion:AnubarAmbusher]])
                mana(10)
            }
        }

        root = new HearthTreeNode(startingBoard)
    }

    def "dying with no deathrattle targets"() {
        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 1, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
            }
        }
    }

    def "does not bounce enemies"() {
        startingBoard.placeMinion(WAITING_PLAYER, new BloodfenRaptor(), 0)

        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 1, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
            }
        }
    }

    def "dying with 1 deathrattle target"() {
        startingBoard.placeMinion(CURRENT_PLAYER, new BloodfenRaptor(), 0)

        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 2, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(1)
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
                addCardToHand(BloodfenRaptor)
            }
        }
    }

    def "bouncing with full hand"() {
        startingBoard.placeMinion(CURRENT_PLAYER, new BloodfenRaptor(), 0)
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())
        startingBoard.placeCardHand(CURRENT_PLAYER, new TheCoin())

        def copiedBoard = startingBoard.deepCopy()
        def theCard = new Fireball()
        def ret = theCard.useOn(CURRENT_PLAYER, 2, root)

        expect:
        assertNotNull(ret)
        assertEquals(0, ret.numChildren())
        assertFalse(ret instanceof RandomEffectNode)

        assertBoardDelta(copiedBoard, ret.data_) {
            currentPlayer {
                removeMinion(1)
                removeMinion(0)
                mana(6)
                numCardsUsed(1)
            }
        }
    }

    def "dying with 2 deathrattle target"() {
        startingBoard.placeMinion(CURRENT_PLAYER, new BloodfenRaptor(), 0)
        startingBoard.placeMinion(CURRENT_PLAYER, new RiverCrocolisk(), 1)

        def copiedBoard = startingBoard.deepCopy()
{'fraction_non_alphanumeric': 0.08330038223276658, 'fraction_numerical': 0.007249242124686964, 'mean_word_length': 2.4272809394760615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5397812', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2170, 'n_words': 407}