Skip to content

Commit 9de64ce

Browse files
authored
Merge pull request #199 from Tiagobuzzz/codex/adicionar-sistema-de-doenças-e-curas-baseadas-em-crença
2 parents 27be8d1 + 93d0ef4 commit 9de64ce

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace UltraWorldAI.Health;
6+
7+
public class FaithBeliefDisease
8+
{
9+
public string Name = string.Empty;
10+
public string TriggerBelief = string.Empty;
11+
public string Culture = string.Empty;
12+
public float InfectionRate;
13+
public string Symptom = string.Empty;
14+
public bool Active;
15+
}
16+
17+
public class FaithBeliefCure
18+
{
19+
public string Name = string.Empty;
20+
public string HealingBelief = string.Empty;
21+
public string Culture = string.Empty;
22+
public string Effect = string.Empty;
23+
}
24+
25+
public static class FaithBasedAilmentSystem
26+
{
27+
public static List<FaithBeliefDisease> ActiveDiseases { get; } = new();
28+
public static List<FaithBeliefCure> ActiveCures { get; } = new();
29+
30+
public static void TriggerDisease(string culture, string belief, string symptom, float rate)
31+
{
32+
var disease = new FaithBeliefDisease
33+
{
34+
Name = $"Doen\u00e7a de {belief}",
35+
TriggerBelief = belief,
36+
Culture = culture,
37+
InfectionRate = rate,
38+
Symptom = symptom,
39+
Active = true
40+
};
41+
42+
ActiveDiseases.Add(disease);
43+
Console.WriteLine($"\uD83E\uDD9A {disease.Name} surgiu em '{culture}' (Sintoma: {symptom})");
44+
}
45+
46+
public static void RegisterCure(string culture, string healingBelief, string effect)
47+
{
48+
var cure = new FaithBeliefCure
49+
{
50+
Name = $"Cura de {healingBelief}",
51+
HealingBelief = healingBelief,
52+
Culture = culture,
53+
Effect = effect
54+
};
55+
56+
ActiveCures.Add(cure);
57+
Console.WriteLine($"\uD83D\uDC8A Cura registrada: '{cure.Name}' (Cultura: {culture} \u2192 Efeito: {effect})");
58+
}
59+
60+
public static void ApplyCure(string ai, string belief, string culture)
61+
{
62+
var cure = ActiveCures.FirstOrDefault(c => c.Culture == culture && c.HealingBelief == belief);
63+
if (cure != null)
64+
{
65+
Console.WriteLine($"\uD83E\uDEF8 {ai} usou a cura: {cure.Name} \u2192 {cure.Effect}");
66+
}
67+
else
68+
{
69+
Console.WriteLine($"\u26A0\uFE0F {ai} tentou usar cura baseada em '{belief}', mas nada aconteceu.");
70+
}
71+
}
72+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.IO;
3+
using UltraWorldAI.Health;
4+
using Xunit;
5+
6+
public class FaithBasedAilmentSystemTests
7+
{
8+
[Fact]
9+
public void TriggerDiseaseAddsDisease()
10+
{
11+
FaithBasedAilmentSystem.ActiveDiseases.Clear();
12+
FaithBasedAilmentSystem.TriggerDisease("Sarith", "Som da flauta atrai demonios", "Surdez parcial", 0.3f);
13+
Assert.Contains(FaithBasedAilmentSystem.ActiveDiseases, d => d.Culture == "Sarith" && d.TriggerBelief == "Som da flauta atrai demonios");
14+
}
15+
16+
[Fact]
17+
public void ApplyCureOutputsWhenCureExists()
18+
{
19+
FaithBasedAilmentSystem.ActiveCures.Clear();
20+
FaithBasedAilmentSystem.RegisterCure("Sarith", "Beijo na testa", "Remove delirio");
21+
var original = Console.Out;
22+
using var writer = new StringWriter();
23+
Console.SetOut(writer);
24+
FaithBasedAilmentSystem.ApplyCure("Thalor", "Beijo na testa", "Sarith");
25+
Console.SetOut(original);
26+
Assert.Contains("usou a cura", writer.ToString());
27+
}
28+
}

0 commit comments

Comments
 (0)