Skip to content

Commit

Permalink
Add the effects field even if there is no effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Lounek09 committed Oct 23, 2024
1 parent b3c2569 commit 61d4ed3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Cyberia.Api.Data.Incarnations;
using Cyberia.Api.Data.Items;
using Cyberia.Api.Data.Spells;
using Cyberia.Api.Factories.Effects;
using Cyberia.Salamandra.Commands.Dofus.Item;
using Cyberia.Salamandra.Commands.Dofus.Spell;
using Cyberia.Salamandra.Enums;
Expand Down Expand Up @@ -100,11 +99,8 @@ private async Task<DiscordEmbedBuilder> EmbedBuilder()
Translation.Get<BotTranslations>("Embed.Field.ItemType.Title", _culture), _itemData.GetItemTypeName(_culture), true)
.AddEmptyField(true);

IEnumerable<IEffect> effects = _incarnationData.GetRealEffects();
if (effects.Any())
{
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.Effects.Title", _culture), effects, true, _culture);
}
var effects = _incarnationData.GetRealEffects();
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.Effects.Title", _culture), effects, true, _culture);

if (_itemData.WeaponData is not null)
{
Expand Down
6 changes: 2 additions & 4 deletions Cyberia.Salamandra/Commands/Dofus/Item/ItemMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ private async Task<DiscordEmbedBuilder> EmbedBuilder()
embed.AddField(Translation.Get<BotTranslations>("Embed.Field.ItemSet.Title", _culture), _itemSetData.Name.ToString(_culture), true);
}

if (_itemStatsData is not null)
{
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.ItemSet.Title", _culture), _itemStatsData.Effects, true, _culture);
}
var effects = _itemStatsData?.Effects ?? Enumerable.Empty<IEffect>();
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.ItemSet.Title", _culture), effects, true, _culture);

if (_itemData.Criteria.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ private Task<DiscordEmbedBuilder> EmbedBuilder()
}

var effects = _itemSetData.GetEffects(_nbItemSelected);
if (effects.Count > 0)
{
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.Effects.Title", _culture), effects, true, _culture);
}
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.Effects.Title", _culture), effects, true, _culture);

return Task.FromResult(embed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ private async Task<DiscordEmbedBuilder> EmbedBuilder()
}
else
{
var effects = _spellLevelData.Effects;
if (effects.Count > 0)
{
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.Effects.Title", _culture), effects, false, _culture);
}
embed.AddEffectFields(Translation.Get<BotTranslations>("Embed.Field.Effects.Title", _culture), _spellLevelData.Effects, false, _culture);

var trapEffects = _spellLevelData.GetTrapEffects();
if (trapEffects.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ public static DiscordEmbedBuilder AddFields(this DiscordEmbedBuilder embed, stri

public static DiscordEmbedBuilder AddEffectFields(this DiscordEmbedBuilder embed, string name, IEnumerable<IEffect> effects, bool sort, CultureInfo? culture, bool inline = false)
{
var effectsParse = GetEffectsParse(effects, sort, culture, x => Formatter.Bold(Formatter.Sanitize(x)));
return embed.AddFields(name, effectsParse, inline);
if (effects.Any())
{
var effectsParse = GetEffectsParse(effects, sort, culture, x => Formatter.Bold(Formatter.Sanitize(x)));
return embed.AddFields(name, effectsParse, inline);
}

return embed.AddField(name, Translation.Get<BotTranslations>("Embed.Field.Effects.Content.None", culture), inline);
}

public static DiscordEmbedBuilder AddCriteriaFields(this DiscordEmbedBuilder embed, CriteriaReadOnlyCollection criteria, CultureInfo? culture, bool inline = false)
Expand Down
9 changes: 9 additions & 0 deletions Cyberia.Translations/Resources/BotTranslations.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cyberia.Translations/Resources/BotTranslations.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,7 @@ Pour fuir à 100%, il te faudra au minimum #4 agi.</value>
<data name="Rgpd.Deleted" xml:space="preserve">
<value>Toutes vos données personnelles ont été supprimées.</value>
</data>
<data name="Embed.Field.Effects.Content.None" xml:space="preserve">
<value>Aucun</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Cyberia.Translations/Resources/BotTranslations.resx
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,7 @@ To escape at 100%, you will need at minimum #4 agi.</value>
<data name="Rgpd.Deleted" xml:space="preserve">
<value>All your personal data has been deleted.</value>
</data>
<data name="Embed.Field.Effects.Content.None" xml:space="preserve">
<value>None</value>
</data>
</root>

0 comments on commit 61d4ed3

Please sign in to comment.