Skip to content

Commit a7976ef

Browse files
committed
Allow Repeated Commanders for Lottery (Sometimes)
- 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
1 parent 048f1a7 commit a7976ef

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Si_CommManagement/CommanderApplications.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,24 @@ public static void Postfix(MusicJukeboxHandler __instance, GameMode __0)
173173
continue;
174174
}
175175

176-
// remove previous commanders from applicant list
177-
for (int j = 0; j < previousCommanders.Count; j++)
176+
// remove previous commanders from applicant list, if there is a choice
177+
if (commanderApplicants[i].Count > 1)
178178
{
179-
RemovePlayer = commanderApplicants[i].Find(k => k == previousCommanders[j].Commander);
180-
if (RemovePlayer != null)
179+
for (int j = 0; j < previousCommanders.Count; j++)
181180
{
182-
MelonLogger.Msg("Removing applicant from 2 rounds ago from random selection: " + RemovePlayer.PlayerName);
183-
GameMode.CurrentGameMode.SpawnUnitForPlayer(RemovePlayer, RemovePlayer.Team);
184-
commanderApplicants[i].Remove(RemovePlayer);
181+
RemovePlayer = commanderApplicants[i].Find(k => k == previousCommanders[j].Commander);
182+
if (RemovePlayer != null)
183+
{
184+
MelonLogger.Msg("Removing applicant from 2 rounds ago from random selection: " + RemovePlayer.PlayerName);
185+
GameMode.CurrentGameMode.SpawnUnitForPlayer(RemovePlayer, RemovePlayer.Team);
186+
commanderApplicants[i].Remove(RemovePlayer);
187+
}
185188
}
186-
}
187189

188-
if (commanderApplicants[i].Count == 0)
189-
{
190-
continue;
190+
if (commanderApplicants[i].Count == 0)
191+
{
192+
continue;
193+
}
191194
}
192195

193196
int iCommanderIndex = randomIndex.Next(0, commanderApplicants[i].Count - 1);

Si_CommManagement/Si_CommanderManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License
3434
using System.Linq;
3535
using System.Collections.Generic;
3636

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

0 commit comments

Comments
 (0)