Ejemplo n.º 1
0
        public static bool ChangeVal(DMEnv env, Scenario scenario, Investigator inv, string valueName, Dice increment, bool posotive)
        {
            int inc = increment.Roll() * (posotive ? 1 : -1);

            env.Append(inv.Change(valueName, inc));
            SaveUtil.Save(scenario);
            return(true);
        }
Ejemplo n.º 2
0
        public static void Kill(DMEnv env, Investigator source, int index, string weaponName)
        {
            List <Horse> horses = env.Sce.Horses;

            if (horses.Count == 0)
            {
                env.Next = "🏇已经结束!";
                return;
            }
            if (index <= 0 || index > horses.Count)
            {
                env.Next = $"找不到{index}号🐎";
                return;
            }

            Horse  horse     = horses[index - 1];
            string horseName = Indices[index - 1] + "号🐎";

            if (horse.Sources.Contains(source.Name))
            {
                env.Next = $"{source.Name}本轮已经杀过此🐎了!";
                return;
            }

            Item w = source.GetItem(weaponName);

            horse.Sources.Add(source.Name);

            if (!source.Check(w.SkillName, out CheckResult sr, out string str))
            {
                env.Save();
                env.Append(str);
                return;
            }
            env.AppendLine(str);
            if (!sr.succeed)
            {
                env.Save();
                env.Append("杀🐎失败,该回合不能再杀此🐎");
                return;
            }
            // 检定🐎的闪避
            CheckResult hr = new Value(horse.Ponential).Check();

            env.AppendLine($"{horseName} => {hr.points},逃离{hr.TypeString}");
            if (hr.succeed && hr.type <= sr.type)
            {
                env.Save();
                env.Next = $"{source.Name}没有打中飞速移动中的{horseName}";
                return;
            }
            // 计算伤害
            int r = Dice.RollWith(w.Damage, source.DamageBonus);

            env.Append($"造成伤害:{r}");
            if (r > 0)
            {
                int prev = horse.Health;
                horse.Health = Math.Min(Math.Max(0, prev - r), Horse.MaxHealth);
                env.LineAppend($"{horseName}的体力:{prev} - {r} => {horse.Health}");
                if (horse.Health <= 0)
                {
                    int totalBets = 0;
                    foreach (int bet in horse.Bets.Values)
                    {
                        totalBets += bet;
                    }
                    horse.Bets.Clear();
                    env.AppendLine($"{source.Name}获得{horseName}身上的所有筹码({totalBets})");
                    env.Append(source.Change("账户", totalBets));
                }
            }
            env.Save();
        }
Ejemplo n.º 3
0
        private static void CalculateDamage(DMEnv env, Investigator source, Investigator target, string weaponName)
        {
            Item w = null;

            if (weaponName != null)
            {
                if (!source.Inventory.TryGetValue(weaponName, out w))
                {
                    env.Next = $"未找到{source.Name}武器:{weaponName}";
                }
            }
            else
            {
                w = new Item("身体");
            }

            if (w.CurrentLoad <= 0)
            {
                env.Next = "弹药不足,请装弹";
            }

            // 计算伤害值
            int r    = Dice.RollWith(w.Damage, source.DamageBonus);
            int cost = Math.Min(w.Cost, w.CurrentLoad);

            w.CurrentLoad -= cost;
            env.Append($"{source.Name}对{target.Name}造成伤害{r}");
            if (w.Cost == 0)
            {
                env.Append($",弹药消耗{cost},弹药剩余{w.CurrentLoad}/{w.Capacity}");
            }
            env.Line();
            // 计算护甲格挡
            if (target.Values.TryGet("护甲", out Value protect) && protect.Val > 0)
            {
                r = Math.Max(0, r - protect.Val);
                env.AppendLine("护甲阻挡部分伤害,最终实际伤害:" + r);
            }
            // 施加伤害
            if (r > 0)
            {
                if (!target.Values.TryGet("体力", out Value th))
                {
                    env.Append("而对方没有体力").ToString();
                    return;
                }
                // 真正减少体力
                int prev = th.Val;
                env.Append(target.Change("体力", -r));
                if (prev < r)   // 检定是否可急救
                {
                    env.Line().Append("受伤过重,无法治疗");
                }
                else if (r >= (int)(th.Max / 2.0) && th.Val > 0)     // 检定昏迷
                {
                    env.Line().Append("一次失血过半,");
                    if (!target.Values.TryWidelyGet("意志", out Value san))
                    {
                        san = new Value(50);
                    }
                    if (!target.Check("意志", out CheckResult cr, out string str))
                    {
                        env.Append(str);
                        return;
                    }
                    env.Append(str).Append(",");
                    if (cr.succeed)
                    {
                        env.Append($"{target.Name}成功挺住");
                    }
                    else
                    {
                        env.Append($"{target.Name}昏厥");
                    }
                }
            }
            env.Save();
        }