Skip to content
Snippets Groups Projects
Commit 068bbd1c authored by phenixceleste's avatar phenixceleste
Browse files

TODO added, private mutable variable in pokemon

parent e6081432
No related branches found
No related tags found
1 merge request!6Resolve "Upgrade Pokemon class"
Pipeline #9680 passed with stage
in 2 minutes and 6 seconds
trait Pokemon( // must add later max_life...
var name: String,
var life: Int,
trait Pokemon( // TODO: must add later max_life...
private var _name: String,
private var _life: Int,
val ptype: List[Type],
var pcapacity: List[Capacity],
val attack: Int, // val or var ?
val defense: Int, // val or var ?
val speed: Int // val or var ?
_pcapacity: List[Capacity],
_attack: Int,
_defense: Int,
_speed: Int
):
def rename(newName: String) =
this.name = newName
def name: String = this._name
def name_=(name: String) = this._name = name
def attack(capacity: Capacity, other: Pokemon) =
val multiplier = other.ptype.foldLeft(1.0)(_ * capacity.ctype.typeEfficiency(_).factor)
other.decreaseLife(Math.round(multiplier.toFloat))
def decreaseLife(x: Int) = this.life = this.life - x
def life: Int = this._life
def life_=(life: Int) = this._life = life
def decreaseLife(x: Int) = this._life = this._life - x
override def toString(): String = s"[${this.name}] Life: ${this.life}"
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