// [Fact] public void CharacterSerializedConstructorTest() { var serializedCharacter = new SerializableCharacter { Name = "Name", Experience = 50, AspectMalus = new List<Aspect> {Aspect.Arcane, Aspect.Feu}, AspectBonus = new List<Aspect> {Aspect.Acier, Aspect.Eau}, }; var character = new Character(serializedCharacter, talentsManager,classManager: new MockClassManager()); Assert.Equal("Name", character.Name); Assert.Equal(200, character.ExperienceAvailable); Assert.Equal(220, character.ExperienceRemaining); Assert.Equal(180, character.ExperienceUsed); }
public Character( SerializableCharacter serializableCharacter, ITalentsManager manager, IRacesManager racesManager = null, IClassManager classManager = null ) : this(serializableCharacter.Name, manager) { if (racesManager == null) racesManager = RacesManager.Instance; if (classManager == null) classManager = ClassManager.Instance; if (serializableCharacter.Talents != null) { foreach (var item in serializableCharacter.Talents) { try { Talent talent = GetTalent(item.id); if (item.bonus) { talent.Increment(item.level - 1); } else { talent.Increment(item.level); } talent.HaveBonus = item.bonus; talent.SpeLevel = item.speLevel; } catch { continue; } } } _aspectBonus = serializableCharacter.AspectBonus; _aspectMalus = serializableCharacter.AspectMalus; _race = racesManager.GetRace(serializableCharacter.Race); if (serializableCharacter.Classe != null && !serializableCharacter.Classe.Equals("")) classeChar = classManager.getFormName(serializableCharacter.Classe); else classeChar = null; ExperienceAvailable = serializableCharacter.Experience; Inventaire = serializableCharacter.Inventaire; if (_race != null) _bonusAspect = _race.AspectBonus; penPoid = serializableCharacter.penPoid; inventory = serializableCharacter.Inventory ?? new Inventory(); RecomputePA(); }
public Character(SerializableCharacter serializableCharacter) : this(serializableCharacter, TalentsManager.Instance) { }