From 41588bd237d26c8ccc0375079678822e43a3c8a1 Mon Sep 17 00:00:00 2001 From: Acentech Dev Date: Wed, 15 Jul 2026 00:36:20 +0300 Subject: [PATCH] feat(CS-P2): registration fee (zen) + already-registered guard on Guardsman --- .../CastleSiege/CastleSiegeConfiguration.cs | 6 ++++++ .../CastleSiegeGuardsmanTalkPlugIn.cs | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/GameLogic/CastleSiege/CastleSiegeConfiguration.cs b/src/GameLogic/CastleSiege/CastleSiegeConfiguration.cs index 62a874a..d969d8d 100644 --- a/src/GameLogic/CastleSiege/CastleSiegeConfiguration.cs +++ b/src/GameLogic/CastleSiege/CastleSiegeConfiguration.cs @@ -25,6 +25,12 @@ public class CastleSiegeConfiguration /// Gets or sets how long the siege phase lasts. public TimeSpan SiegeDuration { get; set; } = TimeSpan.FromMinutes(10); + /// + /// Gets or sets the registration fee (in zen) a guild master must pay to register the guild + /// for the siege. 0 disables the fee. + /// + public int RegistrationFee { get; set; } = 100000; + /// /// Returns true if falls within a 5-second window of any configured /// registration-open time. diff --git a/src/GameLogic/CastleSiege/CastleSiegeGuardsmanTalkPlugIn.cs b/src/GameLogic/CastleSiege/CastleSiegeGuardsmanTalkPlugIn.cs index 6a00304..962a47b 100644 --- a/src/GameLogic/CastleSiege/CastleSiegeGuardsmanTalkPlugIn.cs +++ b/src/GameLogic/CastleSiege/CastleSiegeGuardsmanTalkPlugIn.cs @@ -65,8 +65,23 @@ public class CastleSiegeGuardsmanTalkPlugIn : IPlayerTalkToNpcPlugIn } } + if (context.RegisteredGuilds.Contains(guildName)) + { + await ShowAsync(player, $"Your guild '{guildName}' is already registered for the Castle Siege.").ConfigureAwait(false); + return; + } + + var fee = context.Configuration.RegistrationFee; + if (fee > 0 && !player.TryRemoveMoney(fee)) + { + await ShowAsync(player, $"You need {fee} zen to register your guild for the Castle Siege.").ConfigureAwait(false); + return; + } + context.RegisterGuild(guildName); - await ShowAsync(player, $"Your guild '{guildName}' is registered for the Castle Siege.").ConfigureAwait(false); + await ShowAsync(player, fee > 0 + ? $"Your guild '{guildName}' is registered for the Castle Siege. ({fee} zen paid)" + : $"Your guild '{guildName}' is registered for the Castle Siege.").ConfigureAwait(false); } private static ValueTask ShowAsync(Player player, string text)