Skip to content

Commit

Permalink
Added configurable bazaar timers
Browse files Browse the repository at this point in the history
  • Loading branch information
alborrajo committed Dec 19, 2024
1 parent 86fe018 commit dd995b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Arrowgene.Ddon.GameServer/BazaarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public class BazaarManager
{
private static readonly double TAXES = 0.05; // 5%, value taken from the ingame menu

// TODO: Make it configurable
private static readonly TimeSpan EXHIBITION_TIME_SPAN = TimeSpan.FromDays(3);
private static readonly TimeSpan COOLDOWN_TIME_SPAN = TimeSpan.FromDays(1);

public BazaarManager(DdonGameServer server)
{
Server = server;
Expand Down Expand Up @@ -43,7 +39,7 @@ public ulong Exhibit(GameClient client, StorageType storageType, string itemUID,
exhibition.Info.ItemInfo.ExhibitionTime = now;
exhibition.Info.State = BazaarExhibitionState.OnSale;
exhibition.Info.Proceeds = calculateProceeds(exhibition.Info.ItemInfo.ItemBaseInfo);
exhibition.Info.Expire = now.Add(EXHIBITION_TIME_SPAN);
exhibition.Info.Expire = now.AddSeconds(Server.Setting.GameLogicSetting.BazaarExhibitionTimeSeconds);

ulong bazaarId = Server.Database.InsertBazaarExhibition(exhibition);
return bazaarId;
Expand All @@ -63,7 +59,7 @@ public ulong ReExhibit(ulong bazaarId, uint newPrice)
exhibition.Info.ItemInfo.ItemBaseInfo.Price = newPrice;
exhibition.Info.ItemInfo.ExhibitionTime = now;
exhibition.Info.Proceeds = calculateProceeds(exhibition.Info.ItemInfo.ItemBaseInfo);
exhibition.Info.Expire = now.Add(EXHIBITION_TIME_SPAN);
exhibition.Info.Expire = now.AddSeconds(Server.Setting.GameLogicSetting.BazaarExhibitionTimeSeconds);
Server.Database.UpdateBazaarExhibiton(exhibition);

return exhibition.Info.ItemInfo.BazaarId;
Expand Down Expand Up @@ -158,7 +154,7 @@ public uint ReceiveProceeds(GameClient client)
foreach (BazaarExhibition exhibition in exhibitionsToReceive)
{
exhibition.Info.State = BazaarExhibitionState.Idle;
exhibition.Info.Expire = now.Add(COOLDOWN_TIME_SPAN);
exhibition.Info.Expire = now.AddSeconds(Server.Setting.GameLogicSetting.BazaarCooldownTimeSeconds);
Server.Database.UpdateBazaarExhibiton(exhibition);
}

Expand Down
19 changes: 19 additions & 0 deletions Arrowgene.Ddon.Server/GameLogicSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,25 @@ public class GameLogicSetting
/// </summary>
[DataMember(Order = 37)] public bool? EnableEpitaphWeeklyRewards { get; set; } = true;

/// <summary>
/// Enables main pawns in party to gain EXP and JP from quests
/// Original game apparantly did not have pawns share quest reward, so will set to false for default,
/// change as needed
/// </summary>
[DataMember(Order = 38)] public bool EnableMainPartyPawnsQuestRewards { get; set; }

/// <summary>
/// Specifies the time in seconds that a bazaar exhibit will last.
/// By default, the equivalent of 3 days
/// </summary>
[DataMember(Order = 37)] public ulong BazaarExhibitionTimeSeconds { get; set; }

/// <summary>
/// Specifies the time in seconds that a slot in the bazaar won't be able to be used again.
/// By default, the equivalent of 1 day
/// </summary>
[DataMember(Order = 38)] public ulong BazaarCooldownTimeSeconds { get; set; }

/// <summary>
/// Various URLs used by the client.
/// Shared with the login server.
Expand Down Expand Up @@ -334,6 +347,9 @@ public GameLogicSetting()
EnableEpitaphWeeklyRewards = false;
EnableMainPartyPawnsQuestRewards = false;

BazaarExhibitionTimeSeconds = (ulong) TimeSpan.FromDays(3).TotalSeconds;
BazaarCooldownTimeSeconds = (ulong) TimeSpan.FromDays(1).TotalSeconds;

string urlDomain = $"http://localhost:{52099}";
UrlManual = $"{urlDomain}/manual_nfb/";
UrlShopDetail = $"{urlDomain}/shop/ingame/stone/detail";
Expand Down Expand Up @@ -400,6 +416,9 @@ public GameLogicSetting(GameLogicSetting setting)
EnableEpitaphWeeklyRewards = setting.EnableEpitaphWeeklyRewards;
EnableMainPartyPawnsQuestRewards = setting.EnableMainPartyPawnsQuestRewards;

BazaarExhibitionTimeSeconds = setting.BazaarExhibitionTimeSeconds;
BazaarCooldownTimeSeconds = setting.BazaarCooldownTimeSeconds;

UrlManual = setting.UrlManual;
UrlShopDetail = setting.UrlShopDetail;
UrlShopCounterA = setting.UrlShopCounterA;
Expand Down

0 comments on commit dd995b5

Please sign in to comment.