-
Notifications
You must be signed in to change notification settings - Fork 53
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 #249 from alborrajo/feature/crafting
Initial crafting and bazaar implementation
- Loading branch information
Showing
86 changed files
with
5,965 additions
and
133 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
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
Arrowgene.Ddon.GameServer/Handler/BazaarGetCharacterListHandler.cs
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,21 @@ | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class BazaarGetCharacterListHandler : GameStructurePacketHandler<C2SBazaarGetCharacterListReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BazaarGetCharacterListHandler)); | ||
|
||
public BazaarGetCharacterListHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SBazaarGetCharacterListReq> packet) | ||
{ | ||
client.Send(new S2CBazaarGetCharacterListRes()); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Arrowgene.Ddon.GameServer/Handler/BazaarGetExhibitPossibleNumHandler.cs
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,21 @@ | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class BazaarGetExhibitPossibleNumHandler : GameStructurePacketHandler<C2SBazaarGetExhibitPossibleNumReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BazaarGetExhibitPossibleNumHandler)); | ||
|
||
public BazaarGetExhibitPossibleNumHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SBazaarGetExhibitPossibleNumReq> packet) | ||
{ | ||
client.Send(new S2CBazaarGetExhibitPossibleNumRes()); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Arrowgene.Ddon.GameServer/Handler/BazaarGetItemHistoryInfoHandler.cs
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,21 @@ | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class BazaarGetItemHistoryInfoHandler : GameStructurePacketHandler<C2SBazaarGetItemHistoryInfoReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BazaarGetItemHistoryInfoHandler)); | ||
|
||
public BazaarGetItemHistoryInfoHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SBazaarGetItemHistoryInfoReq> packet) | ||
{ | ||
client.Send(new S2CBazaarGetItemHistoryInfoRes()); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Arrowgene.Ddon.GameServer/Handler/BazaarGetItemInfoHandler.cs
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,44 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Server.Network; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class BazaarGetItemInfoHandler : GameStructurePacketHandler<C2SBazaarGetItemInfoReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BazaarGetItemInfoHandler)); | ||
|
||
public BazaarGetItemInfoHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SBazaarGetItemInfoReq> packet) | ||
{ | ||
// TODO: Fetch from DB | ||
|
||
ClientItemInfo queriedItem = ClientItemInfo.GetInfoForItemId(Server.AssetRepository.ClientItemInfos, packet.Structure.ItemId); | ||
S2CBazaarGetItemInfoRes res = new S2CBazaarGetItemInfoRes(); | ||
for (ushort i = 1; i <= 10; i++) | ||
{ | ||
res.BazaarItemList.Add(new CDataBazaarItemInfo() | ||
{ | ||
BazaarId = 0, | ||
Sequence = 0, | ||
ItemBaseInfo = new CDataBazaarItemBaseInfo() { | ||
ItemId = packet.Structure.ItemId, | ||
Num = i, | ||
Price = (uint) queriedItem.Price * i, | ||
}, | ||
ExhibitionTime = 0 | ||
}); | ||
} | ||
client.Send(res); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Arrowgene.Ddon.GameServer/Handler/BazaarGetItemListHandler.cs
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 System.Linq; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class BazaarGetItemListHandler : GameStructurePacketHandler<C2SBazaarGetItemListReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BazaarGetItemListHandler)); | ||
|
||
public BazaarGetItemListHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SBazaarGetItemListReq> packet) | ||
{ | ||
// TODO: Fetch from DB | ||
|
||
client.Send(new S2CBazaarGetItemListRes() { | ||
ItemList = packet.Structure.ItemIdList.Select(itemId => new CDataBazaarItemNumOfExhibitionInfo() | ||
{ | ||
ItemId = itemId.Value, | ||
Num = (ushort) Enumerable.Range(1, 10).Sum() | ||
}).ToList() | ||
}); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
Arrowgene.Ddon.GameServer/Handler/BazaarProceedsHandler.cs
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,77 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Linq; | ||
using Arrowgene.Ddon.GameServer.Characters; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class BazaarProceedsHandler : GameStructurePacketHandler<C2SBazaarProceedsReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BazaarProceedsHandler)); | ||
|
||
private readonly ItemManager _itemManager; | ||
|
||
public BazaarProceedsHandler(DdonGameServer server) : base(server) | ||
{ | ||
_itemManager = server.ItemManager; | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SBazaarProceedsReq> packet) | ||
{ | ||
// TODO: Fetch price by the BazaarId | ||
ClientItemInfo boughtItemInfo = ClientItemInfo.GetInfoForItemId(Server.AssetRepository.ClientItemInfos, packet.Structure.ItemId); | ||
int totalItemAmount = packet.Structure.ItemStorageIndicateNum.Select(x => (int) x.ItemNum).Sum(); | ||
int totalPrice = boughtItemInfo.Price * totalItemAmount; | ||
|
||
S2CBazaarProceedsRes res = new S2CBazaarProceedsRes(); | ||
res.BazaarId = packet.Structure.BazaarId; | ||
|
||
S2CItemUpdateCharacterItemNtc updateCharacterItemNtc = new S2CItemUpdateCharacterItemNtc(); | ||
updateCharacterItemNtc.UpdateType = 0; | ||
|
||
// UPDATE CHARACTER WALLET | ||
CDataWalletPoint wallet = client.Character.WalletPointList.Where(wp => wp.Type == WalletType.Gold).Single(); | ||
wallet.Value = (uint) Math.Max(0, wallet.Value - totalPrice); | ||
Database.UpdateWalletPoint(client.Character.CharacterId, wallet); | ||
updateCharacterItemNtc.UpdateWalletList.Add(new CDataUpdateWalletPoint() | ||
{ | ||
Type = WalletType.Gold, | ||
AddPoint = (int) -totalPrice, | ||
Value = wallet.Value | ||
}); | ||
|
||
// UPDATE INVENTORY | ||
foreach (CDataItemStorageIndicateNum itemStorageIndicateNum in packet.Structure.ItemStorageIndicateNum) | ||
{ | ||
bool sendToItemBag; | ||
switch(itemStorageIndicateNum.StorageType) { | ||
case 19: | ||
// If packet.Structure.Destination is 19: Send to corresponding item bag | ||
sendToItemBag = true; | ||
break; | ||
case 20: | ||
// If packet.Structure.Destination is 20: Send to storage | ||
sendToItemBag = false; | ||
break; | ||
default: | ||
throw new Exception("Unexpected destination when buying goods: "+itemStorageIndicateNum.StorageType); | ||
} | ||
|
||
CDataItemUpdateResult? itemUpdateResult = _itemManager.AddItem(Server, client.Character, sendToItemBag, packet.Structure.ItemId, itemStorageIndicateNum.ItemNum); | ||
updateCharacterItemNtc.UpdateItemList.Add(itemUpdateResult); | ||
} | ||
|
||
// Send packets | ||
client.Send(updateCharacterItemNtc); | ||
client.Send(res); | ||
// TODO: Send the NTC to the seller? | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Arrowgene.Ddon.GameServer/Handler/CraftGetCraftIRCollectionValueListHandler.cs
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 Arrowgene.Ddon.GameServer.Dump; | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using Arrowgene.Logging; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class CraftGetCraftIRCollectionValueListHandler : GameStructurePacketHandler<C2SCraftGetCraftIRCollectionValueListReq> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(CraftGetCraftIRCollectionValueListHandler)); | ||
|
||
public CraftGetCraftIRCollectionValueListHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SCraftGetCraftIRCollectionValueListReq> packet) | ||
{ | ||
S2CCraftGetCraftIRCollectionValueListRes res = EntitySerializer.Get<S2CCraftGetCraftIRCollectionValueListRes>().Read(InGameDump.data_Dump_109); | ||
client.Send(res); | ||
} | ||
} | ||
} |
Oops, something went wrong.