Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from ethanmoffat/shop
Re-implement shop NPC dialog
- Loading branch information
Showing
45 changed files
with
1,257 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
|
||
namespace EOLib.Domain.Interact | ||
{ | ||
[AutoMappedType] | ||
public class MapNPCActions : IMapNPCActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
|
||
public MapNPCActions(IPacketSendService packetSendService) | ||
{ | ||
_packetSendService = packetSendService; | ||
} | ||
|
||
public void RequestShop(byte index) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Shop, PacketAction.Open) | ||
.AddShort(index) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
} | ||
|
||
public interface IMapNPCActions | ||
{ | ||
void RequestShop(byte index); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
|
||
namespace EOLib.Domain.Interact | ||
{ | ||
[AutoMappedType] | ||
public class PaperdollActions : IPaperdollActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
|
||
public PaperdollActions(IPacketSendService packetSendService) | ||
{ | ||
_packetSendService = packetSendService; | ||
} | ||
|
||
public void RequestPaperdoll(int characterId) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.PaperDoll, PacketAction.Request) | ||
.AddShort((short)characterId) | ||
.Build(); | ||
_packetSendService.SendPacket(packet); | ||
} | ||
} | ||
|
||
public interface IPaperdollActions | ||
{ | ||
void RequestPaperdoll(int characterId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
|
||
namespace EOLib.Domain.Interact.Shop | ||
{ | ||
[AutoMappedType] | ||
public class ShopActions : IShopActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
|
||
public ShopActions(IPacketSendService packetSendService) | ||
{ | ||
_packetSendService = packetSendService; | ||
} | ||
|
||
public void BuyItem(short itemId, int amount) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Shop, PacketAction.Buy) | ||
.AddShort(itemId) | ||
.AddInt(amount) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
|
||
public void SellItem(short itemId, int amount) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Shop, PacketAction.Sell) | ||
.AddShort(itemId) | ||
.AddInt(amount) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
|
||
public void CraftItem(short itemId) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Shop, PacketAction.Create) | ||
.AddShort(itemId) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
} | ||
|
||
public interface IShopActions | ||
{ | ||
void BuyItem(short itemId, int amount); | ||
|
||
void SellItem(short itemId, int amount); | ||
|
||
void CraftItem(short itemId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace EOLib.Domain.Interact.Shop | ||
{ | ||
public class ShopCraftIngredient : IShopCraftIngredient | ||
{ | ||
public int ID { get; } | ||
|
||
public int Amount { get; } | ||
|
||
public ShopCraftIngredient(int id, int amount) | ||
{ | ||
ID = id; | ||
Amount = amount; | ||
} | ||
} | ||
|
||
public interface IShopCraftIngredient | ||
{ | ||
int ID { get; } | ||
|
||
int Amount { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.Domain.Interact.Shop | ||
{ | ||
public class ShopCraftItem : IShopCraftItem | ||
{ | ||
public int ID { get; } | ||
|
||
public IReadOnlyList<IShopCraftIngredient> Ingredients { get; } | ||
|
||
public ShopCraftItem(int id, IEnumerable<IShopCraftIngredient> ingredients) | ||
{ | ||
ID = id; | ||
Ingredients = new List<IShopCraftIngredient>(ingredients); | ||
} | ||
} | ||
|
||
public interface IShopCraftItem | ||
{ | ||
int ID { get; } | ||
|
||
IReadOnlyList<IShopCraftIngredient> Ingredients { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using AutomaticTypeMapper; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.Domain.Interact.Shop | ||
{ | ||
public interface IShopDataRepository : IResettable | ||
{ | ||
int ShopID { get; set; } | ||
|
||
string ShopName { get; set; } | ||
|
||
List<IShopItem> TradeItems { get; set; } | ||
|
||
List<IShopCraftItem> CraftItems { get; set; } | ||
} | ||
|
||
public interface IShopDataProvider : IResettable | ||
{ | ||
int ShopID { get; } | ||
|
||
string ShopName { get; } | ||
|
||
IReadOnlyList<IShopItem> TradeItems { get; } | ||
|
||
IReadOnlyList<IShopCraftItem> CraftItems { get; } | ||
} | ||
|
||
[AutoMappedType(IsSingleton = true)] | ||
public class ShopDataRepository : IShopDataProvider, IShopDataRepository | ||
{ | ||
public int ShopID { get; set; } | ||
public string ShopName { get; set; } | ||
|
||
public List<IShopItem> TradeItems { get; set; } | ||
|
||
public List<IShopCraftItem> CraftItems { get; set; } | ||
|
||
IReadOnlyList<IShopItem> IShopDataProvider.TradeItems => TradeItems; | ||
|
||
IReadOnlyList<IShopCraftItem> IShopDataProvider.CraftItems => CraftItems; | ||
|
||
public ShopDataRepository() | ||
{ | ||
ResetState(); | ||
} | ||
|
||
public void ResetState() | ||
{ | ||
ShopID = 0; | ||
ShopName = string.Empty; | ||
TradeItems = new List<IShopItem>(); | ||
CraftItems = new List<IShopCraftItem>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace EOLib.Domain.Interact.Shop | ||
{ | ||
public class ShopItem : IShopItem | ||
{ | ||
public int ID { get; } | ||
|
||
public int Buy { get; } | ||
|
||
public int Sell { get; } | ||
|
||
public int MaxBuy { get; } | ||
|
||
public ShopItem(int id, int buyPrice, int sellPrice, int maxBuy) | ||
{ | ||
ID = id; | ||
Buy = buyPrice; | ||
Sell = sellPrice; | ||
MaxBuy = maxBuy; | ||
} | ||
} | ||
|
||
public interface IShopItem | ||
{ | ||
int ID { get; } | ||
|
||
int Buy { get; } | ||
|
||
int Sell { get; } | ||
|
||
int MaxBuy { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.