public void SelectWarBand(IWarBand warband) { CurrentWarband = warband; WarbandRoster = new WarBandRoster(CurrentWarband); InvokeEvent(WarBandSelected); }
public void Setup() { _WarbandRoster = new WarBandRoster(new WitchHuntersWarband()); _WarbandRoster.Name = "MordheimDalTests"; //Logic requires to add a new warrior _WitchHunterCaptain = _WarbandRoster.AddWarrior(new WitchHunterCaptain()) as IHero; _WitchHunterCaptain.AddEquipment(new Sword().Name); _WitchHunterCaptain.AddEquipment(new CrossBow().Name); _WitchHunterCaptain.AddEquipment(new Shield().Name); _WitchHunterCaptain.AddEquipment(new LightArmour().Name); _WitchHunterCaptain.AddSkill(new MightyBlow()); _WitchHunterCaptain.AddSkill(new PitFighter()); _ZealotGroup1 = _WarbandRoster.AddWarrior(new Zealot()) as IHenchMen; _ZealotGroup1.AddEquipment(new Sword()); _ZealotGroup1.AddEquipment(new Sword()); _ZealotGroup1.IncreaseGroupByOne(); _ZealotGroup1.IncreaseGroupByOne(); _ZealotGroup2 = _WarbandRoster.AddWarrior(new Zealot()) as IHenchMen; _ZealotGroup2.AddEquipment(new Bow()); _ZealotGroup2.IncreaseGroupByOne(); _ZealotGroup2.IncreaseGroupByOne(); _ZealotGroup2.IncreaseGroupByOne(); _WarriorPriest = _WarbandRoster.AddWarrior(new WarriorPriest()) as WarriorPriest; _WarriorPriest.AddSpell(new HeartsOfSteel()); _WarriorPriest.AddSpell(new TheHammerOfSigmar()); }
public PlayLogic(IWarbandRoster warbandRoster) { if (warbandRoster == null) { throw new ArgumentNullException("The warband roster is null"); } _WarbandRoster = warbandRoster; }
public static XmlHeadNode ToXml(this IWarbandRoster roster) { XmlHeadNode xmlHeadNode = new XmlHeadNode(); xmlHeadNode.WarbandRoster.Name = roster.Name; xmlHeadNode.WarbandRoster.Warband = roster.WarBand.WarBandName; return(xmlHeadNode); }
public void Save(IWarbandRoster roster, string specificFileName) { if (roster == null) { throw new ArgumentNullException("The IWarbandRoster is null"); } XmlHeadNode xmlHeadNode = roster.ToXml(); foreach (IWarrior warrior in roster.Warriors) { xmlHeadNode.WarbandRoster.WarriorList.Add(warrior.ToXml()); } SaveXml(specificFileName, xmlHeadNode); }
public IWarbandRoster LoadWarband(string file) { if (!File.Exists(file)) { throw new FileNotFoundException($"Cannot find file {file}"); } XmlHeadNode xmlHeadNode = XMLUtils.Load <XmlHeadNode>(file); BuilderLogicFactory.Instance.SelectWarBand(xmlHeadNode.WarbandRoster.Warband); IWarbandRoster warbandRoster = BuilderLogicFactory.Instance.WarbandRoster; foreach (var xmlWarrior in xmlHeadNode.WarbandRoster.WarriorList) { IWarrior warrior = warbandRoster.FromXml(xmlWarrior); } return(warbandRoster); }
public void Save(IWarbandRoster roster) { if (roster == null) { throw new ArgumentNullException("The IWarbandRoster is null"); } string rosterName = roster.Name; string filename = BuildFileNameAndCreateStoragerDirectory(rosterName); XmlHeadNode xmlHeadNode = new XmlHeadNode(); xmlHeadNode.WarbandRoster.Name = rosterName; xmlHeadNode.WarbandRoster.Warband = roster.WarBand.WarBandName; foreach (IWarrior warrior in roster.Warriors) { xmlHeadNode.WarbandRoster.WarriorList.Add(warrior.ToXml()); } XMLUtils.AtomicSave <XmlHeadNode>(xmlHeadNode, Path.Combine(STORAGE_PATH, filename)); }
public static IWarrior FromXml(this IWarbandRoster warbandRoster, XmlWarrior xmlWarrior) { IWarrior warrior = warbandRoster.WarBand.GetWarrior(xmlWarrior.TypeOfWarrior); warrior = warbandRoster.AddWarrior(warrior); foreach (string item in xmlWarrior.EquipmentList) { warrior.AddEquipment(item); } if (warrior is IHenchMen) { IHenchMen henchMan = warrior as IHenchMen; for (int i = 1; i < xmlWarrior.AmountInGroup; i++) { henchMan.IncreaseGroupByOne(); } } else if (warrior is IHero) { IHero hero = warrior as IHero; foreach (string skill in xmlWarrior.SkillList) { hero.AddSkill(skill); } } if (warrior is IWizard) { IWizard wizard = warrior as IWizard; foreach (string item in xmlWarrior.SpellList) { wizard.AddSpell(item); } } return(warrior); }