Skip to content

Commit 3d338bb

Browse files
committed
select mostly chicken maps for chicken game mode, select teams maps for non-chicken bot matches
1 parent 824270f commit 3d338bb

1 file changed

Lines changed: 38 additions & 20 deletions

File tree

ZkLobbyServer/autohost/MapPicker.cs

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace ZeroKWeb.SpringieInterface
1212
{
1313
public static class MapPicker
1414
{
15+
private static Random chickenRand = new Random();
16+
private static bool UseNormalMapForChickens { get { return chickenRand.Next(3) == 0; } }
1517
/// <summary>
1618
/// Picks a map and writes a message if applicable
1719
/// </summary>
@@ -38,16 +40,22 @@ public static Resource GetRecommendedMap(LobbyHostingContext context)
3840
var allyteams = context.Players.Where(x => !x.IsSpectator).Select(p => p.AllyID).Union(context.Bots.Select(b => b.AllyID)).Distinct().Count();
3941

4042
var level = context.IsMatchMakerGame ? MapSupportLevel.MatchMaker : MapSupportLevel.Featured;
41-
42-
if (mode == AutohostMode.GameFFA)
43-
{
44-
allyteams = humanPlayers;
45-
}
46-
if (mode == AutohostMode.None)
47-
{
48-
if (allyteams > 2) mode = AutohostMode.GameFFA;
49-
if (context.Players.Where(x => !x.IsSpectator).Select(p => p.AllyID).Distinct().Count() == 1 && botPlayers > 0 && context.Bots.Any(b => b.IsChicken)) mode = AutohostMode.GameChickens;
50-
if (humanPlayers == 2 && botPlayers == 0 && allyteams == 2) mode = AutohostMode.Game1v1;
43+
44+
45+
switch (mode) {
46+
case AutohostMode.GameChickens:
47+
if (!context.Bots.Any(b => b.IsChicken)) mode = AutohostMode.Teams;
48+
break;
49+
50+
case AutohostMode.GameFFA:
51+
allyteams = humanPlayers;
52+
break;
53+
54+
case AutohostMode.None:
55+
if (allyteams > 2) mode = AutohostMode.GameFFA;
56+
if (context.Players.Where(x => !x.IsSpectator).Select(p => p.AllyID).Distinct().Count() == 1 && botPlayers > 0 && context.Bots.Any(b => b.IsChicken)) mode = AutohostMode.GameChickens;
57+
if (humanPlayers == 2 && botPlayers == 0 && allyteams == 2) mode = AutohostMode.Game1v1;
58+
break;
5159
}
5260
switch (mode)
5361
{
@@ -74,20 +82,30 @@ public static Resource GetRecommendedMap(LobbyHostingContext context)
7482
x => x.TypeID == ResourceType.Map && x.MapSupportLevel >= level && x.MapIs1v1 == true && x.MapIsSpecial != true).ToList();
7583
break;
7684
case AutohostMode.GameChickens:
77-
ret =
85+
if (UseNormalMapForChickens)
86+
{
87+
ret =
7888
db.Resources.Where(
7989
x =>
8090
x.TypeID == ResourceType.Map && x.MapSupportLevel >= level && x.MapIsSpecial != true &&
81-
(x.MapIsChickens == true || x.MapWaterLevel == 1));
82-
if (humanPlayers > 5) ret = ret.Where(x => x.MapHeight*x.MapHeight + x.MapWidth*x.MapWidth > 16*16);
83-
else if (humanPlayers > 4)
91+
(x.MapWaterLevel == 1));
92+
if (humanPlayers > 5) ret = ret.Where(x => x.MapHeight * x.MapHeight + x.MapWidth * x.MapWidth > 16 * 16);
93+
else if (humanPlayers > 4)
94+
ret =
95+
ret.Where(
96+
x =>
97+
x.MapHeight * x.MapHeight + x.MapWidth * x.MapWidth > 16 * 16 &&
98+
x.MapHeight * x.MapHeight + x.MapWidth * x.MapWidth <= 24 * 24);
99+
else if (humanPlayers > 2) ret = ret.Where(x => x.MapHeight * x.MapHeight + x.MapWidth * x.MapWidth <= 24 * 24 || x.MapIs1v1 == true);
100+
else ret = ret.Where(x => x.MapHeight * x.MapHeight + x.MapWidth * x.MapWidth <= 16 * 16 || x.MapIs1v1 == true);
101+
}else
102+
{
84103
ret =
85-
ret.Where(
86-
x =>
87-
x.MapHeight*x.MapHeight + x.MapWidth*x.MapWidth > 16*16 &&
88-
x.MapHeight*x.MapHeight + x.MapWidth*x.MapWidth <= 24*24);
89-
else if (humanPlayers > 2) ret = ret.Where(x => x.MapHeight*x.MapHeight + x.MapWidth*x.MapWidth <= 24*24 || x.MapIs1v1 == true);
90-
else ret = ret.Where(x => x.MapHeight*x.MapHeight + x.MapWidth*x.MapWidth <= 16*16 || x.MapIs1v1 == true);
104+
db.Resources.Where(
105+
x =>
106+
x.TypeID == ResourceType.Map && x.MapSupportLevel >= level && x.MapIsSpecial != true && x.MapIsChickens == true);
107+
}
108+
91109
list = ret.ToList();
92110

93111
break;

0 commit comments

Comments
 (0)