Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gp shop #644

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Arrowgene.Ddon.GameServer/Characters/WalletManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public WalletManager(DdonGameServer server)
Server = server;
WalletLimits = server.Setting.GameLogicSetting.WalletLimits;
}
public bool AddToWalletNtc(Client Client, Character Character, WalletType Type, uint Amount, uint BonusAmount = 0, ItemNoticeType updateType = ItemNoticeType.Default, DbConnection? connectionIn = null)

public uint AddToWalletNtc(Client Client, Character Character, WalletType Type, uint Amount, uint BonusAmount = 0, ItemNoticeType updateType = ItemNoticeType.Default, DbConnection? connectionIn = null)
{
CDataUpdateWalletPoint UpdateWalletPoint = AddToWallet(Character, Type, Amount, BonusAmount, connectionIn);

Expand All @@ -34,7 +35,7 @@ public bool AddToWalletNtc(Client Client, Character Character, WalletType Type,

Client.Send(UpdateCharacterItemNtc);

return true;
return UpdateWalletPoint.Value;
}

public CDataUpdateWalletPoint AddToWallet(Character Character, WalletType Type, uint Amount, uint BonusAmount = 0, DbConnection? connectionIn = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ public class MotherlodeCommand : ChatCommand
{
private static readonly Dictionary<string, WalletType> WalletTypeNames = new Dictionary<string, WalletType>()
{
{"G", WalletType.Gold},
{"RP", WalletType.RiftPoints},
{"BO", WalletType.BloodOrbs},
{"HO", WalletType.HighOrbs},
{"GG", WalletType.GoldenGemstones},
{"RC", WalletType.ResetCraftSkills}
{ "G", WalletType.Gold },
{ "RP", WalletType.RiftPoints },
{ "BO", WalletType.BloodOrbs },
{ "HO", WalletType.HighOrbs },
{ "GG", WalletType.GoldenGemstones },
{ "RC", WalletType.ResetCraftSkills },
{ "ST", WalletType.SilverTickets },
};

private static readonly uint DefaultAmount = 10000;
private static readonly HashSet<WalletType> DefaultWalletTypes = new HashSet<WalletType> {

private static readonly HashSet<WalletType> DefaultWalletTypes = new HashSet<WalletType>
{
WalletType.Gold,
WalletType.RiftPoints,
WalletType.BloodOrbs
Expand All @@ -42,8 +45,8 @@ public override void Execute(string[] command, GameClient client, ChatMessage me
{
uint amount = DefaultAmount;
if (command.Length >= 1)
{
if(UInt32.TryParse(command[0], out uint parsedAmount))
{
if (UInt32.TryParse(command[0], out uint parsedAmount))
{
amount = parsedAmount;
}
Expand All @@ -66,7 +69,8 @@ public override void Execute(string[] command, GameClient client, ChatMessage me
}
else
{
responses.Add(ChatResponse.CommandError(client, $"Invalid wallet type \"{arg}\". It must be one of the following: {string.Join(", ", WalletTypeNames.Keys)}"));
responses.Add(ChatResponse.CommandError(client,
$"Invalid wallet type \"{arg}\". It must be one of the following: {string.Join(", ", WalletTypeNames.Keys)}"));
return;
}
}
Expand All @@ -78,6 +82,7 @@ public override void Execute(string[] command, GameClient client, ChatMessage me
CDataUpdateWalletPoint updateWalletPoint = _server.WalletManager.AddToWallet(client.Character, walletType, amount);
updateCharacterItemNtc.UpdateWalletList.Add(updateWalletPoint);
}

client.Send(updateCharacterItemNtc);
}
}
Expand Down
31 changes: 26 additions & 5 deletions Arrowgene.Ddon.GameServer/DdonGameServer.cs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as in the other PR, it's better to have these in alphabetical order, as theyre already grouped by the group name prefix

Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ private void LoadPacketHandler()
AddHandler(new CharacterPawnGoldenReviveHandler(this));
AddHandler(new CharacterPawnPointReviveHandler(this));
AddHandler(new CharacterSetOnlineStatusHandler(this));
AddHandler(new CharacterEditGetShopPriceHandler(this));
AddHandler(new CharacterEditUpdateCharacterEditParamHandler(this));
AddHandler(new CharacterEditGetShopPriceHandler(this));
AddHandler(new CharacterEditUpdateCharacterEditParamHandler(this));
AddHandler(new CharacterEditUpdateCharacterEditParamExHandler(this));
AddHandler(new CharacterEditUpdatePawnEditParamHandler(this));
AddHandler(new CharacterEditUpdatePawnEditParamHandler(this));
AddHandler(new CharacterEditUpdatePawnEditParamExHandler(this));
AddHandler(new CharacterCharacterDeadHandler(this));
AddHandler(new CharacterCharacterDownCancelHandler(this));
Expand Down Expand Up @@ -313,6 +313,24 @@ private void LoadPacketHandler()
AddHandler(new CraftRecipeGetCraftRecipeHandler(this));
AddHandler(new CraftStartCraftHandler(this));
AddHandler(new CraftSkillUpHandler(this));

AddHandler(new GpShopDisplayTypeHandler(this));
AddHandler(new GpCogGetIdHandler(this));
AddHandler(new GpGetCapToGpChangeListHandler(this));
AddHandler(new GpChangeCapToGpHandler(this));
AddHandler(new GpCourseGetValidListHandler(this));
AddHandler(new GpShopGetBuyHistoryHandler(this));
AddHandler(new GpCourseUseFromAvailableHandler(this));
AddHandler(new GpGetCapHandler(this));

AddHandler(new GachaListHandler(this));
AddHandler(new BoxGachaListHandler(this));
AddHandler(new BoxGachaBuyHandler(this));
AddHandler(new GachaBuyHandler(this));
AddHandler(new BoxGachaDrawInfoHandler(this));

AddHandler(new EventCodeInputHandler(this));

AddHandler(new CraftGetCraftProductInfoHandler(this));
AddHandler(new CraftCancelCraftHandler(this));
AddHandler(new CraftTimeSaveHandler(this));
Expand Down Expand Up @@ -409,6 +427,7 @@ private void LoadPacketHandler()
AddHandler(new ItemGetSpecifiedHavingItemListHandler(this));
AddHandler(new ItemEmbodyItemsHandler(this));
AddHandler(new ItemChangeAttrDiscardHandler(this));
AddHandler(new ItemGetItemStorageInfoHandler(this));

AddHandler(new JobChangeJobHandler(this));
AddHandler(new JobChangePawnJobHandler(this));
Expand Down Expand Up @@ -503,6 +522,7 @@ private void LoadPacketHandler()
AddHandler(new PawnExpeditionGetSallyInfoHandler(this));

AddHandler(new PhotoPhotoTakeHandler(this));
AddHandler(new GetFreeRentalPawnListHandler(this));

AddHandler(new ProfileGetCharacterProfileHandler(this));
AddHandler(new ProfileGetMyCharacterProfileHandler(this));
Expand Down Expand Up @@ -532,6 +552,7 @@ private void LoadPacketHandler()
AddHandler(new QuestLeaderQuestProgressRequestHandler(this));
AddHandler(new QuestGetEndContentsGroupHandler(this));
AddHandler(new QuestGetCycleContentsNewsListHandler(this));

AddHandler(new QuestQuestOrderHandler(this));
AddHandler(new QuestQuestProgressHandler(this));
AddHandler(new QuestSendLeaderQuestOrderConditionInfoHandler(this));
Expand Down Expand Up @@ -651,8 +672,8 @@ private void LoadPacketHandler()
AddHandler(new StageGetSpAreaChangeInfoHandler(this));

AddHandler(new StampBonusCheckHandler(this));
AddHandler(new StampBonusGetListHandler(this));
AddHandler(new StampBonusReceiveDailyHandler(this));
AddHandler(new StampBonusGetListHandler(this));
AddHandler(new StampBonusReceiveDailyHandler(this));
AddHandler(new StampBonusReceiveTotalHandler(this));

AddHandler(new WarpAreaWarpHandler(this));
Expand Down
49 changes: 49 additions & 0 deletions Arrowgene.Ddon.GameServer/Handler/BoxGachaBuyHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Collections.Generic;
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.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class BoxGachaBuyHandler : GameRequestPacketHandler<C2SBoxGachaBuyReq, S2CBoxGachaBuyRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BoxGachaBuyHandler));

public BoxGachaBuyHandler(DdonGameServer server) : base(server)
{
}

public override S2CBoxGachaBuyRes Handle(GameClient client, C2SBoxGachaBuyReq request)
{
S2CBoxGachaBuyRes res = new S2CBoxGachaBuyRes();

// TODO: based on gacha ID & draw ID figure out which items were bought
res.BoxGachaId = request.BoxGachaId;
res.BoxGachaItemList.Add(new CDataBoxGachaItemInfo
{
ItemId = 13800,
ItemNum = 5,
ItemStock = 13,
Rank = 2,
Effect = 0,
Probability = 0,
DrawNum = 0
});

List<CDataItemUpdateResult> itemUpdateResult = new List<CDataItemUpdateResult>();
foreach (CDataBoxGachaItemInfo gachaItemInfo in res.BoxGachaItemList)
{
// TODO: support adding to item post
itemUpdateResult.AddRange(Server.ItemManager.AddItem(Server, client.Character, true, gachaItemInfo.ItemId, gachaItemInfo.ItemNum));
}

// TODO: based on Settlement ID figure out which currency was used
Server.WalletManager.RemoveFromWalletNtc(client, client.Character, WalletType.GoldenGemstones, request.Price);

return res;
}
}
}
37 changes: 37 additions & 0 deletions Arrowgene.Ddon.GameServer/Handler/BoxGachaDrawInfoHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class BoxGachaDrawInfoHandler : GameRequestPacketHandler<C2SBoxGachaDrawInfoReq, S2CBoxGachaDrawInfoRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BoxGachaDrawInfoHandler));

public BoxGachaDrawInfoHandler(DdonGameServer server) : base(server)
{
}

public override S2CBoxGachaDrawInfoRes Handle(GameClient client, C2SBoxGachaDrawInfoReq request)
{
S2CBoxGachaDrawInfoRes res = new S2CBoxGachaDrawInfoRes();

// Reflects received results to user in the appropriate tab
// TODO: unsure if request's DrawId should be directly sent back or box gacha ID should be figured out based on DrawId
res.BoxGachaId = 93;
res.BoxGachaItemList.Add(new CDataBoxGachaItemInfo
{
ItemId = 13800,
ItemNum = 5,
ItemStock = 13,
Rank = 2,
Effect = 0,
Probability = 0,
DrawNum = 0
});

return res;
}
}
}
71 changes: 71 additions & 0 deletions Arrowgene.Ddon.GameServer/Handler/BoxGachaListHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class BoxGachaListHandler : GameRequestPacketHandler<C2SBoxGachaListReq, S2CBoxGachaListRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BoxGachaListHandler));

public BoxGachaListHandler(DdonGameServer server) : base(server)
{
}

public override S2CBoxGachaListRes Handle(GameClient client, C2SBoxGachaListReq request)
{
S2CBoxGachaListRes res = new S2CBoxGachaListRes();

res.BoxGachaList.Add(new CDataBoxGachaInfo
{
Id = 93,
Begin = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - 1000,
End = DateTimeOffset.UtcNow.AddMonths(12).ToUnixTimeSeconds(),
Unk1 = true,
Name = "Consumables box lot",
Description = "Rare supplies are available!",
Detail =
"The \"Consumables Box Lot\" is a lottery that can be drawn by spending Silver Tickets.\r\n\r\nYou can get consumables such as \"White Dragon Seal Elixir, Top\" and \"Talisman of the Twin Gods\". \r\n\r\nYou can reset the contents of the box to its initial state with the <COL ffff00>About Box Treasure Slot</COL> reset button, so please use it when you have obtained all the items you are looking for.",
WeightDispType = 1,
FreeSpaceText = "",
ListAddr = "http://localhost:52099/sp_ingame/campaign/bnr/lotto/lot_icon_170316_03.jpg",
ImageAddr = "http://localhost:52099/sp_ingame/campaign/bnr/lotto/lot_icon_170316_03.jpg",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more localhost

SettlementList = new List<CDataBoxGachaSettlementInfo>
{
new()
{
DrawId = 199,
Id = 2,
Price = 10,
BasePrice = 10,
DrawNum = 1,
BonusNum = 0,
PurchaseNum = 0,
PurchaseMaxNum = 0,
SpecialPriceNum = 0,
SpecialPriceMaxNum = 0,
Unk1 = 0
}
},
BoxGachaSets = new List<CDataBoxGachaItemInfo>
{
new()
{
ItemId = 13800,
ItemNum = 5,
ItemStock = 13,
Rank = 2,
Effect = 0,
Probability = 0,
DrawNum = 0
}
}
});

return res;
}
}
}
37 changes: 37 additions & 0 deletions Arrowgene.Ddon.GameServer/Handler/EventCodeInputHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class EventCodeInputHandler : GameRequestPacketHandler<C2SEventCodeInputReq, S2CEventCodeInputRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(EventCodeInputHandler));

public EventCodeInputHandler(DdonGameServer server) : base(server)
{
}

public override S2CEventCodeInputRes Handle(GameClient client, C2SEventCodeInputReq request)
{
S2CEventCodeInputRes res = new S2CEventCodeInputRes();

// TODO: based on event code figure out which items should be sent
// https://h1g.jp/dd-on/?%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%82%B3%E3%83%BC%E3%83%89
// https://dengekionline.com/elem/000/001/138/1138291/
if (request.Code == "UPCT-YUAW-3K16-8255")
{
res.Name = "Silver Tickets and Trial Support Boat Course";
}
else
{
throw new ResponseErrorException(ErrorCode.ERROR_CODE_EVENT_CODE_INPUT_LOCK);
}

// TODO: send mail with items

return res;
}
}
}
Loading
Loading