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

mod : ClanGroup Size Penalty moved to server configuration #1204

Merged
merged 5 commits into from
Aug 11, 2023
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
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
Loading