Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…roject-team-55

� Conflicts:
�	pom.xml
  • Loading branch information
ParhamBateni committed Jun 6, 2021
2 parents 06f255d + 74bd7e9 commit 35213de
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<javafx.version>11</javafx.version>
<maven.compiler.target>11</maven.compiler.target>
<javafx.version>11</javafx.version>
</properties>

<build>
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/controller/AIPlayerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ public String getSpecialCommand() {
lastAICommand = command;
return command;
}
if (lastResponse.contains("number")) {
String command = (CoinDice.rollDice() + CoinDice.rollDice() - 1) + "";
lastAICommand = command;
return command;
}
if (lastResponse.contains("you should special summon right now")) {
String command = "summon";
lastAICommand = command;
Expand Down Expand Up @@ -253,13 +248,19 @@ public String getSpecialCommand() {
return lastAICommand;
}
}
if (lastResponse.contains("choose a monster from your or your opponents graveyard")) {
if (lastResponse.contains("choose a monster from your or your opponents graveyard") ||
lastResponse.contains("(me (number)/opponent (number))")) {
String command;
if (CoinDice.tossCoin() == 1) command = "me " + CoinDice.rollDice();
else command = "opponent " + CoinDice.rollDice();
lastAICommand = command;
return command;
}
if (lastResponse.contains("number")) {
String command = (CoinDice.rollDice() + CoinDice.rollDice() - 1) + "";
lastAICommand = command;
return command;
}

if (CoinDice.rollDice() == 6) {
lastAICommand = "cancel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public void activateTrapEffect(ArrayList<SpellAndTrap> trapsCanBeActivated) {
Cell selectedCell = Cell.getSelectedCell();
for (SpellAndTrap spellAndTrap : trapsCanBeActivated) {
if (selectedCell.getCellCard().getName().equals(spellAndTrap.getName())) {
SpellAndTrap.activateSpellOrTrapEffects(this, spellAndTrap);
SpellAndTrap.activateSpellEffects(this, spellAndTrap);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import model.cards.monsters.TheTricky;
import model.cards.trapandspells.TimeSeal;
import model.cards.trapandspells.TorrentialTribute;
import model.cards.trapandspells.TrapHole;
import model.exceptions.GameException;
import view.ConsoleColors;
import view.ViewInterface;
Expand Down Expand Up @@ -256,6 +255,7 @@ default void activateSpell(GameController gameController) throws GameException {
throw new GameException(GameResponses.NO_CARDS_SELECTED.response);
} else {
Card card = selectedCell.getCellCard();
if (card == null) return;
if (card.isMonster()) {
throw new GameException(GameResponses.ACTIVATION_ONLY_FOR_SPELL.response);
} else {
Expand All @@ -271,7 +271,7 @@ default void activateSpell(GameController gameController) throws GameException {
if(Cell.getSelectedCell().isEmpty()||Cell.getSelectedCell()==null){
System.out.println("error in activate effect");
}
SpellAndTrap.activateSpellOrTrapEffects(gameController, spell);
SpellAndTrap.activateSpellEffects(gameController, spell);
// if(!playerGameBoard.isCellInSpellAndTrapZone(selectedCell)) {
// playerGameBoard.getHandCards().remove(selectedCell);
// if (spell.getAttribute() == SpellOrTrapAttribute.FIELD) {
Expand Down Expand Up @@ -342,6 +342,7 @@ default void specialSummon(GameController gameController) throws GameException {
}

default boolean isSummonable(Cell cell,GameController gameController) {
if (cell.isEmpty()) return false;
Card card=cell.getCellCard();
if (card.isMonster()&&gameController.currentTurnPlayer.getGameBoard().isCellInHandZone(cell)) {
return ((Monster) card).getCardType() != CardType.RITUAL;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/model/cards/SpellAndTrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public SpellAndTrap(String name, String description, int price,
this.status = status;
}

public static void activateSpellOrTrapEffects(GameController gameController, SpellAndTrap spellAndTrap) {
public static void activateSpellEffects(GameController gameController, SpellAndTrap spellAndTrap) {
if (spellAndTrap.name.equals("Monster Reborn")) MonsterReborn.setActivated(gameController);
else if (spellAndTrap.name.equals("Terraforming")) Terraforming.setActivated(gameController);
else if (spellAndTrap.name.equals("Pot of Greed")) PotofGreed.setActivated(gameController);
Expand All @@ -53,14 +53,14 @@ else if (spellAndTrap.name.equals("Sword of dark destruction"))
else {
ViewInterface.showResult(GameResponses.ACTIVATION_ONLY_FOR_SPELL.response);
}
//todo : in be nazaram qhalate (parham)
SpellAbsorption.handleEffect();
}

public static void updateSpellInGameBoard(GameController gameController) {
Cell selectedCell = Cell.getSelectedCell();
if (selectedCell == null) return;
Card card = selectedCell.getCellCard();
SpellAndTrap spell = (SpellAndTrap) card;
if (spell == null) return;
GameBoard playerGameBoard = gameController.getCurrentTurnPlayer().getGameBoard();
if (!playerGameBoard.isCellInSpellAndTrapZone(selectedCell)) {
playerGameBoard.getHandCards().remove(selectedCell);
Expand All @@ -74,6 +74,7 @@ public static void updateSpellInGameBoard(GameController gameController) {
}
}
} else {
SpellAbsorption.handleEffect();
selectedCell.setCardStatus(CardStatus.OCCUPIED);
}
Cell.deselectCell();
Expand Down

0 comments on commit 35213de

Please sign in to comment.