/// <summary> /// This should be called after any postback and/or before any save. due to how we can delete mid-row /// in the UI, properties are only soft-deleted and need to be physically removed here. /// </summary> public void CleanDeletedAndEmptyProperties() { StringStats?.RemoveAll(x => x == null || x.Deleted || string.IsNullOrEmpty(x.Value)); IntStats?.RemoveAll(x => x == null || x.Deleted); Int64Stats?.RemoveAll(x => x == null || x.Deleted); FloatStats?.RemoveAll(x => x == null || x.Deleted); BoolStats?.RemoveAll(x => x == null || x.Deleted); DidStats?.RemoveAll(x => x == null || x.Deleted); Spells?.RemoveAll(x => x == null || x.Deleted); Book?.Pages?.RemoveAll(x => x == null || x.Deleted); Positions?.RemoveAll(x => x == null || x.Deleted); EmoteTable?.ForEach(es => es?.Emotes?.ForEach(esa => esa?.Actions?.RemoveAll(x => x == null || x.Deleted))); EmoteTable?.ForEach(es => es?.Emotes?.RemoveAll(x => x == null || x.Deleted)); EmoteTable?.RemoveAll(x => x == null || x.Deleted || x.Emotes?.Count < 1); Body?.BodyParts?.RemoveAll(x => x == null || x.Deleted); GeneratorTable?.RemoveAll(x => x == null || x.Deleted); CreateList?.RemoveAll(x => x == null || x.Deleted); Skills?.RemoveAll(x => x == null || x.Deleted); // this property's existence causes all sorts of problems. needs to go away. IntStats?.RemoveAll(x => x.Key == 9007); if (!HasAbilities) { Attributes = null; } }
public void Write(TProtocol oprot) { TStruct struc = new TStruct("ColumnStatisticsData"); oprot.WriteStructBegin(struc); TField field = new TField(); if (BooleanStats != null && __isset.booleanStats) { field.Name = "booleanStats"; field.Type = TType.Struct; field.ID = 1; oprot.WriteFieldBegin(field); BooleanStats.Write(oprot); oprot.WriteFieldEnd(); } if (LongStats != null && __isset.longStats) { field.Name = "longStats"; field.Type = TType.Struct; field.ID = 2; oprot.WriteFieldBegin(field); LongStats.Write(oprot); oprot.WriteFieldEnd(); } if (DoubleStats != null && __isset.doubleStats) { field.Name = "doubleStats"; field.Type = TType.Struct; field.ID = 3; oprot.WriteFieldBegin(field); DoubleStats.Write(oprot); oprot.WriteFieldEnd(); } if (StringStats != null && __isset.stringStats) { field.Name = "stringStats"; field.Type = TType.Struct; field.ID = 4; oprot.WriteFieldBegin(field); StringStats.Write(oprot); oprot.WriteFieldEnd(); } if (BinaryStats != null && __isset.binaryStats) { field.Name = "binaryStats"; field.Type = TType.Struct; field.ID = 5; oprot.WriteFieldBegin(field); BinaryStats.Write(oprot); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); }
public static void Main() { //checks if it's a palindrom System.Console.WriteLine("Please enter a string with 10 digits"); string input = ""; do // a loop until the user gives a valid string { try { input = System.Console.ReadLine(); if (input.Length != 10 || !StringStats.isValidInput(input)) { throw new System.Exception("The input is not valid"); } } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } } while (input.Length != 10 || !StringStats.isValidInput(input)); if (StringStats.isPalindrom(input)) //checks if the string is a palindrom { System.Console.WriteLine("The string is a palindrom"); } else { System.Console.WriteLine("The string isn't a palindrom"); } long num = 0; if (long.TryParse(input, out num)) { System.Console.WriteLine("The mean is {0}", StringStats.digitsMean(num)); } else { System.Console.WriteLine("The number of uppercase letters is {0}", StringStats.numOfUpperCase(input)); } //keeps the console open until the user presses a key System.Console.ReadLine(); }
public override string ToString() { StringBuilder sb = new StringBuilder("ColumnStatisticsData("); sb.Append("BooleanStats: "); sb.Append(BooleanStats == null ? "<null>" : BooleanStats.ToString()); sb.Append(",LongStats: "); sb.Append(LongStats == null ? "<null>" : LongStats.ToString()); sb.Append(",DoubleStats: "); sb.Append(DoubleStats == null ? "<null>" : DoubleStats.ToString()); sb.Append(",StringStats: "); sb.Append(StringStats == null ? "<null>" : StringStats.ToString()); sb.Append(",BinaryStats: "); sb.Append(BinaryStats == null ? "<null>" : BinaryStats.ToString()); sb.Append(")"); return(sb.ToString()); }
public Weenie.Weenie ConvertToWeenie(out List <string> messages) { messages = new List <string>(); Weenie.Weenie w = new Weenie.Weenie { DataObjectId = WeenieId, WeenieClassId = WeenieId }; w.IntProperties.Add(new Shared.IntProperty() { IntPropertyId = (int)IntPropertyId.WeenieType, Value = WeenieTypeId }); IntStats.ForEach(stat => { w.IntProperties.Add(new Shared.IntProperty() { IntPropertyId = stat.Key, Value = stat.Value }); }); Int64Stats?.ForEach(stat => { w.Int64Properties.Add(new Shared.Int64Property() { Int64PropertyId = stat.Key, Value = stat.Value }); }); FloatStats?.ForEach(stat => { w.DoubleProperties.Add(new Shared.DoubleProperty() { DoublePropertyId = stat.Key, Value = stat.Value }); }); DidStats?.ForEach(stat => { w.DidProperties.Add(new Shared.DataIdProperty() { DataIdPropertyId = stat.Key, Value = stat.Value }); }); BoolStats?.ForEach(stat => { w.BoolProperties.Add(new Shared.BoolProperty() { BoolPropertyId = stat.Key, Value = stat.BoolValue }); }); StringStats?.ForEach(stat => { w.StringProperties.Add(new Shared.StringProperty() { StringPropertyId = stat.Key, Value = stat.Value }); }); Book?.Pages.ForEach(page => { w.BookProperties.Add(new Shared.BookPage() { AuthorAccount = page.AuthorAccount, AuthorId = page.AuthorId, AuthorName = page.AuthorName, IgnoreAuthor = page.IgnoreAuthor ?? false, Page = 1 + (uint)Book.Pages.IndexOf(page), PageText = page.PageText }); }); Skills?.ForEach(skill => { w.Skills.Add(new Shared.Skill() { SkillId = skill.SkillId, Ranks = skill.Skill.Ranks, ExperienceSpent = skill.Skill.XpInvested, Status = skill.Skill.TrainedLevel, BaseValue = 0 }); }); Spells?.ForEach(spell => { w.Spells.Add(new Shared.Spell() { SpellId = spell.SpellId, Probability = spell.Stats.CastingChance }); }); Positions?.ForEach(position => { w.Positions.Add(new Shared.Position() { X = position.Position.Frame.Position.X, Y = position.Position.Frame.Position.Y, Z = position.Position.Frame.Position.Z, QW = position.Position.Frame.Rotations.W, QX = position.Position.Frame.Rotations.X, QY = position.Position.Frame.Rotations.Y, QZ = position.Position.Frame.Rotations.Z, Landblock = position.Position.LandCellId, PositionType = position.PositionType }); }); GeneratorTable?.ForEach(entry => { Shared.GeneratorTable gt = new Shared.GeneratorTable { Frame = new Shared.Frame() }; gt.Frame.Origin = new Shared.Origin(); gt.Frame.Angles = new Shared.Angles(); PropertyCopier <GeneratorTable, Shared.GeneratorTable> .Copy(entry, gt); gt.Frame.Angles.W = entry.Frame.Rotations.W; gt.Frame.Angles.X = entry.Frame.Rotations.X; gt.Frame.Angles.Y = entry.Frame.Rotations.Y; gt.Frame.Angles.Z = entry.Frame.Rotations.Z; gt.Frame.Origin.X = entry.Frame.Position.X; gt.Frame.Origin.Y = entry.Frame.Position.Y; gt.Frame.Origin.Z = entry.Frame.Position.Z; w.GeneratorTable.Add(gt); }); uint emoteSetCounter = 0; if (EmoteTable != null) { emoteSetCounter = (uint)EmoteTable?.Count; } uint emoteCounter = 0; uint holdCategory = 0; EmoteTable?.ForEach(category => { if (category.EmoteCategoryId != holdCategory) { holdCategory = (uint)category.EmoteCategoryId; if (holdCategory != 0) { emoteSetCounter--; } } category.Emotes.ForEach(e => { var es = new Shared.EmoteSet() { EmoteSetGuid = Guid.NewGuid(), ClassId = e.ClassId, EmoteCategoryId = e.Category, MaxHealth = e.MaxHealth, MinHealth = e.MinHealth, Probability = e.Probability, Quest = e.Quest, Style = e.Style, SubStyle = e.SubStyle, SortOrder = emoteSetCounter, VendorType = e.VendorType }; emoteCounter = 0; e.Emotes.ForEach(ea => { es.Emotes.Add(new Shared.Emote() { Amount = ea.Amount, Amount64 = ea.Amount64, CreationProfile = ea?.Item?.Convert(), Delay = ea.Delay ?? 0f, Deleted = false, Display = ea.Display, EmoteTypeId = ea.EmoteActionType, EmoteGuid = Guid.NewGuid(), EmoteSetGuid = es.EmoteSetGuid, Extent = ea.Extent ?? 0f, HeroXp64 = ea.HeroXp64, Maximum = ea.Max, Maximum64 = ea.Maximum64, MaximumFloat = ea.FMax, Message = ea.Message, Minimum = ea.Min, Minimum64 = ea.Minimum64, MinimumFloat = ea.FMin, Motion = (MotionCommand?)ea.Motion, Percent = ea.Percent, PhysicsScript = (PhysicsScriptType?)ea.PScript, PositionLandBlockId = null, // no source PositionX = ea.Frame?.Position.X, PositionY = ea.Frame?.Position.Y, PositionZ = ea.Frame?.Position.Z, RotationW = ea.Frame?.Rotations.W, RotationX = ea.Frame?.Rotations.X, RotationY = ea.Frame?.Rotations.Y, RotationZ = ea.Frame?.Rotations.Z, Sound = ea.Sound, SpellId = ea.SpellId, Stat = ea.Stat, TestString = ea.TestString, TreasureClass = (TreasureClass?)ea.TreasureClass, TreasureType = (uint?)ea.TreasureType, SortOrder = emoteCounter, WealthRating = (WealthRating?)ea.WealthRating }); emoteCounter++; }); w.EmoteTable.Add(es); }); }); CreateList?.ForEach(ci => { w.CreateList.Add(ci.Convert()); }); if (w.HasAbilities) { w.Abilities.Strength = Attributes.Strength.Convert(AbilityId.Strength); w.Abilities.Endurance = Attributes.Endurance.Convert(AbilityId.Endurance); w.Abilities.Coordination = Attributes.Coordination.Convert(AbilityId.Coordination); w.Abilities.Quickness = Attributes.Quickness.Convert(AbilityId.Quickness); w.Abilities.Focus = Attributes.Focus.Convert(AbilityId.Focus); w.Abilities.Self = Attributes.Self.Convert(AbilityId.Self); w.Vitals.Health = Attributes.Health.Convert(AbilityId.Health); w.Vitals.Stamina = Attributes.Stamina.Convert(AbilityId.Stamina); w.Vitals.Mana = Attributes.Mana.Convert(AbilityId.Mana); } Body?.BodyParts?.ForEach(bp => { var part = new Shared.BodyPart() { BodyHeight = bp.BodyPart.BH, BodyPartType = (BodyPartType)bp.Key, Damage = bp.BodyPart.DVal, DamageType = (DamageType)bp.BodyPart.DType, DamageVariance = bp.BodyPart.DVar }; if (bp.BodyPart.ArmorValues != null) { part.ArmorValues.Base = bp.BodyPart.ArmorValues.BaseArmor; part.ArmorValues.Acid = bp.BodyPart.ArmorValues.ArmorVsAcid; part.ArmorValues.Bludgeon = bp.BodyPart.ArmorValues.ArmorVsBludgeon; part.ArmorValues.Cold = bp.BodyPart.ArmorValues.ArmorVsCold; part.ArmorValues.Electric = bp.BodyPart.ArmorValues.ArmorVsElectric; part.ArmorValues.Fire = bp.BodyPart.ArmorValues.ArmorVsFire; part.ArmorValues.Nether = bp.BodyPart.ArmorValues.ArmorVsNether; part.ArmorValues.Pierce = bp.BodyPart.ArmorValues.ArmorVsPierce; part.ArmorValues.Slash = bp.BodyPart.ArmorValues.ArmorVsSlash; } if (bp.BodyPart.SD != null) { part.TargetingData.HighLeftBack = bp.BodyPart.SD.HLB; part.TargetingData.HighLeftFront = bp.BodyPart.SD.HLF; part.TargetingData.HighRightBack = bp.BodyPart.SD.HRB; part.TargetingData.HighRightFront = bp.BodyPart.SD.HRF; part.TargetingData.LowLeftBack = bp.BodyPart.SD.LLB; part.TargetingData.LowLeftFront = bp.BodyPart.SD.LLF; part.TargetingData.LowRightBack = bp.BodyPart.SD.LRB; part.TargetingData.LowRightFront = bp.BodyPart.SD.LRF; part.TargetingData.MidLeftBack = bp.BodyPart.SD.MLB; part.TargetingData.MidLeftFront = bp.BodyPart.SD.MLF; part.TargetingData.MidRightBack = bp.BodyPart.SD.MRB; part.TargetingData.MidRightFront = bp.BodyPart.SD.MRF; } w.BodyParts.Add(part); }); return(w); }
public string ResolveStringToSlot(string str) { if (stringSlots == null) { // String slots are only used as object fields stringSlots = new SlotAllocation<string>(env.DebugMode, NameFlavor.Identifier, FriendlyStringName); // Collect statistincs on string literals var stringStats = new StringStats(); stringStats.Collect(env.Global, assemblyDef, typeDef); // Setup slots for shared strings foreach (var kv in stringStats) { if (kv.Value == StringBindScope.Type) stringSlots.Add(kv.Key); } } return stringSlots.HasSlot(str) ? stringSlots.For(ctxt, str) : null; }