Skip to content

Commit

Permalink
some bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Salimi committed May 6, 2019
1 parent 0e0db5d commit cbc79de
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion jsonData/accounts/ahmad.account.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsonData/accounts/hadi123.account.json

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions jsonData/itemCards/usable/SuperShield.usable.item.card.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
"duration": 2147483647
},
"target": {
"isForAroundOwnHero": true,
"dimensions": {
"row": 1,
"column": 1
},
"isForDeckCards": true,
"owner": {
"own": true
},
Expand Down
3 changes: 3 additions & 0 deletions src/client/models/comperessedData/CompressedSpell.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public int getLastTurnUsed() {
}

public boolean isCoolDown(int turnNumber) {
if (lastTurnUsed == 0) {
return false;
}
return lastTurnUsed + coolDown * 2 >= turnNumber;
}
}
2 changes: 1 addition & 1 deletion src/client/view/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private void showMoves(AvailableActions availableActions) {
private void showSpecialPower(AvailableActions availableActions) {
if (availableActions.getSpecialPower() != null) {
System.out.println("Special power is available; requires " +
availableActions.getSpecialPower().getHero().getCard().getMannaPoint() + "MP\n");
availableActions.getSpecialPower().getHero().getCard().getSpell().getMannaPoint() + "MP\n");
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/server/models/account/MatchHistory.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package server.models.account;

import server.models.game.Player;

import java.util.Date;

public class MatchHistory {
private String oppName;
private boolean amIWinner;
private Date date;

public MatchHistory(String oppName, boolean amIWinner) {
this.oppName = oppName;
public MatchHistory(Player player, boolean amIWinner) {
if (player.getUserName().equals("AI")) {
this.oppName = player.getDeck().getDeckName();
} else {
this.oppName = player.getUserName();
}
this.amIWinner = amIWinner;
this.date = new Date(System.currentTimeMillis());
}
Expand Down
3 changes: 3 additions & 0 deletions src/server/models/card/spell/Spell.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public SpellAction getAction() {
}

public boolean isCoolDown(int turnNumber) {
if (lastTurnUsed == 0) {
return false;
}
return lastTurnUsed + coolDown * 2 >= turnNumber;
}
}
17 changes: 11 additions & 6 deletions src/server/models/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ public GameMap getGameMap() {
}

public void startGame() throws ServerException {
applyOnStartSpells(playerOne.getDeck());
putMinion(1, playerOne.getHero(), gameMap.getCell(2, 0));

this.turnNumber = 2;
applyOnStartSpells(playerTwo.getDeck());
putMinion(2, playerTwo.getHero(), gameMap.getCell(2, 8));

this.turnNumber = 1;

playerOne.setCurrentMP(20);
Server.getInstance().sendGameUpdateMessage(this);

applyOnStartSpells(playerTwo.getDeck());
applyOnStartSpells(playerTwo.getDeck());
}

public CompressedGame toCompressedGame() {
Expand Down Expand Up @@ -469,7 +470,7 @@ private Troop getAndValidateHero(String cardId) throws ClientException {

private Spell getAndValidateSpecialPower(Troop hero) throws ClientException {
Spell specialPower = hero.getCard().getSpells().get(0);
if (specialPower == null || specialPower.getAvailabilityType().isSpecialPower()) {
if (specialPower == null || !specialPower.getAvailabilityType().isSpecialPower()) {
throw new ClientException("special power is not available");
}

Expand Down Expand Up @@ -747,7 +748,11 @@ private void setTargetData(Spell spell, Cell cardCell, Cell clickCell, Cell hero
for (Card card : player.getDeck().getOthers()) {
addCardToTargetData(spell, targetData, card);
}
for (Card card : player.getHand()) {
addCardToTargetData(spell, targetData, card);
}
addCardToTargetData(spell, targetData, player.getNextCard());
addCardToTargetData(spell, targetData, player.getDeck().getHero());
}
if (spell.getTarget().getDimensions() != null) {
Position centerPosition = getCenterPosition(spell, cardCell, clickCell, heroCell);
Expand Down Expand Up @@ -850,11 +855,11 @@ private int calculateLastCoordinate(int first, int dimension, int maxNumber) {

void setMatchHistories(boolean resultOne, boolean resultTwo) {
playerOne.setMatchHistory(
new MatchHistory(playerTwo.getUserName(), resultOne)
new MatchHistory(playerTwo, resultOne)
);

playerTwo.setMatchHistory(
new MatchHistory(playerOne.getUserName(), resultTwo)
new MatchHistory(playerOne, resultTwo)
);
}

Expand Down

0 comments on commit cbc79de

Please sign in to comment.