-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca346a2
commit e791d70
Showing
10 changed files
with
543 additions
and
357 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main.card.ability; | ||
|
||
import main.Game; | ||
import main.card.MinionCard; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class BloodThirst implements RowAbility { | ||
@Override | ||
public void use(Game game, int affectedRow) { | ||
ArrayList<MinionCard> cards = game.getRow(affectedRow); | ||
cards.forEach(card -> card.addAttackDamage(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main.card.ability; | ||
|
||
import main.Game; | ||
import main.card.MinionCard; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class EarthBorn implements RowAbility { | ||
@Override | ||
public void use(Game game, int affectedRow) { | ||
ArrayList<MinionCard> cards = game.getRow(affectedRow); | ||
cards.forEach(card -> card.addHealth(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main.card.ability; | ||
|
||
import main.Game; | ||
import main.card.MinionCard; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class LowBlow implements RowAbility { | ||
@Override | ||
public void use(Game game, int affectedRow) { | ||
ArrayList<MinionCard> cards = game.getRow(affectedRow); | ||
|
||
MinionCard maxHealth = null; | ||
for (MinionCard card : | ||
cards) { | ||
if ( maxHealth == null || card.getAttackDamage() >= maxHealth.getAttackDamage()) | ||
maxHealth = card; | ||
} | ||
|
||
cards.remove(maxHealth); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main.card.ability; | ||
|
||
import main.Game; | ||
import main.card.MinionCard; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class SubZero implements RowAbility { | ||
@Override | ||
public void use(Game game, int affectedRow) { | ||
ArrayList<MinionCard> cards = game.getRow(affectedRow); | ||
|
||
MinionCard maxHealth = cards.get(0); | ||
for (MinionCard card : | ||
cards) { | ||
if (card.getAttackDamage() > maxHealth.getAttackDamage()) | ||
maxHealth = card; | ||
} | ||
|
||
maxHealth.setFrozen(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main.command; | ||
|
||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import main.Game; | ||
import main.Player; | ||
import main.card.HeroCard; | ||
|
||
public class UseHeroAbility implements Command { | ||
Game game; | ||
int affectedRow; | ||
|
||
public UseHeroAbility(Game game, int affectedRow) { | ||
this.game = game; | ||
this.affectedRow = affectedRow; | ||
} | ||
|
||
@Override | ||
public void execute(ArrayNode output) { | ||
boolean error = false; | ||
String errorMessage = null; | ||
Player player = (game.getPlayerTurn() == 1)? game.getPlayer1() : game.getPlayer2(); | ||
HeroCard hero = player.getHeroCard(); | ||
|
||
if (player.getMana() < hero.getMana()) { | ||
error = true; | ||
errorMessage = "Not enough mana to use hero's ability."; | ||
} | ||
|
||
if (!error && game.getHaveAttacked().contains(hero)) { | ||
error = true; | ||
errorMessage = "Hero has already attacked this turn."; | ||
} | ||
|
||
if (hero.getName().equals("Lord Royce") || hero.getName().equals("Empress Thorina")) { | ||
if (!error && !game.rowBelongsToEnemy(affectedRow)) { | ||
error = true; | ||
errorMessage = "Selected row does not belong to the enemy."; | ||
} | ||
} else { | ||
if (!error && game.rowBelongsToEnemy(affectedRow)) { | ||
error = true; | ||
errorMessage = "Selected row does not belong to the current player."; | ||
} | ||
} | ||
|
||
if (error) { | ||
output.addObject() | ||
.put("command", "useHeroAbility") | ||
.putPOJO("affectedRow", affectedRow) | ||
.put("error", errorMessage); | ||
} else { | ||
hero.useHeroAbility(game, affectedRow); | ||
player.removeMana(hero.getMana()); | ||
game.getHaveAttacked().add(hero); | ||
} | ||
} | ||
} |