Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
abolfazlghalandary committed May 20, 2021
1 parent 0f21993 commit 74bd7e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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 @@ -255,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 Down Expand Up @@ -341,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
2 changes: 2 additions & 0 deletions src/main/java/model/cards/SpellAndTrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ else if (spellAndTrap.name.equals("Sword of dark destruction"))

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 Down

0 comments on commit 74bd7e9

Please sign in to comment.