diff --git a/README.md b/README.md index e7d6320..5608905 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Final Reality is a simplified clone of the renowned game, Final Fantasy. Its main purpose is to serve as an educational tool, teaching foundational programming concepts. +this game will be selling more than final fantasy... + This README is yours to complete it. Take this opportunity to describe your contributions, the design decisions you've made, and any other information you deem necessary. diff --git a/src/main/scala/model/controller/Controller.scala b/src/main/scala/model/controller/Controller.scala new file mode 100644 index 0000000..095d2c2 --- /dev/null +++ b/src/main/scala/model/controller/Controller.scala @@ -0,0 +1,14 @@ +package model.controller + + +class Controller { + // tuve problemas con mi licencia de intellij, lo solucione hoy y no me dio tiempo a terminar esta parte + // si arreglé varias cosas que no estaban del buenas en la entrega parcial 1 + // el cuerpo docente ya esta al tanto de la situacion + + + + + +} + diff --git a/src/main/scala/model/nonplayable/Enemy.scala b/src/main/scala/model/nonplayable/Enemy.scala new file mode 100644 index 0000000..6848301 --- /dev/null +++ b/src/main/scala/model/nonplayable/Enemy.scala @@ -0,0 +1,33 @@ +package model.nonplayable +import model.nonplayable.NonPlayable + +// Enemy class represents a non-playable entity that is an enemy +class Enemy(name: String, weight: Int, + attack: Int, life: Int, + defence: Int) extends NonPlayable { + + // Method to return the name of the enemy + def sayName(): String = { + name + } + + // Method to return the weight of the enemy + def sayWeight(): Int = { + weight + } + + // Method to return the attack power of the enemy + def sayAttack(): Int = { + attack + } + + // Method to return the life points of the enemy + def sayLife(): Int = { + life + } + + // Method to return the defence points of the enemy + def sayDefence(): Int = { + defence + } +} diff --git a/src/main/scala/model/nonplayable/MagicWeapon.scala b/src/main/scala/model/nonplayable/MagicWeapon.scala new file mode 100644 index 0000000..31ef769 --- /dev/null +++ b/src/main/scala/model/nonplayable/MagicWeapon.scala @@ -0,0 +1,35 @@ +package model.nonplayable +import model.nonplayable.NonPlayable +import model.playable.APlayable + +// MagicWeapon class represents a non-playable entity that is a magic weapon +class MagicWeapon(name: String, weight: Int, + attack: Int, mana: Int, + owner: APlayable) extends NonPlayable { + + // Method to return the mana points required to use the magic weapon + def sayMana(): Int ={ + mana + } + + // Method to return the name of the magic weapon + def sayName(): String = { + name + } + + // Method to return the weight of the magic weapon + def sayWeight(): Int = { + weight + } + + // Method to return the attack power of the magic weapon + def sayAttack(): Int = { + attack + } + + // Method to return the owner character of the magic weapon + def sayOwner(): APlayable = { + owner + } +} + diff --git a/src/main/scala/model/nonplayable/NonPlayable.scala b/src/main/scala/model/nonplayable/NonPlayable.scala new file mode 100644 index 0000000..02174c2 --- /dev/null +++ b/src/main/scala/model/nonplayable/NonPlayable.scala @@ -0,0 +1,14 @@ +package model.nonplayable + +// Trait to represent non-playable entities +trait NonPlayable { + // Abstract method to get the name of the non-playable entity + def sayName(): String + + // Abstract method to get the weight of the non-playable entity + def sayWeight(): Int + + // Abstract method to get the attack power of the non-playable entity + def sayAttack(): Int +} + diff --git a/src/main/scala/model/nonplayable/Weapon.scala b/src/main/scala/model/nonplayable/Weapon.scala new file mode 100644 index 0000000..b00f0ec --- /dev/null +++ b/src/main/scala/model/nonplayable/Weapon.scala @@ -0,0 +1,28 @@ +package model.nonplayable +import model.nonplayable.NonPlayable +import model.playable.APlayable + +// Weapon class represents a non-playable entity that is a weapon +class Weapon(name: String, weight: Int, + attack: Int, owner: Character) extends NonPlayable { + + // Method to return the owner character of the weapon + def sayOwner(): Character = { + owner + } + + // Method to return the name of the weapon + def sayName(): String = { + name + } + + // Method to return the weight of the weapon + def sayWeight(): Int = { + weight + } + + // Method to return the attack power of the weapon + def sayAttack(): Int = { + attack + } +} diff --git a/src/main/scala/model/party/Party.scala b/src/main/scala/model/party/Party.scala new file mode 100644 index 0000000..4c878b9 --- /dev/null +++ b/src/main/scala/model/party/Party.scala @@ -0,0 +1,27 @@ +package model.party + +import model.playable.{APlayable} + +import scala.collection.mutable.Map + +// Party class to manage a group of playable characters +class Party { + // Map to store the allies in the party, keyed by their kind/type + val allies: Map[String, APlayable] = Map() + + // Method to add a playable character to the party + def addPlayable(pj: APlayable): Unit = { + allies.put(pj.sayKind(), pj) // Adds the playable character to the allies map with their kind as the key + } + + // Method to check if the party is defeated + def isDefeated: Boolean = { + if (allies.isEmpty) { + // Print a message if the party is empty + true // The party is considered defeated if it's empty + } else { + // The party is considered defeated if all allies have 0 life points + allies.values.forall(_.sayLife() == 0) + } + } +} diff --git a/src/main/scala/model/playable/APlayable.scala b/src/main/scala/model/playable/APlayable.scala new file mode 100644 index 0000000..0ee52ec --- /dev/null +++ b/src/main/scala/model/playable/APlayable.scala @@ -0,0 +1,42 @@ +package model.playable +import model.playable.Playable +abstract class APlayable(val name: String, var life: Int, + val defence: Int, val weight: Int, + var kind: String, var weapon: Boolean, val mana: Int) extends Playable { + + // Method to return the name of the character + def sayName(): String = { + name + } + + // Method to return the life points of the character + def sayLife(): Int = { + life + } + + // Method to return the defense points of the character + def sayDefence(): Int = { + defence + } + + // Method to return the weight of the character + def sayWeight(): Int = { + weight + } + + // Method to return the kind/type of the character + def sayKind(): String = { + kind + } + + // Method to check if the character has a weapon + def havWeapon(): Boolean = { + weapon + } + def sayMana(): Int = { + mana + } + + +} + diff --git a/src/main/scala/model/playable/Character.scala b/src/main/scala/model/playable/Character.scala new file mode 100644 index 0000000..423eaab --- /dev/null +++ b/src/main/scala/model/playable/Character.scala @@ -0,0 +1,25 @@ +package model.playable +import model.playable.Playable +import model.playable.APlayable +// Character class extends the Playable trait +class Paladin(name:String) extends APlayable(name,100,50,50,"Paladin",false,0) { + +} +class Guerrero(name:String) extends APlayable(name,120,80,40,"Guerrero",false,0) { + +} +class Ninja(name:String) extends APlayable(name,50,80,20,"Ninja",false,0) { + +} +class MagoNegro(name:String) extends APlayable(name,100,100,120,"MagoNegro",false,50) { + +} + +class MagoBlanco(name:String) extends APlayable(name,50,150,100,"MagoBlanco",false,80) { + +} // Override equals method to compare two characters based on their attributes + + + + + diff --git a/src/main/scala/model/playable/MagicCharacter.scala b/src/main/scala/model/playable/MagicCharacter.scala new file mode 100644 index 0000000..4000fc9 --- /dev/null +++ b/src/main/scala/model/playable/MagicCharacter.scala @@ -0,0 +1,4 @@ +package model.playable +import model.playable.APlayable + +// MagicCharacter class extends the Playable trait diff --git a/src/main/scala/model/playable/Playable.scala b/src/main/scala/model/playable/Playable.scala new file mode 100644 index 0000000..69a815d --- /dev/null +++ b/src/main/scala/model/playable/Playable.scala @@ -0,0 +1,22 @@ +package model.playable + +trait Playable { + // Abstract method to get the name of the playable entity + def sayName(): String + + // Abstract method to get the life points of the playable entity + def sayLife(): Int + + // Abstract method to get the defense points of the playable entity + def sayDefence(): Int + + // Abstract method to get the weight of the playable entity + def sayWeight(): Int + + // Abstract method to get the kind/type of the playable entity + def sayKind(): String + + // Abstract method to check if the playable entity has a weapon + def havWeapon(): Boolean + +} diff --git a/src/test/scala/PartyTest.scala b/src/test/scala/PartyTest.scala new file mode 100644 index 0000000..e231376 --- /dev/null +++ b/src/test/scala/PartyTest.scala @@ -0,0 +1,48 @@ +import munit.FunSuite +import model.party.Party +import model.playable.{APlayable,Paladin,Guerrero,Ninja,MagoBlanco,MagoNegro} +import model.nonplayable.{Enemy, MagicWeapon, Weapon} +class PartyTest extends FunSuite { + var Team1: Party = _ // We declare a variable Team1 of type Party + var Cristiano: APlayable = _ // We declare a variable Cristiano of type Playable + var Alexis: APlayable = _ // We declare a variable Alexis of type Playable + + + override def beforeEach(context: BeforeEach): Unit = { + Team1 = new Party() // Creates a new instance of the Party class and assigns it to the variable Team1. + // Creates a new instance of the Character class with the specified parameters: + Cristiano = new Paladin("Cristiano") + + // Creates a new instance of the MagicCharacter class with the specified parameters: + Alexis = new MagoBlanco("Alexis")// - Kind: Mago Blanco // - Weapon: false + + } + test("addCharacter") { // Test the method to add a character + Team1.addPlayable(Cristiano) // Add the character Cristiano + val expected: Map[String, APlayable] = Map("Paladin" -> Cristiano) // The expected variable will be a map with the type and name of the character + assertEquals(Team1.allies.toMap, expected) // Compare the result with the Map + } + + test("isEmpty") { // Test if the team is initially empty + var state: Boolean = Team1.isDefeated // Create a variable 'state' that stores the result of checking if a party is defeated + assertEquals(state, true) // Compare the results + } + test("isDefeat") { // Test if a party is defeated or not + Cristiano.life = 0 + Team1.addPlayable(Cristiano) // Add a character with zero health + Alexis.life = 0 + Team1.addPlayable(Alexis) // Add a magic character with zero health + assertEquals(Team1.isDefeated, true) // Check if they are defeated or not (a team with no health is defeated) -> true + } + test("isNotDefeat") { // Test if a party is not defeated + Team1.addPlayable(Cristiano) // Add a character with zero health + Alexis = new MagoBlanco("Alexis") + Team1.addPlayable(Alexis) // Add that living character + assertEquals(Team1.isDefeated, false) // Check that the team is alive (false) + } + + + + + +} diff --git a/src/test/scala/nonplayable/EnemyTest.scala b/src/test/scala/nonplayable/EnemyTest.scala new file mode 100644 index 0000000..7a6c5e7 --- /dev/null +++ b/src/test/scala/nonplayable/EnemyTest.scala @@ -0,0 +1,76 @@ +package nonplayable + +import model.nonplayable.Enemy +import munit.FunSuite +class EnemyTest extends FunSuite { + var Neymar: Enemy = _ // We declare a variable Neymar of type Enemy + var Bale: Enemy = _ // We declare a variable Bale of type Enemy + + override def beforeEach(context: BeforeEach): Unit = { + // Creates a new instance of the Enemy class with the specified parameters: + Neymar = new Enemy("Neymar", 60, 90, 70, 30) // -Name : Neymar // - Weight: 60 // - Attack: 90 // - Life: 70 // - Defence: 30 + // Creates a new instance of the Enemy class with the specified parameters: + Bale = new Enemy("Bale", 70, 85, 75, 50) // -Name : Bale // - Weight: 70 // - Attack: 85 // - Life: 75 // - Defence: 50 + + } + + test("equalsEnemyName") { // Test if the returned name value for an enemy matches the expected value + var name: String = Neymar.sayName() // Retrieve the name value of the enemy Neymar and store it in the 'name' variable + var expected: String = "Neymar" // Define the expected name value + assertEquals(name, expected) // Compare the actual name value with the expected value + } + + test("NotEqualsEnemyName") { // Test if the name values of two different enemies are not equal + var name1: String = Neymar.sayName() // Retrieve the name value of the enemy Neymar and store it in the 'name1' variable + var name2: String = Bale.sayName() // Retrieve the name value of the enemy Bale and store it in the 'name2' variable + assertNotEquals(name1, name2) // Assert that the name values of Neymar and Bale are not equal + } + + test("equalsWeight") { // Test if the returned weight value for an enemy matches the expected value + var weight = Neymar.sayWeight() // Retrieve the weight value of the enemy Neymar and store it in the 'weight' variable + var expected: Int = 60 // Define the expected weight value + assertEquals(weight, expected) // Compare the actual weight value with the expected value + } + + test("NotEqualsWeight") { // Test if the weight values of two different enemies are not equal + var weight1 = Neymar.sayWeight() // Retrieve the weight value of the enemy Neymar and store it in the 'weight1' variable + var weight2 = Bale.sayWeight() // Retrieve the weight value of the enemy Bale and store it in the 'weight2' variable + assertNotEquals(weight1, weight2) // Assert that the weight values of Neymar and Bale are not equal + } + + test("equalsAttack") { // Test if the returned attack value for an enemy matches the expected value + var attack = Neymar.sayAttack() // Retrieve the attack value of the enemy Neymar and store it in the 'attack' variable + var expected: Int = 90 // Define the expected attack value + assertEquals(attack, expected) // Compare the actual attack value with the expected value + } + + test("NotEqualsAttack") { // Test if the attack values of two different enemies are not equal + var attack1 = Neymar.sayAttack() // Retrieve the attack value of the enemy Neymar and store it in the 'attack1' variable + var attack2 = Bale.sayAttack() // Retrieve the attack value of the enemy Bale and store it in the 'attack2' variable + assertNotEquals(attack1, attack2) // Assert that the attack values of Neymar and Bale are not equal + } + + test("equalsLife") { // Test if the returned life value for an enemy matches the expected value + var life = Neymar.sayLife() // Retrieve the life value of the enemy Neymar and store it in the 'life' variable + var expected: Int = 70 // Define the expected life value + assertEquals(life, expected) // Compare the actual life value with the expected value + } + + test("NotEqualsLife") { // Test if the life values of two different enemies are not equal + var life1 = Neymar.sayLife() // Retrieve the life value of the enemy Neymar and store it in the 'life1' variable + var life2 = Bale.sayLife() // Retrieve the life value of the enemy Bale and store it in the 'life2' variable + assertNotEquals(life1, life2) // Assert that the life values of Neymar and Bale are not equal + } + + test("equalsDefence") { // Test if the returned defense value for an enemy matches the expected value + var defense = Neymar.sayDefence() // Retrieve the defense value of the enemy Neymar and store it in the 'defense' variable + var expected: Int = 30 // Define the expected defense value + assertEquals(defense, expected) // Compare the actual defense value with the expected value + } + + test("NotEqualsDefence") { // Test if the defense values of two different enemies are not equal + var defense1 = Neymar.sayDefence() // Retrieve the defense value of the enemy Neymar and store it in the 'defense1' variable + var defense2 = Bale.sayDefence() // Retrieve the de + + } +} diff --git a/src/test/scala/nonplayable/MagicWeaponTest.scala b/src/test/scala/nonplayable/MagicWeaponTest.scala new file mode 100644 index 0000000..152b999 --- /dev/null +++ b/src/test/scala/nonplayable/MagicWeaponTest.scala @@ -0,0 +1,75 @@ +package nonplayable + +import model.nonplayable.MagicWeapon +import model.playable.{APlayable} +import munit.FunSuite +class MagicWeaponTest extends FunSuite { + var Wand: MagicWeapon = _ // We declare a variable Wand of type MagicWeapon + var Staff: MagicWeapon = _ // We declare a variable Staff of type MagicWeapon + var Alexis: APlayable = _ // We declare a variable Alexis of type MagicCharacter + var Vidal: APlayable = _ // We declare a variable Vidal of type MagicCharacter + var Cristiano: APlayable = _ // We declare a variable Cristiano of type Character + + override def beforeEach(context: BeforeEach): Unit = { + // Creates a new instance of the MagicWeapon class with the specified parameters: + Wand = new MagicWeapon("Barita",10,50,50,Alexis) // -Name : Barita // - Weight: 10 // - Attack: 50 // - Mana: 50 //- Owner : Alexis + // Creates a new instance of the MagicWeapon class with the specified parameters: + Staff = new MagicWeapon("Baston",15,60,45,Vidal) // -Name : Baston // - Weight: 15 // - Attack: 60 // - Mana: 45 //- Owner : Vidal + + + } + test("equalsName") { // Test if the returned name value for a wand matches the expected value + var name: String = Wand.sayName() // Retrieve the name value of the wand and store it in the 'name' variable + var expected = "Barita" // Define the expected name value + assertEquals(name, expected) // Compare the actual name value with the expected value + } + + test("NotEqualsName") { // Test if the name values of two different magical items are not equal + var name1 = Wand.sayName() // Retrieve the name value of the wand and store it in the 'name1' variable + var name2 = Staff.sayName() // Retrieve the name value of the staff and store it in the 'name2' variable + assertNotEquals(name1, name2) // Assert that the name values of the wand and the staff are not equal + } + + test("equalsWeight") { // Test if the returned weight value for a wand matches the expected value + var weight = Wand.sayWeight() // Retrieve the weight value of the wand and store it in the 'weight' variable + var expected: Int = 10 // Define the expected weight value + assertEquals(weight, expected) // Compare the actual weight value with the expected value + } + + test("NotEqualsWeight") { // Test if the weight values of two different magical items are not equal + var weight1 = Wand.sayWeight() // Retrieve the weight value of the wand and store it in the 'weight1' variable + var weight2 = Staff.sayWeight() // Retrieve the weight value of the staff and store it in the 'weight2' variable + assertNotEquals(weight1, weight2) // Assert that the weight values of the wand and the staff are not equal + } + + test("equalsAttack") { // Test if the returned attack value for a wand matches the expected value + var attack = Wand.sayAttack() // Retrieve the attack value of the wand and store it in the 'attack' variable + var expected: Int = 50 // Define the expected attack value + assertEquals(attack, expected) // Compare the actual attack value with the expected value + } + + test("NotEqualsAttack") { // Test if the attack values of two different magical items are not equal + var attack1 = Wand.sayAttack() // Retrieve the attack value of the wand and store it in the 'attack1' variable + var attack2 = Staff.sayAttack() // Retrieve the attack value of the staff and store it in the 'attack2' variable + assertNotEquals(attack1, attack2) // Assert that the attack values of the wand and the staff are not equal + } + + test("equalsMana") { // Test if the returned mana value for a wand matches the expected value + var mana = Wand.sayMana() // Retrieve the mana value of the wand and store it in the 'mana' variable + var expected: Int = 50 // Define the expected mana value + assertEquals(mana, expected) // Compare the actual mana value with the expected value + } + + test("NotEqualsMana") { // Test if the mana values of two different magical items are not equal + var mana1 = Wand.sayMana() // Retrieve the mana value of the wand and store it in the 'mana1' variable + var mana2 = Staff.sayAttack() // Retrieve the mana value of the staff and store it in the 'mana2' variable + assertNotEquals(mana1, mana2) // Assert that the mana values of the wand and the staff are not equal + } + + test("equalsMagicOwner") { // Test if the returned owner character for a wand matches the expected character + var owner: APlayable = Wand.sayOwner() // Retrieve the owner character of the wand and store it in the 'owner' variable + var expected: APlayable = Alexis // Define the expected owner character + assertEquals(owner, expected) // Compare the actual owner character with the expected character + } + +} diff --git a/src/test/scala/nonplayable/WeaponTest.scala b/src/test/scala/nonplayable/WeaponTest.scala new file mode 100644 index 0000000..c3f5e58 --- /dev/null +++ b/src/test/scala/nonplayable/WeaponTest.scala @@ -0,0 +1,63 @@ +package nonplayable + +import model.nonplayable.Weapon +import model.playable.APlayable +import munit.FunSuite +class WeaponTest extends FunSuite { + var Sword: Weapon = _ // We declare a variable Sword of type Weapon + var Bow: Weapon = _ // We declare a variable Bow of type Weapon + var Cristiano: Character = _ // We declare a variable Cristiano of type Character + var Messi: Character = _ // We declare a variable Messi of type Character + + override def beforeEach(context: BeforeEach): Unit = { + // Creates a new instance of the Weapon class with the specified parameters: + Sword = new Weapon("Espada",70,100,Cristiano) // -Name : Espada // - Weight: 70 // - Attack: 100 // - Owner : Cristiano + // Creates a new instance of the Weapon class with the specified parameters: + Bow = new Weapon("Arco",25,50,Messi) // -Name : Arco // - Weight: 25 // - Attack: 50 // - Owner : Messi + + } + test("equalsName") { // Test if the returned name value for a sword matches the expected value + var name: String = Sword.sayName() // Retrieve the name value of the sword and store it in the 'name' variable + var expected = "Espada" // Define the expected name value + assertEquals(name, expected) // Compare the actual name value with the expected value + } + + test("NotEqualsName") { // Test if the name values of two different weapons are not equal + var name1 = Sword.sayName() // Retrieve the name value of the sword and store it in the 'name1' variable + var name2 = Bow.sayName() // Retrieve the name value of the bow and store it in the 'name2' variable + assertNotEquals(name1, name2) // Assert that the name values of the sword and the bow are not equal + } + + test("equalsWeight") { // Test if the returned weight value for a sword matches the expected value + var weight = Sword.sayWeight() // Retrieve the weight value of the sword and store it in the 'weight' variable + var expected: Int = 70 // Define the expected weight value + assertEquals(weight, expected) // Compare the actual weight value with the expected value + } + + test("NotEqualsWeight") { // Test if the weight values of two different weapons are not equal + var weight1 = Sword.sayWeight() // Retrieve the weight value of the sword and store it in the 'weight1' variable + var weight2 = Bow.sayWeight() // Retrieve the weight value of the bow and store it in the 'weight2' variable + assertNotEquals(weight1, weight2) // Assert that the weight values of the sword and the bow are not equal + } + + test("equalsAttack") { // Test if the returned attack value for a sword matches the expected value + var attack = Sword.sayAttack() // Retrieve the attack value of the sword and store it in the 'attack' variable + var expected: Int = 100 // Define the expected attack value + assertEquals(attack, expected) // Compare the actual attack value with the expected value + } + + test("NotEqualsAttack") { // Test if the attack values of two different weapons are not equal + var attack1 = Sword.sayAttack() // Retrieve the attack value of the sword and store it in the 'attack1' variable + var attack2 = Bow.sayAttack() // Retrieve the attack value of the bow and store it in the 'attack2' variable + assertNotEquals(attack1, attack2) // Assert that the attack values of the sword and the bow are not equal + } + + test("equalsOwner") { // Test if the returned owner character for a sword matches the expected character + var owner: Character = Sword.sayOwner() // Retrieve the owner character of the sword and store it in the 'owner' variable + var expected: Character = Cristiano // Define the expected owner character + assertEquals(owner, expected) // Compare the actual owner character with the expected character + } + + + +} diff --git a/src/test/scala/playable/CharacterTest.scala b/src/test/scala/playable/CharacterTest.scala new file mode 100644 index 0000000..e875cdb --- /dev/null +++ b/src/test/scala/playable/CharacterTest.scala @@ -0,0 +1,101 @@ +package playable + +import model.playable.{APlayable, Guerrero, Paladin} +import munit.FunSuite +class CharacterTest extends FunSuite { + var Cristiano: APlayable = _ // We declare a variable Cristiano of type Character + var Messi: APlayable = _ // We declare a variable Messi of type Character + + override def beforeEach(context: BeforeEach): Unit = { + // Creates a new instance of the Character class with the specified parameters: + Cristiano = new Paladin("Cristiano") + // Creates a new instance of the Character class with the specified parameters: + Messi = new Guerrero("Messi")// - Weight: 60 // - Kind: Guerrero // - Weapon: true + + } + test("equals") { // Test if two references to the same character are equal + val character: APlayable = Cristiano // Create a reference to the character Cristiano and assign it to the variable 'character' + var expected = Cristiano // Define the expected value as the character Cristiano + assertEquals(character, expected) // Compare the actual reference with the expected value + } + + test("NotEquals") { // Test if two references to different characters are not equal + val character1: APlayable = Cristiano // Create a reference to the character Cristiano and assign it to the variable 'character1' + val character2: APlayable = Messi // Create a reference to the character Messi and assign it to the variable 'character2' + assertNotEquals(character1, character2) // Assert that the references to Cristiano and Messi are not equal + } + + test("equalsName") { // Test if the returned name value for a character matches the expected value + var name = Cristiano.sayName() // Retrieve the name value of the character Cristiano and store it in the 'name' variable + val expected: String = "Cristiano" // Define the expected name value + assertEquals(name, expected) // Compare the actual name value with the expected value + } + + test("NotEqualsName") { // Test if the name values of two different characters are not equal + var name1 = Cristiano.sayName() // Retrieve the name value of the character Cristiano and store it in the 'name1' variable + var name2 = Messi.sayName() // Retrieve the name value of the character Messi and store it in the 'name2' variable + assertNotEquals(name1, name2) // Assert that the name values of Cristiano and Messi are not equal + } + + test("equalsLife") { // Test if the returned life value for a character matches the expected value + var life = Cristiano.sayLife() // Retrieve the life value of the character Cristiano and store it in the 'life' variable + var expected: Int = 100 // Define the expected life value + assertEquals(life, expected) // Compare the actual life value with the expected value + } + + test("NotEqualsLife") { // Test if the life values of two different characters are not equal + var life1 = Cristiano.sayLife() // Retrieve the life value of the character Cristiano and store it in the 'life1' variable + var life2 = Messi.sayLife() // Retrieve the life value of the character Messi and store it in the 'life2' variable + assertNotEquals(life1, life2) // Assert that the life values of Cristiano and Messi are not equal + } + test("equalsDefence") { // Test if the returned defense value for a character matches the expected value + var defense = Cristiano.sayDefence() // Retrieve the defense value of the character Cristiano and store it in the 'defense' variable + var expected: Int = 50 // Define the expected defense value + assertEquals(defense, expected) // Compare the actual defense value with the expected value + } + + test("NotEqualsDefence") { // Test if the defense values of two different characters are not equal + var defense1 = Cristiano.sayDefence() // Retrieve the defense value of the character Cristiano and store it in the 'defense1' variable + var defense2 = Messi.sayDefence() // Retrieve the defense value of the character Messi and store it in the 'defense2' variable + assertNotEquals(defense1, defense2) // Assert that the defense values of Cristiano and Messi are not equal + } + + test("equalsWeight") { // Test if the returned weight value for a character matches the expected value + var weight = Cristiano.sayWeight() // Retrieve the weight value of the character Cristiano and store it in the 'weight' variable + var expected: Int = 50 // Define the expected weight value + assertEquals(weight, expected) // Compare the actual weight value with the expected value + } + + test("NotEqualsWeight") { // Test if the weight values of two different characters are not equal + var weight1 = Cristiano.weight // Retrieve the weight value of the character Cristiano and store it in the 'weight1' variable + var weight2 = Messi.weight // Retrieve the weight value of the character Messi and store it in the 'weight2' variable + assertNotEquals(weight1, weight2) // Assert that the weight values of Cristiano and Messi are not equal + } + + test("equalsKind") { // Test if the returned kind value for a character matches the expected value + var kind = Cristiano.sayKind() // Retrieve the kind value of the character Cristiano and store it in the 'kind' variable + var expected: String = "Paladin" // Define the expected kind value + assertEquals(kind, expected) // Compare the actual kind value with the expected value + } + + test("NotEqualsKind") { // Test if the kind values of two different characters are not equal + var kind1 = Cristiano.sayKind() // Retrieve the kind value of the character Cristiano and store it in the 'kind1' variable + var kind2 = Messi.sayKind() // Retrieve the kind value of the character Messi and store it in the 'kind2' variable + assertNotEquals(kind1, kind2) // Assert that the kind values of Cristiano and Messi are not equal + } + + test("haveWeapon") { // Test if the character Messi has a weapon + Messi.weapon = true + val hasWeapon = Messi.weapon // Check if the character Messi has a weapon and store the result in the 'hasWeapon' variable + var expected = true // Define the expected value indicating that Messi has a weapon + assertEquals(hasWeapon, expected) // Compare the actual result with the expected value + } + + test("haveNotWeapon") { // Test if the character Cristiano doesn't have a weapon + val hasWeapon = Cristiano.weapon // Check if the character Cristiano has a weapon and store the result in the 'hasWeapon' variable + var expected = false // Define the expected value indicating that Cristiano doesn't have a weapon + assertEquals(hasWeapon, expected) // Compare the actual result with the expected value + } + + +} \ No newline at end of file diff --git a/src/test/scala/playable/MagicCharacterTest.scala b/src/test/scala/playable/MagicCharacterTest.scala new file mode 100644 index 0000000..5435954 --- /dev/null +++ b/src/test/scala/playable/MagicCharacterTest.scala @@ -0,0 +1,94 @@ +package playable + +import model.playable.{APlayable, MagoBlanco, MagoNegro} +import munit.FunSuite +class MagicCharacterTest extends FunSuite { + var Alexis: APlayable = _ // We declare a variable Alexis of type MagicCharacter + var Vidal: APlayable = _ // We declare a variable Vidal of type MagicCharacter + + override def beforeEach(context: BeforeEach): Unit = { + // Creates a new instance of the Magic Character class with the specified parameters: + Alexis = new MagoBlanco("Alexis") // - Kind: Mago Blanco // - Weapon: false + // Creates a new instance of the Magic Character class with the specified parameters: + Vidal = new MagoNegro("Vidal") // - Kind: Mago Negro // - Weapon: true + + } + test("equalsName") { // Test if the sayName method behaves correctly + var name = Alexis.sayName() // Store the name of the character in the 'name' variable + val expected: String = "Alexis" // Declare the variable for comparison + assertEquals(name, expected) // Compare the results + } + + + test("NotEqualsName") { // Test if the names returned by the sayName method for two different characters are not equal + var name1 = Alexis.sayName() // Store the name of the first character in the 'name1' variable + var name2 = Vidal.sayName() // Store the name of the second character in the 'name2' variable + assertNotEquals(name1, name2) // Assert that the two names are not equal + } + test("equalsLife") { // Test if the returned life value for a character matches the expected value + var life = Alexis.life // Retrieve the life value of the character Alexis and store it in the 'life' variable + var expected: Int = 50 // Define the expected life value + assertEquals(life, expected) // Compare the actual life value with the expected value + } + test("NotEqualsLife") { // Test if the life values of two different characters are not equal + var life1 = Alexis.sayLife() // Retrieve the life value of the character Alexis and store it in the 'life1' variable + var life2 = Vidal.sayLife() // Retrieve the life value of the character Vidal and store it in the 'life2' variable + assertNotEquals(life1, life2) // Assert that the life values of Alexis and Vidal are not equal + } + + test("NotEqualsDefence") { // Test if the defense values of two different characters are not equal + var defense1 = Alexis.defence // Retrieve the defense value of the character Alexis and store it in the 'defense1' variable + var defense2 = Vidal.defence // Retrieve the defense value of the character Vidal and store it in the 'defense2' variable + assertNotEquals(defense1, defense2) // Assert that the defense values of Alexis and Vidal are not equal + } + + + + test("NotEqualsWeight") { // Test if the weight values of two different characters are not equal + var weight1 = Alexis.weight // Retrieve the weight value of the character Alexis and store it in the 'weight1' variable + var weight2 = Vidal.weight // Retrieve the weight value of the character Vidal and store it in the 'weight2' variable + assertNotEquals(weight1, weight2) // Assert that the weight values of Alexis and Vidal are not equal + } + + + test("haveNotWeapon") { // Test if the character Alexis doesn't have a weapon + val hasWeapon = Alexis.weapon // Check if the character Alexis has a weapon and store the result in the 'hasWeapon' variable + var expected = false // Define the expected value indicating that Alexis doesn't have a weapon + assertEquals(hasWeapon, expected) // Compare the actual result with the expected value + } + + + test("NotEqualsMana") { // Test if the mana values of two different characters are not equal + var mana1 = Alexis.mana // Retrieve the mana value of the character Alexis and store it in the 'mana1' variable + var mana2 = Vidal.mana // Retrieve the mana value of the character Vidal and store it in the 'mana2' variable + assertNotEquals(mana1, mana2) // Assert that the mana values of Alexis and Vidal are not equal + } + + test("equalsMagicKind") { // Test if the returned magic kind for a character matches the expected value + var magicKind = Alexis.kind // Retrieve the magic kind of the character Alexis and store it in the 'magicKind' variable + var expected: String = "MagoBlanco" // Define the expected magic kind + assertEquals(magicKind, expected) // Compare the actual magic kind with the expected value + } + + test("NotEqualsMagicKind") { // Test if the magic kinds of two different characters are not equal + var magicKind1 = Alexis.sayKind() // Retrieve the magic kind of the character Alexis and store it in the 'magicKind1' variable + var magicKind2 = Vidal.sayKind() // Retrieve the magic kind of the character Vidal and store it in the 'magicKind2' variable + assertNotEquals(magicKind1, magicKind2) // Assert that the magic kinds of Alexis and Vidal are not equal + } + + test("equalsMagicCharacter") { // Test if two references to the same magic character are equal + val pmc: APlayable = Alexis // Create a reference to the character Alexis and assign it to the variable 'pmc' + var expected = Alexis // Define the expected value as the character Alexis + assertEquals(pmc, expected) // Compare the actual reference with the expected value + } + + test("NotEqualsMagicCharacter") { // Test if two references to different magic characters are not equal + val pmc1: APlayable = Alexis // Create a reference to the character Alexis and assign it to the variable 'pmc1' + val pmc2: APlayable = Vidal // Create a reference to the character Vidal and assign it to the variable 'pmc2' + assertNotEquals(pmc1, pmc2) // Assert that the references to Alexis and Vidal are not equal + } + + + + +} \ No newline at end of file