public VerbInfo this[string name] { get { Verbs verb = VerbsUtils.ConvertStringToVerbs(name); return(this[verb]); } }
public VerbDefinitions(string name, System.IO.Stream stream) : base(name, stream) { foreach (Resource.InfoSection section in Sections) { foreach (Resource.InfoLine line in section.Lines) { VerbInfo verb; verb.Verb = VerbsUtils.ConvertStringToVerbs(line.Value); line.TryGetAttribute("cursor", out verb.Cursor); line.TryGetAttribute("up", out verb.UpButton); line.TryGetAttribute("down", out verb.DownButton); line.TryGetAttribute("hover", out verb.HoverButton); line.TryGetAttribute("disable", out verb.DisableButton); verb.Type = VerbType.Normal; string type; if (line.TryGetAttribute("type", out type)) { if (type.Equals("Normal", StringComparison.OrdinalIgnoreCase)) { verb.Type = VerbType.Normal; } else if (type.Equals("Topic", StringComparison.OrdinalIgnoreCase)) { verb.Type = VerbType.Topic; } else if (type.Equals("Inventory", StringComparison.OrdinalIgnoreCase)) { verb.Type = VerbType.Inventory; } else if (type.Equals("RecurringTopic", StringComparison.OrdinalIgnoreCase)) { verb.Type = VerbType.RecurringTopic; } else if (type.Equals("Chat", StringComparison.OrdinalIgnoreCase)) { verb.Type = VerbType.Chat; } else { throw new Resource.InfoResourceException("Unknown verb button type: " + type); } } _verbs.Add(verb.Verb, verb); } } }
public static bool NounHasTopicsLeft(Nouns noun) { List <NounVerbCase> nvcs; if (_nounNvcMap.TryGetValue(noun, out nvcs)) { foreach (NounVerbCase nvc in nvcs) { if (VerbsUtils.IsTopicVerb(nvc.Verb) && evaluateNvcLogic(nvc.Noun, nvc.Verb, nvc.Case)) { return(true); } } } return(false); }
public LocalizedStrings(string name, System.IO.Stream stream) : base(name, stream) { string[] lines = Text.Split('\n'); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } int equalPos = line.IndexOf("="); if (equalPos >= 0 && equalPos < line.Length - 1) { string left = line.Substring(0, equalPos); string right = line.Substring(equalPos + 1); if (left.IndexOf("//") >= 0 || left.IndexOf("[") >= 0) { continue; } if (left.StartsWith("V_", StringComparison.OrdinalIgnoreCase)) { Verbs v = VerbsUtils.ConvertStringToVerbs(left.Substring(2).Trim()); if (v != Verbs.V_NONE) // not sure why, but estrings.txt seems to have some extra verbs in it? { _verbs.Add(v, right.Trim()); } } else { _common.Add(left.Trim(), right.Trim()); } } } }
public NvcResource(string name, System.IO.Stream stream) : base(name, stream) { // load the Logic aliases foreach (Resource.InfoSection section in _sections) { if (section.Name.Equals("Logic", StringComparison.OrdinalIgnoreCase)) { foreach (Resource.InfoLine line in section.Lines) { _logic.Add(new KeyValuePair <string, string>(line.Attributes[0].Key, line.Attributes[0].Value.Replace("{", "").Replace("}", ""))); } } } foreach (Resource.InfoLine line in GlobalSection.Lines) { NounVerbCase nvc; nvc.Noun = NounUtils.ConvertStringToNoun(line.Value); nvc.Verb = VerbsUtils.ConvertStringToVerbs(line.Attributes[0].Key); nvc.Case = line.Attributes[1].Key; nvc.CaseType = CaseUtils.ConvertStringToCase(line.Attributes[1].Key); string approach; if (line.TryGetAttribute("approach", out approach)) { if (approach.ToUpper() == "WALKTO") { nvc.Approach = NvcApproachType.WalkTo; } else if (approach.ToUpper() == "TURNTOMODEL") { nvc.Approach = NvcApproachType.TurnToModel; } else { nvc.Approach = NvcApproachType.None; } } else { nvc.Approach = NvcApproachType.None; } line.TryGetAttribute("target", out nvc.Target); line.TryGetAttribute("script", out nvc.Script); // remove any { } around the script // (normally they wouldn't mess anything up, but there are a few // that have no ; at the end, and those will mess up) int firstBracket = nvc.Script.IndexOf("{"); int lastBracket = nvc.Script.LastIndexOf("}"); if (firstBracket >= 0 && lastBracket >= 0) { nvc.Script = nvc.Script.Substring(firstBracket + 1, lastBracket - firstBracket - 1); } else if (firstBracket >= 0) { nvc.Script = nvc.Script.Substring(firstBracket + 1); } else if (lastBracket >= 0) { nvc.Script = nvc.Script.Substring(0, lastBracket); } add(nvc); } }
public static int GetTopicCount(string noun, string verb) { return(GetTopicCount(NounUtils.ConvertStringToNoun(noun), VerbsUtils.ConvertStringToVerbs(verb))); }
public static void SetNounVerbCount(string noun, string verb, bool isGabe, int count) { _nounVerbCounts[new NounVerbCombination(NounUtils.ConvertStringToNoun(noun), VerbsUtils.ConvertStringToVerbs(verb), isGabe)] = count; }