Files
KnockOutWhist/src/main/scala/de/knockoutwhist/player/PlayerFactory.scala
Janis 3396355193
Some checks failed
Build and Test (KnockOutWhist) TeamCity build failed
Config Version yay
2024-12-20 10:54:29 +01:00

30 lines
667 B
Scala

package de.knockoutwhist.player
import de.knockoutwhist.player.Playertype.{AI, HUMAN, STUB}
import de.knockoutwhist.player.builder.*
enum Playertype:
case HUMAN
case AI
case STUB
end Playertype
object PlayerFactory {
def createPlayer(name: String = null, playertype: Playertype): AbstractPlayer = {
val buildType: PlayerBuilder = playertype match {
case HUMAN =>
new HumanoidBuilder()
case AI =>
new AIPlayerBuilder()
case STUB =>
new StubPlayerBuilder
}
if (name == null) {
Director.constructWithRandomNames(buildType)
} else {
Director.constructWithName(buildType, name)
}
}
}