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

Configurable bazaar timers and bazaar related GP course effects #665

Merged
merged 2 commits into from
Dec 19, 2024
Merged
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
19 changes: 12 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,16 @@ public uint ReceiveProceeds(GameClient client)
foreach (BazaarExhibition exhibition in exhibitionsToReceive)
{
exhibition.Info.State = BazaarExhibitionState.Idle;
exhibition.Info.Expire = now.Add(COOLDOWN_TIME_SPAN);
ulong totalCooldown;
try
{
totalCooldown = Server.Setting.GameLogicSetting.BazaarCooldownTimeSeconds - Server.GpCourseManager.BazaarReExhibitShorten();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel you could've just checked to see if the shorten time is larger than the time left but I guess this works.

}
catch (OverflowException _)
{
totalCooldown = 0;
}
exhibition.Info.Expire = now.AddSeconds(totalCooldown);
Server.Database.UpdateBazaarExhibiton(exhibition);
}

Expand Down
24 changes: 24 additions & 0 deletions Arrowgene.Ddon.GameServer/Characters/GpCourseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ internal class CourseBonus
public bool DisablePartyExpAdjustment = false;
public double EnemyBloodOrbMultiplier = 0.0;
public bool InfiniteRevive = false;
public uint BazaarExhibitExtend = 0;
public ulong BazaarReExhibitShorten = 0;
};

private void ApplyCourseEffects(uint courseId)
Expand Down Expand Up @@ -73,6 +75,12 @@ private void ApplyCourseEffects(uint courseId)
case GPCourseId.InfiniteRevive:
_CourseBonus.InfiniteRevive = true;
break;
case GPCourseId.BazaarExhibitExtend:
_CourseBonus.BazaarExhibitExtend += effect.Param0;
break;
case GPCourseId.BazaarReExhibitShorten:
_CourseBonus.BazaarReExhibitShorten += effect.Param0;
break;
}
}
}
Expand Down Expand Up @@ -250,5 +258,21 @@ public bool InfiniteReviveRefresh()
return _CourseBonus.InfiniteRevive;
}
}

public uint BazaarExhibitExtend()
{
lock (_CourseBonus)
{
return _CourseBonus.BazaarExhibitExtend;
}
}

public ulong BazaarReExhibitShorten()
{
lock (_CourseBonus)
{
return _CourseBonus.BazaarReExhibitShorten;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public override S2CBazaarGetExhibitPossibleNumRes Handle(GameClient client, C2SB
{
return new S2CBazaarGetExhibitPossibleNumRes()
{
Num = client.Character.MaxBazaarExhibits,
Add = 0 // TODO: Figure out
Num = client.Character.MaxBazaarExhibits + Server.GpCourseManager.BazaarExhibitExtend(),
Add = Server.GpCourseManager.BazaarExhibitExtend() // Not sure what the purpose of this value is
};
}
}
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
Loading