Skip to content

Commit 948735e

Browse files
committed
a lot more detail whom worships whom, deities, forces, creatures
1 parent e0c6503 commit 948735e

File tree

7 files changed

+127
-10
lines changed

7 files changed

+127
-10
lines changed

LegendsViewer.Backend/Extensions/HistoricalFigureExtensions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using LegendsViewer.Backend.Legends.Cytoscape;
22
using LegendsViewer.Backend.Legends.Enums;
3+
using LegendsViewer.Backend.Legends.WorldLinks;
34
using LegendsViewer.Backend.Legends.WorldObjects;
45
using LegendsViewer.Backend.Utilities;
56
using System.Net;
@@ -198,4 +199,33 @@ private static CytoscapeNodeElement CreateFamilyTreeNodeData(HistoricalFigure or
198199
Classes = classes
199200
};
200201
}
202+
203+
public static void AddWorshipper(this HistoricalFigure? worshipped, HistoricalFigure? worshipper, int strength)
204+
{
205+
if (worshipped == null || worshipper == null)
206+
{
207+
return;
208+
}
209+
worshipped.WorshippingFigures ??= [];
210+
var entry = (worshipper, strength);
211+
if (worshipped.WorshippingFigures.Contains(entry))
212+
{
213+
return;
214+
}
215+
worshipped.WorshippingFigures.Add(entry);
216+
}
217+
218+
public static void AddWorshipper(this HistoricalFigure? worshipped, Entity? worshipper)
219+
{
220+
if (worshipped == null || worshipper == null)
221+
{
222+
return;
223+
}
224+
worshipped.WorshippingEntities ??= [];
225+
if (worshipped.WorshippingEntities.Contains(worshipper))
226+
{
227+
return;
228+
}
229+
worshipped.WorshippingEntities.Add(worshipper);
230+
}
201231
}

LegendsViewer.Backend/Legends/World.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Diagnostics;
33
using System.Drawing;
44
using System.Text;
5+
using LegendsViewer.Backend.Extensions;
56
using LegendsViewer.Backend.Legends.Enums;
67
using LegendsViewer.Backend.Legends.EventCollections;
78
using LegendsViewer.Backend.Legends.Events;
@@ -432,6 +433,10 @@ public void ProcessHFtoHfLinks()
432433
HistoricalFigure hf = _hFtoHfLinkHFs[i];
433434
HistoricalFigureLink relation = new(link.SubProperties, this);
434435
hf.RelatedHistoricalFigures.Add(relation);
436+
if (relation.Type == HistoricalFigureLinkType.Deity)
437+
{
438+
relation.HistoricalFigure.AddWorshipper(hf, relation.Strength);
439+
}
435440
}
436441
}
437442

LegendsViewer.Backend/Legends/WorldObjects/Entity.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ public List<ListItemDto> WorshippedLinks
4040
Subtitle = associatedSpheres
4141
});
4242
}
43+
if (Worshipped.Count == 0 && EntityEntityLinks.Count > 0)
44+
{
45+
foreach (EntityEntityLink link in EntityEntityLinks)
46+
{
47+
var deity = link.Target?.Worshipped?.FirstOrDefault();
48+
if (deity == null)
49+
{
50+
continue;
51+
}
52+
string associatedSpheres = string.Join(", ", deity.Spheres);
53+
var newItem = new ListItemDto
54+
{
55+
Title = $"{deity.ToLink(true, this)}",
56+
Subtitle = associatedSpheres
57+
};
58+
if (list.Exists(existingItem => existingItem.Title == newItem.Title))
59+
{
60+
continue;
61+
}
62+
list.Add(newItem);
63+
}
64+
}
4365
return list;
4466
}
4567
}
@@ -375,7 +397,7 @@ public CytoscapeData? WarGraphData
375397
Href = $"/war/{item.Id}",
376398
BackgroundColor = item.Attacker.LineColor.ToRgbaString(0.6f),
377399
ForegroundColor = Formatting.GetReadableForegroundColor(item.Attacker.LineColor),
378-
Width = edgeWidth > 15 ? 15 : edgeWidth == 0 ? 1: edgeWidth,
400+
Width = edgeWidth > 15 ? 15 : edgeWidth == 0 ? 1 : edgeWidth,
379401
Label = $"{item.DeathCount} ✝",
380402
Tooltip = $"{item.ToLink(true, item)}<br/>{item.Subtype}"
381403
}));
@@ -554,6 +576,7 @@ public Entity(List<Property> properties, World world)
554576
if (worshippedDeity != null)
555577
{
556578
Worshipped.Add(worshippedDeity);
579+
worshippedDeity.AddWorshipper(this);
557580
}
558581
break;
559582
//case "claims":

LegendsViewer.Backend/Legends/WorldObjects/HistoricalFigure.cs

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace LegendsViewer.Backend.Legends.WorldObjects;
1616

1717
public class HistoricalFigure : WorldObject
1818
{
19+
private const int MaxListItemCount = 100;
20+
1921
private static readonly List<string> KnownEntitySubProperties = ["entity_id", "link_strength", "link_type", "position_profile_id", "start_year", "end_year"];
2022
private static readonly List<string> KnownSiteLinkSubProperties = ["link_type", "site_id", "sub_id", "entity_id", "occupation_id"];
2123
private static readonly List<string> KnownEntitySquadLinkProperties = ["squad_id", "squad_position", "entity_id", "start_year", "end_year"];
@@ -140,19 +142,72 @@ public List<ListItemDto> WorshippedDeities
140142
{
141143
continue;
142144
}
143-
144-
string raceString = link.HistoricalFigure.GetRaceString();
145-
string typeString = Formatting.InitCaps(raceString ?? link.Type.GetDescription());
145+
string associatedSpheres = string.Join(", ", link.HistoricalFigure.Spheres);
146146
list.Add(new ListItemDto
147147
{
148-
Title = $"{typeString} for {string.Join(", ", link.HistoricalFigure.Spheres)}",
149-
Subtitle = $"{link.HistoricalFigure?.ToLink(true, this)}",
148+
Title = link.HistoricalFigure.ToLink(true, this),
149+
Subtitle = associatedSpheres,
150150
Append = HtmlStyleUtil.GetChipString(link.Strength.ToString())
151151
});
152152
}
153153
return list;
154154
}
155155
}
156+
157+
[JsonIgnore]
158+
public List<(HistoricalFigure Worshipper, int Strength)>? WorshippingFigures { get; set; }
159+
public List<ListItemDto> WorshippingFiguresList
160+
{
161+
get
162+
{
163+
var list = new List<ListItemDto>();
164+
if (WorshippingFigures != null)
165+
{
166+
foreach (var (worshipper, strength) in WorshippingFigures.OrderByDescending(w => w.Strength).Take(MaxListItemCount))
167+
{
168+
list.Add(new ListItemDto
169+
{
170+
Title = worshipper?.ToLink(true, this),
171+
Subtitle = worshipper?.GetLastAssignmentString(),
172+
Append = HtmlStyleUtil.GetChipString(strength.ToString())
173+
});
174+
}
175+
if (WorshippingFigures.Count > MaxListItemCount)
176+
{
177+
list.Add(new ListItemDto
178+
{
179+
Subtitle = $"... and {WorshippingFigures.Count - MaxListItemCount} more!",
180+
});
181+
}
182+
}
183+
184+
return list;
185+
}
186+
}
187+
188+
[JsonIgnore]
189+
public List<Entity>? WorshippingEntities { get; set; }
190+
public List<ListItemDto> WorshippingEntitiesList
191+
{
192+
get
193+
{
194+
var list = new List<ListItemDto>();
195+
if (WorshippingEntities != null)
196+
{
197+
foreach (var worshipper in WorshippingEntities)
198+
{
199+
list.Add(new ListItemDto
200+
{
201+
Title = worshipper?.ToLink(true, this),
202+
Subtitle = worshipper?.EntityType.GetDescription()
203+
});
204+
}
205+
}
206+
207+
return list;
208+
}
209+
}
210+
156211
public List<SiteProperty> SiteProperties { get; set; } = [];
157212
public List<EntityReputation> Reputations { get; set; } = [];
158213
public List<RelationshipProfileHf> RelationshipProfiles { get; set; } = [];
@@ -343,12 +398,12 @@ public List<ListItemDto> MiscList
343398
Subtitle = string.Join(", ", RelatedRegions.ConvertAll(region => region.ToLink()))
344399
});
345400
}
346-
if (WorshippedBy != null)
401+
if (WorshippingFigures != null)
347402
{
348403
list.Add(new ListItemDto
349404
{
350405
Title = "Worshipped By",
351-
Subtitle = WorshippedBy.ToLink(true, this)
406+
Subtitle = $"{WorshippingFigures.Count} historical figures"
352407
});
353408
}
354409
if (LineageCurseParent != null)
@@ -918,7 +973,7 @@ public string GetLastAssignmentString()
918973
{
919974
return lastAssignmentString;
920975
}
921-
if(_jobs == null)
976+
if (_jobs == null)
922977
{
923978
_jobs = [];
924979
foreach (var relevantEvent in Events.OfType<ChangeHfJob>())

LegendsViewer.Frontend/legends-viewer-frontend/src/generated/api-schema.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13448,6 +13448,8 @@ export interface components {
1344813448
creatureTypes?: components["schemas"]["CreatureType"][] | null;
1344913449
readonly relatedHistoricalFigureList?: components["schemas"]["ListItemDto"][] | null;
1345013450
readonly worshippedDeities?: components["schemas"]["ListItemDto"][] | null;
13451+
readonly worshippingFiguresList?: components["schemas"]["ListItemDto"][] | null;
13452+
readonly worshippingEntitiesList?: components["schemas"]["ListItemDto"][] | null;
1345113453
siteProperties?: components["schemas"]["SiteProperty"][] | null;
1345213454
reputations?: components["schemas"]["EntityReputation"][] | null;
1345313455
relationshipProfiles?: components["schemas"]["RelationshipProfileHf"][] | null;

LegendsViewer.Frontend/legends-viewer-frontend/src/views/Entity.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const beforeLists: ComputedRef<LegendLinkListData[]> = computed(() => [
1717
{ title: 'Related Factions and Groups', items: store.object?.entityEntityLinkList ?? [], icon: "mdi-account-group", subtitle: "The organizations and groups connected to this entity" },
1818
{ title: 'Current Sites', items: store.object?.currentSiteList ?? [], icon: "mdi-home-outline", subtitle: "The sites held by this entity, from settlements to strongholds of power" },
1919
{ title: 'Lost Sites', items: store.object?.lostSiteList ?? [], icon: "mdi-home-off-outline", subtitle: "Former strongholds and settlements once under the control of this entity" },
20+
{ title: 'Worshipped Deities', items: store.object?.worshippedLinks ?? [], icon: "mdi-weather-sunset", subtitle: "The divine beings revered across the lands" },
2021
]);
2122
2223
const afterLists: ComputedRef<LegendLinkListData[]> = computed(() => [
2324
{ title: 'Related Sites', items: store.object?.entitySiteLinkList ?? [], icon: "mdi-home-switch-outline", subtitle: "The locations tied to this entity, from settlements to strongholds of power" },
24-
{ title: 'Worshipped Deities', items: store.object?.worshippedLinks ?? [], icon: "mdi-weather-sunset", subtitle: "The divine beings revered across the lands" },
2525
]);
2626
2727
</script>

LegendsViewer.Frontend/legends-viewer-frontend/src/views/HistoricalFigure.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const beforeLists: ComputedRef<LegendLinkListData[]> = computed(() => [
5656
{ title: 'Worshipped Deities', items: store.object?.worshippedDeities ?? [], icon: "mdi-hand-heart-outline", subtitle: "The divine beings revered by the historical figure, shaping their beliefs and actions" },
5757
{ title: 'Journey Pets', items: store.object?.journeyPets ?? [], icon: "mdi-paw", subtitle: "Trusted animal companions that accompanied this figure on their travels" },
5858
{ title: 'Noble Positions', items: store.object?.positionList ?? [], icon: "mdi-seal", subtitle: "The ruling elite, guiding the fate of realms and people" },
59+
{ title: 'Worshipping Figures', items: store.object?.worshippingFiguresList ?? [], icon: "mdi-meditation", subtitle: "Historical figures who revere this creature, deity or force of nature" },
60+
{ title: 'Worshipping Entities', items: store.object?.worshippingEntitiesList ?? [], icon: "mdi-crowd", subtitle: "Groups or organizations that hold this deity in reverence" },
5961
]);
6062
6163
const afterLists: ComputedRef<LegendLinkListData[]> = computed(() => [

0 commit comments

Comments
 (0)