internal static CritChances GetCritChances(VLoadout loadout) { var perks = loadout.Perks; var stats = loadout.Stats; var critChances = new CritChances(); if (stats.CriticalChance <= 0) { critChances.RegularChance = 1.0; } else { var remainingChance = 1.0; var blackCritChance = stats.HasBlackCrits ? stats.CriticalChance / 300.0 : 0; blackCritChance = blackCritChance > 1 ? 1 : blackCritChance; critChances.BlackChance = blackCritChance; remainingChance -= blackCritChance; var redCritChance = stats.HasRedCrits ? remainingChance * stats.CriticalChance / 200 : 0; redCritChance = redCritChance > remainingChance ? remainingChance : redCritChance; critChances.RedChance = redCritChance; remainingChance -= redCritChance; var yellowCritChance = remainingChance * stats.CriticalChance / 100; yellowCritChance = yellowCritChance > remainingChance ? remainingChance : yellowCritChance; critChances.YellowChance = yellowCritChance; remainingChance -= yellowCritChance; critChances.RegularChance = remainingChance; } ErrorReporter.ReportDebug("your crit calculations need to equal 100", () => System.Math.Round(critChances.RegularChance + critChances.YellowChance + critChances.RedChance + critChances.BlackChance, 6) != 1); return(critChances); }
public override IDisposable ApplyPassiveEffect(VLoadout loadout) { ErrorReporter.ReportDebug("OrbOrbiter passive effect is being applied, but OrbOrbiter is not the current unit", () => loadout.CurrentUnit.UnitData.Type != Type); var stacks = loadout.CurrentUnit.CurrentKills / 2000; for (var i = 1; i <= stacks; i++) { loadout.Stats.UpdateAttackSpeed($"OrbOrbiterOrbEssence{i}", 20); loadout.Stats.Attack += 40; loadout.Stats.AdditiveArmor += 40; loadout.Stats.UpdateCooldownSpeed($"OrbOrbiterOrbEssence{i}", 20); } return(new DisposableAction( () => { ErrorReporter.ReportDebug("OrbOrbiter passive effect is being removed, but OrbOrbiter is not the current unit", () => loadout.CurrentUnit.UnitData.Type != Type); for (var i = 1; i <= stacks; i++) { loadout.Stats.UpdateAttackSpeed($"OrbOrbiterOrbEssence{i}", -20); loadout.Stats.Attack -= 40; loadout.Stats.AdditiveArmor -= 40; loadout.Stats.UpdateCooldownSpeed($"OrbOrbiterOrbEssence{i}", -20); } })); }
public static void Delete <T>(string fileName) where T : BusinessObject { var path = DirectoryManager.GetFullPathWithExtension <T>(fileName); if (File.Exists(path)) { File.Delete(path); return; } ErrorReporter.ReportDebug($"filename {fileName} couldn't be found and wasn't deleted. Investigate and Fix."); }
public static VLoadout SetSpec(this VLoadout loadout, UnitType spec, int specLevel = 10, bool hasAllSpec = false) { loadout.UnitSpec = spec; loadout.Perks.UnitSpecialization.DesiredLevel = (short)specLevel; if (hasAllSpec) { ErrorReporter.ReportDebug("spec level must be 10 if you want all spec", () => specLevel != 10); loadout.Perks.UpgradeCache.DesiredLevel = 1; } return(loadout); }
public static Room New(RoomNumber number) { var roomType = Type.GetType($"VBusiness.Rooms.{number}"); if (roomType == null) { ErrorReporter.ReportDebug($"Please create a class named VBusiness.Rooms.Room{number}"); return(null); } var ret = (Room)Activator.CreateInstance(roomType); return(ret); }
void AddMultiplesToDictionary(string key, double value, int quantity) { if (!MultipleKeyDict.ContainsKey(key)) { MultipleKeyDict.Add(key, 0); } for (var i = 0; i < quantity; i++) { MultipleKeyDict[key]++; var mainDictKey = key + MultipleKeyDict[key]; ErrorReporter.ReportDebug(ContainsKey(mainDictKey), $"This Key should be free. Key:{mainDictKey}"); Update(mainDictKey, value); } }
public static VDifficulty New(DifficultyLevel level) { if (level == DifficultyLevel.None) { return(new EmptyDifficulty()); } var diffType = Type.GetType($"VBusiness.Difficulties.{level.AsString(EnumFormat.Name)}"); if (diffType == null) { ErrorReporter.ReportDebug($"Please create a class named VBusiness.Difficulties.{level.AsString(EnumFormat.Name)}"); return(new EmptyDifficulty()); } var diff = (VDifficulty)Activator.CreateInstance(diffType); return(diff); }
public static VUnitRank New(UnitRankType rank) { if (rank == UnitRankType.None) { return(new EmptyRank()); } var rankName = "Rank" + rank.AsString(EnumFormat.Name); var rankType = System.Type.GetType($"VBusiness.Ranks.{rankName}"); if (rankType == null) { ErrorReporter.ReportDebug($"Please create a class named VBusiness.Ranks.{rankName}"); return(new EmptyRank()); } var ret = (UnitRank)Activator.CreateInstance(rankType); return(ret); }
public static Soul New(SoulType type, VLoadoutSouls collection) { if (type == SoulType.None) { return(new EmptySoul()); } var soulName = type.AsString(EnumFormat.Name) + "Soul"; var soulType = System.Type.GetType($"VBusiness.Souls.{soulName}"); if (soulType == null) { ErrorReporter.ReportDebug($"Please create a class named VBusiness.Souls.{soulName}"); return(new EmptySoul()); } var soul = (Soul)Activator.CreateInstance(soulType, collection); return(soul); }
void PopulateChild(BusinessObject bizo, XmlNode childNode) { var matchingProperty = GetPropertyFromXML(bizo.GetType(), childNode); if (matchingProperty == null && ShouldReportError(bizo, childNode)) { ErrorReporter.ReportDebug($"Cannot find property {childNode.Name} on {bizo.GetType().Name} Business Object"); } if (matchingProperty != null) { if (matchingProperty.IsBusinessObject()) { PopulateBusinessObject(bizo, childNode, matchingProperty); } else { PopulateNonKeyProperty(bizo, childNode, matchingProperty); } } }
void RemoveMulitpleFromDictionary(string key, double value, int quantity) { if (!MultipleKeyDict.ContainsKey(key)) { ErrorReporter.ReportDebug($"Can't remove something that never existed. Key:{key}"); return; } for (var i = 0; i > quantity; i--) { var mainDictKey = key + MultipleKeyDict[key]; ErrorReporter.ReportDebug(MultipleKeyDict[key] == 0, $"Zero Keys shouldn't exist, we shouldn't try to remove them. Key={key}, quantity={quantity}, i={i}"); ErrorReporter.ReportDebug(!ContainsKey(mainDictKey), $"We shouldn't be trying to remove values that don't exist Key={key}, quantity={quantity}, i={i}"); if (ContainsKey(mainDictKey)) { Remove(mainDictKey); MultipleKeyDict[key]--; } } }
public static IEnumerable <EnemyQuantity> TierUp(this IEnumerable <EnemyQuantity> quantities, double tier) { if (tier >= 1.0001) { tier = 1; } ErrorReporter.ReportDebug("This shouldn't be possible unless ZX is released, in which case you need to rework what the max tier is for different difficulties", () => tier > 2.001); foreach (var unit in quantities) { var minTier = (int)Math.Floor(tier); var maxTier = minTier + 1; var minTierChance = maxTier - tier; var maxTierChance = 1 - minTierChance; var newMinUnit = unit; if (!(unit.Type.IsBoss() || unit.Type.IsBuilding() || unit.Type == VEntityFramework.Model.EnemyType.None)) { newMinUnit.Type += minTier; newMinUnit.Quantity *= minTierChance; yield return(newMinUnit); if (maxTierChance > 0) { var newMaxUnit = unit; newMaxUnit.Type += maxTier; newMaxUnit.Quantity *= maxTierChance; yield return(newMaxUnit); } } else { yield return(newMinUnit); } } }