From 5bc490fcd7aaa8f00cf3b8fc412b1d1faf5b0950 Mon Sep 17 00:00:00 2001 From: Mostafa Date: Mon, 6 May 2019 23:07:10 +0430 Subject: [PATCH 1/2] Merge branch 'master' of /home/mostafa/Desktop/AP/project-16 with conflicts. --- src/models/Deck.java | 3 +-- src/models/Initializer.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/models/Deck.java b/src/models/Deck.java index c11edaa..f78e97f 100644 --- a/src/models/Deck.java +++ b/src/models/Deck.java @@ -103,8 +103,7 @@ public boolean hasCard(int cardID) { } public boolean isValid() { - return true; - //return this.cards.size() == CARD_CAPACITY && this.getHero() != null; + return this.cards.size() == CARD_CAPACITY && this.getHero() != null; } public Deck getCopy() { diff --git a/src/models/Initializer.java b/src/models/Initializer.java index 04d179d..99caadd 100644 --- a/src/models/Initializer.java +++ b/src/models/Initializer.java @@ -210,7 +210,7 @@ private static void addMinions(ArrayList cards) { .setTargetSociety(new OneUnit(TargetType.MINION, TargetTeam.FRIEND, TargetAttackType.ANY)) .addBuff(new Buff.BuffBuilder() .setDeltaHP(10) - .setDuration(Buff.INFINITY) + .setHalfTurnDuration() .create()) .create()) .setAttackType(new Ranged(3)) From 66b6ce0aca506c1d2f0b6f8d8e2dfec73eba7b7a Mon Sep 17 00:00:00 2001 From: sadeghsalimi Date: Mon, 6 May 2019 23:46:25 +0430 Subject: [PATCH 2/2] maybe bug fix (in getCopy). and optimize AI --- src/models/Deck.java | 5 ++--- src/models/artificialIntelligence/AIPlayer.java | 2 +- src/models/item/Item.java | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/models/Deck.java b/src/models/Deck.java index e970999..4096494 100644 --- a/src/models/Deck.java +++ b/src/models/Deck.java @@ -108,9 +108,8 @@ public boolean isValid() { } public Deck getCopy() { - YaGson yaGson = new YaGson(); - String json = yaGson.toJson(this); - Deck newDeck = yaGson.fromJson(json, this.getClass()); + String json = new YaGson().toJson(this); + Deck newDeck = new YaGson().fromJson(json, this.getClass()); return newDeck; } } diff --git a/src/models/artificialIntelligence/AIPlayer.java b/src/models/artificialIntelligence/AIPlayer.java index 1ee4aac..0d8a472 100644 --- a/src/models/artificialIntelligence/AIPlayer.java +++ b/src/models/artificialIntelligence/AIPlayer.java @@ -186,7 +186,7 @@ private Cell getNearestCell(ArrayList cells, Cell cell) { int distance = 123; //just for sure!! Cell resultCell = null; for (Cell cell1 : cells) { - if (Table.getDistance(cell1, cell) < distance) { + if (Table.getDistance(cell1, cell) < distance && !cell1.hasUnit()) { distance = Table.getDistance(cell1, cell); resultCell = cell1; } diff --git a/src/models/item/Item.java b/src/models/item/Item.java index f418df4..b3ffe89 100644 --- a/src/models/item/Item.java +++ b/src/models/item/Item.java @@ -113,9 +113,8 @@ public String getDescription() { public abstract void use(Player player, Cell cell); public Item getCopy(boolean setCollectionID) { - YaGson yaGson = new YaGson(); - String json = yaGson.toJson(this); - Item newItem = yaGson.fromJson(json, this.getClass()); + String json = new YaGson().toJson(this); + Item newItem = new YaGson().fromJson(json, this.getClass()); if (setCollectionID) { newItem.collectionID = UniqueIDGenerator.getCollectionUniqueID(); }