示例#1
0
 public LobbyQueue(GameType gameType, LobbyGameConfig gameConfig)
 {
     GameType  = gameType;
     SubTypes  = gameConfig.SubTypes;
     Players   = new List <LobbyServerConnection>();
     QueueInfo = new LobbyMatchmakingQueueInfo()
     {
         QueuedPlayers    = 0,
         AverageWaitTime  = TimeSpan.FromSeconds(500),
         GameConfig       = gameConfig,
         PlayersPerMinute = 1,
         QueueStatus      = Framework.Constants.Enums.QueueStatus.Idle,
         ShowQueueSize    = true
     };
     MatchId = 0;
 }
示例#2
0
        private void CreatePvPQueue()
        {
            LobbyGameConfig gameConfig = new LobbyGameConfig()
            {
                GameType            = GameType.PvP,
                IsActive            = true,
                GameOptionFlags     = GameOptionFlag.EnableTeamAIOutput | GameOptionFlag.ReplaceHumansWithBots,
                Spectators          = 0,
                TeamAPlayers        = 1,
                TeamABots           = 0,
                TeamBPlayers        = 1,
                TeamBBots           = 0,
                ResolveTimeoutLimit = 160,
                RoomName            = "default",
                Map      = String.Empty,
                SubTypes = new List <GameSubType>
                {
                    new GameSubType
                    {
                        DuplicationRule       = FreelancerDuplicationRuleTypes.noneInTeam,
                        GameMapConfigs        = GameMapConfig.GetDeatmatchMaps(),
                        InstructionsToDisplay = GameSubType.GameLoadScreenInstructions.Default,
                        LocalizedName         = "GenericPvP@SubTypes",
                        PersistedStatBucket   = PersistedStatBucket.Deathmatch_Unranked,
                        RewardBucket          = GameBalanceVars.GameRewardBucketType.HumanVsBotsRewards,
                        RoleBalancingRule     = FreelancerRoleBalancingRuleTypes.balanceBothTeams,
                        TeamAPlayers          = 1,
                        TeamABots             = 0,
                        TeamBPlayers          = 1,
                        TeamBBots             = 0,
                        Mods = new List <GameSubType.SubTypeMods>
                        {
                            GameSubType.SubTypeMods.HumansHaveFirstSlots,
                            //GameSubType.SubTypeMods.ShowWithAITeammates
                        },
                        TeamComposition = new TeamCompositionRules
                        {
                            Rules = new Dictionary <TeamCompositionRules.SlotTypes, FreelancerSet>
                            {
                                {
                                    TeamCompositionRules.SlotTypes.TeamA,
                                    new FreelancerSet
                                    {
                                        Roles = new List <CharacterRole> {
                                            CharacterRole.Assassin, CharacterRole.Tank, CharacterRole.Support
                                        },
                                    }
                                },
                                {
                                    TeamCompositionRules.SlotTypes.TeamB,
                                    new FreelancerSet
                                    {
                                        Roles = new List <CharacterRole> {
                                            CharacterRole.Assassin, CharacterRole.Tank, CharacterRole.Support
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            LobbyQueue.LobbyQueue queue = new LobbyQueue.LobbyQueue(GameType.PvP, gameConfig);
            Queues.Add(GameType.PvP, queue);
        }
示例#3
0
        private void MakeMatchSubType(GameSubType subType)
        {
            TeamCompositionRules         composition      = subType.TeamComposition;
            List <LobbyServerConnection> availablePlayers = new List <LobbyServerConnection>(Players);
            LobbyTeamInfo teamInfo = new LobbyTeamInfo()
            {
                TeamPlayerInfo = new List <LobbyPlayerInfo>()
            };

            if (
                FillTeam(Team.TeamA, composition, subType.TeamAPlayers, subType.TeamABots, ref availablePlayers, ref teamInfo) &&
                FillTeam(Team.TeamB, composition, subType.TeamBPlayers, subType.TeamBBots, ref availablePlayers, ref teamInfo)
                )
            {
                for (int i = 0; i < teamInfo.TeamPlayerInfo.Count; i++)
                {
                    teamInfo.TeamPlayerInfo[i].PlayerId            = i + 1;
                    teamInfo.TeamPlayerInfo[i].ControllingPlayerId = i + 1; // must be non-zero for players because 0 has a special use

                    if (!teamInfo.TeamPlayerInfo[i].IsNPCBot)
                    {
                    }
                }

                LobbyGameConfig gameConfig = QueueInfo.GameConfig.Clone();
                gameConfig.RoomName = GenerateRoomName();
                gameConfig.Map      = subType.GameMapConfigs[new Random().Next(0, subType.GameMapConfigs.Count - 1)].Map;

                LobbyGameInfo gameInfo = new LobbyGameInfo()
                {
                    GameConfig            = gameConfig,
                    AcceptedPlayers       = teamInfo.TotalPlayerCount,
                    ActiveSpectators      = 0,
                    AcceptTimeout         = TimeSpan.FromSeconds(30),
                    CreateTimestamp       = DateTime.Now.Ticks,
                    GameResult            = GameResult.NoResult,
                    GameServerAddress     = "ws://127.0.0.1:6061",
                    GameStatus            = GameStatus.Launched,
                    GameServerHost        = gameConfig.RoomName,
                    GameServerProcessCode = null,
                    LoadoutSelectTimeout  = EvoSGameConfig.LoadoutSelectTimeout,
                    IsActive = true,
                    LoadoutSelectionStartTimestamp = DateTime.Now.Ticks,
                    SelectionStartTimestamp        = DateTime.Now.Ticks,
                    SelectedBotSkillTeamA          = BotDifficulty.Medium,
                    SelectedBotSkillTeamB          = BotDifficulty.Medium,
                    SelectionSubPhase = FreelancerResolutionPhaseSubType.UNDEFINED,
                    SelectionSubPhaseStartTimestamp = DateTime.Now.Ticks,
                    SelectTimeout   = TimeSpan.FromSeconds(20),
                    UpdateTimestamp = DateTime.Now.Ticks
                };

                if (GameType == GameType.Practice)
                {
                    gameInfo.AcceptTimeout = TimeSpan.Zero;
                }

                Log.Print(LogType.Debug, "Removing players from queue...");
                foreach (LobbyPlayerInfo player in teamInfo.TeamPlayerInfo)
                {
                    if (!player.IsNPCBot)
                    {
                        //Log.Print(LogType.Debug, $"found player {player.Handle}");
                        for (int i = 0; i < Players.Count; i++)
                        {
                            /*if (Players[i].PlayerInfo.GetAccountId() == player.AccountId)
                             * {
                             *  RemovePlayer(Players[i]);
                             *  break;
                             * }*/
                        }
                    }
                }
                try
                {
                    LobbyQueueManager.CreateGame(gameInfo, teamInfo);
                }
                catch (Exception)
                {
                    throw new EvosException("Error on LobbyQueueManager.CreateGame");
                }
            }
        }
示例#4
0
        private void CreatePracticeQueue()
        {
            LobbyGameConfig gameConfig = new LobbyGameConfig()
            {
                GameType            = GameType.Practice,
                IsActive            = false,
                GameOptionFlags     = GameOptionFlag.EnableTeamAIOutput | GameOptionFlag.NoInputIdleDisconnect,
                Spectators          = 0,
                TeamAPlayers        = 1,
                TeamABots           = 0,
                TeamBPlayers        = 0,
                TeamBBots           = 2,
                ResolveTimeoutLimit = 160,
                RoomName            = "default",
                Map      = Maps.Skyway_Deathmatch,
                SubTypes = new List <GameSubType>
                {
                    new GameSubType
                    {
                        DuplicationRule = FreelancerDuplicationRuleTypes.noneInTeam,
                        GameMapConfigs  = new List <GameMapConfig> {
                            new GameMapConfig(Maps.Skyway_Deathmatch)
                        },
                        InstructionsToDisplay = GameSubType.GameLoadScreenInstructions.Default,
                        LocalizedName         = "GenericPractice@SubTypes",
                        PersistedStatBucket   = PersistedStatBucket.Deathmatch_Unranked,
                        RewardBucket          = GameBalanceVars.GameRewardBucketType.NoRewards,
                        RoleBalancingRule     = FreelancerRoleBalancingRuleTypes.none,
                        TeamAPlayers          = 1,
                        TeamABots             = 0,
                        TeamBPlayers          = 0,
                        TeamBBots             = 2,
                        Mods = new List <GameSubType.SubTypeMods>
                        {
                            GameSubType.SubTypeMods.AllowPlayingLockedCharacters,
                            GameSubType.SubTypeMods.HumansHaveFirstSlots,
                            GameSubType.SubTypeMods.NotAllowedForGroups
                        },
                        TeamComposition = new TeamCompositionRules
                        {
                            Rules = new Dictionary <TeamCompositionRules.SlotTypes, FreelancerSet>
                            {
                                {
                                    TeamCompositionRules.SlotTypes.A1,
                                    FreelancerSet.AllRoles
                                },
                                {
                                    TeamCompositionRules.SlotTypes.B1,
                                    new FreelancerSet {
                                        Types = new List <CharacterType> {
                                            CharacterType.PunchingDummy
                                        }
                                    }
                                },
                                {
                                    TeamCompositionRules.SlotTypes.B2,
                                    new FreelancerSet {
                                        Types = new List <CharacterType> {
                                            CharacterType.PunchingDummy
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            LobbyQueue.LobbyQueue queue = new LobbyQueue.LobbyQueue(GameType.Practice, gameConfig);
            Queues.Add(GameType.Practice, queue);
        }