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); }
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); }
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(); }