Skip to content

Commit

Permalink
add protected in choiceType
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwcgt committed Jan 2, 2025
1 parent 1cb2c86 commit 92c76cc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions osu.Game.Tournament/Models/BeatmapChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ public enum ChoiceType
{
Pick,
Ban,
Protected,
}
}
35 changes: 33 additions & 2 deletions osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public partial class MapPoolScreen : TournamentMatchScreen
private TeamColour pickColour;
private ChoiceType pickType;

private OsuButton buttonRedProtected = null!;
private OsuButton buttonBlueProtected = null!;
private OsuButton buttonRedBan = null!;
private OsuButton buttonBlueBan = null!;
private OsuButton buttonRedPick = null!;
Expand Down Expand Up @@ -67,6 +69,18 @@ private void load(MatchIPCInfo ipc)
{
Text = "Current Mode"
},
buttonRedProtected = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Red Protect",
Action = () => setMode(TeamColour.Red, ChoiceType.Protected)
},
buttonBlueProtected = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Blue Protect",
Action = () => setMode(TeamColour.Blue, ChoiceType.Protected)
},
buttonRedBan = new TourneyButton
{
RelativeSizeAxes = Axes.X,
Expand Down Expand Up @@ -141,6 +155,8 @@ private void setMode(TeamColour colour, ChoiceType choiceType)
pickColour = colour;
pickType = choiceType;

buttonRedProtected.Colour = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Protected);
buttonBlueProtected.Colour = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Protected);
buttonRedBan.Colour = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Ban);
buttonBlueBan.Colour = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Ban);
buttonRedPick.Colour = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Pick);
Expand All @@ -160,8 +176,16 @@ private void setNextMode()

TeamColour nextColour;

bool hasAllProtected = CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Protected) >= 2;

bool hasAllBans = CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= totalBansRequired;

if (!hasAllProtected)
{
setMode(getOppositeTeamColour(lastPickColour), ChoiceType.Protected);
return;
}

if (!hasAllBans)
{
// Ban phase: switch teams every second ban.
Expand Down Expand Up @@ -223,8 +247,15 @@ private void addForBeatmap(int beatmapId)
// don't attempt to add if the beatmap isn't in our pool
return;

if (CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
// don't attempt to add if already exists.
if (pickType == ChoiceType.Protected && CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
return;

if (pickType == ChoiceType.Ban && CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
// don't ban if already protected.
return;

if (pickType == ChoiceType.Pick && CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId && p.Type != ChoiceType.Protected))
// don't pick if map already in pickbans unless is protected.
return;

CurrentMatch.Value.PicksBans.Add(new BeatmapChoice
Expand Down

0 comments on commit 92c76cc

Please sign in to comment.