@@ -33,28 +33,37 @@ public static Resource GetRecommendedMap(LobbyHostingContext context)
3333 using ( var db = new ZkDataContext ( ) )
3434 {
3535 List < Resource > list = null ;
36- var players = context . Players . Count ( x => ! x . IsSpectator ) ;
36+ var humanPlayers = context . Players . Count ( x => ! x . IsSpectator ) ;
37+ var botPlayers = context . Bots . Count ;
38+ var allyteams = context . Players . Where ( x => ! x . IsSpectator ) . Select ( p => p . AllyID ) . Union ( context . Bots . Select ( b => b . AllyID ) ) . Distinct ( ) . Count ( ) ;
3739
3840 var level = context . IsMatchMakerGame ? MapSupportLevel . MatchMaker : MapSupportLevel . Featured ;
39-
40- if ( mode == AutohostMode . None && context . Players . Select ( p => p . AllyID ) . Union ( context . Bots . Select ( b => b . AllyID ) ) . Distinct ( ) . Count ( ) > 2 ) mode = AutohostMode . GameFFA ;
41- if ( mode == AutohostMode . None && context . Players . Select ( p => p . AllyID ) . Distinct ( ) . Count ( ) == 1 && context . Bots . Count > 0 && context . Bots . All ( b => b . IsChicken ) ) mode = AutohostMode . GameChickens ;
42- if ( mode == AutohostMode . None && context . Players . Count == 2 && context . Bots . Count == 0 && context . Players . Select ( p => p . AllyID ) . Distinct ( ) . Count ( ) == 2 ) mode = AutohostMode . Game1v1 ;
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 ;
51+ }
4352 switch ( mode )
4453 {
4554 case AutohostMode . Teams :
4655 case AutohostMode . None :
4756 var ret =
4857 db . Resources . Where (
4958 x => x . TypeID == ResourceType . Map && x . MapSupportLevel >= level && x . MapIsTeams != false && x . MapIsSpecial != true ) ;
50- if ( players > 11 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth > 16 * 16 ) ;
51- else if ( players > 8 )
59+ if ( humanPlayers > 11 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth > 16 * 16 ) ;
60+ else if ( humanPlayers > 8 )
5261 ret =
5362 ret . Where (
5463 x =>
5564 x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth > 16 * 16 &&
5665 x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 24 * 24 ) ;
57- else if ( players > 5 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 24 * 24 || x . MapIs1v1 == true ) ;
66+ else if ( humanPlayers > 5 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 24 * 24 || x . MapIs1v1 == true ) ;
5867 else ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 16 * 16 || x . MapIs1v1 == true ) ;
5968 list = ret . ToList ( ) ;
6069
@@ -70,29 +79,29 @@ public static Resource GetRecommendedMap(LobbyHostingContext context)
7079 x =>
7180 x . TypeID == ResourceType . Map && x . MapSupportLevel >= level && x . MapIsSpecial != true &&
7281 ( x . MapIsChickens == true || x . MapWaterLevel == 1 ) ) ;
73- if ( players > 5 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth > 16 * 16 ) ;
74- else if ( players > 4 )
82+ if ( humanPlayers > 5 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth > 16 * 16 ) ;
83+ else if ( humanPlayers > 4 )
7584 ret =
7685 ret . Where (
7786 x =>
7887 x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth > 16 * 16 &&
7988 x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 24 * 24 ) ;
80- else if ( players > 2 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 24 * 24 || x . MapIs1v1 == true ) ;
89+ else if ( humanPlayers > 2 ) ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 24 * 24 || x . MapIs1v1 == true ) ;
8190 else ret = ret . Where ( x => x . MapHeight * x . MapHeight + x . MapWidth * x . MapWidth <= 16 * 16 || x . MapIs1v1 == true ) ;
8291 list = ret . ToList ( ) ;
8392
8493 break ;
8594 case AutohostMode . GameFFA :
8695 list =
8796 db . Resources . Where (
88- x => x . TypeID == ResourceType . Map && x . MapSupportLevel >= level && x . MapIsFfa == true && x . MapFFAMaxTeams == players )
97+ x => x . TypeID == ResourceType . Map && x . MapSupportLevel >= level && x . MapIsFfa == true && x . MapFFAMaxTeams == allyteams )
8998 . ToList ( ) ;
9099 if ( ! list . Any ( ) )
91100 list =
92101 db . Resources . Where (
93102 x =>
94103 x . TypeID == ResourceType . Map && x . MapSupportLevel >= level && x . MapIsFfa == true &&
95- ( players % x . MapFFAMaxTeams == 0 ) ) . ToList ( ) ;
104+ ( humanPlayers % x . MapFFAMaxTeams == 0 ) ) . ToList ( ) ;
96105 if ( ! list . Any ( ) ) list = db . Resources . Where ( x => x . TypeID == ResourceType . Map && x . MapSupportLevel >= level && x . MapIsFfa == true ) . ToList ( ) ;
97106
98107 break ;
0 commit comments