Ejemplo n.º 1
0
        private static bool Attack(DMEnv env, Investigator source, Investigator target, string weaponName)
        {
            Item w = source.GetItem(weaponName);

            if (!source.Check(w.SkillName, out CheckResult result, out string str))
            {
                return(false);
            }
            env.AppendLine(str);
            if (!result.succeed)
            {
                env.Append("攻击失败");
                return(false);
            }

            int mulfunctionCheckResult = Dice.Roll(100);

            if (mulfunctionCheckResult > w.Mulfunction)
            {
                env.Append($"{source.Name}的{w.Name}{(w.Type == "射击" ? "炸膛" : "坏掉")}了!({mulfunctionCheckResult} > {w.Mulfunction})");
            }

            switch (w.Type)
            {
            case "肉搏": CommitFight(env, source, target, weaponName, result.points, result.type); return(true);

            case "投掷": CommitFight(env, source, target, weaponName, result.points, result.type); return(true);

            case "射击": CalculateDamage(env, source, target, weaponName); return(true);

            default: env.Append($"未知的武器类型:{w.Type},只能是:肉搏、投掷、射击"); break;
            }

            return(false);
        }
Ejemplo n.º 2
0
        private static bool Dodge(DMEnv env, Investigator inv)
        {
            FightEvent fight = inv.PeekNextFight(env.Sce, out Investigator source, out Item oppositeWeapon);

            if (oppositeWeapon.Type == "射击")
            {
                env.Next = oppositeWeapon + "是射击武器,仅肉搏或投掷武器可闪避!";
                return(false);
            }

            if (!inv.Check("闪避", out CheckResult result, out string str))
            {
                env.Next = str;
                return(false);
            }
            inv.Fights.Dequeue();

            env.AppendLine(str);
            env.Save();
            if (result.succeed && result.type <= fight.ResultType)
            {
                env.Append($"躲开了{fight}!");
                return(true);
            }
            else
            {
                env.AppendLine($"受到了{fight}");
                CalculateDamage(env, source, inv, fight.WeaponName);
                return(false);
            }
        }
Ejemplo n.º 3
0
 public static bool SimpleCheckTo(DMEnv env, Investigator inv, string valueName, string target)
 {
     if (!inv.Check(valueName, out CheckResult result, out string str))
     {
         env.Append(str);
         return(false);
     }
     env.Append(str + (result.succeed ? $",{inv.Name}把{target}给{valueName}了!" : ""));
     return(result.succeed);
 }
Ejemplo n.º 4
0
        private static bool FightBack(DMEnv env, Investigator target, string weaponName)
        {
            Item       selfWeapon = target.GetItem(weaponName);
            FightEvent fight      = target.PeekNextFight(env.Sce, out Investigator source, out Item oppositeWeapon);

            if (oppositeWeapon.Type != "肉搏")
            {
                env.Next = oppositeWeapon + "不是肉搏武器,仅肉搏可反击!";
                return(false);
            }

            if (!target.Check(oppositeWeapon.SkillName, out CheckResult result, out string str))
            {
                env.Next = str;
                return(false);
            }

            target.Fights.Dequeue();

            env.AppendLine(str);
            if (result.succeed && result.type < fight.ResultType)
            {
                int mulfunctionCheckResult = Dice.Roll(100);
                if (mulfunctionCheckResult > selfWeapon.Mulfunction)
                {
                    env.Append($"{target.Name}的{selfWeapon.Name}{(selfWeapon.Type == "射击" ? "炸膛" : "坏掉")}了!({mulfunctionCheckResult} > {selfWeapon.Mulfunction})");
                    return(false);
                }
                env.Append($"反击了{fight}!");
                CalculateDamage(env, target, source, weaponName);
            }
            else
            {
                env.Append($"受到了{fight}!");
                CalculateDamage(env, source, target, fight.WeaponName);
            }
            return(true);
        }
Ejemplo n.º 5
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.º 6
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();
        }