/* * change the level of the given attribute to 'value' for this instance */ public void setAttributeTo(EAttributeGroup A, int value) { if (value < minLevel || value > maxLevel) throw new ArgumentOutOfRangeException("You attempted to set an attribute to high or to low! Value: " + value); else attributeGroups[A] = value; // update to new level }
/** * Given A, increase the level of A by 'by' * return TRUE, if the given attribute A can be raised by 'by' levels */ public void increaseAttribute(EAttributeGroup A, int by = 1) { if (canLevelUp(A, by)) { attributeGroups[A] += by; } else throw new InvalidAttributeLevelException("increaseAttribute"); }
/** * return TRUE, if the given attribute A can be raised by 'by' levels */ public bool canLevelUp(EAttributeGroup A, int by = 1) { return attributeGroups[A] + by <= maxLevel; }
/** * given A, return the current level of A */ public int getAttributeLevel(EAttributeGroup A) { return attributeGroups[A]; }
/** * ATTRIBUTE RELATED */ public int getAttributeValue(EAttributeGroup A) { return attr.getAttributeLevel(A); }