Skip to content
Snippets Groups Projects
Verified Commit 6308dd90 authored by v-lafeychine's avatar v-lafeychine
Browse files

Add battle turn

parent 95aa5c69
No related branches found
No related tags found
1 merge request!17Resolve "Add Game logic"
Pipeline #9757 passed with stage
in 1 minute and 43 seconds
......@@ -10,6 +10,7 @@ import SFML.SFMLSystem.*
import SFML.SFMLWindow.*
class Game(window: Ptr[sfRenderWindow], private var _currentScene: Scene):
var isTrainerTurn = true
val trainer = Trainer("", List(PokemonFactory("Bulbasaur")), 0)
val trainerEnemy = Trainer("", List(PokemonFactory("Charmander")), 0)
......@@ -20,6 +21,13 @@ class Game(window: Ptr[sfRenderWindow], private var _currentScene: Scene):
def currentScene: Scene = _currentScene
def fetchEvents() =
if !isTrainerTurn then
val pokemonTrainerEnemy = trainerEnemy.primaryPokemon.get
val capacity =
pokemonTrainerEnemy.capacity(scala.util.Random.between(0, pokemonTrainerEnemy.capacity.length))
pokemonTrainerEnemy.useCapacity(capacity, trainer.primaryPokemon.get)
this.isTrainerTurn = true
if queryScene.isDefined then
_currentScene.components = List()
_currentScene = queryScene.get
......
......@@ -15,5 +15,6 @@ class CapacityBox(texture: Ptr[sfTexture], capacity: Capacity) extends Button(12
def onMouseClick(game: Main.Game) =
game.trainer.primaryPokemon.get.useCapacity(capacity, game.trainerEnemy.primaryPokemon.get)
game.queryScene = Some(Scene.Battle.BattleScene)
game.isTrainerTurn = false
def onMouseExit(game: Main.Game) = this.color = 255.toUByte
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