Skip to content

Commit

Permalink
Added support for "white" mods on items
Browse files Browse the repository at this point in the history
  • Loading branch information
dlebansais committed Jun 1, 2024
1 parent 4bfe738 commit 77decf9
Show file tree
Hide file tree
Showing 9 changed files with 393 additions and 35 deletions.
65 changes: 58 additions & 7 deletions Pipeline/Preprocessing/Objects/Ability/Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,48 @@ public Ability(RawAbility rawAbility)

// Remove Lint_NotLearnable for an ability that we can actually learn.
if (InternalName == "SwordSlash" && Keywords is not null)
Keywords = RemoveKeyword(Keywords, "Lint_NotLearnable");

// Add new keywords needed for combat parsing.
if (Skill == "Knife" && DamageType == "Slashing")
Keywords = AddKeyword(Keywords, "KnifeSlashing");
if (Skill == "Staff" && DamageType == "Crushing")
Keywords = AddKeyword(Keywords, "StaffCrushing");

if (Name is not null && Name.StartsWith("Life Steal") && SpecialInfo is not null && SpecialInfo.StartsWith("Steals "))
{
List<string> KeywordsList = Keywords.ToList();
KeywordsList.Remove("Lint_NotLearnable");
Keywords = KeywordsList.ToArray();
Debug.Assert(PvE is not null && PvE.SpecialValues is null);

SpecialValue LifeStealSpecialValue = new();
LifeStealSpecialValue.Label = "Steals";
LifeStealSpecialValue.Suffix = "Health.";
string[] Parts = SpecialInfo.Split(' ');
Debug.Assert(Parts.Length == 3);
LifeStealSpecialValue.Value = int.Parse(Parts[1]);

SpecialInfo = null;
PvE!.SpecialValues = new SpecialValue[] { LifeStealSpecialValue };
}
}

private static string[]? AddKeyword(string[]? Keywords, string keywordToAdd)
{
List<string> KeywordsList = Keywords.ToList();
KeywordsList.Add(keywordToAdd);
Keywords = KeywordsList.ToArray();

return Keywords;
}

private static string[]? RemoveKeyword(string[]? Keywords, string keywordToRemove)
{
List<string> KeywordsList = Keywords.ToList();
KeywordsList.Remove(keywordToRemove);
Keywords = KeywordsList.ToArray();

return Keywords;
}

private static ConditionalKeyword[]? ParseConditionalKeywords(RawConditionalKeyword[]? rawConditionalKeywords)
{
if (rawConditionalKeywords is null)
Expand Down Expand Up @@ -368,11 +403,27 @@ public RawAbility ToRawAbility()
Result.WorksWhileMounted = WorksWhileMounted;
Result.WorksWhileStunned = WorksWhileStunned;

if (InternalName == "SwordSlash" && Result.Keywords is not null)
if (Result.Keywords is not null)
{
if (InternalName == "SwordSlash")
Result.Keywords = AddKeyword(Result.Keywords, "Lint_NotLearnable");

if (Skill == "Knife" && DamageType == "Slashing")
Result.Keywords = RemoveKeyword(Result.Keywords, "KnifeSlashing");
if (Skill == "Staff" && DamageType == "Crushing")
Result.Keywords = RemoveKeyword(Result.Keywords, "StaffCrushing");
}

if (Result.Name is not null && Result.Name.StartsWith("Life Steal") && Result.PvE?.SpecialValues is not null && Result.PvE.SpecialValues.Length == 1)
{
List<string> KeywordsList = Result.Keywords.ToList();
KeywordsList.Add("Lint_NotLearnable");
Result.Keywords = KeywordsList.ToArray();
SpecialValue LifeStealSpecialValue = Result.PvE.SpecialValues[0];
if (LifeStealSpecialValue.Label == "Steals" && LifeStealSpecialValue.Suffix == "Health.")
{
Debug.Assert(Result.SpecialInfo is null);

Result.SpecialInfo = $"{LifeStealSpecialValue.Label} {LifeStealSpecialValue.Value} {LifeStealSpecialValue.Suffix}";
Result.PvE.SpecialValues = null;
}
}

return Result;
Expand Down
15 changes: 12 additions & 3 deletions Pipeline/Preprocessing/Objects/Item/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ private static ItemEffect ParseEffectDescription(string rawEffectDescription)
string EffectString = rawEffectDescription.Substring(1, rawEffectDescription.Length - 2);
Result = ParseAttributeEffectDescription(EffectString);
}
else if (rawEffectDescription.Contains("{") || rawEffectDescription.Contains("}"))
throw new PreprocessorException();
else
{
Result.Description = Result.Description.Replace("Windstrike", "Wind Strike");

if (rawEffectDescription.Contains("{") || rawEffectDescription.Contains("}"))
throw new PreprocessorException();
}

return Result;
}
Expand Down Expand Up @@ -436,7 +441,11 @@ public RawItem ToRawItem()
private static string EffectDescriptionToString(ItemEffect effectDescription)
{
if (effectDescription.Description is not null)
return effectDescription.Description;
{
string Description = effectDescription.Description;
Description = Description.Replace("Wind Strike", "Windstrike");
return Description;
}
else
return $"{{{effectDescription.AttributeName}}}{{{effectDescription.AttributeEffect!.Value.ToString(CultureInfo.InvariantCulture)}}}";
}
Expand Down
4 changes: 2 additions & 2 deletions Preprocessor/Preprocessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<Product />
<Description>PG json preprocessor</Description>
<Copyright>Copyright © 2023 David Le Bansais</Copyright>
<AssemblyVersion>1.1.0.4864</AssemblyVersion>
<FileVersion>1.1.0.1</FileVersion>
<AssemblyVersion>1.1.0.4869</AssemblyVersion>
<FileVersion>1.1.0.2</FileVersion>
<RepositoryUrl>https://github.com/dlebansais/PgJsonParse</RepositoryUrl>
<NeutralLanguage>en-US</NeutralLanguage>
<RootNamespace>Preprocessor</RootNamespace>
Expand Down
1 change: 1 addition & 0 deletions Translator/CombatParser/CombatParser.Sentences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public partial class CombatParser
new Sentence("Deal %f #D damage", CombatKeyword.DamageBoost),
new Sentence("Deal %f direct #D damage", CombatKeyword.DamageBoost),
new Sentence("Deal direct #D damage to deal %f damage", CombatKeyword.DamageBoost),
new Sentence("Deal direct #D damage", CombatKeyword.ChangeDamageType),
new Sentence("Critical hit deal %f damage", new List<CombatKeyword>() { CombatKeyword.DamageBoost, CombatKeyword.ApplyToCrits }),
new Sentence("Crit Damage %f", new List<CombatKeyword>() { CombatKeyword.DamageBoost, CombatKeyword.ApplyToCrits }),
new Sentence("When they critically hit", CombatKeyword.ApplyToCrits),
Expand Down
Loading

0 comments on commit 77decf9

Please sign in to comment.