Skip to content

Commit

Permalink
Merge pull request #1 from oyachai/master
Browse files Browse the repository at this point in the history
sync test
  • Loading branch information
Hofls committed Aug 26, 2015
2 parents 62f8b21 + ca37e6b commit 1a618be
Show file tree
Hide file tree
Showing 19 changed files with 597 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.hearthsim.card.blackrockmountain.minion.common;

import com.hearthsim.card.CharacterIndex;
import com.hearthsim.card.minion.Minion;
import com.hearthsim.card.minion.MinionBattlecryInterface;
import com.hearthsim.event.effect.EffectCharacter;
import com.hearthsim.model.PlayerSide;
import com.hearthsim.util.HearthAction;
import com.hearthsim.util.tree.HearthTreeNode;
import com.hearthsim.util.tree.RandomEffectNode;

public class FireguardDestroyer extends Minion implements MinionBattlecryInterface {

public FireguardDestroyer() {
super();
}

@Override
public EffectCharacter<Minion> getBattlecryEffect() {
return (PlayerSide targetSide, CharacterIndex minionPlacementIndex, HearthTreeNode boardState) -> {
CharacterIndex thisMinionIndex = minionPlacementIndex.indexToRight();
HearthTreeNode toRet = new RandomEffectNode(boardState,
new HearthAction(HearthAction.Verb.UNTARGETABLE_BATTLECRY, PlayerSide.CURRENT_PLAYER,
thisMinionIndex.getInt(),
PlayerSide.CURRENT_PLAYER, minionPlacementIndex));
for (int indx = 1; indx <= 4; ++indx) {
HearthTreeNode child = new HearthTreeNode(boardState.data_.deepCopy());
child.data_.getCharacter(PlayerSide.CURRENT_PLAYER, thisMinionIndex).addAttack((byte)indx);
toRet.addChild(child);
}
return toRet;
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.hearthsim.card.blackrockmountain.minion.legendary;

import com.hearthsim.card.Card;
import com.hearthsim.card.minion.Minion;
import com.hearthsim.event.effect.EffectHandManaCost;
import com.hearthsim.event.effect.SimpleEffectHand;
import com.hearthsim.exception.HSException;
import com.hearthsim.model.PlayerModel;
import com.hearthsim.model.PlayerSide;
import com.hearthsim.util.tree.HearthTreeNode;

public class EmperorThaurissan extends Minion {

private static final SimpleEffectHand effect = new EffectHandManaCost(-1);

public EmperorThaurissan() {
super();
}

@Override
public HearthTreeNode endTurn(PlayerSide thisMinionPlayerIndex, HearthTreeNode boardModel) throws HSException {
HearthTreeNode tmpState = super.endTurn(thisMinionPlayerIndex, boardModel);
if (isWaitingPlayer(thisMinionPlayerIndex))
return tmpState;

PlayerModel currentPlayer = boardModel.data_.modelForSide(PlayerSide.CURRENT_PLAYER);
for (Card card : currentPlayer.getHand()) {
effect.applyEffect(PlayerSide.CURRENT_PLAYER, this, PlayerSide.CURRENT_PLAYER, card, boardModel.data_);
}

return boardModel;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.hearthsim.card.blackrockmountain.spell.rare;

import com.hearthsim.card.spellcard.SpellCard;
import com.hearthsim.event.effect.EffectCharacter;
import com.hearthsim.event.effect.EffectCharacterDamageSpell;
import com.hearthsim.event.effect.EffectOnResolveAoe;
import com.hearthsim.event.filter.FilterCharacter;

/**
* Created by oyachai on 8/23/15.
*/
public class Demonwrath extends SpellCard implements EffectOnResolveAoe {

private static final EffectCharacter effect = new EffectCharacterDamageSpell<>(2);

public Demonwrath() {
super();
}

@Override
public EffectCharacter getAoeEffect() {
return Demonwrath.effect;
}

@Override
public FilterCharacter getAoeFilter() {
return FilterCharacter.ALL_NON_DEMONS;
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/hearthsim/card/minion/Minion.java
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ public Card deepCopy() {
minion.destroyOnTurnStart_ = destroyOnTurnStart_;
minion.destroyOnTurnEnd_ = destroyOnTurnEnd_;
minion.deathrattleAction_ = deathrattleAction_;
minion.immune_ = immune_;
minion.cantAttack = cantAttack;
minion.inHand = inHand;
minion.hasBeenUsed = hasBeenUsed;
// TODO: continue here.
Expand Down Expand Up @@ -907,6 +909,12 @@ public boolean equals(Object other) {
if (spellDamage_ != otherMinion.spellDamage_)
return false;

if (immune_ != otherMinion.immune_)
return false;

if (cantAttack != otherMinion.cantAttack)
return false;

// This is checked for reference equality
if (deathrattleAction_ == null && ((Minion)other).deathrattleAction_ != null)
return false;
Expand Down Expand Up @@ -942,6 +950,8 @@ public int hashCode() {
result = 31 * result + (destroyOnTurnStart_ ? 1 : 0);
result = 31 * result + (destroyOnTurnEnd_ ? 1 : 0);
result = 31 * result + spellDamage_;
result = 31 * result + (immune_ ? 1 : 0);
result = 31 * result + (cantAttack ? 1 : 0);
result = 31 * result + (deathrattleAction_ != null ? deathrattleAction_.hashCode() : 0);
result = 31 * result + (this.getPlacementImportant() ? 1 : 0);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public HearthTreeNode heroAbilityUsedEvent(PlayerSide thisMinionPlayerSide, Play
for (BoardModel.MinionPlayerPair mp : minions) {
if (mp.getPlayerSide() == PlayerSide.CURRENT_PLAYER &&
filter.targetMatches(thisMinionPlayerSide, this, mp.getPlayerSide(), mp.getMinion(), boardState.data_)) {
toRet = effect.applyEffect(mp.getPlayerSide(), mp.getMinion(), toRet);
HearthTreeNode tempNode = effect.applyEffect(mp.getPlayerSide(), mp.getMinion(), toRet);
if (tempNode != null)
toRet = tempNode;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.hearthsim.card.thegrandtournament.minion.common;

import com.hearthsim.card.minion.Minion;

public class TournamentAttendee extends Minion {

public TournamentAttendee() {
super();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.hearthsim.card.thegrandtournament.minion.rare;

import com.hearthsim.card.CharacterIndex;
import com.hearthsim.card.minion.Minion;
import com.hearthsim.card.minion.MinionBattlecryInterface;
import com.hearthsim.event.effect.EffectCharacter;
import com.hearthsim.model.PlayerSide;
import com.hearthsim.util.tree.HearthTreeNode;

public class InjuredKvaldir extends Minion implements MinionBattlecryInterface {

public InjuredKvaldir() {
super();
}

@Override
public EffectCharacter getBattlecryEffect() {
return new EffectCharacter<Minion>() {

@Override
public HearthTreeNode applyEffect(PlayerSide targetSide, CharacterIndex targetCharacterIndex, HearthTreeNode boardState) {
HearthTreeNode toRet;
toRet = InjuredKvaldir.this.takeDamageAndNotify((byte) 3, PlayerSide.CURRENT_PLAYER, PlayerSide.CURRENT_PLAYER, boardState, false, true);
return toRet;
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.hearthsim.card.thegrandtournament.spell.epic;

import com.hearthsim.card.spellcard.SpellCard;
import com.hearthsim.event.effect.EffectCharacter;
import com.hearthsim.event.effect.EffectOnResolveAoe;
import com.hearthsim.event.filter.FilterCharacter;

/**
* Created by oyachai on 8/23/15.
*/
public class Confuse extends SpellCard implements EffectOnResolveAoe {

public Confuse() {
super();
}

@Override
public EffectCharacter getAoeEffect() {
return EffectCharacter.SWAP_ATTACK_HEALTH;
}

@Override
public FilterCharacter getAoeFilter() {
return FilterCharacter.ALL_MINIONS;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/hearthsim/event/filter/FilterCharacter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ protected Minion.MinionTribe tribeFilter() {
return null;
}

protected Minion.MinionTribe excludeTribe() {
return null;
}

public boolean targetMatches(PlayerSide originSide, Card origin, PlayerSide targetSide, Minion targetCharacter, BoardModel board) {

if (this.includeOrigin() && targetCharacter == origin) {
Expand Down Expand Up @@ -73,6 +77,10 @@ public boolean targetMatches(PlayerSide originSide, Card origin, PlayerSide targ
return false;
}

if (this.excludeTribe() != null && targetCharacter.getTribe() == this.excludeTribe()) {
return false;
}

if (this.maxAttack() >= 0 && targetCharacter.getTotalAttack() > this.maxAttack()) {
return false;
}
Expand Down Expand Up @@ -147,6 +155,23 @@ protected boolean includeOwnMinions() {
}
};

public final static FilterCharacter ALL_NON_DEMONS = new FilterCharacter() {
@Override
protected boolean includeEnemyMinions() {
return true;
}

@Override
protected boolean includeOwnMinions() {
return true;
}

@Override
protected Minion.MinionTribe excludeTribe() {
return Minion.MinionTribe.DEMON;
}
};

public final static FilterCharacter ALL_HEROES = new FilterCharacter() {
@Override
protected boolean includeEnemyHero() {
Expand Down
30 changes: 30 additions & 0 deletions src/main/resources/implemented_cards.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@
"id": "GVG_019",
"name": "Demonheart"
},
{
"class": "com.hearthsim.card.blackrockmountain.spell.rare.Demonwrath",
"id": "BRM_005",
"name": "Demonwrath"
},
{
"class": "com.hearthsim.card.classic.spell.rare.DivineFavor",
"id": "EX1_349",
Expand Down Expand Up @@ -599,6 +604,11 @@
"id": "EX1_170",
"name": "Emperor Cobra"
},
{
"class": "com.hearthsim.card.blackrockmountain.minion.legendary.EmperorThaurissan",
"id": "BRM_028",
"name": "Emperor Thaurissan"
},
{
"class": "com.hearthsim.card.classic.spell.rare.Equality",
"id": "EX1_619",
Expand Down Expand Up @@ -659,6 +669,11 @@
"id": "CS2_042",
"name": "Fire Elemental"
},
{
"class": "com.hearthsim.card.blackrockmountain.minion.common.FireguardDestroyer",
"id": "BRM_012",
"name": "Fireguard Destroyer"
},
{
"class": "com.hearthsim.card.basic.spell.Fireball",
"id": "CS2_029",
Expand Down Expand Up @@ -2214,6 +2229,21 @@
"id": "AT_055",
"name": "Flash Heal"
},
{
"class": "com.hearthsim.card.thegrandtournament.minion.common.TournamentAttendee",
"id": "AT_097",
"name": "Tournament Attendee"
},
{
"class": "com.hearthsim.card.thegrandtournament.minion.rare.InjuredKvaldir",
"id": "AT_105",
"name": "Injured Kvaldir"
},
{
"class": "com.hearthsim.card.thegrandtournament.spell.epic.Confuse",
"id": "AT_016",
"name": "Confuse"
},
{
"class": "com.hearthsim.card.blackrockmountain.spell.rare.Revenge",
"id": "BRM_015",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CardSpec extends Specification {
assert oldMinion.stealthedUntilRevealed == newMinion.stealthedUntilRevealed
assert oldMinion.stealthedUntilNextTurn == newMinion.stealthedUntilNextTurn
assert oldMinion.hasBeenUsed == newMinion.hasBeenUsed
assert oldMinion.cantAttack == newMinion.cantAttack
assert oldMinion == newMinion //catch all
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.hearthsim.test.groovy.card.blackrockmountain.minion

import com.hearthsim.Game
import com.hearthsim.card.CharacterIndex
import com.hearthsim.card.basic.minion.BloodfenRaptor
import com.hearthsim.card.blackrockmountain.minion.legendary.EmperorThaurissan
import com.hearthsim.card.classic.minion.common.Wisp
import com.hearthsim.card.goblinsvsgnomes.minion.common.SpiderTank
import com.hearthsim.model.BoardModel
import com.hearthsim.test.groovy.card.CardSpec
import com.hearthsim.test.helpers.BoardModelBuilder
import com.hearthsim.util.tree.HearthTreeNode

import static com.hearthsim.model.PlayerSide.CURRENT_PLAYER
import static org.junit.Assert.assertFalse

class EmperorThaurissanSpec extends CardSpec{

HearthTreeNode root
BoardModel startingBoard

def setup() {

startingBoard = new BoardModelBuilder().make {
currentPlayer {
hand([EmperorThaurissan, SpiderTank, BloodfenRaptor])
mana(10)
}
waitingPlayer {
hand([EmperorThaurissan, SpiderTank, BloodfenRaptor])
mana(10)
}
}

root = new HearthTreeNode(startingBoard)
}

def "at the end of currentPlayer turn, reduce the Cost of currentPlayer cards by 1"() {
def copiedBoard = startingBoard.deepCopy()
def theCard = root.data_.getCurrentPlayer().getHand().get(0)
def ret = theCard.useOn(CURRENT_PLAYER, CharacterIndex.HERO, root)

expect:
assertFalse(ret == null);

assertBoardDelta(copiedBoard, ret.data_) {
currentPlayer {
playMinion(EmperorThaurissan)
mana(4)
numCardsUsed(1)
}
}

def retAfterEndTurn = new HearthTreeNode(Game.endTurn(ret.data_))
assertBoardDelta(copiedBoard, retAfterEndTurn.data_) {
currentPlayer {
playMinion(EmperorThaurissan)
mana(4)
numCardsUsed(1)
updateCardInHand(0, [manaDelta: -1])
updateCardInHand(1, [manaDelta: -1])
}
waitingPlayer {
updateCardInHand(0, [manaDelta: 0])
updateCardInHand(1, [manaDelta: 0])
updateCardInHand(2, [manaDelta: 0])
}
}

}
}
Loading

0 comments on commit 1a618be

Please sign in to comment.