Skip to content
Snippets Groups Projects
Commit 41f1144d authored by phenixceleste's avatar phenixceleste
Browse files

trainer class added

parent ba6afda0
1 merge request!11Resolve "Trainer class"
......@@ -3,5 +3,5 @@ class Capacity(val name: String, val ctype: Type, val maxUses: Int, private var
// getter
def usesLeft: Int = this._usesLeft
def use() =
def use: Unit =
this._usesLeft = this._usesLeft - 1
......@@ -23,9 +23,9 @@ trait Pokemon(
def speed: Int = 5 + scala.math.floor(2.0 * this.baseSpeed * this.level / 100.0).toInt
def maxLife: Int = scala.math.floor(2.0 * this.baseSpeed * this.level / 100.0).toInt + 10 + this.level
def useCapacity(capacity: Capacity, other: Pokemon) =
def useCapacity(capacity: Capacity, other: Pokemon): Unit =
capacity.use()
capacity.use
val multiplier = other.ptype.foldLeft(1.0)(_ * capacity.ctype.typeEfficiency(_).factor)
......@@ -37,7 +37,7 @@ trait Pokemon(
other.decreaseLife(Math.round(damage.toFloat))
def decreaseLife(x: Int) = this._life = this.life - x
def decreaseLife(x: Int): Unit = this._life = this.life - x
override def toString(): String =
s"[${this.name}] Life: ${this.life}\nMaxLife: ${this.maxLife}\nAttack: ${this.attack}\nDefense: ${this.defense}\nSpeed: ${this.speed}\n"
class Trainer(val name: String, var listPokemon: List[Pokemon], var indexPrimaryPokemon: Int):
def getNumberPokemon: Int =
this.listPokemon.length
def getPrimaryPokemon: Option[Pokemon] =
this.listPokemon.lift(this.indexPrimaryPokemon)
def changePrimaryPokemon(index: Int): Unit =
assert(0 <= index && index < this.getNumberPokemon)
this.indexPrimaryPokemon = index
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment