Skip to content

Commit

Permalink
Consider mp_halftime in max rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
abnerfs committed Feb 25, 2024
1 parent 02df466 commit 139443b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Core/MaxRoundsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class MaxRoundsManager : IPluginDependency<Plugin, Config>

private GameRules _gameRules;
private ConVar? _maxRounds;
private int MaxRoundsValue => _maxRounds!.GetPrimitiveValue<int>();
private ConVar? _halfTime;
private int MaxRoundsValue => _maxRounds?.GetPrimitiveValue<int>() ?? 0;
private bool HalfTime => _halfTime?.GetPrimitiveValue<bool>() ?? true;

public bool UnlimitedRounds => MaxRoundsValue <= 0;
private bool _lastBeforeHalf = false;
public int RemainingRounds
Expand Down Expand Up @@ -43,6 +46,9 @@ public int MaxWins
if (MaxRoundsValue <= 0)
return 0;

if (!HalfTime)
return MaxRoundsValue;

return ((int)Math.Floor(MaxRoundsValue / 2M)) + 1;
}
}
Expand All @@ -57,6 +63,7 @@ public MaxRoundsManager(GameRules gameRules)
void LoadCvar()
{
_maxRounds = ConVar.Find("mp_maxrounds");
_halfTime = ConVar.Find("mp_halftime");
}


Expand Down
2 changes: 1 addition & 1 deletion Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void ConfigureServices(IServiceCollection serviceCollection)
public partial class Plugin : BasePlugin, IPluginConfig<Config>
{
public override string ModuleName => "RockTheVote";
public override string ModuleVersion => "1.7.1";
public override string ModuleVersion => "1.7.2";
public override string ModuleAuthor => "abnerfs";
public override string ModuleDescription => "General purpose map voting plugin";

Expand Down

0 comments on commit 139443b

Please sign in to comment.