public virtual void Kill(IInjured injured, IUserinterface ui, Guid round, string diedOf) { if (injured.Owner is IActor a) { a.Kill(ui, round, diedOf); } }
public virtual bool IsHealableBy(IActor actor, IInjured injured, out string reason) { if (HealerStat == null) { reason = "cannot be " + HealVerb; return(false); } var requiredStat = injured.Severity * HealerStatMultiplier; var result = injured.Owner is IActor i? ResistHeal.Calculate(i, false) : ResistHeal.Calculate(injured.Owner); //result == 0 if (Math.Abs(result) < Tolerance) { reason = $"{injured.Owner} is immune to healing (this injury type)"; return(false); } //vulnerable to healing makes you easier to heal. ResistInflict healing makes you harder to heal requiredStat *= 1 / result; if (actor.GetFinalStats()[HealerStat] > requiredStat) { reason = null; return(true); } reason = $"{HealerStat} was too low (required {requiredStat})"; return(false); }
public bool ShouldWorsen(IInjured injury, int roundsSeen) { if (WorsenRate <= 0) { return(false); } if (IsWithinNaturalHealingThreshold(injury)) { return(false); } if (injury.Owner is IActor a && a.Dead) { return(false); } double ratio = ResistWorsen.Calculate(injury.Owner); //immune if (Math.Abs(ratio) < Tolerance) { return(false); } return(roundsSeen > (1 / ratio) * WorsenRate); }
public virtual bool HasFatalInjuries(IInjured injured, out string diedOf) { //Combined total of serious wounds (2 or higher) severity is 100 if (injured.Owner.Adjectives.OfType <Injured>().Where(IncludeInFatalSum).Sum(i => i.Severity) >= FatalThreshold) { diedOf = FatalVerb; return(true); } diedOf = null; return(false); }
private void Amplify(IInjured injured, double value, IUserinterface ui, Guid round) { injured.Severity += 10; //if injury names should be updated with severity if (SyncDescriptions) { var newInjury = GetBlueprintFor(injured.Severity); if (newInjury != null && injured.Name != newInjury.Name) { ui.Log.Info(new LogEntry($"{injured.Owner} {injured.Name} became a {newInjury.Name}", round, injured.Owner as IActor)); injured.Name = newInjury.Name; } } }
public bool ShouldNaturallyHeal(IInjured injured, int roundsSeenCount) { //if your dead you are not getting better if (injured.Owner is IActor a && a.Dead) { return(false); } //if the wound is too bad to heal by itself if (!IsWithinNaturalHealingThreshold(injured)) { return(false); } return(roundsSeenCount > NaturalHealRate); }
public virtual void Worsen(IInjured injured, IUserinterface ui, Guid round) { Amplify(injured, 10, ui, round); //if wounds can become infected if (!injured.IsInfected && Infection) { injured.IsInfected = true; ui.Log.Info(new LogEntry($"{injured.Owner} {injured.Name} became infected", round, injured.Owner as IActor)); injured.Name = "Infected " + injured.Name; } else { ui.Log.Info(new LogEntry($"{injured.Owner} {injured.Name} {WorsenVerb}", round, injured.Owner as IActor)); } Spreads?.HandleSpreading(injured, this, ui, round); }
internal void HandleSpreading(IInjured injured, IInjurySystem injurySystem, IUserinterface ui, Guid round) { if (injured.Owner is IRoom p) { if (RoomsToRooms) { foreach (var adjacent in p.World.Map.GetAdjacentRooms(p, false)) { injurySystem.Apply(new SystemArgs(p.World, ui, 1, null, adjacent.Value, round)); } } if (RoomsToActors) { foreach (var actor in p.Actors) { injurySystem.Apply(new SystemArgs(p.World, ui, 1, null, actor, round)); } } } if (injured.Owner is IActor a) { var world = a.CurrentLocation.World; if (ActorsToActors) { foreach (var actor in a.GetCurrentLocationSiblings(false)) { injurySystem.Apply(new SystemArgs(world, ui, 1, null, actor, round)); } } if (ActorsToRooms) { injurySystem.Apply(new SystemArgs(world, ui, 1, null, a.CurrentLocation, round)); } } }
/// <summary> /// Injury should get better by itself (and not worsen), override to create injury /// systems that do not heal by themselves or where the threshold is higher /// </summary> /// <param name="injured"></param> /// <returns></returns> protected virtual bool IsWithinNaturalHealingThreshold(IInjured injured) { return(injured.Severity <= NaturalHealThreshold); }
public virtual void Heal(IInjured injured, IUserinterface ui, Guid round) { injured.Owner.Adjectives.Remove(injured); ui.Log.Info(new LogEntry($"{injured.Name} was {HealVerb}", round, injured.Owner as IActor)); }