/// <summary> /// Find the actual cross reference of a user attribute. /// </summary> private static void ProcessUserAttribute(MushEntryAttribute mea, ref TinyMushObjectAttribute attr) { if (!Universe.Attributes.ContainsKey(mea.Id)) { attr = null; return; } string tempAttrName = Universe.Attributes[ mea.Id ].Text; if (!tempAttrName.Contains(":")) { attr = null; return; } // Set flags for attribute var header = ParseAttributeHeader(tempAttrName); if (header == null) { attr = null; return; } AttributeFlags.SetFlags(header.Item1, attr); attr.Name = header.Item2; }
/// <summary> /// Parse out the default name of the attribute if it's already defined in /// <see cref="ObjectGameBaseAttributeValues"/> or parse it out cross referencing /// with data in <see cref="Universe"/>. Also grab the flags and textual information. /// </summary> private static TinyMushObjectAttribute MakeAttribute(MushEntryAttribute mea, long owner) { var attr = new TinyMushObjectAttribute(); if (Enum.IsDefined(typeof (ObjectGameBaseAttributeValues), (ObjectGameBaseAttributeValues) mea.Id)) { // Dealing with stock game attribute attr.Name = Enum.ToObject(typeof (ObjectGameBaseAttributeValues), mea.Id).ToString(); } else { ProcessUserAttribute(mea, ref attr); if (attr == null) { return null; } } attr.Id = mea.Id; if (mea.Text[ 0 ] != Marker) { attr.Text = mea.Text; attr.Owner = owner; return attr; } ProcessComplexUserAttribute(mea, owner, ref attr); return attr; }
/// <summary> /// Break apart the text of an attribute if needed and convert /// the owners and flags. /// </summary> private static void ProcessComplexUserAttribute( MushEntryAttribute mea, long owner, ref TinyMushObjectAttribute attr) { string temp = mea.Text.Substring(1); var p = ObjectDataParsers.AttributeParser().TryParse(temp); if (!p.WasSuccessful) { attr = null; return; } var t = p.Value; attr.Owner = owner; if (t.Item1 != "") { long own; bool didOwn = long.TryParse(t.Item1, out own); if (didOwn) { attr.Owner = own; } } if (t.Item2 != "") { long flags; bool didFlags = long.TryParse(t.Item2, out flags); if (didFlags) { AttributeFlags.SetFlags(flags, attr); } } if (t.Item3 == "") { return; } attr.Text = t.Item3; }