io.github.pidoveproject.showdown.battle.SideCondition.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-showdown-api_3 Show documentation
Show all versions of scala-showdown-api_3 Show documentation
A Scala wrapper of Pokemon Showdown's API
The newest version!
package io.github.pidoveproject.showdown.battle
import io.github.iltotore.iron.*
import io.github.pidoveproject.showdown.Count
import scala.math.Integral.Implicits.infixIntegralOps
/**
* The condition of a side.
*
* @param effects the effects bound to the represented side
*/
case class SideCondition(effects: Map[SideFieldEffect, Count]):
/**
* Add an effect to the the side.
*
* @param effect the effect to add
* @return a copy of the side's condition with the given effect
*/
def withEffect(effect: SideFieldEffect): SideCondition =
this.copy(effects = effects.updated(effect, effects.getOrElse(effect, Count(0)) + Count(1)))
/**
* Remove an effect to the the side.
*
* @param effect the effect to remove
* @return a copy of the side's condition without the given effect
*/
def removedEffect(effect: SideFieldEffect): SideCondition =
this.copy(effects = effects.removed(effect))
/**
* Clear all the effects of the represented side.
*/
def cleared: SideCondition = this.copy(effects = Map.empty)