brn:
  name: 'brn'
  id: 'brn'
  num: 0
  effectType: 'Status'
  onModifyStat: |
    if (stat == PAtk) {
      1 \\ 2
    } else {
      1.frac
    }
  onStart: |
    msg(s"${mon} was burned!")
  onEnd: |
    msg(s"${mon} was healed of its burn.")
  onResidualOrder: 9
  onResidual: |
    mon.takeDamage(mon(Hp) / 16);
    msg(s"${mon} was hurt by its burn!")
    
confusion:
  id: confusion
  name: confusion
  num: 0
  onBeforeMove: |-
    self.intData("time") -= 1
    if (self.intData("time") <= 0) {
      mon -= self
      true
    } else {
      msg(s"${mon} is confused!")
      if (rng.chance(1, 3)) {
        // confusion damage
        val maxDmg = (2 * mon.level / 5 + 2) * 40 * mon(PAtk) / (mon(PDef) * 50) + 2
        val minDmg = (17 \\ 20) * maxDmg
        val dmg = rng.nextInt(minDmg, maxDmg)
        msg(s"${mon} hurt itself in its confusion.")
        mon.takeDamage(dmg)
        false
      } else {
        true
      }
    }
    /*
    this.activeTarget = mon;
    let damage = this.getDamage(mon, mon, 40);
    if (typeof damage !== 'number') throw new Error('Confusion damage not dealt');
    mon.takeDamage(damage, mon, mon, /** @type {ActiveMove} */ ({
        'id': 'confused',
        'effectType': 'Move',
        'type': '???'
    }));
    */
  onBeforeMovePriority: 3
  onEnd: msg(s"${mon} snapped out of its confusion.")
  onStart: |-
    msg(s"${mon} was confused!")
    self.intData("time") = rng.nextInt(2, 6);
    
par:
  name: 'par'
  id: 'par'
  num: 0
  effectType: 'Status'
  onStart: |
    msg(s"${mon} was paralyzed!")
  onEnd: |
    msg(s"${mon} is no longer paralyzed!")
  onModifyStat: |
    if (stat == Speed /* && !mon.hasAbility('quickfeet') */) {
      1 \\ 2
    } else {
      1.frac
    }
  onBeforeMovePriority: 1
  onBeforeMove: |
    if (rng.chance(1, 4)) {
      msg(s"${mon} is fully paralyzed!")
      false
    } else {
      true
    }
  
slp:
  name: 'slp'
  id: 'slp'
  num: 0
  effectType: 'Status'
  onStart: |
    msg(s"${mon} fell asleep!")
    // 1-3 turns
    self.intData("startTime") = rng.nextInt(2, 5)
    self.intData("time") = self.intData("startTime")
  onEnd: |
    msg(s"${mon} woke up!")
  onBeforeMovePriority: 10
  onBeforeMove: |
    /*
    if (mon.hasAbility('earlybird')) {
      this.intData.time--;
    }
    */
    self.intData("time") -= 1;
    if (self.intData("time") <= 0) {
      mon.cureStatus();
      true
    } else {
      msg(s"${mon} is fast asleep.")
      !move.flags("sleepUsable")
    }
  
flinch:
  duration: 1
  id: flinch
  name: flinch
  num: 0
  onBeforeMove: |-
    msg(s"${mon} flinched!")
    false
  onBeforeMovePriority: 8
  onResidualOrder: 13
  onResidual: |
    mon -= self
  
frz:
  name: 'frz'
  effectType: Status
  id: frz
  num: 0
  onBeforeMove: |-
    if (move.flags("defrost") || rng.chance(1, 5)) {
      mon.cureStatus()
      true
    } else {
      msg(s"${mon} is completely frozen!")
      false
    }
  onBeforeMovePriority: 10
  onHit: |-
    if (move.flags("thaws") || move.element === 'Fire' && move.category !== MoveType.Status) {
        target.cureStatus()
    }
  onStart: |-
    msg(s"${mon} was frozen solid!")
  onEnd: |-
    msg(s"${mon} thawed out.")
  onModifyMove: |
    if (move.flags("defrost")) {
      mon.cureStatus()
    }
  
psn:
  name: 'psn'
  id: 'psn'
  num: 0
  effectType: 'Status'
  onStart: |
    msg(s"${mon} was poisoned!")
  oneEnd: |
    msg(s"${mon} was cured of its poison.")
  onResidualOrder: 9
  onResidual: |
    mon.takeDamage(mon(Hp) / 8);
    msg(s"${mon} was damaged by poison!")
  
tox:
  name: 'tox'
  id: 'tox'
  num: 0
  effectType: 'Status'
  onStart: |
    msg(s"${mon} was baddly poisoned!")
    self.intData("stage") = 0;
  onSwitchIn: |
    this.effectData.stage = 0;
  onResidualOrder: 9
  onResidual: |
    if (self.intData("stage") < 15) {
      self.intData("stage") += 1
    }
    mon.takeDamage(self.intData("stage") \\ 16 * mon(Hp));
    msg(s"${mon} was damaged by poison!")