示例#1
0
 public Character()
 {
     //this.ReferenceInfo = new List<Level>();
     this.sheet = new Sheet();
     this.AbilityScores = new AbilityScores(this.Sheet.Stats);
     this.Defenses = new Defenses(this.Sheet.Stats);
     this.Skills = new Skills(this.Sheet.Stats);
 }
示例#2
0
        private void UpdateCharacter(Sheet sheet)
        {
            this.sheet = sheet;
            if (sheet == null) {
                return;
            }

            this.AbilityScores = new AbilityScores(this.sheet.Stats);
            this.Defenses = new Defenses(this.sheet.Stats);
            this.Skills = new Skills(this.Sheet.Stats);

            // fixup links
            foreach (var stat in this.sheet.Stats) {
                foreach (var mod in stat.Modifiers) {
                    if (String.IsNullOrWhiteSpace(mod.StatLink)) {
                        continue;
                    }

                    mod.Link = this.sheet.Stats[mod.StatLink];
                }
            }

            // fixup rules
            // first, add all the item rules
            var weaponRules = (from i in this.sheet.Items
                               from r in i.Rules
                               select r).Distinct();
            var union = this.sheet.Rules.Union(weaponRules);
            Rules rules = new Rules();
            foreach (var rule in union) {
                rules.Add(rule);
            }
            this.sheet.Rules = rules;

            // next, expand all the weapon rules on powers
            foreach (var power in this.sheet.Powers) {
                foreach (var weapon in power.Weapons) {
                    var ids = (from r in weapon.Rules
                               select r.InternalId).ToArray();
                    weapon.Rules.Clear();
                    foreach (var id in ids) {
                        weapon.Rules.Add(this.sheet.Rules[id]);
                    }
                }
            }
        }