From a7db7a7525671e2770b03d16f9f6c66d7209054b Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Sun, 9 Apr 2023 21:28:17 -0400
Subject: [PATCH 1/9] new branch
---
.bsp/sbt.json | 2 +-
.idea/codeStyles/codeStyleConfig.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.bsp/sbt.json b/.bsp/sbt.json
index d041aef..0e7fda3 100644
--- a/.bsp/sbt.json
+++ b/.bsp/sbt.json
@@ -1 +1 @@
-{"name":"sbt","version":"1.8.2","bspVersion":"2.1.0-M1","languages":["scala"],"argv":["C:\\Users\\Ignacio\\.jdks\\openjdk-19/bin/java","-Xms100m","-Xmx100m","-classpath","C:/Users/Ignacio/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/223.8836.41.plugins/Scala/launcher/sbt-launch.jar","-Dsbt.script=C:\\Program%20Files%20(x86)\\sbt\\bin\\sbt.bat","xsbt.boot.Boot","-bsp"]}
\ No newline at end of file
+{"name":"sbt","version":"1.8.2","bspVersion":"2.1.0-M1","languages":["scala"],"argv":["C:\\Users\\Usuario\\.jdks\\openjdk-19.0.2/bin/java","-Xms100m","-Xmx100m","-classpath","C:/Users/Usuario/AppData/Roaming/JetBrains/IntelliJIdea2022.3/plugins/Scala/launcher/sbt-launch.jar","xsbt.boot.Boot","-bsp","--sbt-launch-jar=C:/Users/Usuario/AppData/Roaming/JetBrains/IntelliJIdea2022.3/plugins/Scala/launcher/sbt-launch.jar"]}
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 6df95bc..a55e7a1 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
From ae358f224213a864cd947800bceaeebe47defcb4 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Sun, 9 Apr 2023 22:25:45 -0400
Subject: [PATCH 2/9] TEST
Added PlayerTest and CardTest
---
.idea/.name | 1 +
.idea/codeStyles/Project.xml | 543 ------------------
.../libraries/sbt__junit_junit_4_13_2_jar.xml | 6 +-
...bt__org_hamcrest_hamcrest_core_1_3_jar.xml | 6 +-
..._scala_lang_scala3_library_3_3_2_2_jar.xml | 90 +--
...g_scala_lang_scala_library_2_13_10_jar.xml | 6 +-
...__org_scala_sbt_test_interface_1_0_jar.xml | 6 +-
...g_scalameta_junit_interface_0_7_29_jar.xml | 6 +-
.../sbt__org_scalameta_munit_3_0_7_29_jar.xml | 6 +-
.idea/modules/gwent-build.iml | 6 +-
.idea/modules/gwent.iml | 2 +-
src/test/scala/gwent/player/CardTest.scala | 20 +
src/test/scala/gwent/player/PlayerTest.scala | 39 ++
13 files changed, 127 insertions(+), 610 deletions(-)
create mode 100644 .idea/.name
create mode 100644 src/test/scala/gwent/player/CardTest.scala
create mode 100644 src/test/scala/gwent/player/PlayerTest.scala
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..4dcbefa
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+gwent
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index dd0d86e..d6b961a 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,53 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -96,500 +48,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- GETTERS_AND_SETTERS
- KEEP
-
-
- OVERRIDDEN_METHODS
- KEEP
-
-
- DEPENDENT_METHODS
- BREADTH_FIRST
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- xmlns:android
-
- ^$
-
-
-
-
-
-
-
-
- xmlns:.*
-
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:id
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- style
-
- ^$
-
-
-
-
-
-
-
-
- .*
-
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:.*Style
-
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*:layout_width
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_height
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_weight
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_margin
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_marginTop
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_marginBottom
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_marginStart
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_marginEnd
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_marginLeft
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_marginRight
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_.*
-
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*:padding
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:paddingTop
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:paddingBottom
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:paddingStart
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:paddingEnd
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:paddingLeft
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:paddingRight
-
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- http://schemas.android.com/apk/res-auto
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- http://schemas.android.com/tools
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- .*
-
-
- BY_NAME
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/sbt__junit_junit_4_13_2_jar.xml b/.idea/libraries/sbt__junit_junit_4_13_2_jar.xml
index 48da8ef..6340917 100644
--- a/.idea/libraries/sbt__junit_junit_4_13_2_jar.xml
+++ b/.idea/libraries/sbt__junit_junit_4_13_2_jar.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/sbt__org_hamcrest_hamcrest_core_1_3_jar.xml b/.idea/libraries/sbt__org_hamcrest_hamcrest_core_1_3_jar.xml
index e415d3b..e9a5a19 100644
--- a/.idea/libraries/sbt__org_hamcrest_hamcrest_core_1_3_jar.xml
+++ b/.idea/libraries/sbt__org_hamcrest_hamcrest_core_1_3_jar.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/sbt__org_scala_lang_scala3_library_3_3_2_2_jar.xml b/.idea/libraries/sbt__org_scala_lang_scala3_library_3_3_2_2_jar.xml
index b48c846..62a9dd5 100644
--- a/.idea/libraries/sbt__org_scala_lang_scala3_library_3_3_2_2_jar.xml
+++ b/.idea/libraries/sbt__org_scala_lang_scala3_library_3_3_2_2_jar.xml
@@ -3,60 +3,60 @@
Scala_3_2
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/sbt__org_scala_lang_scala_library_2_13_10_jar.xml b/.idea/libraries/sbt__org_scala_lang_scala_library_2_13_10_jar.xml
index ea17d8a..f3892ab 100644
--- a/.idea/libraries/sbt__org_scala_lang_scala_library_2_13_10_jar.xml
+++ b/.idea/libraries/sbt__org_scala_lang_scala_library_2_13_10_jar.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/sbt__org_scala_sbt_test_interface_1_0_jar.xml b/.idea/libraries/sbt__org_scala_sbt_test_interface_1_0_jar.xml
index b74c24e..9522148 100644
--- a/.idea/libraries/sbt__org_scala_sbt_test_interface_1_0_jar.xml
+++ b/.idea/libraries/sbt__org_scala_sbt_test_interface_1_0_jar.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/sbt__org_scalameta_junit_interface_0_7_29_jar.xml b/.idea/libraries/sbt__org_scalameta_junit_interface_0_7_29_jar.xml
index 1d6d600..3eecfb4 100644
--- a/.idea/libraries/sbt__org_scalameta_junit_interface_0_7_29_jar.xml
+++ b/.idea/libraries/sbt__org_scalameta_junit_interface_0_7_29_jar.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/sbt__org_scalameta_munit_3_0_7_29_jar.xml b/.idea/libraries/sbt__org_scalameta_munit_3_0_7_29_jar.xml
index a175522..40a2a8e 100644
--- a/.idea/libraries/sbt__org_scalameta_munit_3_0_7_29_jar.xml
+++ b/.idea/libraries/sbt__org_scalameta_munit_3_0_7_29_jar.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/modules/gwent-build.iml b/.idea/modules/gwent-build.iml
index 3b0273d..baca593 100644
--- a/.idea/modules/gwent-build.iml
+++ b/.idea/modules/gwent-build.iml
@@ -109,8 +109,8 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/gwent.iml b/.idea/modules/gwent.iml
index 54312c4..fac9c5f 100644
--- a/.idea/modules/gwent.iml
+++ b/.idea/modules/gwent.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/src/test/scala/gwent/player/CardTest.scala b/src/test/scala/gwent/player/CardTest.scala
new file mode 100644
index 0000000..b00520b
--- /dev/null
+++ b/src/test/scala/gwent/player/CardTest.scala
@@ -0,0 +1,20 @@
+package cl.uchile.dcc
+package gwent.player
+import munit.FunSuite
+
+class CardTest extends FunSuite {
+ var Card1: Card = null
+ var Card2: Card = null
+ var Card3: Card = null
+
+ override BeforeEach(context: BeforeEach): Unit = {
+ /*Cartas tiene nombre y efecto*/
+ Card1 = new Card("Triss")
+ Card2 = new Card("Geralt")
+ }
+ test("Cards have names"){
+ assertEquals(Card1.name,"Triss")
+ assertEquals(Card2.name, "Geralt")
+ assertNotEquals(Card1.name, Card2.name)
+ }
+}
diff --git a/src/test/scala/gwent/player/PlayerTest.scala b/src/test/scala/gwent/player/PlayerTest.scala
new file mode 100644
index 0000000..29efe5d
--- /dev/null
+++ b/src/test/scala/gwent/player/PlayerTest.scala
@@ -0,0 +1,39 @@
+package cl.uchile.dcc
+package gwent.player
+import munit.FunSuite
+
+class PlayerTest extends FunSuite {
+ var Player1: Player = null
+ var Player2: Player = null
+
+ override def BeforeEach(context: BeforeEach): Unit = {
+ /* nombre, sec tab, gems, deck, hand */
+ Player1 = new Player("Geralt")
+ Player2 = new Player("Roach")
+ /*crear decks y cartas de prueba*/
+ }
+
+ test("Players have names"){
+ assertEquals(Player1.name,"Geralt")
+ assertEquals(Player2.name, "Roach")
+ assertNotEquals(Player1.name, Player2.name)
+ }
+
+ test("Players have gems"){
+ assertEquals(Player1.gems,2)
+ assertEquals(Player2.gems, Player2.gems)
+ /*Probar en el futuro el perder gemas*/
+ }
+ test("Players have decks"){
+ /*les damos decks y verificamos*/
+ }
+ test("Players have cards in hand"){
+ /*ponemos cartas en sus manos*/
+ }
+ test("Players can play cards") {
+ /*juegan una carta en la mano*/
+ }
+ test("Players draw cards"){
+ /*roban cartas del deck (3)*/
+ }
+}
From a1605926e10b84d408e701d402c838035dc817b7 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Sun, 9 Apr 2023 23:36:20 -0400
Subject: [PATCH 3/9] FEAT
Added the Player and Card classes and their respective Traits
---
src/main/scala/gwent/card/Card.scala | 10 ++++++
src/main/scala/gwent/card/ICard.scala | 9 +++++
src/main/scala/gwent/player/IPlayer.scala | 15 +++++++++
src/main/scala/gwent/player/Player.scala | 33 +++++++++++++++++++
.../gwent/{player => card}/CardTest.scala | 8 ++---
5 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 src/main/scala/gwent/card/Card.scala
create mode 100644 src/main/scala/gwent/card/ICard.scala
create mode 100644 src/main/scala/gwent/player/IPlayer.scala
create mode 100644 src/main/scala/gwent/player/Player.scala
rename src/test/scala/gwent/{player => card}/CardTest.scala (77%)
diff --git a/src/main/scala/gwent/card/Card.scala b/src/main/scala/gwent/card/Card.scala
new file mode 100644
index 0000000..bb8dff4
--- /dev/null
+++ b/src/main/scala/gwent/card/Card.scala
@@ -0,0 +1,10 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents a card in the game Gwent */
+class Card(name: String, effect: Unit) extends ICard {
+
+ override def getName(): String = {
+ this.name
+ }
+}
diff --git a/src/main/scala/gwent/card/ICard.scala b/src/main/scala/gwent/card/ICard.scala
new file mode 100644
index 0000000..6c9ba67
--- /dev/null
+++ b/src/main/scala/gwent/card/ICard.scala
@@ -0,0 +1,9 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Trait that dictates the general behavior of a Card */
+trait ICard {
+ /** Method that returns the Card's name */
+ def getName (): String
+
+}
diff --git a/src/main/scala/gwent/player/IPlayer.scala b/src/main/scala/gwent/player/IPlayer.scala
new file mode 100644
index 0000000..733f355
--- /dev/null
+++ b/src/main/scala/gwent/player/IPlayer.scala
@@ -0,0 +1,15 @@
+package cl.uchile.dcc
+package gwent.player
+
+/** Trait that dictates the general actions of a Player class */
+trait IPlayer {
+ /** Method that returns the Player's name */
+ def getName(): String
+
+ /** Method that plays a Card */
+ def playCard(): Boolean
+
+ /** Method that draws cards from a Player's deck */
+ def drawCards(): Boolean
+
+}
diff --git a/src/main/scala/gwent/player/Player.scala b/src/main/scala/gwent/player/Player.scala
new file mode 100644
index 0000000..ecfd12d
--- /dev/null
+++ b/src/main/scala/gwent/player/Player.scala
@@ -0,0 +1,33 @@
+package cl.uchile.dcc
+package gwent.player
+
+/** Class that represents a player in Gwent */
+class Player(val name: String) extends IPlayer {
+ /** Gems are the "HP" in Gwent */
+ var gems: Int = 2
+ //var deck: Array[String]
+ //var hand: Array[String]
+ /*var deck: Array[Card] = null*/
+ /*var hand: Array[Card] = null*/
+
+ def this(name: String, gems: Int) = {
+ this(name)
+ this.gems = 2
+ }
+
+ override def equals(obj: Any): Boolean = super.equals(obj)
+
+ override def getName(): String = {
+ this.name
+ }
+
+ override def drawCards(): Boolean = {
+ /* if there are cards in deck -> add to hand and true, if not false */
+ false
+ }
+
+ override def playCard(): Boolean = {
+ /* if the card is in hand -> true and play it, if not false */
+ false
+ }
+}
diff --git a/src/test/scala/gwent/player/CardTest.scala b/src/test/scala/gwent/card/CardTest.scala
similarity index 77%
rename from src/test/scala/gwent/player/CardTest.scala
rename to src/test/scala/gwent/card/CardTest.scala
index b00520b..80ecea7 100644
--- a/src/test/scala/gwent/player/CardTest.scala
+++ b/src/test/scala/gwent/card/CardTest.scala
@@ -1,16 +1,16 @@
package cl.uchile.dcc
-package gwent.player
+package gwent.card
+
import munit.FunSuite
class CardTest extends FunSuite {
var Card1: Card = null
var Card2: Card = null
- var Card3: Card = null
override BeforeEach(context: BeforeEach): Unit = {
/*Cartas tiene nombre y efecto*/
- Card1 = new Card("Triss")
- Card2 = new Card("Geralt")
+ Card1 = new Card("Triss",null)
+ Card2 = new Card("Geralt",null)
}
test("Cards have names"){
assertEquals(Card1.name,"Triss")
From 271bd7983f9c62b042e6045976cffa16e6c10714 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Mon, 10 Apr 2023 20:33:16 -0400
Subject: [PATCH 4/9] FIX
Fixed problems on the definition of CardTest, PlayerTest and the class Card
---
src/main/scala/gwent/card/Card.scala | 2 +-
src/test/scala/gwent/card/CardTest.scala | 3 +--
src/test/scala/gwent/player/PlayerTest.scala | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/main/scala/gwent/card/Card.scala b/src/main/scala/gwent/card/Card.scala
index bb8dff4..131bd05 100644
--- a/src/main/scala/gwent/card/Card.scala
+++ b/src/main/scala/gwent/card/Card.scala
@@ -2,7 +2,7 @@ package cl.uchile.dcc
package gwent.card
/** Class that represents a card in the game Gwent */
-class Card(name: String, effect: Unit) extends ICard {
+class Card(val name: String, effect: Unit) extends ICard {
override def getName(): String = {
this.name
diff --git a/src/test/scala/gwent/card/CardTest.scala b/src/test/scala/gwent/card/CardTest.scala
index 80ecea7..a7b74a8 100644
--- a/src/test/scala/gwent/card/CardTest.scala
+++ b/src/test/scala/gwent/card/CardTest.scala
@@ -6,8 +6,7 @@ import munit.FunSuite
class CardTest extends FunSuite {
var Card1: Card = null
var Card2: Card = null
-
- override BeforeEach(context: BeforeEach): Unit = {
+ def BeforeEach(context: BeforeEach): Unit = {
/*Cartas tiene nombre y efecto*/
Card1 = new Card("Triss",null)
Card2 = new Card("Geralt",null)
diff --git a/src/test/scala/gwent/player/PlayerTest.scala b/src/test/scala/gwent/player/PlayerTest.scala
index 29efe5d..aebbe1b 100644
--- a/src/test/scala/gwent/player/PlayerTest.scala
+++ b/src/test/scala/gwent/player/PlayerTest.scala
@@ -6,7 +6,7 @@ class PlayerTest extends FunSuite {
var Player1: Player = null
var Player2: Player = null
- override def BeforeEach(context: BeforeEach): Unit = {
+ def BeforeEach(context: BeforeEach): Unit = {
/* nombre, sec tab, gems, deck, hand */
Player1 = new Player("Geralt")
Player2 = new Player("Roach")
From 92fcda7759a87e1ac17f66413b6873463dca61cd Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Tue, 18 Apr 2023 11:44:07 -0400
Subject: [PATCH 5/9] REFACTOR & FIX
Moved the class Player to root package gwent and Fixed class name in PlayerTest and CardTest
---
.../scala/gwent/{player => }/IPlayer.scala | 3 ++-
.../scala/gwent/{player => }/Player.scala | 12 +++++-------
.../scala/gwent/{player => }/PlayerTest.scala | 19 +++++++++++--------
src/test/scala/gwent/card/CardTest.scala | 6 +++---
4 files changed, 21 insertions(+), 19 deletions(-)
rename src/main/scala/gwent/{player => }/IPlayer.scala (90%)
rename src/main/scala/gwent/{player => }/Player.scala (87%)
rename src/test/scala/gwent/{player => }/PlayerTest.scala (68%)
diff --git a/src/main/scala/gwent/player/IPlayer.scala b/src/main/scala/gwent/IPlayer.scala
similarity index 90%
rename from src/main/scala/gwent/player/IPlayer.scala
rename to src/main/scala/gwent/IPlayer.scala
index 733f355..f741bf1 100644
--- a/src/main/scala/gwent/player/IPlayer.scala
+++ b/src/main/scala/gwent/IPlayer.scala
@@ -1,10 +1,11 @@
package cl.uchile.dcc
-package gwent.player
+package gwent
/** Trait that dictates the general actions of a Player class */
trait IPlayer {
/** Method that returns the Player's name */
def getName(): String
+ def getGems(): Int
/** Method that plays a Card */
def playCard(): Boolean
diff --git a/src/main/scala/gwent/player/Player.scala b/src/main/scala/gwent/Player.scala
similarity index 87%
rename from src/main/scala/gwent/player/Player.scala
rename to src/main/scala/gwent/Player.scala
index ecfd12d..89146e7 100644
--- a/src/main/scala/gwent/player/Player.scala
+++ b/src/main/scala/gwent/Player.scala
@@ -1,5 +1,5 @@
package cl.uchile.dcc
-package gwent.player
+package gwent
/** Class that represents a player in Gwent */
class Player(val name: String) extends IPlayer {
@@ -9,18 +9,16 @@ class Player(val name: String) extends IPlayer {
//var hand: Array[String]
/*var deck: Array[Card] = null*/
/*var hand: Array[Card] = null*/
-
- def this(name: String, gems: Int) = {
- this(name)
- this.gems = 2
- }
-
override def equals(obj: Any): Boolean = super.equals(obj)
override def getName(): String = {
this.name
}
+ override def getGems(): Int = {
+ this.gems
+ }
+
override def drawCards(): Boolean = {
/* if there are cards in deck -> add to hand and true, if not false */
false
diff --git a/src/test/scala/gwent/player/PlayerTest.scala b/src/test/scala/gwent/PlayerTest.scala
similarity index 68%
rename from src/test/scala/gwent/player/PlayerTest.scala
rename to src/test/scala/gwent/PlayerTest.scala
index aebbe1b..8dc6fe6 100644
--- a/src/test/scala/gwent/player/PlayerTest.scala
+++ b/src/test/scala/gwent/PlayerTest.scala
@@ -1,21 +1,24 @@
package cl.uchile.dcc
-package gwent.player
+package gwent
+
import munit.FunSuite
class PlayerTest extends FunSuite {
- var Player1: Player = null
- var Player2: Player = null
+ var Player1: Player = _
+ var Player2: Player = _
+ var name1: String = "Geralt"
+ var name2: String = "Roach"
- def BeforeEach(context: BeforeEach): Unit = {
+ override def beforeEach(context: BeforeEach): Unit = {
/* nombre, sec tab, gems, deck, hand */
- Player1 = new Player("Geralt")
- Player2 = new Player("Roach")
+ Player1 = new Player(name1)
+ Player2 = new Player(name2)
/*crear decks y cartas de prueba*/
}
test("Players have names"){
- assertEquals(Player1.name,"Geralt")
- assertEquals(Player2.name, "Roach")
+ assertEquals(Player1.name,name1)
+ assertEquals(Player2.name, name2)
assertNotEquals(Player1.name, Player2.name)
}
diff --git a/src/test/scala/gwent/card/CardTest.scala b/src/test/scala/gwent/card/CardTest.scala
index a7b74a8..1bb986b 100644
--- a/src/test/scala/gwent/card/CardTest.scala
+++ b/src/test/scala/gwent/card/CardTest.scala
@@ -4,9 +4,9 @@ package gwent.card
import munit.FunSuite
class CardTest extends FunSuite {
- var Card1: Card = null
- var Card2: Card = null
- def BeforeEach(context: BeforeEach): Unit = {
+ var Card1: Card = _
+ var Card2: Card = _
+ override def beforeEach(context: BeforeEach): Unit = {
/*Cartas tiene nombre y efecto*/
Card1 = new Card("Triss",null)
Card2 = new Card("Geralt",null)
From c2be11bc2a10915f6ceb927e52dbaa2511d0bd23 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Mon, 24 Apr 2023 13:43:32 -0400
Subject: [PATCH 6/9] FIX, FEAT
Fixed Multiple methods on the player package.
Added the UnitCard and its respective types. Also added the respective Tests for each class.
---
src/main/scala/gwent/IPlayer.scala | 15 ++---
src/main/scala/gwent/Player.scala | 58 ++++++++++++++-----
src/main/scala/gwent/card/AbstractCard.scala | 9 +++
.../scala/gwent/card/AbstractUnitCard.scala | 22 +++++++
src/main/scala/gwent/card/Card.scala | 10 ----
src/main/scala/gwent/card/ClimateCard.scala | 23 ++++++++
src/main/scala/gwent/card/ICard.scala | 3 +
src/main/scala/gwent/card/IUnit.scala | 6 ++
src/main/scala/gwent/card/MeleeUnitCard.scala | 25 ++++++++
src/main/scala/gwent/card/RangeUnitCard.scala | 24 ++++++++
src/main/scala/gwent/card/SiegeUnitCard.scala | 30 ++++++++++
src/test/scala/gwent/PlayerTest.scala | 43 ++++++++++----
src/test/scala/gwent/card/CardTest.scala | 19 ------
.../scala/gwent/card/ClimateCardTest.scala | 42 ++++++++++++++
.../scala/gwent/card/MeleeUnitCardTest.scala | 54 +++++++++++++++++
.../scala/gwent/card/RangeUnitCardTest.scala | 53 +++++++++++++++++
.../scala/gwent/card/SiegeUnitCardTest.scala | 53 +++++++++++++++++
17 files changed, 428 insertions(+), 61 deletions(-)
create mode 100644 src/main/scala/gwent/card/AbstractCard.scala
create mode 100644 src/main/scala/gwent/card/AbstractUnitCard.scala
delete mode 100644 src/main/scala/gwent/card/Card.scala
create mode 100644 src/main/scala/gwent/card/ClimateCard.scala
create mode 100644 src/main/scala/gwent/card/IUnit.scala
create mode 100644 src/main/scala/gwent/card/MeleeUnitCard.scala
create mode 100644 src/main/scala/gwent/card/RangeUnitCard.scala
create mode 100644 src/main/scala/gwent/card/SiegeUnitCard.scala
delete mode 100644 src/test/scala/gwent/card/CardTest.scala
create mode 100644 src/test/scala/gwent/card/ClimateCardTest.scala
create mode 100644 src/test/scala/gwent/card/MeleeUnitCardTest.scala
create mode 100644 src/test/scala/gwent/card/RangeUnitCardTest.scala
create mode 100644 src/test/scala/gwent/card/SiegeUnitCardTest.scala
diff --git a/src/main/scala/gwent/IPlayer.scala b/src/main/scala/gwent/IPlayer.scala
index f741bf1..1370377 100644
--- a/src/main/scala/gwent/IPlayer.scala
+++ b/src/main/scala/gwent/IPlayer.scala
@@ -1,16 +1,17 @@
package cl.uchile.dcc
package gwent
+import card.ICard
+
+import scala.collection.mutable.ListBuffer
/** Trait that dictates the general actions of a Player class */
trait IPlayer {
- /** Method that returns the Player's name */
- def getName(): String
- def getGems(): Int
-
+ val name: String
/** Method that plays a Card */
- def playCard(): Boolean
-
- /** Method that draws cards from a Player's deck */
+ def playCard(card: ICard): Boolean
+ /** Method that shuffles the Player's Deck */
+ def shuffleDeck(deck: ListBuffer[ICard]): Boolean
+ /** Method that draws cards from the Player's deck */
def drawCards(): Boolean
}
diff --git a/src/main/scala/gwent/Player.scala b/src/main/scala/gwent/Player.scala
index 89146e7..e91eb4e 100644
--- a/src/main/scala/gwent/Player.scala
+++ b/src/main/scala/gwent/Player.scala
@@ -1,31 +1,61 @@
package cl.uchile.dcc
package gwent
+import card.{AbstractCard, ICard}
+
+import scala.collection.mutable.ListBuffer
+import scala.util.Random
+
/** Class that represents a player in Gwent */
-class Player(val name: String) extends IPlayer {
+class Player(val name: String, var deck: ListBuffer[ICard]) extends IPlayer with Equals {
/** Gems are the "HP" in Gwent */
var gems: Int = 2
- //var deck: Array[String]
- //var hand: Array[String]
- /*var deck: Array[Card] = null*/
- /*var hand: Array[Card] = null*/
- override def equals(obj: Any): Boolean = super.equals(obj)
-
- override def getName(): String = {
- this.name
+ val hand: ListBuffer[ICard] = ListBuffer()
+
+ override def equals(that: Any): Boolean = {
+ if(canEqual(that)){
+ val other = that.asInstanceOf[Player]
+ (this eq other) || (this.name == other.name && this.deck == other.deck && this.hand == other.hand)
+ } else {
+ false
+ }
}
- override def getGems(): Int = {
- this.gems
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[Player]
}
override def drawCards(): Boolean = {
/* if there are cards in deck -> add to hand and true, if not false */
- false
+ if (this.deck.isEmpty){
+ false
+ } else{
+ val card: ICard = deck.head
+ this.hand.addOne(card)
+ deck.remove(0)
+ true
+ }
+ }
+
+ override def shuffleDeck(deck: ListBuffer[ICard]): Boolean = {
+ if (deck.nonEmpty) {
+ Random.shuffle(deck)
+ true
+ } else {
+ println("Deck is empty")
+ false
+ }
}
- override def playCard(): Boolean = {
+ override def playCard(card: ICard): Boolean = {
/* if the card is in hand -> true and play it, if not false */
- false
+ if (hand.contains(card) && hand.nonEmpty){
+ //Not yet implemented
+ hand -= card
+ true
+ } else{
+ println("Card not in hand")
+ false
+ }
}
}
diff --git a/src/main/scala/gwent/card/AbstractCard.scala b/src/main/scala/gwent/card/AbstractCard.scala
new file mode 100644
index 0000000..387bc89
--- /dev/null
+++ b/src/main/scala/gwent/card/AbstractCard.scala
@@ -0,0 +1,9 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents a card in the game Gwent */
+abstract class AbstractCard(val name: String, val effect: String) extends ICard {
+ override def getName(): String
+
+ override def getEffect(): String
+}
diff --git a/src/main/scala/gwent/card/AbstractUnitCard.scala b/src/main/scala/gwent/card/AbstractUnitCard.scala
new file mode 100644
index 0000000..9c90292
--- /dev/null
+++ b/src/main/scala/gwent/card/AbstractUnitCard.scala
@@ -0,0 +1,22 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents the Unit Cards in the game Gwent */
+abstract class AbstractUnitCard(name: String, effect: String, var power: Int) extends AbstractCard(name,effect) with Equals {
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[AbstractUnitCard]
+ }
+
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)) {
+ val other = that.asInstanceOf[AbstractUnitCard]
+ (this eq other) || (this.name == other.name && this.effect == other.effect && this.power == other.power)
+ } else {
+ false
+ }
+ }
+ def getPower(): Int = this.power
+ def setPower(value: Int): Unit = {
+ this.power = value
+ }
+}
diff --git a/src/main/scala/gwent/card/Card.scala b/src/main/scala/gwent/card/Card.scala
deleted file mode 100644
index 131bd05..0000000
--- a/src/main/scala/gwent/card/Card.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-package cl.uchile.dcc
-package gwent.card
-
-/** Class that represents a card in the game Gwent */
-class Card(val name: String, effect: Unit) extends ICard {
-
- override def getName(): String = {
- this.name
- }
-}
diff --git a/src/main/scala/gwent/card/ClimateCard.scala b/src/main/scala/gwent/card/ClimateCard.scala
new file mode 100644
index 0000000..fb87233
--- /dev/null
+++ b/src/main/scala/gwent/card/ClimateCard.scala
@@ -0,0 +1,23 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents the Climate Cards in the game Gwent */
+class ClimateCard(name: String, effect: String) extends AbstractCard(name, effect) with Equals{
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[ClimateCard]
+ }
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)){
+ val other = that.asInstanceOf[ClimateCard]
+ (this eq other) || (this.name == other.name && this.effect == other.effect)
+ } else {
+ false
+ }
+ }
+ override def getEffect(): String = {
+ this.effect
+ }
+ override def getName(): String = {
+ this.name
+ }
+}
diff --git a/src/main/scala/gwent/card/ICard.scala b/src/main/scala/gwent/card/ICard.scala
index 6c9ba67..21b9157 100644
--- a/src/main/scala/gwent/card/ICard.scala
+++ b/src/main/scala/gwent/card/ICard.scala
@@ -4,6 +4,9 @@ package gwent.card
/** Trait that dictates the general behavior of a Card */
trait ICard {
/** Method that returns the Card's name */
+ val name: String
+ val effect: String
def getName (): String
+ def getEffect(): String
}
diff --git a/src/main/scala/gwent/card/IUnit.scala b/src/main/scala/gwent/card/IUnit.scala
new file mode 100644
index 0000000..47772a8
--- /dev/null
+++ b/src/main/scala/gwent/card/IUnit.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.card
+
+trait IUnit {
+
+}
diff --git a/src/main/scala/gwent/card/MeleeUnitCard.scala b/src/main/scala/gwent/card/MeleeUnitCard.scala
new file mode 100644
index 0000000..c5fba6f
--- /dev/null
+++ b/src/main/scala/gwent/card/MeleeUnitCard.scala
@@ -0,0 +1,25 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents a Melee Unit Card in the game Gwent */
+class MeleeUnitCard(name: String, effect: String, power: Int) extends AbstractUnitCard(name, effect, power) with Equals {
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[MeleeUnitCard]
+ }
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)) {
+ val other = that.asInstanceOf[MeleeUnitCard]
+ (this eq other) || (this.name == other.name && this.effect == other.effect && this.power == other.power)
+ } else {
+ false
+ }
+ }
+ override def getName(): String = this.name
+
+ override def getEffect(): String = this.effect
+
+ override def getPower(): Int = this.power
+
+ override def setPower(value: Int): Unit = super.setPower(value)
+
+}
diff --git a/src/main/scala/gwent/card/RangeUnitCard.scala b/src/main/scala/gwent/card/RangeUnitCard.scala
new file mode 100644
index 0000000..8afa895
--- /dev/null
+++ b/src/main/scala/gwent/card/RangeUnitCard.scala
@@ -0,0 +1,24 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents a Range Unit Card in the game Gwent */
+class RangeUnitCard(name: String, effect: String, power: Int) extends AbstractUnitCard(name, effect, power) with Equals {
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[RangeUnitCard]
+ }
+
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)) {
+ val other = that.asInstanceOf[RangeUnitCard]
+ (this eq other) || (this.name == other.name && this.effect == other.effect && this.power == other.power)
+ } else {
+ false
+ }
+ }
+
+ override def getName(): String = this.name
+ override def getEffect(): String = this.effect
+ override def getPower(): Int = this.power
+ override def setPower(value: Int): Unit = super.setPower(value)
+
+}
diff --git a/src/main/scala/gwent/card/SiegeUnitCard.scala b/src/main/scala/gwent/card/SiegeUnitCard.scala
new file mode 100644
index 0000000..ec4e129
--- /dev/null
+++ b/src/main/scala/gwent/card/SiegeUnitCard.scala
@@ -0,0 +1,30 @@
+package cl.uchile.dcc
+package gwent.card
+
+/** Class that represents a Siege Unit Card in the game Gwent */
+class SiegeUnitCard(name: String, effect: String, power: Int) extends AbstractUnitCard(name,effect,power) with Equals {
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[SiegeUnitCard]
+ }
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)){
+ val other = that.asInstanceOf[SiegeUnitCard]
+ (this eq other) || (this.name == other.name && this.effect == other.effect && this.power == other.power)
+ } else {
+ false
+ }
+ }
+ override def getName(): String = {
+ this.name
+ }
+ override def getEffect(): String = {
+ this.effect
+ }
+ override def getPower(): Int = {
+ this.power
+ }
+ override def setPower(value: Int): Unit = {
+ super.setPower(value)
+ }
+
+}
diff --git a/src/test/scala/gwent/PlayerTest.scala b/src/test/scala/gwent/PlayerTest.scala
index 8dc6fe6..ee429a4 100644
--- a/src/test/scala/gwent/PlayerTest.scala
+++ b/src/test/scala/gwent/PlayerTest.scala
@@ -2,18 +2,24 @@ package cl.uchile.dcc
package gwent
import munit.FunSuite
+import gwent.card.*
+
+import scala.collection.mutable.ListBuffer
class PlayerTest extends FunSuite {
var Player1: Player = _
var Player2: Player = _
- var name1: String = "Geralt"
- var name2: String = "Roach"
-
+ val name1: String = "Geralt"
+ val name2: String = "Roach"
+ val climateCard: ICard = new ClimateCard("cartita",null)
+ val siegeCard: ICard = new SiegeUnitCard("cartota","null",5)
+ val meleeCard1: ICard = new MeleeUnitCard("Juan","null",3)
+ val meleeCard2: ICard = new MeleeUnitCard("Geralt","null",4)
+ val rangeCard: ICard = new RangeUnitCard("Daff", null,2)
+ val deck: ListBuffer[ICard] = ListBuffer(climateCard,meleeCard1,meleeCard2,rangeCard,siegeCard)
override def beforeEach(context: BeforeEach): Unit = {
- /* nombre, sec tab, gems, deck, hand */
- Player1 = new Player(name1)
- Player2 = new Player(name2)
- /*crear decks y cartas de prueba*/
+ Player1 = new Player(name1,deck)
+ Player2 = new Player(name2,deck)
}
test("Players have names"){
@@ -28,13 +34,28 @@ class PlayerTest extends FunSuite {
/*Probar en el futuro el perder gemas*/
}
test("Players have decks"){
+
/*les damos decks y verificamos*/
}
- test("Players have cards in hand"){
- /*ponemos cartas en sus manos*/
+ test("Players can draw cards"){
+ assert(Player1.deck.nonEmpty)
+ assert(Player2.deck.nonEmpty)
+ assert(Player1.drawCards())//1
+ assert(Player1.drawCards())//2
+ assert(Player1.drawCards())//3
+ assert(Player1.drawCards())//4
+ assert(Player1.drawCards())//5
+ //No quedan cartas
+ assert(!Player1.drawCards())
}
- test("Players can play cards") {
- /*juegan una carta en la mano*/
+ test("Players can play cards from their hands") {
+ //No tiene cartas en mano
+ assert(!Player1.playCard(climateCard))
+ //obtnemos carta y la jugamos
+ Player1.drawCards()
+ assert(Player1.playCard(climateCard))
+ //nuevamente no tenemos carta
+ assert(!Player1.playCard(climateCard))
}
test("Players draw cards"){
/*roban cartas del deck (3)*/
diff --git a/src/test/scala/gwent/card/CardTest.scala b/src/test/scala/gwent/card/CardTest.scala
deleted file mode 100644
index 1bb986b..0000000
--- a/src/test/scala/gwent/card/CardTest.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-package cl.uchile.dcc
-package gwent.card
-
-import munit.FunSuite
-
-class CardTest extends FunSuite {
- var Card1: Card = _
- var Card2: Card = _
- override def beforeEach(context: BeforeEach): Unit = {
- /*Cartas tiene nombre y efecto*/
- Card1 = new Card("Triss",null)
- Card2 = new Card("Geralt",null)
- }
- test("Cards have names"){
- assertEquals(Card1.name,"Triss")
- assertEquals(Card2.name, "Geralt")
- assertNotEquals(Card1.name, Card2.name)
- }
-}
diff --git a/src/test/scala/gwent/card/ClimateCardTest.scala b/src/test/scala/gwent/card/ClimateCardTest.scala
new file mode 100644
index 0000000..1ac865b
--- /dev/null
+++ b/src/test/scala/gwent/card/ClimateCardTest.scala
@@ -0,0 +1,42 @@
+package cl.uchile.dcc
+package gwent.card
+
+import munit.FunSuite
+
+class ClimateCardTest extends FunSuite{
+ var card1: ICard = _
+ var card2: ICard = _
+ val name1: String = "Lluvia Torrencial"
+ val effect1: String = "Rain"
+ val name2: String = "Clima Despejado"
+ val effect2: String = "None"
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ card1 = new ClimateCard(name1,effect1)
+ card2 = new ClimateCard(name2,effect2)
+ }
+
+ test("Cards have names"){
+ assertEquals(card1.name,name1)
+ assertEquals(card2.name,name2)
+ assertNotEquals(card1.name,card2.name)
+ }
+ test("Card have effects"){
+ assertEquals(card1.effect,effect1)
+ assertEquals(card2.effect,effect2)
+ assertNotEquals(card1.effect,card2.effect)
+ }
+ test("Cards can be compared"){
+ val card3: ICard = new ClimateCard(name1,effect1)
+ assert(card1.equals(card3))
+ assert(card1.equals(card1))
+ assert(!card1.equals(card2))
+ val card4: ICard = new RangeUnitCard(name1, effect1, 3)
+ val card5: ICard = new SiegeUnitCard(name2, effect2, 3)
+ val card6: ICard = new MeleeUnitCard(name1,effect2,3)
+ //compared to different card class
+ assert(!card1.equals(card4))
+ assert(!card1.equals(card5))
+ assert(!card1.equals(card6))
+ }
+}
diff --git a/src/test/scala/gwent/card/MeleeUnitCardTest.scala b/src/test/scala/gwent/card/MeleeUnitCardTest.scala
new file mode 100644
index 0000000..fb01cca
--- /dev/null
+++ b/src/test/scala/gwent/card/MeleeUnitCardTest.scala
@@ -0,0 +1,54 @@
+package cl.uchile.dcc
+package gwent.card
+
+import munit.Clue.generate
+import munit.FunSuite
+
+class MeleeUnitCardTest extends FunSuite{
+ var card1: AbstractUnitCard = _
+ var card2: AbstractUnitCard = _
+ val name1: String = "Geralt"
+ val name2: String = "Roach"
+ val effect1: String = "a"
+ val effect2: String = "b"
+ val power1: Int = 5
+ val power2: Int = 2
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ card1 = new MeleeUnitCard(name1,effect1,power1)
+ card2 = new MeleeUnitCard(name2,effect2,power2)
+ }
+
+ test("Cards have names") {
+ assertEquals(card1.name, name1)
+ assertEquals(card2.name, name2)
+ assertNotEquals(card1.name, card2.name)
+ }
+ test("Card have effects") {
+ assertEquals(card1.effect, effect1)
+ assertEquals(card2.effect, effect2)
+ assertNotEquals(card1.effect, card2.effect)
+ }
+ test("Melee Cards have power"){
+ assertEquals(card1.power, power1)
+ assertEquals(card2.power,power2)
+ assertNotEquals(card1.power,card2.power)
+ }
+ test("Cards can be compared") {
+ val card3: ICard = new MeleeUnitCard(name1,effect1,power1)
+ //compared to itself
+ assert(card1.equals(card1))
+ //compared to an identical card
+ assert(card1.equals(card3))
+ //compared to a different card
+ assert(!card1.equals(card2))
+ val card4: ICard = new RangeUnitCard(name1,effect1,power1)
+ val card5: ICard = new SiegeUnitCard(name2,effect2,power2)
+ //compared to different class with same params
+ assert(!card1.equals(card4))
+ //compared to different class with diff params
+ assert(!card1.equals(card5))
+ val card6: ICard = new ClimateCard(name1,effect1)
+ assert(!card1.equals(card6))
+ }
+}
diff --git a/src/test/scala/gwent/card/RangeUnitCardTest.scala b/src/test/scala/gwent/card/RangeUnitCardTest.scala
new file mode 100644
index 0000000..948850a
--- /dev/null
+++ b/src/test/scala/gwent/card/RangeUnitCardTest.scala
@@ -0,0 +1,53 @@
+package cl.uchile.dcc
+package gwent.card
+
+import munit.FunSuite
+
+class RangeUnitCardTest extends FunSuite{
+ var card1: AbstractUnitCard = _
+ var card2: AbstractUnitCard = _
+ val name1: String = "Geralt"
+ val name2: String = "Roach"
+ val effect1: String = "a"
+ val effect2: String = "b"
+ val power1: Int = 5
+ val power2: Int = 2
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ card1 = new RangeUnitCard(name1, effect1, power1)
+ card2 = new RangeUnitCard(name2, effect2, power2)
+ }
+
+ test("Cards have names") {
+ assertEquals(card1.name, name1)
+ assertEquals(card2.name, name2)
+ assertNotEquals(card1.name, card2.name)
+ }
+ test("Card have effects") {
+ assertEquals(card1.effect, effect1)
+ assertEquals(card2.effect, effect2)
+ assertNotEquals(card1.effect, card2.effect)
+ }
+ test("Range Cards have power") {
+ assertEquals(card1.power, power1)
+ assertEquals(card2.power, power2)
+ assertNotEquals(card1.power, card2.power)
+ }
+ test("Cards can be compared") {
+ val card3: ICard = new RangeUnitCard(name1, effect1, power1)
+ //compared to itself
+ assert(card1.equals(card1))
+ //compared to an identical card
+ assert(card1.equals(card3))
+ //compared to a different card
+ assert(!card1.equals(card2))
+ val card4: ICard = new MeleeUnitCard(name1, effect1, power1)
+ val card5: ICard = new SiegeUnitCard(name2, effect2, power2)
+ //compared to different class with same params
+ assert(!card1.equals(card4))
+ //compared to different class with diff params
+ assert(!card1.equals(card5))
+ val card6: ICard = new ClimateCard(name1, effect1)
+ assert(!card1.equals(card6))
+ }
+}
diff --git a/src/test/scala/gwent/card/SiegeUnitCardTest.scala b/src/test/scala/gwent/card/SiegeUnitCardTest.scala
new file mode 100644
index 0000000..9c95ef1
--- /dev/null
+++ b/src/test/scala/gwent/card/SiegeUnitCardTest.scala
@@ -0,0 +1,53 @@
+package cl.uchile.dcc
+package gwent.card
+
+import munit.FunSuite
+
+class SiegeUnitCardTest extends FunSuite{
+ var card1: AbstractUnitCard = _
+ var card2: AbstractUnitCard = _
+ val name1: String = "Geralt"
+ val name2: String = "Roach"
+ val effect1: String = "a"
+ val effect2: String = "b"
+ val power1: Int = 5
+ val power2: Int = 2
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ card1 = new SiegeUnitCard(name1, effect1, power1)
+ card2 = new SiegeUnitCard(name2, effect2, power2)
+ }
+
+ test("Cards have names") {
+ assertEquals(card1.name, name1)
+ assertEquals(card2.name, name2)
+ assertNotEquals(card1.name, card2.name)
+ }
+ test("Card have effects") {
+ assertEquals(card1.effect, effect1)
+ assertEquals(card2.effect, effect2)
+ assertNotEquals(card1.effect, card2.effect)
+ }
+ test("Siege Cards have power") {
+ assertEquals(card1.power, power1)
+ assertEquals(card2.power, power2)
+ assertNotEquals(card1.power, card2.power)
+ }
+ test("Cards can be compared") {
+ val card3: ICard = new SiegeUnitCard(name1, effect1, power1)
+ //compared to itself
+ assert(card1.equals(card1))
+ //compared to an identical card
+ assert(card1.equals(card3))
+ //compared to a different card
+ assert(!card1.equals(card2))
+ val card4: ICard = new RangeUnitCard(name1, effect1, power1)
+ val card5: ICard = new MeleeUnitCard(name2, effect2, power2)
+ //compared to different class with same params
+ assert(!card1.equals(card4))
+ //compared to different class with diff params
+ assert(!card1.equals(card5))
+ val card6: ICard = new ClimateCard(name1, effect1)
+ assert(!card1.equals(card6))
+ }
+}
From 0aaf7cb321243ce90f53f6b2da35d97838051393 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Tue, 25 Apr 2023 00:01:00 -0400
Subject: [PATCH 7/9] FIX
Fixed Classes and Tests
---
src/main/scala/gwent/IPlayer.scala | 13 ++++++-
src/main/scala/gwent/Player.scala | 39 +++++++++++++------
src/main/scala/gwent/card/AbstractCard.scala | 4 +-
.../scala/gwent/card/AbstractUnitCard.scala | 5 ++-
src/main/scala/gwent/card/ClimateCard.scala | 4 +-
src/main/scala/gwent/card/ICard.scala | 4 +-
src/main/scala/gwent/card/MeleeUnitCard.scala | 6 +--
src/main/scala/gwent/card/RangeUnitCard.scala | 6 +--
src/main/scala/gwent/card/SiegeUnitCard.scala | 11 ++----
src/test/scala/gwent/PlayerTest.scala | 38 ++++++++++++------
.../scala/gwent/card/ClimateCardTest.scala | 12 +++---
.../scala/gwent/card/MeleeUnitCardTest.scala | 18 ++++-----
.../scala/gwent/card/RangeUnitCardTest.scala | 18 ++++-----
.../scala/gwent/card/SiegeUnitCardTest.scala | 18 ++++-----
14 files changed, 118 insertions(+), 78 deletions(-)
diff --git a/src/main/scala/gwent/IPlayer.scala b/src/main/scala/gwent/IPlayer.scala
index 1370377..dbedfba 100644
--- a/src/main/scala/gwent/IPlayer.scala
+++ b/src/main/scala/gwent/IPlayer.scala
@@ -7,11 +7,22 @@ import scala.collection.mutable.ListBuffer
/** Trait that dictates the general actions of a Player class */
trait IPlayer {
val name: String
+ var deck: ListBuffer[ICard]
/** Method that plays a Card */
def playCard(card: ICard): Boolean
/** Method that shuffles the Player's Deck */
- def shuffleDeck(deck: ListBuffer[ICard]): Boolean
+ def shuffleDeck: Boolean
/** Method that draws cards from the Player's deck */
def drawCards(): Boolean
+ /** Method that returns the Hand of the Player */
+ def getHand: ListBuffer[ICard]
+ /** Method that returns the Deck of the Player */
+ def getDeck: ListBuffer[ICard]
+ /** Method that returns the name of the Player */
+ def getName: String
+ /** Method that returns the current gems of the Player */
+ def getGems: Int
+ /** Method that returns True if the Player can lose the given gems or false if not*/
+ def setGems(value: Int): Boolean
}
diff --git a/src/main/scala/gwent/Player.scala b/src/main/scala/gwent/Player.scala
index e91eb4e..af66d0c 100644
--- a/src/main/scala/gwent/Player.scala
+++ b/src/main/scala/gwent/Player.scala
@@ -9,8 +9,8 @@ import scala.util.Random
/** Class that represents a player in Gwent */
class Player(val name: String, var deck: ListBuffer[ICard]) extends IPlayer with Equals {
/** Gems are the "HP" in Gwent */
- var gems: Int = 2
- val hand: ListBuffer[ICard] = ListBuffer()
+ private var gems: Int = 2
+ private var hand: ListBuffer[ICard] = ListBuffer()
override def equals(that: Any): Boolean = {
if(canEqual(that)){
@@ -20,26 +20,41 @@ class Player(val name: String, var deck: ListBuffer[ICard]) extends IPlayer with
false
}
}
-
override def canEqual(that: Any): Boolean = {
that.isInstanceOf[Player]
}
-
override def drawCards(): Boolean = {
/* if there are cards in deck -> add to hand and true, if not false */
if (this.deck.isEmpty){
false
} else{
- val card: ICard = deck.head
- this.hand.addOne(card)
- deck.remove(0)
+ val card: ICard = this.deck.head
+ this.hand += card
+ this.deck.remove(0)
+ true
+ }
+ }
+
+ override def getName: String = this.name
+
+ override def getGems: Int = this.gems
+
+ override def setGems(value: Int): Boolean = {
+ if (this.gems > 0) {
+ this.gems -= value
true
+ } else {
+ false
}
}
- override def shuffleDeck(deck: ListBuffer[ICard]): Boolean = {
- if (deck.nonEmpty) {
- Random.shuffle(deck)
+ override def getDeck: ListBuffer[ICard] = this.deck
+
+ override def getHand: ListBuffer[ICard] = this.hand
+
+ override def shuffleDeck: Boolean = {
+ if (this.deck.nonEmpty) {
+ Random.shuffle(this.deck)
true
} else {
println("Deck is empty")
@@ -49,9 +64,9 @@ class Player(val name: String, var deck: ListBuffer[ICard]) extends IPlayer with
override def playCard(card: ICard): Boolean = {
/* if the card is in hand -> true and play it, if not false */
- if (hand.contains(card) && hand.nonEmpty){
+ if (this.hand.contains(card) && this.hand.nonEmpty){
//Not yet implemented
- hand -= card
+ this.hand -= card
true
} else{
println("Card not in hand")
diff --git a/src/main/scala/gwent/card/AbstractCard.scala b/src/main/scala/gwent/card/AbstractCard.scala
index 387bc89..6382dcc 100644
--- a/src/main/scala/gwent/card/AbstractCard.scala
+++ b/src/main/scala/gwent/card/AbstractCard.scala
@@ -3,7 +3,7 @@ package gwent.card
/** Class that represents a card in the game Gwent */
abstract class AbstractCard(val name: String, val effect: String) extends ICard {
- override def getName(): String
+ override def getName: String
- override def getEffect(): String
+ override def getEffect: String
}
diff --git a/src/main/scala/gwent/card/AbstractUnitCard.scala b/src/main/scala/gwent/card/AbstractUnitCard.scala
index 9c90292..5e5d61c 100644
--- a/src/main/scala/gwent/card/AbstractUnitCard.scala
+++ b/src/main/scala/gwent/card/AbstractUnitCard.scala
@@ -15,7 +15,10 @@ abstract class AbstractUnitCard(name: String, effect: String, var power: Int) ex
false
}
}
- def getPower(): Int = this.power
+ /** Method that returns the power from a Unit Card */
+ def getPower: Int = this.power
+
+ /** Method that changed the value of power from a Unit Card */
def setPower(value: Int): Unit = {
this.power = value
}
diff --git a/src/main/scala/gwent/card/ClimateCard.scala b/src/main/scala/gwent/card/ClimateCard.scala
index fb87233..9a8f3db 100644
--- a/src/main/scala/gwent/card/ClimateCard.scala
+++ b/src/main/scala/gwent/card/ClimateCard.scala
@@ -14,10 +14,10 @@ class ClimateCard(name: String, effect: String) extends AbstractCard(name, effec
false
}
}
- override def getEffect(): String = {
+ override def getEffect: String = {
this.effect
}
- override def getName(): String = {
+ override def getName: String = {
this.name
}
}
diff --git a/src/main/scala/gwent/card/ICard.scala b/src/main/scala/gwent/card/ICard.scala
index 21b9157..3b4cf18 100644
--- a/src/main/scala/gwent/card/ICard.scala
+++ b/src/main/scala/gwent/card/ICard.scala
@@ -6,7 +6,7 @@ trait ICard {
/** Method that returns the Card's name */
val name: String
val effect: String
- def getName (): String
- def getEffect(): String
+ def getName: String
+ def getEffect: String
}
diff --git a/src/main/scala/gwent/card/MeleeUnitCard.scala b/src/main/scala/gwent/card/MeleeUnitCard.scala
index c5fba6f..14429be 100644
--- a/src/main/scala/gwent/card/MeleeUnitCard.scala
+++ b/src/main/scala/gwent/card/MeleeUnitCard.scala
@@ -14,11 +14,11 @@ class MeleeUnitCard(name: String, effect: String, power: Int) extends AbstractUn
false
}
}
- override def getName(): String = this.name
+ override def getName: String = this.name
- override def getEffect(): String = this.effect
+ override def getEffect: String = this.effect
- override def getPower(): Int = this.power
+ override def getPower: Int = this.power
override def setPower(value: Int): Unit = super.setPower(value)
diff --git a/src/main/scala/gwent/card/RangeUnitCard.scala b/src/main/scala/gwent/card/RangeUnitCard.scala
index 8afa895..d85aa0b 100644
--- a/src/main/scala/gwent/card/RangeUnitCard.scala
+++ b/src/main/scala/gwent/card/RangeUnitCard.scala
@@ -16,9 +16,9 @@ class RangeUnitCard(name: String, effect: String, power: Int) extends AbstractUn
}
}
- override def getName(): String = this.name
- override def getEffect(): String = this.effect
- override def getPower(): Int = this.power
+ override def getName: String = this.name
+ override def getEffect: String = this.effect
+ override def getPower: Int = this.power
override def setPower(value: Int): Unit = super.setPower(value)
}
diff --git a/src/main/scala/gwent/card/SiegeUnitCard.scala b/src/main/scala/gwent/card/SiegeUnitCard.scala
index ec4e129..77215ba 100644
--- a/src/main/scala/gwent/card/SiegeUnitCard.scala
+++ b/src/main/scala/gwent/card/SiegeUnitCard.scala
@@ -14,17 +14,14 @@ class SiegeUnitCard(name: String, effect: String, power: Int) extends AbstractUn
false
}
}
- override def getName(): String = {
+ override def getName: String = {
this.name
}
- override def getEffect(): String = {
+ override def getEffect: String = {
this.effect
}
- override def getPower(): Int = {
+ override def getPower: Int = {
this.power
}
- override def setPower(value: Int): Unit = {
- super.setPower(value)
- }
-
+ override def setPower(value: Int): Unit = super.setPower(value)
}
diff --git a/src/test/scala/gwent/PlayerTest.scala b/src/test/scala/gwent/PlayerTest.scala
index ee429a4..b2615c5 100644
--- a/src/test/scala/gwent/PlayerTest.scala
+++ b/src/test/scala/gwent/PlayerTest.scala
@@ -23,19 +23,34 @@ class PlayerTest extends FunSuite {
}
test("Players have names"){
- assertEquals(Player1.name,name1)
- assertEquals(Player2.name, name2)
- assertNotEquals(Player1.name, Player2.name)
+ assertEquals(Player1.getName,name1)
+ assertEquals(Player2.getName, name2)
+ assertNotEquals(Player1.getName, Player2.getName)
}
test("Players have gems"){
- assertEquals(Player1.gems,2)
- assertEquals(Player2.gems, Player2.gems)
- /*Probar en el futuro el perder gemas*/
+ assertEquals(Player1.getGems,2)
+ assertEquals(Player2.getGems, Player2.getGems)
}
- test("Players have decks"){
-
- /*les damos decks y verificamos*/
+ test("Players can lose gems"){
+ assertEquals(Player1.getGems,2)
+ assert(Player1.setGems(1))
+ assertEquals(Player1.getGems,1)
+ assert(Player2.setGems(2))
+ assertEquals(Player2.getGems,0)
+ assert(!Player2.setGems(1))
+ }
+ test("Player can be compared"){
+ assert(Player1.equals(Player1))
+ val Player3: IPlayer = new Player(name1,deck)
+ assert(Player1.equals(Player3))
+ assert(Player3.equals(Player1))
+ assert(!Player2.equals(Player1))
+ assert(!Player1.equals(climateCard))
+ }
+ test("Decks can be shuffled"){
+ assertEquals(Player1.getDeck, deck)
+ assert(Player1.shuffleDeck)
}
test("Players can draw cards"){
assert(Player1.deck.nonEmpty)
@@ -53,11 +68,10 @@ class PlayerTest extends FunSuite {
assert(!Player1.playCard(climateCard))
//obtnemos carta y la jugamos
Player1.drawCards()
+ //
+ assert(Player1.getHand.nonEmpty)
assert(Player1.playCard(climateCard))
//nuevamente no tenemos carta
assert(!Player1.playCard(climateCard))
}
- test("Players draw cards"){
- /*roban cartas del deck (3)*/
- }
}
diff --git a/src/test/scala/gwent/card/ClimateCardTest.scala b/src/test/scala/gwent/card/ClimateCardTest.scala
index 1ac865b..8d53ecb 100644
--- a/src/test/scala/gwent/card/ClimateCardTest.scala
+++ b/src/test/scala/gwent/card/ClimateCardTest.scala
@@ -17,14 +17,14 @@ class ClimateCardTest extends FunSuite{
}
test("Cards have names"){
- assertEquals(card1.name,name1)
- assertEquals(card2.name,name2)
- assertNotEquals(card1.name,card2.name)
+ assertEquals(card1.getName,name1)
+ assertEquals(card2.getName,name2)
+ assertNotEquals(card1.getEffect,card2.getName)
}
test("Card have effects"){
- assertEquals(card1.effect,effect1)
- assertEquals(card2.effect,effect2)
- assertNotEquals(card1.effect,card2.effect)
+ assertEquals(card1.getEffect,effect1)
+ assertEquals(card2.getEffect,effect2)
+ assertNotEquals(card1.getEffect,card2.getEffect)
}
test("Cards can be compared"){
val card3: ICard = new ClimateCard(name1,effect1)
diff --git a/src/test/scala/gwent/card/MeleeUnitCardTest.scala b/src/test/scala/gwent/card/MeleeUnitCardTest.scala
index fb01cca..581e0fa 100644
--- a/src/test/scala/gwent/card/MeleeUnitCardTest.scala
+++ b/src/test/scala/gwent/card/MeleeUnitCardTest.scala
@@ -20,19 +20,19 @@ class MeleeUnitCardTest extends FunSuite{
}
test("Cards have names") {
- assertEquals(card1.name, name1)
- assertEquals(card2.name, name2)
- assertNotEquals(card1.name, card2.name)
+ assertEquals(card1.getName, name1)
+ assertEquals(card2.getName, name2)
+ assertNotEquals(card1.getEffect, card2.getName)
}
test("Card have effects") {
- assertEquals(card1.effect, effect1)
- assertEquals(card2.effect, effect2)
- assertNotEquals(card1.effect, card2.effect)
+ assertEquals(card1.getEffect, effect1)
+ assertEquals(card2.getEffect, effect2)
+ assertNotEquals(card1.getEffect, card2.getEffect)
}
test("Melee Cards have power"){
- assertEquals(card1.power, power1)
- assertEquals(card2.power,power2)
- assertNotEquals(card1.power,card2.power)
+ assertEquals(card1.getPower, power1)
+ assertEquals(card2.getPower,power2)
+ assertNotEquals(card1.getPower,card2.getPower)
}
test("Cards can be compared") {
val card3: ICard = new MeleeUnitCard(name1,effect1,power1)
diff --git a/src/test/scala/gwent/card/RangeUnitCardTest.scala b/src/test/scala/gwent/card/RangeUnitCardTest.scala
index 948850a..55cae57 100644
--- a/src/test/scala/gwent/card/RangeUnitCardTest.scala
+++ b/src/test/scala/gwent/card/RangeUnitCardTest.scala
@@ -19,19 +19,19 @@ class RangeUnitCardTest extends FunSuite{
}
test("Cards have names") {
- assertEquals(card1.name, name1)
- assertEquals(card2.name, name2)
- assertNotEquals(card1.name, card2.name)
+ assertEquals(card1.getName, name1)
+ assertEquals(card2.getName, name2)
+ assertNotEquals(card1.getEffect, card2.getName)
}
test("Card have effects") {
- assertEquals(card1.effect, effect1)
- assertEquals(card2.effect, effect2)
- assertNotEquals(card1.effect, card2.effect)
+ assertEquals(card1.getEffect, effect1)
+ assertEquals(card2.getEffect, effect2)
+ assertNotEquals(card1.getEffect, card2.getEffect)
}
test("Range Cards have power") {
- assertEquals(card1.power, power1)
- assertEquals(card2.power, power2)
- assertNotEquals(card1.power, card2.power)
+ assertEquals(card1.getPower, power1)
+ assertEquals(card2.getPower, power2)
+ assertNotEquals(card1.getPower, card2.getPower)
}
test("Cards can be compared") {
val card3: ICard = new RangeUnitCard(name1, effect1, power1)
diff --git a/src/test/scala/gwent/card/SiegeUnitCardTest.scala b/src/test/scala/gwent/card/SiegeUnitCardTest.scala
index 9c95ef1..043849a 100644
--- a/src/test/scala/gwent/card/SiegeUnitCardTest.scala
+++ b/src/test/scala/gwent/card/SiegeUnitCardTest.scala
@@ -19,19 +19,19 @@ class SiegeUnitCardTest extends FunSuite{
}
test("Cards have names") {
- assertEquals(card1.name, name1)
- assertEquals(card2.name, name2)
- assertNotEquals(card1.name, card2.name)
+ assertEquals(card1.getName, name1)
+ assertEquals(card2.getName, name2)
+ assertNotEquals(card1.getEffect, card2.getName)
}
test("Card have effects") {
- assertEquals(card1.effect, effect1)
- assertEquals(card2.effect, effect2)
- assertNotEquals(card1.effect, card2.effect)
+ assertEquals(card1.getEffect, effect1)
+ assertEquals(card2.getEffect, effect2)
+ assertNotEquals(card1.getEffect, card2.getEffect)
}
test("Siege Cards have power") {
- assertEquals(card1.power, power1)
- assertEquals(card2.power, power2)
- assertNotEquals(card1.power, card2.power)
+ assertEquals(card1.getPower, power1)
+ assertEquals(card2.getPower, power2)
+ assertNotEquals(card1.getPower, card2.getPower)
}
test("Cards can be compared") {
val card3: ICard = new SiegeUnitCard(name1, effect1, power1)
From b8c8ba1ccdea7c7c23a85f017589fffe083dbc11 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Mon, 22 May 2023 18:20:34 -0400
Subject: [PATCH 8/9] FEAT Board Package
Added the board package and some classes and traits. Also some placeholder tests.
---
src/main/scala/gwent/board/AbstractZone.scala | 6 ++++++
src/main/scala/gwent/board/Board.scala | 6 ++++++
src/main/scala/gwent/board/IBoard.scala | 6 ++++++
src/main/scala/gwent/board/IZone.scala | 6 ++++++
src/main/scala/gwent/board/MeleeZone.scala | 6 ++++++
src/main/scala/gwent/board/PlayerBoard.scala | 6 ++++++
src/main/scala/gwent/board/RangeZone.scala | 6 ++++++
src/main/scala/gwent/board/SiegeZone.scala | 6 ++++++
src/test/scala/gwent/board/BoardTest.scala | 11 +++++++++++
src/test/scala/gwent/board/MeleeZoneTest.scala | 11 +++++++++++
src/test/scala/gwent/board/PlayerBoardTest.scala | 10 ++++++++++
src/test/scala/gwent/board/RangeZoneTest.scala | 11 +++++++++++
src/test/scala/gwent/board/SiegeZoneTest.scala | 11 +++++++++++
13 files changed, 102 insertions(+)
create mode 100644 src/main/scala/gwent/board/AbstractZone.scala
create mode 100644 src/main/scala/gwent/board/Board.scala
create mode 100644 src/main/scala/gwent/board/IBoard.scala
create mode 100644 src/main/scala/gwent/board/IZone.scala
create mode 100644 src/main/scala/gwent/board/MeleeZone.scala
create mode 100644 src/main/scala/gwent/board/PlayerBoard.scala
create mode 100644 src/main/scala/gwent/board/RangeZone.scala
create mode 100644 src/main/scala/gwent/board/SiegeZone.scala
create mode 100644 src/test/scala/gwent/board/BoardTest.scala
create mode 100644 src/test/scala/gwent/board/MeleeZoneTest.scala
create mode 100644 src/test/scala/gwent/board/PlayerBoardTest.scala
create mode 100644 src/test/scala/gwent/board/RangeZoneTest.scala
create mode 100644 src/test/scala/gwent/board/SiegeZoneTest.scala
diff --git a/src/main/scala/gwent/board/AbstractZone.scala b/src/main/scala/gwent/board/AbstractZone.scala
new file mode 100644
index 0000000..175d738
--- /dev/null
+++ b/src/main/scala/gwent/board/AbstractZone.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+class AbstractZone {
+
+}
diff --git a/src/main/scala/gwent/board/Board.scala b/src/main/scala/gwent/board/Board.scala
new file mode 100644
index 0000000..574fe0f
--- /dev/null
+++ b/src/main/scala/gwent/board/Board.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+class Board {
+
+}
diff --git a/src/main/scala/gwent/board/IBoard.scala b/src/main/scala/gwent/board/IBoard.scala
new file mode 100644
index 0000000..1e71f42
--- /dev/null
+++ b/src/main/scala/gwent/board/IBoard.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+trait IBoard {
+
+}
diff --git a/src/main/scala/gwent/board/IZone.scala b/src/main/scala/gwent/board/IZone.scala
new file mode 100644
index 0000000..7e5d653
--- /dev/null
+++ b/src/main/scala/gwent/board/IZone.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+trait IZone {
+
+}
diff --git a/src/main/scala/gwent/board/MeleeZone.scala b/src/main/scala/gwent/board/MeleeZone.scala
new file mode 100644
index 0000000..4d1bb3d
--- /dev/null
+++ b/src/main/scala/gwent/board/MeleeZone.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+class MeleeZone extends AbstractZone {
+
+}
diff --git a/src/main/scala/gwent/board/PlayerBoard.scala b/src/main/scala/gwent/board/PlayerBoard.scala
new file mode 100644
index 0000000..ee2b50d
--- /dev/null
+++ b/src/main/scala/gwent/board/PlayerBoard.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+class PlayerBoard {
+
+}
diff --git a/src/main/scala/gwent/board/RangeZone.scala b/src/main/scala/gwent/board/RangeZone.scala
new file mode 100644
index 0000000..1f5a7ae
--- /dev/null
+++ b/src/main/scala/gwent/board/RangeZone.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+class RangeZone extends AbstractZone{
+
+}
diff --git a/src/main/scala/gwent/board/SiegeZone.scala b/src/main/scala/gwent/board/SiegeZone.scala
new file mode 100644
index 0000000..1e3b2c3
--- /dev/null
+++ b/src/main/scala/gwent/board/SiegeZone.scala
@@ -0,0 +1,6 @@
+package cl.uchile.dcc
+package gwent.board
+
+class SiegeZone extends AbstractZone {
+
+}
diff --git a/src/test/scala/gwent/board/BoardTest.scala b/src/test/scala/gwent/board/BoardTest.scala
new file mode 100644
index 0000000..f369c2f
--- /dev/null
+++ b/src/test/scala/gwent/board/BoardTest.scala
@@ -0,0 +1,11 @@
+package cl.uchile.dcc
+package gwent.board
+
+import munit.FunSuite
+
+class BoardTest extends FunSuite{
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ }
+
+}
diff --git a/src/test/scala/gwent/board/MeleeZoneTest.scala b/src/test/scala/gwent/board/MeleeZoneTest.scala
new file mode 100644
index 0000000..27ee031
--- /dev/null
+++ b/src/test/scala/gwent/board/MeleeZoneTest.scala
@@ -0,0 +1,11 @@
+package cl.uchile.dcc
+package gwent.board
+
+import munit.FunSuite
+
+class MeleeZoneTest extends FunSuite{
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ }
+
+}
diff --git a/src/test/scala/gwent/board/PlayerBoardTest.scala b/src/test/scala/gwent/board/PlayerBoardTest.scala
new file mode 100644
index 0000000..f4ac715
--- /dev/null
+++ b/src/test/scala/gwent/board/PlayerBoardTest.scala
@@ -0,0 +1,10 @@
+package cl.uchile.dcc
+package gwent.board
+
+import munit.FunSuite
+
+class PlayerBoardTest extends FunSuite{
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ }
+}
diff --git a/src/test/scala/gwent/board/RangeZoneTest.scala b/src/test/scala/gwent/board/RangeZoneTest.scala
new file mode 100644
index 0000000..0ac2349
--- /dev/null
+++ b/src/test/scala/gwent/board/RangeZoneTest.scala
@@ -0,0 +1,11 @@
+package cl.uchile.dcc
+package gwent.board
+
+import munit.FunSuite
+
+class RangeZoneTest extends FunSuite{
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ }
+
+}
diff --git a/src/test/scala/gwent/board/SiegeZoneTest.scala b/src/test/scala/gwent/board/SiegeZoneTest.scala
new file mode 100644
index 0000000..08290cb
--- /dev/null
+++ b/src/test/scala/gwent/board/SiegeZoneTest.scala
@@ -0,0 +1,11 @@
+package cl.uchile.dcc
+package gwent.board
+
+import munit.FunSuite
+
+class SiegeZoneTest extends FunSuite{
+
+ override def beforeEach(context: BeforeEach): Unit = {
+ }
+
+}
From 4be87f81010ad1407b7b5218311da839d21839c1 Mon Sep 17 00:00:00 2001
From: Pepereiram <89109716+Pepereiram@users.noreply.github.com>
Date: Tue, 30 May 2023 11:46:50 -0400
Subject: [PATCH 9/9] REFACTOR, FEAT
Changed the structure of the board package.
Added new method to the Card package called playCard, to make the Double Dispatch with board work.
---
src/main/scala/gwent/board/AbstractZone.scala | 6 --
src/main/scala/gwent/board/Board.scala | 47 +++++++++++++-
src/main/scala/gwent/board/IBoard.scala | 6 --
src/main/scala/gwent/board/IZone.scala | 6 --
src/main/scala/gwent/board/MeleeZone.scala | 6 --
src/main/scala/gwent/board/PlayerBoard.scala | 6 --
src/main/scala/gwent/board/PlayerSide.scala | 65 +++++++++++++++++++
src/main/scala/gwent/board/RangeZone.scala | 6 --
src/main/scala/gwent/board/SiegeZone.scala | 6 --
.../scala/gwent/card/AbstractUnitCard.scala | 13 ++--
src/main/scala/gwent/card/ClimateCard.scala | 11 ++--
src/main/scala/gwent/card/ICard.scala | 6 +-
src/main/scala/gwent/card/IUnit.scala | 6 --
src/main/scala/gwent/card/MeleeUnitCard.scala | 10 ++-
src/main/scala/gwent/card/RangeUnitCard.scala | 9 +--
src/main/scala/gwent/card/SiegeUnitCard.scala | 13 ++--
src/test/scala/gwent/board/BoardTest.scala | 11 ----
.../scala/gwent/board/MeleeZoneTest.scala | 11 ----
.../scala/gwent/board/PlayerBoardTest.scala | 10 ---
.../scala/gwent/board/RangeZoneTest.scala | 11 ----
.../scala/gwent/board/SiegeZoneTest.scala | 11 ----
.../scala/gwent/card/MeleeUnitCardTest.scala | 2 +-
22 files changed, 142 insertions(+), 136 deletions(-)
delete mode 100644 src/main/scala/gwent/board/AbstractZone.scala
delete mode 100644 src/main/scala/gwent/board/IBoard.scala
delete mode 100644 src/main/scala/gwent/board/IZone.scala
delete mode 100644 src/main/scala/gwent/board/MeleeZone.scala
delete mode 100644 src/main/scala/gwent/board/PlayerBoard.scala
create mode 100644 src/main/scala/gwent/board/PlayerSide.scala
delete mode 100644 src/main/scala/gwent/board/RangeZone.scala
delete mode 100644 src/main/scala/gwent/board/SiegeZone.scala
delete mode 100644 src/main/scala/gwent/card/IUnit.scala
delete mode 100644 src/test/scala/gwent/board/BoardTest.scala
delete mode 100644 src/test/scala/gwent/board/MeleeZoneTest.scala
delete mode 100644 src/test/scala/gwent/board/PlayerBoardTest.scala
delete mode 100644 src/test/scala/gwent/board/RangeZoneTest.scala
delete mode 100644 src/test/scala/gwent/board/SiegeZoneTest.scala
diff --git a/src/main/scala/gwent/board/AbstractZone.scala b/src/main/scala/gwent/board/AbstractZone.scala
deleted file mode 100644
index 175d738..0000000
--- a/src/main/scala/gwent/board/AbstractZone.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-class AbstractZone {
-
-}
diff --git a/src/main/scala/gwent/board/Board.scala b/src/main/scala/gwent/board/Board.scala
index 574fe0f..a0642df 100644
--- a/src/main/scala/gwent/board/Board.scala
+++ b/src/main/scala/gwent/board/Board.scala
@@ -1,6 +1,51 @@
package cl.uchile.dcc
package gwent.board
+import gwent.card.{ClimateCard, ICard, MeleeUnitCard, RangeUnitCard, SiegeUnitCard}
+import gwent.IPlayer
-class Board {
+/** Class representing a Board in the game Gwen't
+ *
+ * The board has players and zones for each player.
+ *
+ * @constructor Create a new board with two players
+ * @param side1 Player 1.
+ * @param side2 Player 2.
+ * @param climateSlot where the ClimateCard is placed
+ *
+ * @author Jose Pereira Morgado
+ * @version 1.2
+ * @since 1.2
+ */
+class Board(val side1: PlayerSide, val side2: PlayerSide, var climateSlot: ClimateCard) extends Equals{
+
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[Board]
+ }
+
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)) {
+ val other = that.asInstanceOf[Board]
+ (this eq other) || (this.side1 == other.side1 && this.side2 == other.side2)
+ } else {
+ false
+ }
+ }
+
+ /** Places a ClimateCard on it's Slot */
+ def placeClimateCard(cl: ClimateCard): Unit = {
+ climateSlot = cl
+ }
+
+ def placeMeleeCard(m: MeleeUnitCard): Unit = {
+ side1.placeMeleeCard(m)
+ }
+
+ def placeRangeCard(r: RangeUnitCard): Unit = {
+ side1.placeRangeCard(r)
+ }
+
+ def placeSiegeCard(s: SiegeUnitCard): Unit = {
+ side1.placeSiegeCard(s)
+ }
}
diff --git a/src/main/scala/gwent/board/IBoard.scala b/src/main/scala/gwent/board/IBoard.scala
deleted file mode 100644
index 1e71f42..0000000
--- a/src/main/scala/gwent/board/IBoard.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-trait IBoard {
-
-}
diff --git a/src/main/scala/gwent/board/IZone.scala b/src/main/scala/gwent/board/IZone.scala
deleted file mode 100644
index 7e5d653..0000000
--- a/src/main/scala/gwent/board/IZone.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-trait IZone {
-
-}
diff --git a/src/main/scala/gwent/board/MeleeZone.scala b/src/main/scala/gwent/board/MeleeZone.scala
deleted file mode 100644
index 4d1bb3d..0000000
--- a/src/main/scala/gwent/board/MeleeZone.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-class MeleeZone extends AbstractZone {
-
-}
diff --git a/src/main/scala/gwent/board/PlayerBoard.scala b/src/main/scala/gwent/board/PlayerBoard.scala
deleted file mode 100644
index ee2b50d..0000000
--- a/src/main/scala/gwent/board/PlayerBoard.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-class PlayerBoard {
-
-}
diff --git a/src/main/scala/gwent/board/PlayerSide.scala b/src/main/scala/gwent/board/PlayerSide.scala
new file mode 100644
index 0000000..0ddbc92
--- /dev/null
+++ b/src/main/scala/gwent/board/PlayerSide.scala
@@ -0,0 +1,65 @@
+package cl.uchile.dcc
+package gwent.board
+import gwent.IPlayer
+import gwent.card.{ClimateCard, ICard, MeleeUnitCard, RangeUnitCard, SiegeUnitCard}
+
+import scala.collection.mutable.ListBuffer
+
+/** Class representing a Player's Board in the game Gwen't
+ *
+ * The player's board has space for every kind of Card
+ * Only one for ClimateCards (shared by both players)! read the README for more info
+ *
+ * @constructor Create a new player's board for a given Player
+ * @param player Player that uses the board.
+ * @param climateSlot Contains the currently active ClimateCard.
+ * @param meleeZone where the MeleeUnitCards will be placed
+ * @param rangeZone where the RangeUnitCards will be placed
+ * @param siegeZone where the SiegeUnitCards will be placed
+ *
+ * @author Jose Pereira Morgado
+ * @version 1.2
+ * @since 1.2
+ */
+class PlayerSide(val player: IPlayer,
+ var climateSlot: ICard,
+ val meleeZone: ListBuffer[ICard],
+ val rangeZone: ListBuffer[ICard],
+ val siegeZone: ListBuffer[ICard]) extends Equals {
+ override def canEqual(that: Any): Boolean = {
+ that.isInstanceOf[PlayerSide]
+ }
+
+ override def equals(that: Any): Boolean = {
+ if (canEqual(that)) {
+ val other = that.asInstanceOf[PlayerSide]
+ (this eq other) || (this.player == other.player &&
+ this.meleeZone == other.meleeZone &&
+ this.rangeZone == other.rangeZone &&
+ this.siegeZone == other.siegeZone)
+ } else {
+ false
+ }
+ }
+
+ /** Places a ClimateCard on it's Slot */
+ def placeClimateCard(cl: ClimateCard): Unit = {
+ climateSlot = cl
+ }
+
+ /** Places a Melee Card on it's Zone/Row */
+ def placeMeleeCard(m : MeleeUnitCard): Unit = {
+ meleeZone.addOne(m)
+ }
+
+ /** Places a RangeUnitCard on it's Zone/Row */
+ def placeRangeCard(r: RangeUnitCard): Unit = {
+ meleeZone.addOne(r)
+ }
+
+ /** Places a SiegeUnitCard on it's Zone/Row */
+ def placeSiegeCard(s: SiegeUnitCard): Unit = {
+ meleeZone.addOne(s)
+ }
+
+}
diff --git a/src/main/scala/gwent/board/RangeZone.scala b/src/main/scala/gwent/board/RangeZone.scala
deleted file mode 100644
index 1f5a7ae..0000000
--- a/src/main/scala/gwent/board/RangeZone.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-class RangeZone extends AbstractZone{
-
-}
diff --git a/src/main/scala/gwent/board/SiegeZone.scala b/src/main/scala/gwent/board/SiegeZone.scala
deleted file mode 100644
index 1e3b2c3..0000000
--- a/src/main/scala/gwent/board/SiegeZone.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-class SiegeZone extends AbstractZone {
-
-}
diff --git a/src/main/scala/gwent/card/AbstractUnitCard.scala b/src/main/scala/gwent/card/AbstractUnitCard.scala
index 5e5d61c..f82a988 100644
--- a/src/main/scala/gwent/card/AbstractUnitCard.scala
+++ b/src/main/scala/gwent/card/AbstractUnitCard.scala
@@ -1,8 +1,9 @@
package cl.uchile.dcc
package gwent.card
+import gwent.board.PlayerSide
/** Class that represents the Unit Cards in the game Gwent */
-abstract class AbstractUnitCard(name: String, effect: String, var power: Int) extends AbstractCard(name,effect) with Equals {
+abstract class AbstractUnitCard(val name: String, val effect: String, var _power: Int) extends ICard with Equals {
override def canEqual(that: Any): Boolean = {
that.isInstanceOf[AbstractUnitCard]
}
@@ -10,16 +11,18 @@ abstract class AbstractUnitCard(name: String, effect: String, var power: Int) ex
override def equals(that: Any): Boolean = {
if (canEqual(that)) {
val other = that.asInstanceOf[AbstractUnitCard]
- (this eq other) || (this.name == other.name && this.effect == other.effect && this.power == other.power)
+ (this eq other) || (this.name == other.name && this.effect == other.effect && this._power == other._power)
} else {
false
}
}
/** Method that returns the power from a Unit Card */
- def getPower: Int = this.power
+ def power: Int = _power
/** Method that changed the value of power from a Unit Card */
- def setPower(value: Int): Unit = {
- this.power = value
+ def power_(newPower: Int): Unit = {
+ _power = newPower
}
+ /** Method that plays a UnitCard on the board */
+ override def playCard(b: PlayerSide): Unit
}
diff --git a/src/main/scala/gwent/card/ClimateCard.scala b/src/main/scala/gwent/card/ClimateCard.scala
index 9a8f3db..a75f1e8 100644
--- a/src/main/scala/gwent/card/ClimateCard.scala
+++ b/src/main/scala/gwent/card/ClimateCard.scala
@@ -1,8 +1,9 @@
package cl.uchile.dcc
package gwent.card
+import gwent.board.PlayerSide
/** Class that represents the Climate Cards in the game Gwent */
-class ClimateCard(name: String, effect: String) extends AbstractCard(name, effect) with Equals{
+class ClimateCard(val name: String, val effect: String) extends ICard with Equals{
override def canEqual(that: Any): Boolean = {
that.isInstanceOf[ClimateCard]
}
@@ -14,10 +15,8 @@ class ClimateCard(name: String, effect: String) extends AbstractCard(name, effec
false
}
}
- override def getEffect: String = {
- this.effect
- }
- override def getName: String = {
- this.name
+
+ override def playCard(b: PlayerSide): Unit = {
+ b.placeClimateCard(this)
}
}
diff --git a/src/main/scala/gwent/card/ICard.scala b/src/main/scala/gwent/card/ICard.scala
index 3b4cf18..7aa647e 100644
--- a/src/main/scala/gwent/card/ICard.scala
+++ b/src/main/scala/gwent/card/ICard.scala
@@ -1,12 +1,14 @@
package cl.uchile.dcc
package gwent.card
+import gwent.board.PlayerSide
+
/** Trait that dictates the general behavior of a Card */
trait ICard {
/** Method that returns the Card's name */
val name: String
val effect: String
- def getName: String
- def getEffect: String
+
+ def playCard(b: PlayerSide): Unit
}
diff --git a/src/main/scala/gwent/card/IUnit.scala b/src/main/scala/gwent/card/IUnit.scala
deleted file mode 100644
index 47772a8..0000000
--- a/src/main/scala/gwent/card/IUnit.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package cl.uchile.dcc
-package gwent.card
-
-trait IUnit {
-
-}
diff --git a/src/main/scala/gwent/card/MeleeUnitCard.scala b/src/main/scala/gwent/card/MeleeUnitCard.scala
index 14429be..e05573e 100644
--- a/src/main/scala/gwent/card/MeleeUnitCard.scala
+++ b/src/main/scala/gwent/card/MeleeUnitCard.scala
@@ -1,5 +1,6 @@
package cl.uchile.dcc
package gwent.card
+import gwent.board.PlayerSide
/** Class that represents a Melee Unit Card in the game Gwent */
class MeleeUnitCard(name: String, effect: String, power: Int) extends AbstractUnitCard(name, effect, power) with Equals {
@@ -14,12 +15,9 @@ class MeleeUnitCard(name: String, effect: String, power: Int) extends AbstractUn
false
}
}
- override def getName: String = this.name
- override def getEffect: String = this.effect
-
- override def getPower: Int = this.power
-
- override def setPower(value: Int): Unit = super.setPower(value)
+ override def playCard(b: PlayerSide): Unit = {
+ b.placeMeleeCard(this)
+ }
}
diff --git a/src/main/scala/gwent/card/RangeUnitCard.scala b/src/main/scala/gwent/card/RangeUnitCard.scala
index d85aa0b..fae7fa1 100644
--- a/src/main/scala/gwent/card/RangeUnitCard.scala
+++ b/src/main/scala/gwent/card/RangeUnitCard.scala
@@ -1,6 +1,8 @@
package cl.uchile.dcc
package gwent.card
+import gwent.board.PlayerSide
+
/** Class that represents a Range Unit Card in the game Gwent */
class RangeUnitCard(name: String, effect: String, power: Int) extends AbstractUnitCard(name, effect, power) with Equals {
override def canEqual(that: Any): Boolean = {
@@ -16,9 +18,8 @@ class RangeUnitCard(name: String, effect: String, power: Int) extends AbstractUn
}
}
- override def getName: String = this.name
- override def getEffect: String = this.effect
- override def getPower: Int = this.power
- override def setPower(value: Int): Unit = super.setPower(value)
+ override def playCard(b: PlayerSide): Unit = {
+ b.placeRangeCard(this)
+ }
}
diff --git a/src/main/scala/gwent/card/SiegeUnitCard.scala b/src/main/scala/gwent/card/SiegeUnitCard.scala
index 77215ba..b63b4bf 100644
--- a/src/main/scala/gwent/card/SiegeUnitCard.scala
+++ b/src/main/scala/gwent/card/SiegeUnitCard.scala
@@ -1,5 +1,6 @@
package cl.uchile.dcc
package gwent.card
+import gwent.board.PlayerSide
/** Class that represents a Siege Unit Card in the game Gwent */
class SiegeUnitCard(name: String, effect: String, power: Int) extends AbstractUnitCard(name,effect,power) with Equals {
@@ -14,14 +15,8 @@ class SiegeUnitCard(name: String, effect: String, power: Int) extends AbstractUn
false
}
}
- override def getName: String = {
- this.name
- }
- override def getEffect: String = {
- this.effect
- }
- override def getPower: Int = {
- this.power
+
+ override def playCard(b: PlayerSide): Unit = {
+ b.placeSiegeCard(this)
}
- override def setPower(value: Int): Unit = super.setPower(value)
}
diff --git a/src/test/scala/gwent/board/BoardTest.scala b/src/test/scala/gwent/board/BoardTest.scala
deleted file mode 100644
index f369c2f..0000000
--- a/src/test/scala/gwent/board/BoardTest.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-import munit.FunSuite
-
-class BoardTest extends FunSuite{
-
- override def beforeEach(context: BeforeEach): Unit = {
- }
-
-}
diff --git a/src/test/scala/gwent/board/MeleeZoneTest.scala b/src/test/scala/gwent/board/MeleeZoneTest.scala
deleted file mode 100644
index 27ee031..0000000
--- a/src/test/scala/gwent/board/MeleeZoneTest.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-import munit.FunSuite
-
-class MeleeZoneTest extends FunSuite{
-
- override def beforeEach(context: BeforeEach): Unit = {
- }
-
-}
diff --git a/src/test/scala/gwent/board/PlayerBoardTest.scala b/src/test/scala/gwent/board/PlayerBoardTest.scala
deleted file mode 100644
index f4ac715..0000000
--- a/src/test/scala/gwent/board/PlayerBoardTest.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-import munit.FunSuite
-
-class PlayerBoardTest extends FunSuite{
-
- override def beforeEach(context: BeforeEach): Unit = {
- }
-}
diff --git a/src/test/scala/gwent/board/RangeZoneTest.scala b/src/test/scala/gwent/board/RangeZoneTest.scala
deleted file mode 100644
index 0ac2349..0000000
--- a/src/test/scala/gwent/board/RangeZoneTest.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-import munit.FunSuite
-
-class RangeZoneTest extends FunSuite{
-
- override def beforeEach(context: BeforeEach): Unit = {
- }
-
-}
diff --git a/src/test/scala/gwent/board/SiegeZoneTest.scala b/src/test/scala/gwent/board/SiegeZoneTest.scala
deleted file mode 100644
index 08290cb..0000000
--- a/src/test/scala/gwent/board/SiegeZoneTest.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package cl.uchile.dcc
-package gwent.board
-
-import munit.FunSuite
-
-class SiegeZoneTest extends FunSuite{
-
- override def beforeEach(context: BeforeEach): Unit = {
- }
-
-}
diff --git a/src/test/scala/gwent/card/MeleeUnitCardTest.scala b/src/test/scala/gwent/card/MeleeUnitCardTest.scala
index 581e0fa..1f76038 100644
--- a/src/test/scala/gwent/card/MeleeUnitCardTest.scala
+++ b/src/test/scala/gwent/card/MeleeUnitCardTest.scala
@@ -30,7 +30,7 @@ class MeleeUnitCardTest extends FunSuite{
assertNotEquals(card1.getEffect, card2.getEffect)
}
test("Melee Cards have power"){
- assertEquals(card1.getPower, power1)
+ assertEquals(card1.power(), power1)
assertEquals(card2.getPower,power2)
assertNotEquals(card1.getPower,card2.getPower)
}