Skip to content

Commit

Permalink
Health update
Browse files Browse the repository at this point in the history
  • Loading branch information
badnickname committed Nov 30, 2024
1 parent c9f34d7 commit 622c24f
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions HemaDungeon/Abilities/HealthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,8 @@ public sealed class HealthService
public double Enrich(Character character)
{
var value = (character.Score > 0 ? character.Score : 1) * 5;
var factor = (double) 0;
var criticalDay = new DateTime(2024, 11, 2, 0, 0, 0, DateTimeKind.Utc);
var prevDay = character.Visits?.FirstOrDefault();
var harm = (double) 0;
foreach (var visit in character.Visits?.Where(x => !x.CanSkip).OrderBy(x => x.Date) ?? Enumerable.Empty<Visit>())
{
if (visit.WasHere) factor += 1;
else
{
if (visit.Date < criticalDay)
{
factor /= 2.0;
harm /= 2.0;
}
else
{
factor /= 3;
harm /= 3.0;
}
}

var delta = Math.Max((visit.Date?.Month ?? 0) - (prevDay?.Date?.Month ?? 0), 0);
if (delta > 0)
{
harm += (value * factor - harm) / 2.0;
}

prevDay = visit;
}

var result = value * factor == 0 ? value : value * factor - harm;
return result < 1 ? 1 : result;
var factor = character.Visits?.Where(x => !x.CanSkip).Select(x => x.WasHere).Aggregate(0.0, (root, x) => x ? root + 1 : root / 2.0) ?? 0.0;
if (factor * value == 0) return value;
return value * factor;
}
}

0 comments on commit 622c24f

Please sign in to comment.