public int GetAffinity(string aspect) { // validate the aspect if (!_aspectGlossary.Contains(aspect)) { throw InvalidAspectException.FromAspect(aspect); } if (_affinities.ContainsKey(aspect)) { return(_affinities[aspect]); } // If an aspect is not represented, we consider it to have an affinity // of 0, i.e. no positive or negative relation. return(0); }
public void SetAffinity(string aspect, int val) { // validate the aspect if (!_aspectGlossary.Contains(aspect)) { throw InvalidAspectException.FromAspect(aspect); } // bound the affinity value int boundedVal = val; if (val > MaxAffinity) { boundedVal = MaxAffinity; } else if (val < MinAffinity) { boundedVal = MinAffinity; } // TODO: handle opposed and related aspects, etc. _affinities[aspect] = boundedVal; }