Beispiel #1
0
        public static bool UseSpell(DMEnv env, Investigator inv, string name)
        {
            Scenario sce = env.Sce;

            if (!inv.Spells.Contains(name))
            {
                env.Append(inv.Name + "还没学会" + name);
                return(false);
            }
            else if (!sce.Spells.TryGetValue(name, out Spell spell))
            {
                env.Append("不存在法术:" + name);
                return(false);
            }
            else if (!spell.Use(inv, out string reply))
            {
                env.Append("施法失败\n" + reply);
                return(false);
            }
            else
            {
                env.Save();
                env.Append(inv.Name + "使用了" + name + (inv.Is("HIDE_VALUE") ? "" : reply));
                return(true);
            }
        }
 public static string GenResultStr(Investigator inv, CheckResult result, bool showTypeString)
 {
     return
         ((inv.Is("HIDE_VALUE") ? "(???)" : $"({result.target}/{result.value})") +
          $" => {result.points}" +
          (showTypeString ? $",{result.ActualTypeString}" : ""));
 }
Beispiel #3
0
        public static void OrderByValue(DMEnv env, Scenario scenario, string[] invNames, string valueName)
        {
            IList <string> notFoundNames        = new List <string>();
            IList <string> notFoundValues       = new List <string>();
            IDictionary <Investigator, int> map = new Dictionary <Investigator, int>();

            foreach (string name in invNames)
            {
                Match  m       = Regex.Match(name, @"[+-]\d+$");
                int    fix     = 0;
                string invName = name;
                if (m.Success)
                {
                    invName = name.Substring(0, name.Length - m.Value.Length);
                    fix     = int.Parse(m.Value);
                }
                if (scenario.TryGetInvestigator(invName, out Investigator inv))
                {
                    if (inv.Values.TryGet(valueName, out Value value))
                    {
                        map[inv] = value.Val + fix;
                    }
                    else
                    {
                        notFoundValues.Add(invName);
                    }
                }
                else
                {
                    notFoundNames.Add(invName);
                }
            }

            if (map.Count > 0)
            {
                List <Investigator> list = new List <Investigator>(map.Keys);
                list.Sort((a, b) => map[b] - map[a]);
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        env.Append(" > ");
                    }
                    Investigator inv = list[i];
                    env.Append(inv.Name).Append('(').Append(inv.Is("HIDE_VALUE") ? "???" : Convert.ToString(map[inv])).Append(')');
                }
            }
            if (notFoundNames.Count > 0)
            {
                env.LineAppend("未找到调查员:").Append(string.Join("、", notFoundNames));
            }
            if (notFoundValues.Count > 0)
            {
                env.LineAppend($"未找到带{valueName}调查员:").Append(string.Join("、", notFoundValues));
            }
        }