/*
 * This file is Open Game Content, covered by the OGL.
 */
package org.evilsoft.gaming.System;

import org.evilsoft.gaming.*;

public class SystemAttribute {

  private String name;
  private int value;
  private String description;
  private SystemDie die;
  private final boolean DEBUG = false;

  public SystemAttribute(String name, int value, String description, SystemDie die) {
    this.name = name;
    this.value = value;
    this.description = description;
    this.die = die;
  }

  public SystemAttribute(String name, int value, SystemDie die) {
    this(name, value, "", die);
  }

  public SystemAttribute(String name, int value, String description) {
    this(name, value, description, new SystemDie());
  }

  public SystemAttribute(String name, int value) {
    this(name, value, "", new SystemDie());
  }

  public int check() {
    return check(0);
  }

  public int check(int mod) {
    return die.roll() + this.getModifier() + mod;
  }

  public boolean difficultyCheck(int difficulty) {
    return difficultyCheck(difficulty, 0);
  }

  public boolean difficultyCheck(int difficulty, int mod) {
    int check = check(mod);
    if(check >= difficulty) {
      return true;
    }
    else {
      return false;
    }
  }

  public String getDescription() {
    return description;
  }

  public int getModifier() {
    if(!DEBUG) {
      System.out.println("OGC: Attribute Modifier = (" + value + " / 2 ) - 5");
      System.out.println("Code:");
      System.out.println("return (value / 2) - 5;");
    }
    return (value / 2) - 5;
  }

  public String getName() {
    return name;
  }

  public int getValue() {
    return value;
  }

  public void setValue(int value) {
    this.value = value;
  }
  
  public void setDie(SystemDie die) {
      this.die = die;
  }
}
