Skip to content

Commit

Permalink
Allow Repeated Commanders for Lottery (Sometimes)
Browse files Browse the repository at this point in the history
- When selecting a commander the lottery normally removes an applicant who has recently served as commander. However, if there is only a single applicant on a given team then it will skip this step and allow serving as commander for multiple successive rounds
  • Loading branch information
data-bomb committed Jul 29, 2024
1 parent 048f1a7 commit a7976ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions Si_CommManagement/CommanderApplications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,24 @@ public static void Postfix(MusicJukeboxHandler __instance, GameMode __0)
continue;
}

// remove previous commanders from applicant list
for (int j = 0; j < previousCommanders.Count; j++)
// remove previous commanders from applicant list, if there is a choice
if (commanderApplicants[i].Count > 1)
{
RemovePlayer = commanderApplicants[i].Find(k => k == previousCommanders[j].Commander);
if (RemovePlayer != null)
for (int j = 0; j < previousCommanders.Count; j++)
{
MelonLogger.Msg("Removing applicant from 2 rounds ago from random selection: " + RemovePlayer.PlayerName);
GameMode.CurrentGameMode.SpawnUnitForPlayer(RemovePlayer, RemovePlayer.Team);
commanderApplicants[i].Remove(RemovePlayer);
RemovePlayer = commanderApplicants[i].Find(k => k == previousCommanders[j].Commander);
if (RemovePlayer != null)
{
MelonLogger.Msg("Removing applicant from 2 rounds ago from random selection: " + RemovePlayer.PlayerName);
GameMode.CurrentGameMode.SpawnUnitForPlayer(RemovePlayer, RemovePlayer.Team);
commanderApplicants[i].Remove(RemovePlayer);
}
}
}

if (commanderApplicants[i].Count == 0)
{
continue;
if (commanderApplicants[i].Count == 0)
{
continue;
}
}

int iCommanderIndex = randomIndex.Next(0, commanderApplicants[i].Count - 1);
Expand Down
2 changes: 1 addition & 1 deletion Si_CommManagement/Si_CommanderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License
using System.Linq;
using System.Collections.Generic;

[assembly: MelonInfo(typeof(CommanderManager), "Commander Management", "1.8.0", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(CommanderManager), "Commander Management", "1.8.1", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

Expand Down

0 comments on commit a7976ef

Please sign in to comment.