Example #1
0
        public void DeletePlayerGroup(PlayerGroup group)
        {
            using (var entities = Database.GetEntities())
            {
                foreach (var playerData in entities.PlayerDatas.Where(x => x.GroupId == group.Id))
                {
                    RemovePlayer(entities, playerData.Id, false);
                }

                var groupData = entities.PlayerGroupDatas.Single(x => x.Id == group.Id);
                int teamId    = groupData.TeamId;

                entities.DeleteObject(groupData);
                entities.SaveChanges();

                // Ensure proper ordering
                short order = 0;
                foreach (var playerGroupData in entities.PlayerGroupDatas
                         .Where(x => x.TeamId == teamId).OrderBy(x => x.Order).ToList())
                {
                    playerGroupData.Order = order;
                    order++;
                }
                entities.SaveChanges();
            }
        }
Example #2
0
        public PlayerGroup UpdatePlayerGroup(PlayerGroup group)
        {
            using (var entities = Database.GetEntities())
            {
                var groupData = entities.PlayerGroupDatas.Single(x => x.Id == group.Id);
                groupData.Name = group.Name;

                if (groupData.Order != group.Order) // A reordering
                {
                    // Swapping
                    var swapping = entities.PlayerGroupDatas.FirstOrDefault(x => x.TeamId == group.TeamId && x.Order == group.Order);
                    if (swapping != null)
                    {
                        swapping.Order = groupData.Order; // Give it the current order
                    }

                    // Matching
                    groupData.Order = group.Order; // Give it the new order

                    entities.SaveChanges();

                    // Ensure proper ordering
                    short order = 0;
                    foreach (var orderedGroupData in entities.PlayerGroupDatas.Where(x => x.TeamId == group.TeamId).OrderBy(x => x.Order).ToList())
                    {
                        orderedGroupData.Order = order;
                        order++;
                    }
                }

                entities.SaveChanges();

                return(group);
            }
        }
Example #3
0
        public async Task <IActionResult> UpdatePlayerGroup([FromBody] PlayerGroupViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    PlayerGroup playergroup = new PlayerGroup()
                    {
                        GroupId              = model.GroupId,
                        PlayerId             = model.PlayerId,
                        IsInvitationAccepted = model.IsInvitationAccepted
                    };

                    await _groupManager.UpdatePlayerGroup(playergroup);

                    return(Ok(ApiResponse(ApiResponseStatus.Success, playergroup, $@"group invitation successfully updated.")));
                }

                return(BadRequest(ApiResponse(ApiResponseStatus.Fail, GetModelStateErrors(ModelState), "Model validation failure.")));
            }

            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(HandleException("1", e, "An error occurred while updating record. Please try again later."));
            }
        }
Example #4
0
        public static ChangePlayerTurn Create(PlayerGroup group)
        {
            ChangePlayerTurn command = new ChangePlayerTurn();

            command.group = group;
            return(command);
        }
Example #5
0
        private void Callback_JobCreated(PlayerGroup playerGroup, Job job)
        {
            //If there's no "affected" positions, then no highlights are needed.
            if (!playerGroup.JobQueries.AffectsAnyPoses(job))
            {
                return;
            }

            //Create the list of jobs.
            //Use an old discarded list if one exists to reduce garbage.
            List <ulong> jobHighlights;

            if (extraHighlightLists.Count == 0)
            {
                jobHighlights = new List <ulong>();
            }
            else
            {
                jobHighlights = extraHighlightLists[extraHighlightLists.Count - 1];
                extraHighlightLists.RemoveAt(extraHighlightLists.Count - 1);
            }
            highlightsPerJob.Add(job, jobHighlights);

            //Create one hghlight for each affected job.
            foreach (Vector2i affectedPos in playerGroup.JobQueries.GetAffectedPoses(job))
            {
                jobHighlights.Add(MyUI.TileHighlighter.Instance.CreateHighlight(affectedPos,
                                                                                jobColor_Pending));
                MyUI.TileHighlighter.Instance.SetSprite(jobHighlights[jobHighlights.Count - 1],
                                                        spritesByJobType[job.ThisType]);
            }
        }
Example #6
0
        public void RemovePlayerGroup(Player player, PlayerGroup group)
        {
            string sql = "DELETE FROM prefix_players_groups WHERE player_id = @player_id AND group_id = @group_id";

            NonQuery(sql, "@player_id", player.DatabaseId, "@group_id", group.Id);
            player.MainGroup = GetTopGroup(player);
        }
Example #7
0
 private void OnRemove(PlayerGroup playerGroup)
 {
     foreach (var listener in this.listeners)
     {
         listener.OnRemove(playerGroup);
     }
 }
Example #8
0
    public static void RemovePlayerGroup(PlayerGroup group, Action callback = null,
                                         Action <Exception> eHandler        = null)
    {
        var groupName = group.Name;

        RemovePlayerGroup(groupName, callback, eHandler);
    }
Example #9
0
        public async Task BroadCast(byte[] bytes)
        {
            var bytebuf = PooledByteBufferAllocator.Default.Buffer();

            bytebuf.WriteBytes(bytes);
            await PlayerGroup.BroadCast(bytebuf);
        }
        public async Task <IHttpActionResult> PutPlayerGroup(int id, PlayerGroup playerGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != playerGroup.ID)
            {
                return(BadRequest());
            }

            db.Entry(playerGroup).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlayerGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #11
0
 internal void Win(PlayerGroup group)
 {
     parent.gameObject.SetActive(true);
     text.text   = "You won!!! ";
     color.color = group.MaterialColor;
     Invoke("DisablePopup", 2f);
 }
Example #12
0
        public async Task <IHttpActionResult> GetGroupMessages(int IdGroup)
        {
            Group group = await db.Groups.FindAsync(IdGroup);

            if (group == null)
            {
                return(NotFound());
            }
            List <dynamic> messages = new List <dynamic>();
            var            mes      = db.MessageGroups.Where(x => x.IdGroup == IdGroup).ToArray();

            foreach (var v in mes)
            {
                PlayerGroup pg = await db.PlayerGroups.FindAsync(v.ID_Relation);

                Player p = await db.Gamers.FindAsync(pg.IdPlayer);

                messages.Add(new
                {
                    content    = v.Content,
                    senderID   = p.ID,
                    senderName = p.Nickname
                });
            }
            return(Ok(messages));
        }
Example #13
0
    public static PlayerGroup Create(List <PlayerState> playerList)
    {
        PlayerGroup group = new PlayerGroup();

        group._playerList = playerList;
        return(group);
    }
Example #14
0
        public void Use(Player p, string[] args)
        {
            if (args.Length == 0)
            {
                string send = "Current groups: ";
                foreach (PlayerGroup z in PlayerGroup.Groups)
                {
                    send = send + z.Color + z.Name + Server.DefaultColor + ", ";
                }
                p.SendMessage(send);
                return;
            }
            PlayerGroup group = PlayerGroup.Find(args[0]);

            if (group == null)
            {
                p.SendMessage("The rank \"" + args[0] + "\" doesn't exist!"); return;
            }
            try
            {
                string[] players = File.ReadAllLines(group.File);
                string   send    = "People with the rank " + group.Color + group.Name + Server.DefaultColor + ": ";
                foreach (string player in players)
                {
                    send += player + "&a, " + Server.DefaultColor;
                }
                p.SendMessage(send.Remove(send.Length - 4, 4));
            }
            catch { p.SendMessage("Error reading ranks!"); return; }
        }
Example #15
0
        //
        // GET: /PlayerGroup/Edit/5

        public ActionResult Edit(int id)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                PlayerGroup playergroup = repository.GetPlayerGroup(id);
                ViewData["ValidationMessage"] = String.Empty;

                return(View(playergroup));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayerGroup", "Edit", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }
Example #16
0
        public override bool AffectPlayer(Player affectedPlayer, Player player, string commandLine, string[] parameters, int paramIdx)
        {
            if (parameters.Length <= paramIdx)
            {
                SendFormatted(OnNoGroup, "{usage}", Usage);
                return(false);
            }

            PlayerGroup group = Core.Database.GetPlayerGroup(parameters[paramIdx]);

            if (group == null)
            {
                SendFormatted(OnInvalidGroup, "{group}", parameters[paramIdx]);
                return(false);
            }

            if (CheckLevel && !player.isSuperuser() && (player.MainGroup == null || player.MainGroup.Level <= group.Level))
            {
                SendFormatted(OnInvalidLevel, "{group}", group.Name);
                return(false);
            }

            if (!Core.Database.IsGroupMember(affectedPlayer, group))
            {
                SendFormatted(OnNoMember, "{player}", affectedPlayer.Name, "{group}", group.Name);
                return(false);
            }

            Core.Database.RemovePlayerGroup(affectedPlayer, group);
            SendFormatted(OnPutGroup, "{player}", affectedPlayer.Name, "{group}", group.Name);
            return(true);
        }
Example #17
0
        public void SetPlayerGroup(PlayerGroup playerGroup)
        {
            if (PermissionLevel != playerGroup.PermissionLevel ||
                PlayerGroup.CommandPermission != playerGroup.CommandPermission ||
                ActionPermissions != playerGroup.ActionPermission)
            {
                //Initialize Player UserPermission level for commands
                PermissionLevel   = playerGroup.PermissionLevel;
                CommandPermission = (int)playerGroup.CommandPermission;
                ActionPermissions = playerGroup.ActionPermission;

                SendAdventureSettings();

                //Send Command Hint Changes if the group is possible going to receive more
                if (playerGroup.IsAtLeast(PlayerGroup.Vip))
                {
                    SendAvailableCommands();
                }
            }

            PlayerGroup = playerGroup;

            SetHideNameTag(false);
            UpdatePlayerName();
        }
Example #18
0
        public PlayerGroup GetTopGroup(Player player)
        {
            string sql =
                "SELECT * " +
                "FROM " +
                "prefix_players_groups " +
                "INNER JOIN prefix_groups ON prefix_players_groups.group_id = prefix_groups.id " +
                "WHERE player_id = @player_id " +
                "ORDER BY group_level DESC LIMIT 1";

            using (DbDataReader reader = Query(sql, "@player_id", player.DatabaseId))
            {
                PlayerGroup group = ReadGroup(reader);
                if (group == null)
                {
                    reader.Close();
                    PlayerGroup defaultGroup = GetDefaultGroup();
                    if (defaultGroup != null)
                    {
                        AddPlayerGroup(player, defaultGroup);
                    }
                    return(defaultGroup);
                }
                return(group);
            }
        }
Example #19
0
    //for buttons controll
    public void OnButtunClick(string ButtonName)
    {
        Debug.Log(" clicked on " + ButtonName);
        switch (ButtonName)
        {
        //for play button
        case "Play":

            PlayerGroup.SetActive(true);
            SoundController.Static.PlayClickSound();             //for click sound
            MainMenuParent.SetActive(false);
            PlayerSelectionmenuParent.SetActive(true);
            MainMenuScreens.currentScreen = MainMenuScreens.MenuScreens.playerSelectionMenu;            //for state chenge in to mainmenu screen
            break;

        //for more button
        case "More":
            //for open playstore acegames games
                        #if UNITY_IPHONE
            Application.OpenURL("https://play.google.com/store/apps/developer?id=Ace+Games");
                        # elif UNITY_ANDROID
            Application.OpenURL("https://play.google.com/store/apps/developer?id=Ace+Games");
                        #elif UNITY_WP8
            Application.OpenURL("https://play.google.com/store/apps/developer?id=Ace+Games");
                        #endif
            SoundController.Static.PlayClickSound();             //for click sound
            break;
Example #20
0
 public static void Load()
 {
     RankList.Clear();
     LevelList.Clear();
     foreach (string line in File.ReadAllLines("properties/economy.properties"))
     {
         string[] s = line.Split(':');
         if (s[0] == "SetupPermission")
         {
             SetupPermission = byte.Parse(s[1]);
         }
         if (s[0] == "EconomyEnabled")
         {
             Enabled = bool.Parse(s[1]);
         }
         if (s[0] == "TitlesEnabled")
         {
             TitlesEnabled = bool.Parse(s[1]);
         }
         if (s[0] == "TitlePrice")
         {
             TitlePrice = int.Parse(s[1]);
         }
         if (s[0] == "ColorsEnabled")
         {
             ColorsEnabled = bool.Parse(s[1]);
         }
         if (s[0] == "ColorPrice")
         {
             ColorPrice = int.Parse(s[1]);
         }
         if (s[0] == "RanksEnabled")
         {
             RanksEnabled = bool.Parse(s[1]);
         }
         if (s[0] == "Rank")
         {
             Rank rank = new Rank();
             rank.Group = PlayerGroup.Find(s[1]);
             rank.Price = int.Parse(s[2]);
             RankList.Add(rank);
         }
         if (s[0] == "LevelsEnabled")
         {
             LevelsEnabled = bool.Parse(s[1]);
         }
         if (s[0] == "Level")
         {
             Economy.Level lvl = new Economy.Level();
             lvl.Name  = s[1];
             lvl.X     = s[2];
             lvl.Y     = s[3];
             lvl.Z     = s[4];
             lvl.Type  = s[5];
             lvl.Price = int.Parse(s[6]);
             LevelList.Add(lvl);
         }
     }
 }
Example #21
0
    public static void AddPlayerToGroup(PlayerGroup group, Player player, Action <PlayerGroup> callback = null,
                                        Action <Exception> eHandler = null)
    {
        var groupName = group.Name;
        var key       = player.AuthToken;

        AddPlayerToGroupToken(groupName, key, callback, eHandler);
    }
Example #22
0
 public void Initialize()
 {
     playerGroup  = ModelLoader.LoadModel <PlayerGroup>("PlayerGroup");
     neutralGroup = ModelLoader.LoadModel <NeutralGroup>("NeutralGroup");
     CreateAIs();
     cameraControl = new CameraMovementController(playerGroup);
     scores.Initialize(aiGroups.Union(new Group[] { playerGroup }));
 }
Example #23
0
        private PlayerGroup FillNulls(PlayerGroup playergroup)
        {
            if (playergroup.PlayerGroupDescription == null)
            {
                playergroup.PlayerGroupDescription = String.Empty;
            }

            return(playergroup);
        }
Example #24
0
        public void AddPlayerGroup(Player player, PlayerGroup group)
        {
            string sql = "INSERT INTO prefix_players_groups " +
                         "(player_id, group_id) VALUES " +
                         "(@player_id, @group_id)";

            NonQuery(sql, "@player_id", player.DatabaseId, "@group_id", group.Id);
            player.MainGroup = GetTopGroup(player);
        }
Example #25
0
        public void Seed()
        {
            this.ctx.Database.EnsureCreated();

            if (!this.ctx.Users.Any())
            {
                var user = new User()
                {
                    UserName = "******"
                };
                var user2 = new User()
                {
                    UserName = "******"
                };

                var match = new Match()
                {
                    StartDate = new DateTime(2018, 6, 15, 19, 0, 0),
                    EndDate   = new DateTime(2018, 6, 15, 20, 30, 0),
                    IsWeekly  = true
                };

                var group = new Group()
                {
                    Name    = "Telenor",
                    AdminId = user.Id,
                    Matches = new List <Match>()
                    {
                        match
                    }
                };

                var playerGroup = new PlayerGroup()
                {
                    Player = user, Group = group
                };
                var playerGroup2 = new PlayerGroup()
                {
                    Player = user2, Group = group
                };

                var attendeeMatch = new AttendeeMatch()
                {
                    Attendee = user, Match = match
                };
                var attendeeMatch2 = new AttendeeMatch()
                {
                    Attendee = user2, Match = match
                };

                this.ctx.Users.Add(user);
                this.ctx.Users.Add(user2);
                this.ctx.Matches.Add(match);
                this.ctx.Groups.Add(group);
                this.ctx.SaveChanges();
            }
        }
Example #26
0
    public static ChangePlayerTurn Create(PlayerGroup playerGroup,
                                          int newPlayerIndex = -1)
    {
        ChangePlayerTurn command = new ChangePlayerTurn();

        command._playerGroup    = playerGroup;
        command._newPlayerIndex = newPlayerIndex;
        return(command);
    }
        public void Use(Player p, string[] args)
        {
            if (args.Length < 2)
            {
                Help(p);
                return;
            }

            byte        perVisit = 0;
            PlayerGroup g        = null;
            Level       l        = null;

            l = Level.FindLevel(args[0]);

            if (l == null)
            {
                p.SendMessage("Level not found!");
                return; //no need to continue (troll)
            }

            try
            {
                perVisit = byte.Parse(args[1]);
            }
            catch
            {
                try
                {
                    g        = PlayerGroup.Find(args[1]);
                    perVisit = g.Permission;
                }
                catch
                {
                    p.SendMessage("Error parsing new build permission");
                    return;
                }
            }

            if (perVisit > p.Group.Permission)
            {
                p.SendMessage("You cannot set the build permission to a greater rank or permission than yours");
                return;
            }


            l.Settings.pervisit = perVisit;

            if (g != null)
            {
                p.SendMessage("Successfully put " + Colors.gold + l.Name + Server.DefaultColor + "'s visit permission to " + g.Color + g.Name);
            }
            else
            {
                p.SendMessage("Successfully put " + Colors.gold + l.Name + Server.DefaultColor + "'s visit permission to " + Colors.red + perVisit);
            }
        }
Example #28
0
        public static MoveCommand Create(MoveRequest request, Board board, PlayerGroup group, MoveValidator validator)
        {
            MoveCommand command = new MoveCommand();

            command.board       = board;
            command.playerGroup = group;
            command.moveRequest = request;
            command.validator   = validator;
            return(command);
        }
Example #29
0
    public static TradeEscrow Create(TeamCollection teamCollection, PlayerGroup playerGroup)
    {
        TradeEscrow command = new TradeEscrow();

        command._playerGroup         = playerGroup;
        command._teamCollection      = teamCollection;
        command.transactionCompleted = false;

        return(command);
    }
Example #30
0
        public static void playerDisconnectFromGame([FromSource] Player player, string reason)
        {
            var licenseIdentifier = player.Identifiers["steam"];
            //=====================
            PlayerJob job = PlayerJobHolder.getPlayerJob(player);

            if (job != null)
            {
                MYSQL.execute($"UPDATE playerjob " +
                              $"SET name = '{job.getJobName()}'," +
                              $"grade = '{job.getJobGrade()}' " +
                              $"WHERE steamid = '{licenseIdentifier}'; ");

                PlayerJobHolder.removePlayerFromJobList(player);
            }
            //=====================
            PlayerMoney money = PlayerMoneyHolder.getPlayerMoney(player);

            if (money != null)
            {
                MYSQL.execute($"UPDATE playermoney " +
                              $"SET money = '{money.getMoney()}'," +
                              $"bank = '{money.getBankMoney()}'," +
                              $"dirty_money='{money.getDirtyMoney()}'" +
                              $"WHERE steamid = '{licenseIdentifier}'; ");

                PlayerMoneyHolder.removePlayerFromMoneyList(player);
            }
            //=====================
            PlayerGroup group = PlayerGroupHolder.getPlayerGroup(player);

            if (group != null)
            {
                List <string> gp = group.playerGroups();
                StringBuilder sb = new StringBuilder();
                if (gp.Count != 0)
                {
                    for (int i = 0; i < gp.Count; i++)
                    {
                        sb.Append($"('{licenseIdentifier}', '{gp[i]}'),");
                    }


                    MYSQL.execute($"DELETE FROM `groupusers` WHERE steamid = '{licenseIdentifier}';" +
                                  $"INSERT INTO `groupusers` (`steamid`, `group`) VALUES {sb.ToString().Remove(sb.Length - 1)}");
                }
                PlayerGroupHolder.removePlayerFromGroupList(player);
            }
            //=====================

            //=====================

            //=====================
            Debug.WriteLine($"Player {player.Name} has disconnected! ================================== :(");
        }
 protected abstract void ProcessPlayerGroup(PlayerGroup playerGroup);
 protected void AddPlayerToProcessing(PlayerGroup playerGroup)
 {
     _playerBuffer.Post(playerGroup);
 }