Skip to content

Commit

Permalink
Add quest effect to show item gain in chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 25, 2023
1 parent febeffd commit ca6966b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Edelstein.Protocol.Utilities.Packets;

namespace Edelstein.Common.Gameplay.Game.Objects.User.Effects;

public record QuestEffect(
ICollection<Tuple<int, int>> Items
) : IPacketWritable
{
public void WriteTo(IPacketWriter writer)
{
writer.WriteByte((byte)EffectType.Quest);
writer.WriteByte((byte)Items.Count);
foreach (var tuple in Items)
{
writer.WriteInt(tuple.Item1);
writer.WriteInt(tuple.Item2);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Immutable;
using System.Text;
using Edelstein.Common.Gameplay.Constants;
using Edelstein.Common.Gameplay.Game.Objects.User.Effects;
using Edelstein.Common.Gameplay.Game.Objects.User.Messages;
using Edelstein.Common.Gameplay.Models.Inventories.Items;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
Expand Down Expand Up @@ -216,6 +217,10 @@ public async Task<QuestResultType> Act(QuestAction action, IQuestTemplate templa
} else
await user.ModifyInventory(i => i.Remove(reward.ItemID, Math.Abs((short)reward.Count)));
}

await user.Effect(new QuestEffect(rewards
.Select(r => Tuple.Create(r.ItemID, r.Count))
.ToImmutableList()));
}

return QuestResultType.Success;
Expand Down

0 comments on commit ca6966b

Please sign in to comment.