Skip to content

Commit

Permalink
fix a few bugs
Browse files Browse the repository at this point in the history
hopefully no more bugs
  • Loading branch information
koboldunderlord authored Aug 5, 2022
1 parent a6fe9e4 commit 492c39f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
23 changes: 11 additions & 12 deletions LegendaryDogsDogBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,23 @@ public class LegendaryDogsDogBuilder
"Stub-tailed"
};

public static string BuildTitle()
{
string Title = Titles.GetRandomElement();
if (Title == "Good")
{
Title = BuildGoodTitle();
}
return Title;
}

public static string BuildGoodTitle()
{
StringBuilder VeryGoodBuilder = new StringBuilder();
int Chance = Stat.RandomCosmetic(1, 2);
if (Chance == 2)
{
MessageQueue.AddPlayerMessage("Very");
VeryGoodBuilder.Append("Very");
Chance = Stat.RandomCosmetic(1, 2);
while (Chance == 2)
Expand Down Expand Up @@ -233,18 +244,6 @@ public static void AddModifiers(GameObject dog)

public bool BuildObject(GameObject dog, string Context = null)
{
string Title = Titles.GetRandomElement();
if (Title == "Good")
{
Title = BuildGoodTitle();
LegendaryDogsDogHero1 heroPart = dog.GetPart<LegendaryDogsDogHero1>();
heroPart.VeryGoodText = Title.ToLower();
}
string name = BuildName(dog.DisplayName, Title);
dog.DisplayName = name;

AddModifiers(dog);

dog.HasProperName = true;

return true;
Expand Down
23 changes: 15 additions & 8 deletions LegendaryDogsDogHero1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
using XRL.Rules;
using XRL.UI;
using XRL.World.Effects;
using XRL.Messages;
using XRL.World.Encounters.EncounterObjectBuilders;

namespace XRL.World.Parts
{
[Serializable]
public class LegendaryDogsDogHero1 : IPart
{
public bool bCreated;
public int GoodFactionPenalty;
public string VeryGoodText;
public string Title;

public LegendaryDogsDogHero1()
{
if (this.VeryGoodText == null)
{
this.VeryGoodText = "";
}
this.Title = LegendaryDogsDogBuilder.BuildTitle();
this.GoodFactionPenalty = 0;
}

public override bool SameAs(IPart p)
Expand All @@ -32,17 +31,25 @@ public override void Register(GameObject Object)
{
Object.RegisterPartEvent(this, "BeforeDeathRemoval");
Object.RegisterPartEvent(this, "AfterLookedAt");
Object.RegisterPartEvent(this, "ObjectCreated");
base.Register(Object);
}



public override bool FireEvent(Event E)
{
if (E.ID == "BeforeDeathRemoval" && this.GoodFactionPenalty > 0)
if (E.ID == "ObjectCreated")
{
ParentObject.DisplayName = LegendaryDogsDogBuilder.BuildName(ParentObject.DisplayName, Title);
LegendaryDogsDogBuilder.AddModifiers(ParentObject);
} else if (E.ID == "BeforeDeathRemoval" && this.GoodFactionPenalty > 0)
{
GameObject gameObjectParameter = E.GetGameObjectParameter("Killer");
if (gameObjectParameter != null && (gameObjectParameter.IsPlayer() || gameObjectParameter.IsPlayerLed()))
{
Popup.Show("You murdered a " + VeryGoodText + " dog. You are cursed.");
Popup.Show("You murdered a " + this.Title + " dog. You are cursed.");
// JournalAPI.AddAccomplishment("You murdered the " + ParentObject. + str + ".", HistoricStringExpander.ExpandString("In the month of " + Calendar.getMonth() + " of " + Calendar.getYear().ToString() + ", brave =name= slew <spice.commonPhrases.odious.!random> " + str + " in single combat."), muralCategory: JournalAccomplishment.MuralCategory.Slays, muralWeight: JournalAccomplishment.MuralWeight.Low);
}
}
else if (E.ID == "AfterLookedAt" && ParentObject.DisplayName.Contains("Loveable"))
Expand Down
5 changes: 3 additions & 2 deletions LegendaryDogsGivesRep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public void ReplaceFactions()
{
GivesRep RepPart = this;
GameObject dog = ParentObject;

LegendaryDogsDogHero1 HeroPart = dog.GetPart<LegendaryDogsDogHero1>();

if (HeroPart.GoodFactionPenalty > 0)
if (ParentObject.DisplayName.Contains("Good"))
{
RepPart.ResetRelatedFactions();
foreach (Faction Faction in Factions.loop())
Expand All @@ -32,7 +33,7 @@ public void ReplaceFactions()
FriendorFoe FoF = new FriendorFoe();
FoF.faction = Faction.Name;
FoF.status = "friend";
FoF.reason = "for being a " + HeroPart.VeryGoodText + " dog";
FoF.reason = "for being a " + HeroPart.Title + " dog";
RepPart.relatedFactions.Add(FoF);
if (dog.pBrain.FactionFeelings.ContainsKey(Faction.Name))
{
Expand Down
17 changes: 8 additions & 9 deletions LegendaryDogsWorgGivesRep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public void ReplaceFactions()
{
GivesRep RepPart = this;
GameObject dog = ParentObject;
LegendaryDogsWorgHero1 HeroPart = dog.GetPart<LegendaryDogsWorgHero1>();

foreach (FriendorFoe FoF in RepPart.relatedFactions)
{
Expand All @@ -34,13 +33,13 @@ public void ReplaceFactions()
}
}

public override bool HandleEvent(GetShortDescriptionEvent E)
{
if (!FixedRep) {
ReplaceFactions();
FixedRep = true;
}
return base.HandleEvent(E);
}
public override bool HandleEvent(GetShortDescriptionEvent E)
{
if (!FixedRep) {
ReplaceFactions();
FixedRep = true;
}
return base.HandleEvent(E);
}
}
}

0 comments on commit 492c39f

Please sign in to comment.