public ItemWithAttributesInfo GetAttributesInfo() { var info = new ItemWithAttributesInfo { Name = this.ActionName }; var result = new List <NameValueInfo> { new NameValueInfo { Name = "CompareStatisticName", Value = this.CompareStatisticName }, new NameValueInfo { Name = "CompareValue", Value = this.CompareValue.ToString(CultureInfo.InvariantCulture) }, new NameValueInfo { Name = "TargetStatisticName", Value = this.TargetStatisticName }, new NameValueInfo { Name = "ChangeValue", Value = this.ChangeValue.ToString(CultureInfo.InvariantCulture) } }; info.Attributes = result; return(info); }
public ItemWithAttributesInfo GetAttributesInfo() { var item = new ItemWithAttributesInfo { Name = this.RequirementName }; item.ChildItems.Add(this.LeftBuildItemRequirement.GetAttributesInfo()); item.ChildItems.Add(this.RightBuildItemRequirement.GetAttributesInfo()); return(item); }
public ItemWithAttributesInfo GetAttributesInfo() { var item = new ItemWithAttributesInfo { Name = this.RequirementName, Attributes = new List <NameValueInfo> { new NameValueInfo { Name = "RequiredValue", Value = this.RequiredValue.ToString(CultureInfo.InvariantCulture) } } }; return(item); }
public ItemWithAttributesInfo GetAttributesInfo() { var item = new ItemWithAttributesInfo { Name = this.RequirementName, Attributes = new List <NameValueInfo> { new NameValueInfo { Name = "TargetItemName", Value = this.TargetItemName } } }; return(item); }
public static IBuildItemAction ConstructAction(ItemWithAttributesInfo info) { if (info.Name == ChangeStatisticAction) { string targetStatName = info.Attributes.First(p => p.Name == "TargetStatisticName").Value; int changeValue = Convert.ToInt32(info.Attributes.First(p => p.Name == "ChangeValue").Value); string limitStatisticName = info.Attributes.First(p => p.Name == "LimitStatisticName").Value; var result = new ChangeStatisticAction(targetStatName, changeValue, limitStatisticName); return(result); } if (info.Name == IfStatEqualToValueChangeStatisticAction) { string compareStatisticName = info.Attributes.First(p => p.Name == "CompareStatisticName").Value; int compareValue = Convert.ToInt32(info.Attributes.First(p => p.Name == "CompareValue").Value); string targetStatName = info.Attributes.First(p => p.Name == "TargetStatisticName").Value; int changeValue = Convert.ToInt32(info.Attributes.First(p => p.Name == "ChangeValue").Value); var result = new IfStatEqualToValueChangeStatisticAction(compareStatisticName, compareValue, targetStatName, changeValue); return(result); } if (info.Name == ChangeStatisticByStatisticAction) { string sourceStatisticName = info.Attributes.First(p => p.Name == "SourceStatisticName").Value; string targetStatName = info.Attributes.First(p => p.Name == "TargetStatisticName").Value; var result = new ChangeStatisticByStatisticAction(sourceStatisticName, targetStatName); return(result); } if (info.Name == SetStatisticToValueAction) { string targetStatisticName = info.Attributes.First(p => p.Name == "TargetStatisticName").Value; int targetValue = Convert.ToInt32(info.Attributes.First(p => p.Name == "TargetValue").Value); var result = new SetStatisticToValueAction(targetStatisticName, targetValue); return(result); } throw new ApplicationException(string.Format("Action '{0}' is not supported", info.Name)); }
public ItemWithAttributesInfo GetAttributesInfo() { var item = new ItemWithAttributesInfo { Name = this.RequirementName, Attributes = new List <NameValueInfo> { new NameValueInfo { Name = "LeftStatistic", Value = this.LeftStatistic }, new NameValueInfo { Name = "RightStatistic", Value = this.RightStatistic } } }; return(item); }
public ItemWithAttributesInfo GetAttributesInfo() { var item = new ItemWithAttributesInfo { Name = this.RequirementName, Attributes = new List <NameValueInfo> { new NameValueInfo { Name = "LeftAddition", Value = this.GetStatsList(this.LeftAddition) }, new NameValueInfo { Name = "RightAddition", Value = this.GetStatsList(this.RightAddition) } } }; return(item); }
public ItemWithAttributesInfo GetAttributesInfo() { var info = new ItemWithAttributesInfo { Name = this.ActionName }; var result = new List <NameValueInfo> { new NameValueInfo { Name = "SourceStatisticName", Value = this.SourceStatisticName }, new NameValueInfo { Name = "TargetStatisticName", Value = this.TargetStatisticName } }; info.Attributes = result; return(info); }
public ItemWithAttributesInfo GetAttributesInfo() { var item = new ItemWithAttributesInfo { Name = this.RequirementName, Attributes = new List <NameValueInfo> { new NameValueInfo { Name = "LeftStatName", Value = this.LeftStatName }, new NameValueInfo { Name = "RightStatName", Value = this.RightStatName }, new NameValueInfo { Name = "AdditionValue", Value = this.AdditionValue.ToString(CultureInfo.InvariantCulture) } } }; return(item); }
public static IBuildItemRequirement ConstructRequirement(ItemWithAttributesInfo info) { if (info.Name == CastRequirement) { int requiredValue = info.ReadIntAttribute("RequiredValue").Value; return(new CastRequirement(requiredValue)); } if (info.Name == ItemExistsOrOnBuildingRequirement) { var targetItemName = info.ReadStringAttribute("TargetItemName"); return(new ItemExistsOrOnBuildingRequirement(targetItemName)); } if (info.Name == LarvaRequirement) { int requiredValue = info.ReadIntAttribute("RequiredValue").Value; return(new LarvaRequirement(requiredValue)); } if (info.Name == OrBuildItemRequirement) { var left = info.ChildItems[0]; var right = info.ChildItems[1]; var leftReq = ConstructRequirement(left); var rightReq = ConstructRequirement(right); return(new OrBuildItemRequirement(leftReq, rightReq)); } if (info.Name == StatBiggerOrEqualThenStatRequirement) { var leftStatName = info.ReadStringAttribute("LeftStatName"); var rightStatName = info.ReadStringAttribute("RightStatName"); return(new StatBiggerOrEqualThenStatRequirement(leftStatName, rightStatName)); } if (info.Name == StatBiggerOrEqualThenStatWithAdditionRequirement) { var leftStatName = info.ReadStringAttribute("LeftStatName"); var rightStatName = info.ReadStringAttribute("RightStatName"); int additionValue = info.ReadIntAttribute("AdditionValue").Value; return(new StatBiggerOrEqualThenStatWithAdditionRequirement(leftStatName, rightStatName, additionValue)); } if (info.Name == StatBiggerOrEqualThenValueRequirement) { var targetStatName = info.ReadStringAttribute("TargetStatName"); int value = info.ReadIntAttribute("Value").Value; return(new StatBiggerOrEqualThenValueRequirement(targetStatName, value)); } if (info.Name == StatLessThenStatRequirement) { var leftStatName = info.ReadStringAttribute("LeftStatistic"); var rightStatName = info.ReadStringAttribute("RightStatistic"); return(new StatLessThenStatRequirement(leftStatName, rightStatName)); } if (info.Name == StatLessThenValueRequirement) { var targetStatName = info.ReadStringAttribute("TargetStatName"); int value = info.ReadIntAttribute("Value").Value; return(new StatLessThenValueRequirement(targetStatName, value)); } if (info.Name == StatsAdditionIsBiggerThenStatsAdditionRequirement) { var leftStat = info.ReadStringAttribute("LeftAddition").Split(','); var rightStat = info.ReadStringAttribute("RightAddition").Split(','); return(new StatsAdditionIsBiggerThenStatsAdditionRequirement(leftStat, rightStat)); } throw new ApplicationException(string.Format("Requirement '{0}' is not supported", info.Name)); }