Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
mod: move clan group size penalty to server configuration (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
namidaka authored Aug 11, 2023
1 parent 6f5feb3 commit 330a902
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Module.Server/Balancing/ClanGroup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Crpg.Module.Helpers;
using Crpg.Module.Common;
using Crpg.Module.Helpers;

namespace Crpg.Module.Balancing;

Expand All @@ -23,7 +24,7 @@ public void Add(WeightedCrpgUser user)

public float Weight(float p = MatchBalancer.PowerParameter)
{
const float clanGroupSizePenalty = 0.048f;
float clanGroupSizePenalty = CrpgServerConfiguration.TeamBalancerClanGroupSizePenalty;
return MathHelper.PowerSumBy(Members, u => u.Weight, p) * (1 + Size * clanGroupSizePenalty);
}

Expand Down
8 changes: 6 additions & 2 deletions src/Module.Server/Balancing/MatchBalancer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Crpg.Module.Common;
using Crpg.Module.Helpers;
using TaleWorlds.Library;

Expand Down Expand Up @@ -92,8 +93,11 @@ public GameMatch BannerBalancingWithEdgeCases(GameMatch gameMatch, bool firstBal
{
// This are failcases in case bannerbalance was not enough
Debug.Print("ratio difference is above 10%");
// disabled because does not take in account clangroup penalty yet
// balancedBannerGameMatch = BalanceTeamOfSimilarSizes(balancedBannerGameMatch, bannerBalance: false, 0.10f);
// to rewrite to work with all penalty values
if (CrpgServerConfiguration.TeamBalancerClanGroupSizePenalty == 0f)
{
balancedBannerGameMatch = BalanceTeamOfSimilarSizes(balancedBannerGameMatch, bannerBalance: false, 0.10f);
}

if (IsBalanceGoodEnough(balancedBannerGameMatch, maxSizeRatio: 0.85f, maxDifference: 10f, percentageDifference: 0.15f))
{
Expand Down
17 changes: 17 additions & 0 deletions src/Module.Server/Common/CrpgServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,28 @@ public static void Init()
public static CrpgRegion Region { get; }
public static string Service { get; }
public static string Instance { get; }
public static float TeamBalancerClanGroupSizePenalty { get; private set; } = 0f;
public static float ServerExperienceMultiplier { get; private set; } = 1.0f;
public static int RewardTick { get; private set; } = 60;
public static bool TeamBalanceOnce { get; private set; }
public static Tuple<TimeSpan, TimeSpan, TimeZoneInfo>? HappyHours { get; private set; }

[UsedImplicitly]
[ConsoleCommandMethod("crpg_team_balancer_clan_group_size_penalty", "Apply a rating increase to members of the same clan that are playing in the same team")]
private static void SetClanGroupSizePenalty(string? sizePenaltyStr)
{
if (sizePenaltyStr == null
|| !float.TryParse(sizePenaltyStr, out float sizePenalty)
|| sizePenalty > 1.5f)
{
Debug.Print($"Invalid team balancer clangroup size penalty: {sizePenaltyStr}");
return;
}

TeamBalancerClanGroupSizePenalty = sizePenalty;
Debug.Print($"Set ClanGroup Size Penalty to {sizePenalty}");
}

[UsedImplicitly]
[ConsoleCommandMethod("crpg_experience_multiplier", "Sets a reward multiplier for the server.")]
private static void SetServerExperienceMultiplier(string? multiplierStr)
Expand Down

0 comments on commit 330a902

Please sign in to comment.