Beispiel #1
0
        public bool SetTeamPlayers(TeamSelection teamSelection, Dictionary <Guid, Player> players, out string errorText)
        {
            var selectedTeam = dataFile.Teams[teamSelection];

            if (dataFile.Basis.RoundCount > 0 && dataFile.Basis.GameCount > 0)
            {
                foreach (var existed in selectedTeam.Players.Keys)
                {
                    if (!players.ContainsKey(existed))
                    {
                        foreach (var round in dataFile.Games)
                        {
                            foreach (var game in round)
                            {
                                if (game.PlayerIds[teamSelection] == existed)
                                {
                                    errorText = "已参与比赛的选手不允许删除。";
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }

            selectedTeam.Players = players;
            Save();
            errorText = null;
            return(true);
        }
Beispiel #2
0
        public IActionResult Team(TeamSelection teamSelection)
        {
            var data = FacadeService.Facade.GetTeam(teamSelection);

            ViewBag.TeamSelection = teamSelection;
            return(View(data));
        }
Beispiel #3
0
    public void PositionPlayers()
    {
        switch (TeamSelection.GetTeam())
        {
        case 0:
            Player.transform.position = ScienceGeeksSpawnObject.transform.position;
            Player.tag = "scienceGeek";
            SpawnScienceGeeksNPCs(NUM_NPCS - 1);
            SpawnJocksNPCs(NUM_NPCS);
            SpawnBookWormsNPCs(NUM_NPCS);
            break;

        case 1:
            SpawnScienceGeeksNPCs(NUM_NPCS);
            Player.transform.position = JocksSpawnObject.transform.position;
            Player.tag = "jocks";
            SpawnJocksNPCs(NUM_NPCS - 1);
            SpawnBookWormsNPCs(NUM_NPCS);
            break;

        case 2:
            SpawnScienceGeeksNPCs(NUM_NPCS);
            SpawnJocksNPCs(NUM_NPCS);
            Player.transform.position = BookWormsSpawnObject.transform.position;
            Player.tag = "bookWorm";
            SpawnBookWormsNPCs(NUM_NPCS - 1);
            break;
        }
    }
        public bool RequestTeam(TeamSelection teamSelection)
        {
            bool ret = RakNetPINVOKE.CSharp_RakNet_TM_TeamMember_RequestTeam(swigCPtr, TeamSelection.getCPtr(teamSelection));

            if (RakNetPINVOKE.SWIGPendingException.Pending)
            {
                throw RakNetPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #5
0
    }                                           // The current player to modify
    #endregion

    #region Event Functions
    // Awake is called before Start
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
        }
    }
        /// <summary>
        /// 显示队员信息。
        /// </summary>
        /// <returns></returns>
        public IActionResult Player(TeamSelection team, Guid id)
        {
            var player = FacadeService.Facade.GetPlayer(team, id);

            if (player == null)
            {
                return(NotFound());
            }

            ViewBag.Team     = team;
            ViewBag.PlayerId = id;
            return(View(player));
        }
Beispiel #7
0
        public IActionResult UpdateTeamName(TeamSelection teamSelection, Team model)
        {
            if (string.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError(nameof(model.Name), "必须提供队伍名称。");
            }

            if (ModelState.IsValid)
            {
                FacadeService.Facade.SetTeamName(teamSelection, model.Name);
                OperationMessageAccessor.Messages.Add(OperationMessageLevel.Success, "操作成功", "队伍名称已经更新");
                return(RedirectToAction("Team", "Manage", new { teamSelection }));
            }

            ViewBag.TeamSelection = teamSelection;
            return(View("Team", model));
        }
Beispiel #8
0
        //If we're in tournament mode, we'll actually be alive when we recieve the initial
        //ConnectResponse. When we do, we need to check to see if Teams is enabled
        //so we can offer the team selection screen if needed.
        protected override void Client_ConnectedToServer(ConnectResponse response)
        {
            base.Client_ConnectedToServer(response);

            UnityMainThreadDispatcher.Instance().Enqueue(() =>
            {
                _splashScreen.StatusText = "Waiting for the coordinator to create your match...";

                if ((response.Self as Player).Team.Id == Guid.Empty && Plugin.client.State.ServerSettings.Teams.Length > 0)
                {
                    _teamSelection = BeatSaberUI.CreateViewController <TeamSelection>();
                    _teamSelection.TeamSelected += teamSelection_TeamSelected;
                    _teamSelection.SetTeams(new List <Team>(Plugin.client.State.ServerSettings.Teams));
                    ShowTeamSelection();
                }
            });
        }
Beispiel #9
0
 public void Update()
 {
     if (isInit == false)
     {
         _teamSelection = FindObjectOfType <TeamSelection>();
         isInit         = true;
         if (_teamSelection != null)
         {
             _teamSelection.ShowMenu();
         }
     }
     else if (Input.GetKeyDown("1"))
     {
         _teamSelection.SelectTeam1();
     }
     else if (Input.GetKeyDown("2"))
     {
         _teamSelection.SelectTeam2();
     }
 }
Beispiel #10
0
 private void InitialScore(Score score, TeamSelection teamSelection, Dictionary <Guid, PlayerWithGameCount> players)
 {
     score.TeamName.Add(teamSelection, dataFile.Teams[teamSelection].Name);
     score.CurrentSource.Add(teamSelection, 0);
     foreach (var player in dataFile.Teams[teamSelection].Players)
     {
         var item = new PlayerWithGameCount
         {
             Id   = player.Key,
             Team = teamSelection,
             //item.Played = 0;
             //item.Won = 0;
             //item.Lost = 0;
             Name         = player.Value.Name,
             DefaultRace  = player.Value.DefaultRace,
             MaxAttending = player.Value.MaxAttending,
             MinAttending = player.Value.MinAttending
         };
         players.Add(player.Key, item);
     }
 }
Beispiel #11
0
        public IActionResult UpdateTeamPlayers(TeamSelection teamSelection, KeyedItem <Guid, Player>[] model)
        {
            // 为所有项目创建新Key。
            foreach (var item in model)
            {
                if (item.Key == Guid.Empty)
                {
                    item.Key = Guid.NewGuid();
                }
            }


            if (FacadeService.Facade.SetTeamPlayers(teamSelection, model.ToDictionary(), out var error))
            {
                OperationMessageAccessor.Messages.Add(OperationMessageLevel.Success, "操作成功", "参赛者列表已经更新。");
            }
            else
            {
                OperationMessageAccessor.Messages.Add(OperationMessageLevel.Error, "操作失败", error);
            }

            return(RedirectToAction("Team", "Manage", new { teamSelection }));
        }
Beispiel #12
0
        public List <GameWithIndex> GetGamesByPlayer(TeamSelection teamSelection, Guid playerId)
        {
            if (dataFile.Games == null)
            {
                return(null);
            }
            else
            {
                var results = new List <GameWithIndex>();
                for (var roundIndex = 0; roundIndex < dataFile.Games.Count; roundIndex++)
                {
                    var round = dataFile.Games[roundIndex];
                    for (var gameIndex = 0; gameIndex < round.Count; gameIndex++)
                    {
                        var game = round[gameIndex];
                        if (game.PlayerIds[teamSelection] == playerId)
                        {
                            var gameWithIndex = new GameWithIndex
                            {
                                GameResult     = game.GameResult,
                                GameTime       = game.GameTime,
                                IsTimeIncluded = game.IsTimeIncluded,
                                MapId          = game.MapId,
                                RaceIds        = game.RaceIds,
                                PlayerIds      = game.PlayerIds,
                                RoundIndex     = roundIndex,
                                GameIndex      = gameIndex
                            };
                            results.Add(gameWithIndex);
                        }
                    }
                }

                return(results);
            }
        }
Beispiel #13
0
        public static TeamSelection SpecificTeam(TM_Team specificTeamToJoin)
        {
            TeamSelection ret = new TeamSelection(RakNetPINVOKE.CSharp_RakNet_TeamSelection_SpecificTeam(TM_Team.getCPtr(specificTeamToJoin)), true);

            return(ret);
        }
Beispiel #14
0
        public static TeamSelection AnyAvailable()
        {
            TeamSelection ret = new TeamSelection(RakNetPINVOKE.CSharp_RakNet_TeamSelection_AnyAvailable(), true);

            return(ret);
        }
Beispiel #15
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TeamSelection obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #16
0
 public IActionResult Team(TeamSelection team)
 {
     ViewBag.TeamSelection = team;
     return(View("Team", FacadeService.Facade.GetTeam(team)));
 }
Beispiel #17
0
 public Team GetTeam(TeamSelection teamSelection)
 {
     return(dataFile.Teams[teamSelection]);
 }
Beispiel #18
0
 public void SetTeamName(TeamSelection teamSelection, string name)
 {
     dataFile.Teams[teamSelection].Name = name;
     Save();
 }
Beispiel #19
0
 public void Start()
 {
     _teamSelection = FindObjectOfType <TeamSelection>();
 }
Beispiel #20
0
 public IEnumerable <KeyedItem <Guid, Player> > Player(TeamSelection teamSelection)
 {
     return(FacadeService.Facade.GetTeam(teamSelection).Players.ToKeyed().OrderBy(i => i.Value.Name));
 }
Beispiel #21
0
 public async Task GameAsync(SocketTextChannel lobbyChannel, int gameNumber, TeamSelection winning_team, [Remainder] string comment = null)
 {
     await GameAsync(gameNumber, winning_team, lobbyChannel, comment);
 }
Beispiel #22
0
        public static TeamSelection NoTeam(byte noTeamSubcategory)
        {
            TeamSelection ret = new TeamSelection(RakNetPINVOKE.CSharp_RakNet_TeamSelection_NoTeam(noTeamSubcategory), true);

            return(ret);
        }
Beispiel #23
0
	void Awake()
	{
		_instance = this;
	}
Beispiel #24
0
 private static Boolean KawigiEdit_RunTest(int testNum, int[] p0, string[] p1, Boolean hasAnswer, int p2)
 {
     Console.Write("Test " + testNum + ": [" + "{");
     for (int i = 0; p0.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write(p0[i]);
     }
     Console.Write("}" + "," + "{");
     for (int i = 0; p1.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write("\"" + p1[i] + "\"");
     }
     Console.Write("}");
     Console.WriteLine("]");
     TeamSelection obj;
     int answer;
     obj = new TeamSelection();
     DateTime startTime = DateTime.Now;
     answer = obj.selectBestTeam(p0, p1);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.WriteLine("\t" + p2);
     }
     Console.WriteLine("Your answer:");
     Console.WriteLine("\t" + answer);
     if (hasAnswer) {
         res = answer == p2;
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }
Beispiel #25
0
 public virtual async Task GameAsync(int gameNumber, TeamSelection winning_team, SocketTextChannel lobbyChannel = null, [Remainder] string comment = null)
 {
     await GSS.GameAsync(Context, gameNumber, winning_team, lobbyChannel, comment);
 }
Beispiel #26
0
 public string GetTeamName(TeamSelection teamSelection)
 {
     return(dataFile.Teams[teamSelection].Name);
 }
Beispiel #27
0
        public async Task GameAsync(int gameNumber, TeamSelection winning_team, SocketTextChannel lobbyChannel = null, [Remainder] string comment = null)
        {
            if (lobbyChannel == null)
            {
                //If no lobby is provided, assume that it is the current channel.
                lobbyChannel = Context.Channel as SocketTextChannel;
            }

            var lobby = Service.GetLobby(Context.Guild.Id, lobbyChannel.Id);

            if (lobby == null)
            {
                //Reply error not a lobby.
                await SimpleEmbedAsync("Channel is not a lobby.", Color.Red);

                return;
            }

            var game = Service.GetGame(Context.Guild.Id, lobby.ChannelId, gameNumber);

            if (game == null)
            {
                //Reply not valid game number.
                await SimpleEmbedAsync($"Game not found. Most recent game is {lobby.CurrentGameCount}", Color.DarkBlue);

                return;
            }

            if (game.GameState == GameResult.State.Decided || game.GameState == GameResult.State.Draw)
            {
                await SimpleEmbedAsync("Game results cannot currently be overwritten without first running the `undogame` command.", Color.Red);

                return;
            }

            var competition = Service.GetOrCreateCompetition(Context.Guild.Id);

            List <(Player, int, Rank, RankChangeState, Rank)> winList;
            List <(Player, int, Rank, RankChangeState, Rank)> loseList;

            if (winning_team == TeamSelection.team1)
            {
                winList  = UpdateTeamScoresAsync(competition, true, game.Team1.Players);
                loseList = UpdateTeamScoresAsync(competition, false, game.Team2.Players);
            }
            else
            {
                loseList = UpdateTeamScoresAsync(competition, false, game.Team1.Players);
                winList  = UpdateTeamScoresAsync(competition, true, game.Team2.Players);
            }

            var allUsers = new List <(Player, int, Rank, RankChangeState, Rank)>();

            allUsers.AddRange(winList);
            allUsers.AddRange(loseList);

            foreach (var user in allUsers)
            {
                //Ignore user updates if they aren't found in the server.
                var gUser = Context.Guild.GetUser(user.Item1.UserId);
                if (gUser == null)
                {
                    continue;
                }

                await Service.UpdateUserAsync(competition, user.Item1, gUser);
            }

            game.GameState    = GameResult.State.Decided;
            game.ScoreUpdates = allUsers.ToDictionary(x => x.Item1.UserId, y => y.Item2);
            game.WinningTeam  = (int)winning_team;
            game.Comment      = comment;
            game.Submitter    = Context.User.Id;
            Service.SaveGame(game);

            var winField = new EmbedFieldBuilder
            {
                //TODO: Is this necessary to show which team the winning team was?
                Name  = $"Winning Team, Team{(int)winning_team}",
                Value = GetResponseContent(winList).FixLength(1023)
            };
            var loseField = new EmbedFieldBuilder
            {
                Name  = $"Losing Team",
                Value = GetResponseContent(loseList).FixLength(1023)
            };
            var response = new EmbedBuilder
            {
                Fields = new List <EmbedFieldBuilder> {
                    winField, loseField
                },
                //TODO: Remove this if from the vote command
                Title = $"{lobbyChannel.Name} Game: #{gameNumber} Result called by {Context.User.Username}#{Context.User.Discriminator}".FixLength(127)
            };

            if (!string.IsNullOrWhiteSpace(comment))
            {
                response.AddField("Comment", comment.FixLength(1023));
            }

            await AnnounceResultAsync(lobby, response);
        }
Beispiel #28
0
 public Player GetPlayer(TeamSelection teamSelection, Guid playerId)
 {
     return(dataFile.Teams[teamSelection].Players[playerId]);
 }
        public TeamSelection GetRequestedTeam()
        {
            TeamSelection ret = new TeamSelection(RakNetPINVOKE.CSharp_RakNet_TM_TeamMember_GetRequestedTeam(swigCPtr), true);

            return(ret);
        }
 public void RecordTeamSelection(int playerTeamChoice)
 {
     TeamSelection.SetTeam(playerTeamChoice);
 }