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

pokemon stat upgrade

parent 3c034986
No related branches found
No related tags found
1 merge request!6Resolve "Upgrade Pokemon class"
Pipeline #9678 passed with stage
in 2 minutes and 14 seconds
class Capacity(name: String, val ctype: Type)
// must add later : max_used
// uses : var or val ?
class Capacity(name: String, val ctype: Type, var uses: Int)
object CapacityFactory:
private case class VineWhip() extends Capacity("Vine Whip", Grass)
private case class VineWhip() extends Capacity("Vine Whip", Grass, 15)
def apply(name: String): Capacity = name match
case "Vine Whip" => VineWhip()
trait Pokemon(var name: String, var life: Int, val ptype: List[Type]):
trait Pokemon( // must add later max_life...
var name: String,
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 ?
):
def rename(newName: String) =
this.name = newName
def attack(capacity: Capacity, other: Pokemon) =
val multiplier = other.ptype.foldLeft(1.0)(_ * capacity.ctype.typeEfficiency(_).factor)
......
object PokemonFactory:
private case class Bulbasaur() extends Pokemon("Bulbasaur", 25, List(Grass, Poison))
private case class Charmander() extends Pokemon("Charmander", 30, List(Fire))
private case class Squirtle() extends Pokemon("Squirtle", 25, List(Water))
private case class Bulbasaur() extends Pokemon("Bulbasaur", 25, List(Grass, Poison), List(), 0, 0, 0)
private case class Charmander() extends Pokemon("Charmander", 30, List(Fire), List(), 0, 0, 0)
private case class Squirtle() extends Pokemon("Squirtle", 25, List(Water), List(), 0, 0, 0)
def apply(name: String): Pokemon = name match
case "Bulbasaur" => Bulbasaur()
......
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