All files / src/tokens Modifier.ts

100% Statements 17/17
100% Branches 6/6
100% Functions 6/6
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48  1x         1x             204x 109x 109x     1x 1068x     1x 431x                 1x 368x     1x 12x 10x         2x     1x  
import { TokenEffect } from "./TokenEffect";
import { TokenEffectType } from "./TokenEffectType";
 
/**
 * A token effect that modify the skill value for the test.
 */
export class Modifier implements TokenEffect {
  private _value: number;
  private _isRedraw: boolean;
 
  /**
   * Create a new modifier given the modifier value.
   */
  constructor(value: number, isRedraw = false) {
    this._value = value;
    this._isRedraw = isRedraw;
  }
 
  public getOutcome(): TokenEffectType {
    return TokenEffectType.MODIFIER;
  }
 
  public isRedraw() {
    return this._isRedraw;
  }
 
  /**
   * Get the value of this modifier effect.
   *
   * @return {number}
   *   The value of this modifier effect.
   */
  public getValue(): number {
    return this._value;
  }
 
  public sameAs(other: TokenEffect): boolean {
    if (other instanceof Modifier) {
      return (
        this.getValue() === (other as Modifier).getValue() &&
        this.isRedraw() === (other as Modifier).isRedraw()
      );
    } else {
      return false;
    }
  }
}