コード例 #1
0
 public override void InitPopUp(GuildMember guildMember)
 {
     this.mGuildMember = guildMember;
     this.Refresh();
     if (this.mGuildMember != null)
     {
         FriendData friendData = Globals.Instance.Player.FriendSystem.GetFriendData(this.mGuildMember.ID);
         if (friendData != null)
         {
             this.friendType = friendData.FriendType;
         }
     }
 }
コード例 #2
0
 public GuildObject(PlayerObject owner, string name)
 {
     Name = name;
     Rank Owner = new Rank() { Name = "Leader", Options = (RankOptions)255 , Index = 0};
     GuildMember Leader = new GuildMember() { name = owner.Info.Name, Player = owner, Id = owner.Info.Index, LastLogin = Envir.Now, Online = true};
     Owner.Members.Add(Leader);
     Ranks.Add(Owner);
     Membercount++;
     NeedSave = true;
     if (Level < Settings.Guild_ExperienceList.Count)
         MaxExperience = Settings.Guild_ExperienceList[Level];
     if (Level < Settings.Guild_MembercapList.Count)
         MemberCap = Settings.Guild_MembercapList[Level];
 }
コード例 #3
0
ファイル: GuildManager.cs プロジェクト: trueever/aura
        /// <summary>
        /// Adds creature to the guild as applicant.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="guild"></param>
        public void Apply(Creature creature, Guild guild, string application)
        {
            if (guild.HasMember(creature.EntityId))
            {
                throw new ArgumentException("Character is already a member of this guild. (" + creature.Name + ", " + guild.Name + ")");
            }

            var member = new GuildMember();

            member.GuildId     = guild.Id;
            member.CharacterId = creature.EntityId;
            member.Rank        = GuildMemberRank.Applied;
            member.JoinedDate  = DateTime.Now;
            member.Application = application;

            creature.Guild       = guild;
            creature.GuildMember = member;

            guild.AddMember(member);

            ChannelServer.Instance.Database.AddGuildMember(member);
        }
コード例 #4
0
    static void LoadGuild(Player player)
    {
        // in a guild?
        string guild = (string)ExecuteScalar("SELECT guild FROM character_guild WHERE character=@character", new SqliteParameter("@character", player.name));

        if (guild != null)
        {
            // load guild info
            player.guildName = guild;
            List <List <object> > table = ExecuteReader("SELECT notice FROM guild_info WHERE name=@guild", new SqliteParameter("@guild", guild));
            if (table.Count == 1)
            {
                List <object> row = table[0];
                player.guild.notice = (string)row[0];
            }

            // load members list
            List <GuildMember> members = new List <GuildMember>();
            table = ExecuteReader("SELECT character, rank FROM character_guild WHERE guild=@guild", new SqliteParameter("@guild", player.guildName));
            foreach (List <object> row in table)
            {
                GuildMember member = new GuildMember();
                member.name   = (string)row[0];
                member.rank   = (GuildRank)Convert.ToInt32((long)row[1]);
                member.online = Player.onlinePlayers.ContainsKey(member.name);
                if (member.name == player.name)
                {
                    member.level = player.level;
                }
                else
                {
                    object scalar = ExecuteScalar("SELECT level FROM characters WHERE name=@character", new SqliteParameter("@character", member.name));
                    member.level = scalar != null?Convert.ToInt32((long)scalar) : 1;
                }
                members.Add(member);
            }
            player.guild.members = members.ToArray(); // guild.AddMember each time is too slow because array resizing
        }
    }
コード例 #5
0
    private static void HandleGuildDonate(GameSession session, PacketReader packet)
    {
        int donateQuantity = packet.ReadInt();
        int donationAmount = donateQuantity * 10000;

        Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

        if (guild == null)
        {
            return;
        }

        GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp);

        GuildMember member = guild.Members.First(x => x.Player == session.Player);

        if (member.DailyDonationCount >= guildProperty.DonationMax)
        {
            return;
        }

        if (!session.Player.Wallet.Meso.Modify(-donationAmount))
        {
            session.Send(GuildPacket.ErrorNotice((byte)GuildErrorNotice.NotEnoughMesos));
            return;
        }

        Item coins = new(id : 30000861, amount : guildProperty.DonateGuildCoin * donateQuantity, rarity : 4);

        session.Player.Inventory.AddItem(session, coins, true);

        int contribution = GuildContributionMetadataStorage.GetContributionAmount("donation");

        member.DailyDonationCount += (byte)donateQuantity;
        member.AddContribution(contribution * donateQuantity);
        guild.ModifyFunds(session, guildProperty, donationAmount);
        session.Send(GuildPacket.UpdatePlayerDonation());
        guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, donateQuantity));
    }
コード例 #6
0
ファイル: GuildObject.cs プロジェクト: zhaokai1982/mir2
        public void NewMember(PlayerObject newMember)
        {
            if (Ranks.Count < 2)
            {
                Ranks.Add(new GuildRank()
                {
                    Name = "Members", Index = 1
                });
            }

            GuildRank   lowestRank = Ranks[Ranks.Count - 1];
            GuildMember member     = new GuildMember()
            {
                Name = newMember.Info.Name, Player = newMember, Id = newMember.Info.Index, LastLogin = Envir.Now, Online = true
            };

            lowestRank.Members.Add(member);

            PlayerLogged(newMember, true, true);
            Info.Membercount++;
            NeedSave = true;
        }
コード例 #7
0
        // Called when a member leaves the Discord server
        private void Discord_MemberRemoved(GuildMember member)
        {
            var steamId = API_GetSteam(member.user.id);

            // No user found
            if (steamId == null)
            {
                return;
            }

            if (config.Info.Deauthenticate)
            {
                Deauthenticate(steamId, member.user.id);
                member.user.CreateDM(Client, dm => dm.CreateMessage(Client, GetEmbed(Formatter.ToPlaintext(Lang("Discord-Deauthenticated", steamId, Client.DiscordServer.name)), 9905970)));
                return;
            }

            if (config.Info.RemovefromGroup)
            {
                permission.RemoveUserGroup(steamId, config.Info.Group);
                member.user.CreateDM(Client, dm => dm.CreateMessage(Client, GetEmbed(Formatter.ToPlaintext(Lang("Group Revoked", steamId, config.Info.Group)), 16098851)));
            }
        }
コード例 #8
0
        public bool ChangeMaster(GuildEntity guild, GuildMember newMaster, GuildMember oldMaster)
        {
            GuildMemberKey      key   = newMaster.Key;
            HeroesGuildUserType value = GuildMemberRank.Operator.ToGroupUserType();
            int num = -1;

            try
            {
                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                num = heroesGuildDBDataContext.GuildGroupChangeMaster(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(key.NexonSN), new long?((long)key.CharacterSN), key.CharacterName, new int?((int)value));
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in ChangeMaster", ex);
            }
            if (num == 0)
            {
                GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, newMaster.Key.CID, OperationType.HeroesCore_ChangeMaster, GuildLedgerEventType.Success, guild.GuildInfo.MasterName, newMaster.Key.CharacterName));
                return(true);
            }
            GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, newMaster.Key.CID, OperationType.HeroesCore_ChangeMaster, GuildLedgerEventType.DatabaseFail, guild.GuildInfo.MasterName, newMaster.Key.CharacterName));
            return(false);
        }
コード例 #9
0
ファイル: Identity.cs プロジェクト: matrix2113/discord-masz
        /// <summary>
        /// This method checksif the discord user is member of a specified guild and has a mod role or higher as they are specified in the database.
        /// https://discord.com/developers/docs/resources/guild#get-guild-member
        /// </summary>
        /// <param name="guildId">guild that the user requestes for</param>
        /// <returns>the guildmember object if the current user could be found on that guild.</returns>
        public async Task <GuildMember> GetGuildMembership(string guildId)
        {
            if (GuildMemberships.ContainsKey(guildId))
            {
                return(GuildMemberships[guildId]);
            }
            else
            {
                await ValidateBasicDetails();

                if (DiscordUser == null)
                {
                    return(null);
                }
                else
                {
                    GuildMember guildMember = await discord.FetchMemberInfo(guildId, DiscordUser.Id);

                    GuildMemberships.Add(guildId, guildMember);
                    return(guildMember);
                }
            }
        }
コード例 #10
0
        private static void HandleGuildAlert(GameSession session, string message, ChatType type)
        {
            Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

            if (guild == null)
            {
                return;
            }

            GuildMember member = guild.Members.FirstOrDefault(x => x.Player == session.Player);

            if (member == null)
            {
                return;
            }

            if (!((GuildRights)guild.Ranks[member.Rank].Rights).HasFlag(GuildRights.CanGuildAlert))
            {
                return;
            }

            guild.BroadcastPacketGuild(ChatPacket.Send(session.Player, message, type));
        }
コード例 #11
0
        public static Packet MemberBroadcastJoinNotice(GuildMember member, string inviterName, bool displayNotice)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD);

            pWriter.WriteEnum(GuildPacketMode.MemberBroadcastJoinNotice);
            pWriter.WriteUnicodeString(inviterName);
            pWriter.WriteUnicodeString(member.Player.Name);
            pWriter.WriteBool(displayNotice);
            pWriter.WriteByte(0x3);
            pWriter.WriteByte(member.Rank);
            pWriter.WriteLong(member.Player.CharacterId);
            WriteGuildMember(pWriter, member.Player);
            pWriter.WriteShort(); // unk, filler?
            pWriter.WriteLong();  // timestamp
            pWriter.WriteLong();  // timestamp
            pWriter.WriteLong();  // timestamp
            pWriter.WriteLong();  // unk
            pWriter.WriteLong();  // unk
            pWriter.WriteLong();  // unk
            pWriter.WriteLong();  // unk
            pWriter.WriteByte();  // unk
            return(pWriter);
        }
コード例 #12
0
        private static void HandleRankChange(GameSession session, PacketReader packet)
        {
            string memberName = packet.ReadUnicodeString();
            byte   rank       = packet.ReadByte();

            Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

            if (guild == null || session.Player.CharacterId != guild.LeaderCharacterId)
            {
                return;
            }

            GuildMember member = guild.Members.First(x => x.Player.Name == memberName);

            if (member == null || member.Rank == rank)
            {
                return;
            }

            member.Rank = rank;
            session.Send(GuildPacket.RankChangeConfirm(memberName, rank));
            guild.BroadcastPacketGuild(GuildPacket.RankChangeNotice(session.Player.Name, memberName, rank));
        }
コード例 #13
0
        void UpdatePlayerClan(GuildMember discordMember, ulong steamId, Channel channel)
        {
            pinVerification.Remove(steamId);

            IEnumerable <Clan> currentClans = Clan.AllClans.Where(x => x.Members.Contains(steamId));

            for (int i = 0; i < currentClans.Count(); i++)
            {
                currentClans.ElementAt(i)?.RemoveMember(steamId);
            }

            Clan newClan = Clan.AllClans.FirstOrDefault(x => discordMember.roles.Any(c => c.Equals(x.DiscordRoleID)));

            // No Appropriate Clan Found.
            if (newClan == null)
            {
                channel?.CreateMessage(discordClient, $"You are not in any clans. Please choose your clan in #choose-your-clan before re-verifying.");
                return;
            }

            newClan.AddMember(steamId);
            channel?.CreateMessage(discordClient, $"Synced Discord clan with server clan.");
        }
コード例 #14
0
    private static void HandleCheckIn(GameSession session)
    {
        Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

        if (guild == null)
        {
            return;
        }
        GuildMember member = guild.Members.First(x => x.Player == session.Player);

        // Check if attendance timestamp is today
        DateTimeOffset date = DateTimeOffset.FromUnixTimeSeconds(member.AttendanceTimestamp);

        if (date == DateTime.Today)
        {
            return;
        }

        int contributionAmount         = GuildContributionMetadataStorage.GetContributionAmount("attend");
        GuildPropertyMetadata property = GuildPropertyMetadataStorage.GetMetadata(guild.Exp);

        member.AddContribution(contributionAmount);
        member.AttendanceTimestamp = TimeInfo.Now() + Environment.TickCount;
        session.Send(GuildPacket.CheckInBegin());

        Item guildCoins = new(30000861)
        {
            Rarity = 4,
            Amount = property.AttendGuildCoin
        };

        session.Player.Inventory.AddItem(session, guildCoins, true);
        guild.AddExp(session, property.AttendExp);
        guild.ModifyFunds(session, property, property.AttendFunds);
        guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, contributionAmount));
        session.Send(GuildPacket.FinishCheckIn(member));
    }
コード例 #15
0
        public GuildObject(PlayerObject owner, string name)
        {
            Name = name;
            Rank Owner = new Rank()
            {
                Name = "Leader", Options = (RankOptions)255, Index = 0
            };
            GuildMember Leader = new GuildMember()
            {
                name = owner.Info.Name, Player = owner, Id = owner.Info.Index, LastLogin = Envir.Now, Online = true
            };

            Owner.Members.Add(Leader);
            Ranks.Add(Owner);
            Membercount++;
            NeedSave = true;
            if (Level < Settings.Guild_ExperienceList.Count)
            {
                MaxExperience = Settings.Guild_ExperienceList[Level];
            }
            if (Level < Settings.Guild_MembercapList.Count)
            {
                MemberCap = Settings.Guild_MembercapList[Level];
            }

            if (Name == Settings.NewbieName)
            {
                MemberCap = 1000;
            }

            if (Name == Settings.NewbieName)
            {
                Level = 20;
            }

            FlagColour = Color.FromArgb(255, Envir.Random.Next(255), Envir.Random.Next(255), Envir.Random.Next(255));
        }
コード例 #16
0
        private string BuildUpdateGuildMemberSQL(string theguildname, GuildMember guildmember)
        {
            StringBuilder sb = new StringBuilder();

            sb.Clear();
            sb.Append(String.Format("UPDATE PLAYERS SET PlayerName = '{0}', GuildName = '{1}', Class = '{2}', Gender = '{3}', Realm = '{4}', LastModifiedFromGuild = '{5}', LastModifiedReadableFromGuild = '{6}', Level = '{7}', Race = '{8}', GuildRank = '{9}', SpecName = '{10}', SpecRole = '{11}', CachedDateUnix = '{12}' WHERE PlayerName = '{13}'",
                                    guildmember.Character.Name,
                                    theguildname,
                                    Utility.ToTitleCase(guildmember.Character.Class.ToString()),
                                    Utility.ToTitleCase(guildmember.Character.Gender.ToString()),
                                    guildmember.Character.GuildRealm,
                                    guildmember.Character.LastModified,
                                    Utility.ConvertUnixToLocalTime(long.Parse(guildmember.Character.LastModified)),
                                    guildmember.Character.Level.ToString(),
                                    Utility.ToTitleCase(guildmember.Character.Race.ToString()),
                                    guildmember.Rank.ToString(),
                                    guildmember.Character.Specialization != null ? guildmember.Character.Specialization.Name : "UNKNOWN",
                                    guildmember.Character.Specialization != null ? guildmember.Character.Specialization.Role : "UNKNOWN",
                                    Utility.ConvertLocalTimeToUnix(DateTime.Now),
                                    guildmember.Character.Name
                                    ));

            return(sb.ToString());
        }
コード例 #17
0
    void OnCloseReserveClick()
    {
        if (false == GameManager.gameManager.PlayerDataPool.IsHaveGuild())
        {
            return;
        }

        Guild info = GameManager.gameManager.PlayerDataPool.GuildInfo;

        GuildMember mainPlayerGuildInfo = info.GetMainPlayerGuildInfo();

        if (false == mainPlayerGuildInfo.IsValid())
        {
            return;
        }

        if (false == info.IsHaveAuthority(mainPlayerGuildInfo.Job, (int)GameDefine_Globe.GUILD_ROUTINE.GUILD_ROUTINE_CHANGE_JOINREQ))
        {
            GUIData.AddNotifyData("#{2513}");
            return;
        }

        MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{10385}"), "", CloseReserveOK);
    }
コード例 #18
0
ファイル: PlatformGuildAPI.cs プロジェクト: ratiel/Vindictus
        public bool ChangeMaster(GuildEntity guild, GuildMember newMaster, GuildMember oldMaster)
        {
            if (!FeatureMatrix.IsEnable("EnableChangeGuildMaster"))
            {
                return(false);
            }
            GuildMemberKey key = newMaster.Key;

            Log <GuildAPI> .Logger.InfoFormat("ChangeMaster: Guild[{0}], newMasterKey[{1}], oldMasterKey[{2}]", guild.ToString(), key.ToString(), oldMaster.Key.ToString());

            Log <GuildAPI> .Logger.InfoFormat("ChangeMaster: serverCode[{0}] guildSn[{1}] NexonSN[{2}] C_SN[{3}] Name[{4}] Rank[{5}]", new object[]
            {
                GuildAPI.ServerCode,
                guild.GuildSN,
                key.NexonSN,
                key.CharacterSN,
                key.CharacterName,
                GuildMemberRank.Operator.ToGroupUserType()
            });

            HeroesGuildUserType type = GuildMemberRank.Operator.ToGroupUserType();

            return(HeroesGuild.GroupChangeMaster(GuildAPI.ServerCode, guild.GuildSN, key.NexonSN, (long)key.CharacterSN, key.CharacterName, this.ConvertToGroupUserType(type)));
        }
コード例 #19
0
        /// <summary>
        /// Adds a member to the guild.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="rank">The starting rank.</param>
        /// <param name="update">A boolean determining whether the client of the player should be updated.</param>
        public void AddMember(Models.Entities.Player player, Enums.GuildRank rank, bool update = true)
        {
            var guildMember = new GuildMember(new Database.Models.DbGuildRank
            {
                GuildId        = Guild.Id,
                PlayerId       = player.DbPlayer.Id,
                PlayerName     = player.Name,
                PlayerLevel    = player.Level,
                SilverDonation = 0,
                CPDonation     = 0,
                GuildRank      = rank.ToString(),
                JoinDate       = Drivers.Time.GetTime(Drivers.Time.TimeType.Day)
            });

            if (guildMember.DbGuildRank.Create() && _members.TryAdd(player.DbPlayer.Id, guildMember))
            {
                player.AddActionLog("JoinGuild", Guild.Id);

                guildMember.Player = player;
                player.Guild       = Guild;
                player.GuildMember = guildMember;

                if (rank == Enums.GuildRank.GuildLeader)
                {
                    Guild.GuildLeader = guildMember;
                }

                if (update)
                {
                    player.UpdateClientGuild();
                    player.UpdateScreen(true);
                }
            }

            _cachedSortedMembers = null;
        }
コード例 #20
0
        public void DeleteMembers()
        {//carefull this can lead to guild with no ranks or members(or no leader)
            GuildMember Member     = null;
            Rank        MemberRank = null;

            for (int i = 0; i < Ranks.Count; i++)
            {
                for (int j = 0; j < Ranks[i].Members.Count; j++)
                {
                    Member     = Ranks[i].Members[j];
                    MemberRank = Ranks[i];

                    MemberDeleted(Member.name, (PlayerObject)Member.Player, true);
                    if (Member.Player != null)
                    {
                        PlayerObject LeavingMember = (PlayerObject)Member.Player;
                        LeavingMember.RefreshStats();
                    }
                    MemberRank.Members.Remove(Member);
                    NeedSave = true;
                    Membercount--;
                }
            }
        }
コード例 #21
0
ファイル: GuildMemberManager.cs プロジェクト: GedasFX/Alderto
        /// <summary>
        /// Adds a member to <see cref="AldertoDbContext.GuildMembers"/> and, if needed,
        /// creates a guild in <see cref="AldertoDbContext.Guilds"/> and a member in <see cref="AldertoDbContext.Members"/>
        /// </summary>
        /// <param name="guildMember">New <see cref="GuildMember"/> to add.</param>
        public async Task AddGuildMemberAsync(GuildMember guildMember)
        {
            var guild = await _context.Guilds.FindAsync(guildMember.GuildId);

            // Check if guild exists, and if it doesn't - add one.
            // Otherwise the database will spew foreign key violation problems.
            if (guild == null)
            {
                guild = new Guild(guildMember.GuildId);
                await _context.Guilds.AddAsync(guild);
            }

            var member = await _context.Members.FindAsync(guildMember.MemberId);

            if (member == null)
            {
                member = new Member(guildMember.MemberId);
                await _context.Members.AddAsync(member);
            }

            await _context.GuildMembers.AddAsync(guildMember);

            await _context.SaveChangesAsync();
        }
コード例 #22
0
 public override IEnumerable <object> Run()
 {
     base.Finished = true;
     if (!base.Entity.IsInitialized)
     {
         yield return(new OkMessage());
     }
     else
     {
         GuildMember member = base.Entity.GetGuildMember(base.Operation.CharacterName);
         if (member != null)
         {
             member.SetLevel(base.Operation.Level);
             base.Entity.ReportGuildMemberChanged(member.Key);
             base.Entity.Sync();
             yield return(new OkMessage());
         }
         else
         {
             yield return(new FailMessage("[ReportGuildMemberChangedProcessor] member"));
         }
     }
     yield break;
 }
コード例 #23
0
        public bool AcceptJoin(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, bool accept)
        {
            int num = -1;

            try
            {
                if (operatorRank.HasAcceptJoinPermission(targetMember.Rank))
                {
                    HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                    if (accept)
                    {
                        num = heroesGuildDBDataContext.GuildUserJoinApply(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName);
                    }
                    else
                    {
                        num = heroesGuildDBDataContext.GuildUserJoinReject(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName);
                    }
                }
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in AcceptJoin(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, bool accept)", ex);
            }
            GuildLedgerEventType eventType;

            if (num == 0)
            {
                eventType = GuildLedgerEventType.Success;
            }
            else
            {
                eventType = GuildLedgerEventType.DatabaseFail;
            }
            GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_ResponseJoin, eventType, string.Format("GuildSn: {0}, isAccept: {1}", guild.GuildSN, accept.ToString()), targetMember.Key.ToString()));
            return(num == 0);
        }
コード例 #24
0
        public static async Task AddGuildMemberAsync(Player player, int index, GuildMember member)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, "name");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, member.Name);
            Amf3Helper.WriteText(writer, "zone");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, member.Zone);
            Amf3Helper.WriteText(writer, "rank");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, member.Rank);
            Amf3Helper.WriteText(writer, "online");

            writer.Write((byte)(member.Online ? Amf3Type.True : Amf3Type.False));
            Amf3Helper.WriteText(writer, "index");

            writer.Write((byte)Amf3Type.Integer);
            Amf3Helper.WriteNumber2(writer, (uint)index);

            writer.Write((byte)Amf3Type.Null);

            player.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = player,
                Content     = stream.ToArray(),
                MessageName = "AddGuildMember"
            });
        }
コード例 #25
0
 public void AddMemberItem(GuildMember member)
 {
     this.mMemberItemsTable.AddData(new GuildMemberItemData(member));
 }
コード例 #26
0
        public bool DeleteMember(PlayerObject Kicker, string membername)
        {//carefull this can lead to guild with no ranks or members(or no leader)
            GuildMember Member     = null;
            Rank        MemberRank = null;

            if ((Kicker.MyGuild != this) || (Kicker.MyGuildRank == null))
            {
                return(false);
            }
            for (int i = 0; i < Ranks.Count; i++)
            {
                for (int j = 0; j < Ranks[i].Members.Count; j++)
                {
                    if (Ranks[i].Members[j].name == membername)
                    {
                        Member     = Ranks[i].Members[j];
                        MemberRank = Ranks[i];
                        goto Found;
                    }
                }
            }

Found:
            if (Member == null)
            {
                return(false);
            }
            if (((Kicker.MyGuildRank.Index >= MemberRank.Index) && (Kicker.MyGuildRank.Index != 0)) && (Kicker.Info.Name != membername))
            {
                Kicker.ReceiveChat("你的职位权限不够。", ChatType.System);
                return(false);
            }
            if (MemberRank.Index == 0)
            {
                if (MemberRank.Members.Count < 2)
                {
                    Kicker.ReceiveChat("你不能离开行会,因为你是领导者。", ChatType.System);
                    return(false);
                }
                for (int i = 0; i < MemberRank.Members.Count; i++)
                {
                    if ((MemberRank.Members[i].Online) && (MemberRank.Members[i] != Member))
                    {
                        goto AllOk;
                    }
                }
                Kicker.ReceiveChat("需要至少1个行会领导在线。", ChatType.System);
                return(false);
            }
AllOk:
            MemberDeleted(membername, (PlayerObject)Member.Player, Member.name == Kicker.Info.Name);
            if (Member.Player != null)
            {
                PlayerObject LeavingMember = (PlayerObject)Member.Player;
                LeavingMember.RefreshStats();
            }
            MemberRank.Members.Remove(Member);
            NeedSave = true;
            Membercount--;
            return(true);
        }
コード例 #27
0
ファイル: UIGuild.cs プロジェクト: ElionGreed/Project-M
    void Update()
    {
        Player player = Player.localPlayer;

        if (player)
        {
            // hotkey (not while typing in chat, etc.)
            if (Input.GetKeyDown(hotKey) && !UIUtils.AnyInputActive())
            {
                panel.SetActive(!panel.activeSelf);
            }

            // only update the panel if it's active
            if (panel.activeSelf)
            {
                Guild guild       = player.guild;
                int   memberCount = guild.members != null ? guild.members.Length : 0;

                // guild properties
                nameText.text            = player.guild.name;
                masterText.text          = guild.master;
                currentCapacityText.text = memberCount.ToString();
                maximumCapacityText.text = GuildSystem.Capacity.ToString();

                // notice edit button
                noticeEditButton.interactable = guild.CanNotify(player.name) &&
                                                !noticeInput.interactable;
                noticeEditButton.onClick.SetListener(() => {
                    noticeInput.interactable = true;
                });

                // notice set button
                noticeSetButton.interactable = guild.CanNotify(player.name) &&
                                               noticeInput.interactable &&
                                               NetworkTime.time >= player.nextRiskyActionTime;
                noticeSetButton.onClick.SetListener(() => {
                    noticeInput.interactable = false;
                    if (noticeInput.text.Length > 0 &&
                        !string.IsNullOrWhiteSpace(noticeInput.text) &&
                        noticeInput.text != guild.notice)
                    {
                        player.CmdSetGuildNotice(noticeInput.text);
                    }
                });

                // notice input: copies notice while not editing it
                if (!noticeInput.interactable)
                {
                    noticeInput.text = guild.notice ?? "";
                }
                noticeInput.characterLimit = GuildSystem.NoticeMaxLength;

                // leave
                leaveButton.interactable = guild.CanLeave(player.name);
                leaveButton.onClick.SetListener(() => {
                    player.CmdLeaveGuild();
                });

                // instantiate/destroy enough slots
                UIUtils.BalancePrefabs(slotPrefab.gameObject, memberCount, memberContent);

                // refresh all members
                for (int i = 0; i < memberCount; ++i)
                {
                    UIGuildMemberSlot slot   = memberContent.GetChild(i).GetComponent <UIGuildMemberSlot>();
                    GuildMember       member = guild.members[i];

                    slot.onlineStatusImage.color    = member.online ? onlineColor : offlineColor;
                    slot.nameText.text              = member.name;
                    slot.levelText.text             = member.level.ToString();
                    slot.rankText.text              = member.rank.ToString();
                    slot.promoteButton.interactable = guild.CanPromote(player.name, member.name);
                    slot.promoteButton.onClick.SetListener(() => {
                        player.CmdGuildPromote(member.name);
                    });
                    slot.demoteButton.interactable = guild.CanDemote(player.name, member.name);
                    slot.demoteButton.onClick.SetListener(() => {
                        player.CmdGuildDemote(member.name);
                    });
                    slot.kickButton.interactable = guild.CanKick(player.name, member.name);
                    slot.kickButton.onClick.SetListener(() => {
                        player.CmdGuildKick(member.name);
                    });
                }
            }
        }
        else
        {
            panel.SetActive(false);
        }
    }
コード例 #28
0
ファイル: MessageAuthor.cs プロジェクト: LegendModzYT/Anarchy
        public MessageAuthor(DiscordUser user, GuildMember member)
        {
            User = user;

            Member = member;
        }
コード例 #29
0
 public override void Deserialize(ICustomDataInput reader)
 {
     m_member = new GuildMember();
     m_member.Deserialize(reader);
 }
コード例 #30
0
 private void OnAddMemberUpdateEvent(GuildMember gdMb)
 {
     this.mGuildMemberTabLayer.AddMemberItem(gdMb);
 }
コード例 #31
0
ファイル: GuildSubSystem.cs プロジェクト: floatyears/Decrypt
 public void OnMsgGuildMemberUpdate(MemoryStream stream)
 {
     MS2C_GuildMemberUpdate mS2C_GuildMemberUpdate = Serializer.NonGeneric.Deserialize(typeof(MS2C_GuildMemberUpdate), stream) as MS2C_GuildMemberUpdate;
     GuildMember guildMember = this.GetMember(mS2C_GuildMemberUpdate.ID);
     if (guildMember == null)
     {
         if (mS2C_GuildMemberUpdate.ID == 0uL)
         {
             return;
         }
         guildMember = new GuildMember();
         guildMember.ID = mS2C_GuildMemberUpdate.ID;
         guildMember.Level = mS2C_GuildMemberUpdate.Level;
         guildMember.TotalReputation = mS2C_GuildMemberUpdate.TotalReputation;
         guildMember.CurReputation = mS2C_GuildMemberUpdate.CurReputation;
         guildMember.Rank = mS2C_GuildMemberUpdate.Rank;
         guildMember.Flag = mS2C_GuildMemberUpdate.Flag;
         guildMember.LastOnlineTime = mS2C_GuildMemberUpdate.LastOnlineTime;
         guildMember.Name = mS2C_GuildMemberUpdate.Name;
         this.Members.Add(guildMember);
         if (this.AddMemberUpdateEvent != null)
         {
             this.AddMemberUpdateEvent(guildMember);
         }
     }
     else
     {
         if (mS2C_GuildMemberUpdate.Level != 0)
         {
             guildMember.Level = mS2C_GuildMemberUpdate.Level;
         }
         if (mS2C_GuildMemberUpdate.TotalReputation != 0)
         {
             guildMember.TotalReputation = mS2C_GuildMemberUpdate.TotalReputation;
         }
         if (mS2C_GuildMemberUpdate.CurReputation != 0)
         {
             if (mS2C_GuildMemberUpdate.CurReputation == -1)
             {
                 guildMember.CurReputation = 0;
             }
             else
             {
                 guildMember.CurReputation = mS2C_GuildMemberUpdate.CurReputation;
             }
         }
         if (mS2C_GuildMemberUpdate.Rank != 0)
         {
             guildMember.Rank = mS2C_GuildMemberUpdate.Rank;
         }
         if (mS2C_GuildMemberUpdate.Flag != 0)
         {
             guildMember.Flag = mS2C_GuildMemberUpdate.Flag;
         }
         if (this.MemberUpdateEvent != null)
         {
             this.MemberUpdateEvent(guildMember);
         }
     }
 }
コード例 #32
0
ファイル: GuildObject.cs プロジェクト: chilin/mir2
 public void NewMember(PlayerObject newmember)
 {
     if (Ranks.Count < 2)
         Ranks.Add(new Rank() { Name = "Members", Index = 1});
     Rank currentrank = Ranks[Ranks.Count - 1];
     GuildMember Member = new GuildMember() { name = newmember.Info.Name, Player = newmember, Id = newmember.Info.Index, LastLogin = Envir.Now, Online = true };
     currentrank.Members.Add(Member);
     PlayerLogged(newmember, true, true);
     newmember.RefreshStats();
     newmember.Enqueue(new ServerPackets.GuildBuffList() { ActiveBuffs = BuffList });
     Membercount++;
     NeedSave = true;
 }
コード例 #33
0
ファイル: GameUIBasePopup.cs プロジェクト: floatyears/Decrypt
 public virtual void InitPopUp(GuildMember guildMember)
 {
 }
コード例 #34
0
ファイル: GuildMember.cs プロジェクト: CptDefault/ggj2016
    private void DisplayChatMessage(string message, GuildMember member)
    {
        DamageNumberManager.DisplayMessage(message, member.gameObject.transform);

        ChatBox.Instance.AddChatMessage(string.Format("[{0}]{1}[-]: {2}", ColorToHex(member.Config.Color), member.Name, message));
    }
コード例 #35
0
 protected override void Awake()
 {
     _guildMember = GetComponent<GuildMember>();
     base.Awake();
 }
コード例 #36
0
ファイル: GuildObject.cs プロジェクト: Ilmarinen946/mir2
        public void NewMember(PlayerObject newmember)
        {
            if (Ranks.Count < 2)
                Ranks.Add(new Rank() { Name = "Members", Index = 1});
            Rank currentrank = Ranks[Ranks.Count - 1];
            GuildMember Member = new GuildMember() { name = newmember.Info.Name, Player = newmember, Id = newmember.Info.Index, LastLogin = Envir.Now, Online = true };
            currentrank.Members.Add(Member);
            PlayerLogged(newmember, true, true);

            Membercount++;
            NeedSave = true;
        }
コード例 #37
0
ファイル: guild_home.cs プロジェクト: aura-project/aura
	private void CancelApplication(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error)
	{
		member.Rank = GuildMemberRank.Declined;
		WebServer.Instance.Database.UpdateGuildMemberRank(member);

		success = "Your application will be canceled shortly.";
	}
コード例 #38
0
 public GuildInformationsMemberUpdateMessage(GuildMember member)
 {
     m_member = member;
 }
コード例 #39
0
ファイル: guild_home.cs プロジェクト: aura-project/aura
	private void LeaveGuild(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error)
	{
		member.Rank = GuildMemberRank.Declined;
		WebServer.Instance.Database.UpdateGuildMemberRank(member);

		success = "You will be leaving the guild shortly.";
	}
コード例 #40
0
ファイル: Action6017.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            int nameLength = System.Text.Encoding.Default.GetByteCount(guildName);
            List <UserQueue> queueArray = new GameDataCacheSet <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui);

            if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0 && queueArray[0].IsSuspend == false)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6006_GuildMemberNotDate;
                return(false);
            }
            int createGoinNum = ConfigEnvSet.GetInt("UserGuild.CreateGoinNum");
            int createLv      = ConfigEnvSet.GetInt("UserGuild.CreateUserLv");

            if (ContextUser.UserLv < createLv)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                return(false);
            }

            if (ContextUser.GameCoin < createGoinNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                return(false);
            }
            if (guildName == "")
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_GuildNameNotEmpty;
                return(false);
            }

            if (nameLength < 4 || nameLength > 12)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_GuildNameTooLong;
                return(false);
            }

            List <GuildMember> memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.UserID == ContextUser.UserID);

            if (memberArray.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_UnionMembers;
                return(false);
            }
            List <UserGuild> guildArray = new ShareCacheStruct <UserGuild>().FindAll(u => u.GuildName == guildName);

            if (guildArray.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_GuildRename;
                return(false);
            }
            List <UserGuild> userGuildArray = new ShareCacheStruct <UserGuild>().FindAll();
            int rankID = 0;

            if (userGuildArray.Count > 0)
            {
                rankID = MathUtils.Addition(userGuildArray.Count, 1, int.MaxValue);
            }
            else
            {
                rankID = 1;
            }

            string guildID = Guid.NewGuid().ToString();

            ContextUser.MercenariesID = guildID;

            ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, createGoinNum, 0);

            UserGuild userGuild = new UserGuild()
            {
                GuildID        = guildID,
                UserID         = ContextUser.UserID,
                GuildName      = guildName,
                GuildLv        = 1,
                GuildRank      = rankID,
                WeekExperience = 0,
                CurrExperience = 0,
                CreateDate     = DateTime.Now,
            };

            new ShareCacheStruct <UserGuild>().Add(userGuild, GameEnvironment.CacheGlobalPeriod);


            GuildMember member = new GuildMember()
            {
                GuildID           = guildID,
                UserID            = ContextUser.UserID,
                PostType          = PostType.Chairman,
                Contribution      = 0,
                TotalContribution = 0,
                DevilNum          = 0,
                SummonNum         = 0,
                IsDevil           = 0,
                IncenseNum        = 0,
                InsertDate        = DateTime.Now
            };

            new ShareCacheStruct <GuildMember>().Add(member, GameEnvironment.CacheGlobalPeriod);
            var temp = new ShareCacheStruct <GuildMember>().FindKey(guildID, ContextUser.UserID);

            if (temp.HasChanged)
            {
                TraceLog.WriteInfo("6017 GuildMember update success.");
            }
            GuildIdol idolInfo = new GuildIdol()
            {
                GuildID        = guildID,
                IdolLv         = 1,
                CurrExperience = 0
            };

            new ShareCacheStruct <GuildIdol>().Add(idolInfo, GameEnvironment.CacheGlobalPeriod);
            return(true);
        }
コード例 #41
0
ファイル: guild_home.cs プロジェクト: aura-project/aura
	private void DeclineApplication(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error)
	{
		member.Rank = GuildMemberRank.Declined;
		WebServer.Instance.Database.UpdateGuildMemberRank(member);

		success = string.Format("{0}'s application has been declined.", member.Name);
	}
コード例 #42
0
ファイル: GuildCreator.cs プロジェクト: CptDefault/ggj2016
 private void SpawnGuildMembers(GuildMember.GuildMemberType type, int count, bool pug = false)
 {
     for (int i = 0; i < count; i++)
     {
         var position = transform.position;
         position.y += (_membersSpawned % 2) == 0 ? 0 : MemberSpacing + Random.Range(-0.1f, 0.1f);
         position.x += (_membersSpawned / 2) * MemberSpacing + Random.Range(-0.3f, 0.3f); 
         var memberGo = (GameObject)Instantiate(Prefab, position, Quaternion.identity);
         var guildMember = memberGo.GetComponent<GuildMember>();
         guildMember.MemberType = type;
         _membersSpawned++;
         if (pug)
             guildMember.PickUpGroup();
     }
 }
コード例 #43
0
ファイル: guild_home.cs プロジェクト: aura-project/aura
	private void RemoveMember(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error)
	{
		member.Rank = GuildMemberRank.Declined;
		WebServer.Instance.Database.UpdateGuildMemberRank(member);

		success = string.Format("{0} will get removed from the guild shortly.", member.Name);
	}
コード例 #44
0
        public bool ChangeRank(PlayerObject Self, string membername, byte RankIndex, string RankName = "Members")
        {
            if ((Self.MyGuild != this) || (Self.MyGuildRank == null))
            {
                return(false);
            }
            if (RankIndex >= Ranks.Count)
            {
                return(false);
            }
            GuildMember Member     = null;
            Rank        MemberRank = null;

            for (int i = 0; i < Ranks.Count; i++)
            {
                for (int j = 0; j < Ranks[i].Members.Count; j++)
                {
                    if (Ranks[i].Members[j].name == membername)
                    {
                        Member     = Ranks[i].Members[j];
                        MemberRank = Ranks[i];
                        goto Found;
                    }
                }
            }

Found:
            if (Member == null)
            {
                return(false);
            }

            MirDatabase.CharacterInfo Character = Envir.GetCharacterInfo(membername);
            if (Character == null)
            {
                return(false);
            }
            if ((RankIndex == 0) && (Character.Level < Settings.Guild_RequiredLevel))
            {
                Self.ReceiveChat(String.Format("行会领导者至少需要{0}级。", Settings.Guild_RequiredLevel), ChatType.System);
                return(false);
            }

            if ((MemberRank.Index >= Self.MyGuildRank.Index) && (Self.MyGuildRank.Index != 0))
            {
                return(false);
            }
            if (MemberRank.Index == 0)
            {
                if (MemberRank.Members.Count <= 2)
                {
                    Self.ReceiveChat("行会至少需要2名领导。", ChatType.System);
                    return(false);
                }
                for (int i = 0; i < MemberRank.Members.Count; i++)
                {
                    if ((MemberRank.Members[i].Player != null) && (MemberRank.Members[i] != Member))
                    {
                        goto AllOk;
                    }
                }
                Self.ReceiveChat("需要至少1个领导在线。", ChatType.System);
                return(false);
            }

AllOk:
            Ranks[RankIndex].Members.Add(Member);
            MemberRank.Members.Remove(Member);

            MemberRank = Ranks[RankIndex];

            List <Rank> NewRankList = new List <Rank>();

            NewRankList.Add(Ranks[RankIndex]);
            NeedSave = true;
            PlayerObject player = (PlayerObject)Member.Player;

            if (player != null)
            {
                player.MyGuildRank = Ranks[RankIndex];
                player.Enqueue(new ServerPackets.GuildMemberChange()
                {
                    Name = Self.Info.Name, Status = (byte)8, Ranks = NewRankList
                });
                player.BroadcastInfo();
            }

            for (int i = 0; i < Ranks.Count; i++)
            {
                for (int j = 0; j < Ranks[i].Members.Count; j++)
                {
                    if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != Member.Player))
                    {
                        player = (PlayerObject)Ranks[i].Members[j].Player;
                        player.Enqueue(new ServerPackets.GuildMemberChange()
                        {
                            Name = Member.name, Status = (byte)5, RankIndex = (byte)MemberRank.Index
                        });
                        player.GuildMembersChanged = true;
                    }
                }
            }
            return(true);
        }
コード例 #45
0
 public GuildMemberItemData(GuildMember gdm)
 {
     this.MemberData = gdm;
 }
コード例 #46
0
        public static MenuFlyout MakeVoiceMemberMenu(GuildMember member)
        {
            MenuFlyout menu = new MenuFlyout();

            menu.MenuFlyoutPresenterStyle = (Style)App.Current.Resources["MenuFlyoutPresenterStyle1"];

            // Add "Profile" button
            MenuFlyoutItem profile = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/Profile"),
                Tag  = member.User,
                Icon = new SymbolIcon(Symbol.ContactInfo)
            };

            profile.Click += FlyoutManager.OpenProfile;
            menu.Items.Add(profile);

            // If member is not current user
            if (member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add "Message" button
                MenuFlyoutItem message = new MenuFlyoutItem()
                {
                    Text = App.GetString("/Flyouts/Message"),
                    Tag  = member.User.Id,
                    Icon = new SymbolIcon(Symbol.Message)
                };
                message.Click += FlyoutManager.MessageUser;
                menu.Items.Add(message);
            }


            // Add Separator
            MenuFlyoutSeparator sep1 = new MenuFlyoutSeparator();

            menu.Items.Add(sep1);


            // If not current user
            if (member.User.Id != LocalState.CurrentUser.Id)
            {
                // Create "Invite to Server" sub item
                MenuFlyoutSubItem InviteToServer = new MenuFlyoutSubItem()
                {
                    Text = App.GetString("/Flyouts/InviteToServer")
                           //Tag = member.Raw.User.Id,
                           //Icon = new SymbolIcon(Symbol.)
                };

                // Check all Guilds
                foreach (KeyValuePair <string, LocalModels.Guild> guild in LocalState.Guilds)
                {
                    // If can Create Instant Invite
                    if (guild.Value.permissions.Administrator || guild.Value.permissions.CreateInstantInvite)
                    {
                        // Add Guild to list
                        MenuFlyoutItem item = new MenuFlyoutItem()
                        {
                            Text = guild.Value.Raw.Name, Tag = new Tuple <string, string>(guild.Value.channels.FirstOrDefault().Value.raw.Id, member.User.Id)
                        };
                        item.Click += FlyoutManager.InviteToServer;
                        InviteToServer.Items.Add(item);
                    }
                }

                // Add "Invite to Server" to menu
                menu.Items.Add(InviteToServer);
            }

            // Create "Add Friend" button
            MenuFlyoutItem addFriend = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/AddFriend"),
                Tag  = member.User.Id,
                Icon = new SymbolIcon(Symbol.AddFriend)
            };

            addFriend.Click += FlyoutManager.AddFriend;

            // Create "Remove Friend" button
            MenuFlyoutItem removeFriend = new MenuFlyoutItem()
            {
                Text       = App.GetString("/Flyouts/RemoveFriend"),
                Tag        = member.User.Id,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                Icon       = new SymbolIcon(Symbol.ContactPresence)
            };

            removeFriend.Click += FlyoutManager.RemoveFriend;

            // Create "Block" button
            MenuFlyoutItem block = new MenuFlyoutItem()
            {
                Text       = App.GetString("/Flyouts/Block"),
                Tag        = member.User.Id,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                Icon       = new SymbolIcon(Symbol.BlockContact)
            };

            block.Click += FlyoutManager.BlockUser;

            // Create "Unblock" button
            MenuFlyoutItem unBlock = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/Unblock"),
                Tag  = member.User.Id,
                Icon = new SymbolIcon(Symbol.ContactPresence)
            };

            unBlock.Click += FlyoutManager.RemoveFriend;

            // Create "Accept Friend Request" button
            MenuFlyoutItem acceptFriendRequest = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/AcceptFriendRequest"),
                Tag  = member.User.Id,
                Icon = new SymbolIcon(Symbol.AddFriend)
            };

            acceptFriendRequest.Click += FlyoutManager.AddFriend;

            // Choose which buttons to show
            if (LocalState.Friends.ContainsKey(member.User.Id))
            {
                switch (LocalState.Friends[member.User.Id].Type)
                {
                // No relation
                case 0:
                    // Add "Add Friend" and "Block" buttons
                    menu.Items.Add(addFriend);
                    menu.Items.Add(block);
                    break;

                // Friend
                case 1:
                    // Add "Remove Friend" and "Block" buttons
                    menu.Items.Add(removeFriend);
                    menu.Items.Add(block);
                    break;

                // Blocked
                case 2:
                    // Add "Block" button
                    menu.Items.Add(unBlock);
                    break;

                // Incoming Friend Request
                case 3:
                    // Add "Accept Friend Request" button
                    menu.Items.Add(acceptFriendRequest);
                    menu.Items.Add(block);
                    break;

                // Outgoing Friend Request
                case 4:
                    // Add "Block" button
                    menu.Items.Add(block);
                    break;
                }
            }
            // Member is current user
            else if (member.User.Id == LocalState.CurrentUser.Id)
            {
                // No buttons for current user
            }
            else
            {
                // Default to no relation
                menu.Items.Add(addFriend);
                menu.Items.Add(block);
            }


            // If member is not current user
            if (member.User.Id != LocalState.CurrentUser.Id)
            {
                MenuFlyoutSeparator sep2 = new MenuFlyoutSeparator();
                menu.Items.Add(sep2);
            }

            // If can change user's nickname
            if (Permissions.CanChangeNickname(member.User.Id, App.CurrentGuildId))
            {
                // Add "Change Nickname" button
                MenuFlyoutItem changeNickname = new MenuFlyoutItem()
                {
                    Text = App.GetString("/Flyouts/ChangeNickname"),
                    Tag  = member.User.Id,
                    Icon = new SymbolIcon(Symbol.Rename)
                };
                changeNickname.Click += FlyoutManager.ChangeNickname;
                menu.Items.Add(changeNickname);
            }

            // If Current User has manage roles permission
            if (LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.ManageRoles)
            {
                // Create "Roles" subitem
                MenuFlyoutSubItem roles = new MenuFlyoutSubItem()
                {
                    Text = App.GetString("/Flyouts/Roles")
                           //Tag = member.Raw.User.Id,
                           //Icon = new SymbolIcon(Symbol.)
                };

                // Add Server's roles to Role SubItem
                foreach (DiscordAPI.SharedModels.Role role in LocalState.Guilds[App.CurrentGuildId].roles.Values.OrderByDescending(x => x.Position))
                {
                    ToggleMenuFlyoutItem roleItem = new ToggleMenuFlyoutItem()
                    {
                        Text       = role.Name,
                        Tag        = new Tuple <string, string>(role.Id, member.User.Id),
                        Foreground = Common.IntToColor(role.Color),
                        IsChecked  = member.Roles != null && member.Roles.Contains(role.Id),
                        //Style = (Style)App.Current.Resources["ToggleOnlyCheckbox"],
                        IsEnabled = LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles.FirstOrDefault() != null && role.Position < LocalState.Guilds[App.CurrentGuildId].roles[LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles.FirstOrDefault()].Position || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id  //TODO: Double check role system
                    };
                    roleItem.Click += FlyoutManager.AddRole;
                    if (role.Name != "@everyone")
                    {
                        roles.Items.Add(roleItem);
                    }
                }

                // Add Roles subitem to menu
                menu.Items.Add(roles);
            }

            // If Current User has kick members permission
            if ((LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.KickMembers) && LocalState.Guilds[App.CurrentGuildId].GetHighestRole(member.Roles).Position < LocalState.Guilds[App.CurrentGuildId].GetHighestRole(LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles).Position || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id && member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add "Kick Member" button
                MenuFlyoutItem kickMember = new MenuFlyoutItem()
                {
                    Text       = App.GetString("/Flyouts/KickMember"),
                    Tag        = member.User.Id,
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                    Icon       = new SymbolIcon(Symbol.BlockContact)
                };
                kickMember.Click += FlyoutManager.KickMember;
                menu.Items.Add(kickMember);
            }
            // If Member is current user and current user is not owner
            else if (member.User.Id == LocalState.CurrentUser.Id && LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId != LocalState.CurrentUser.Id)
            {
                // Add "Leave Server" button
                MenuFlyoutItem leaveServer = new MenuFlyoutItem()
                {
                    Text       = App.GetString("/Flyouts/LeaveServer"),
                    Tag        = member.User.Id,
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                    Icon       = new SymbolIcon(Symbol.Remove)
                };
                leaveServer.Click += FlyoutManager.LeaveServer;
                menu.Items.Add(leaveServer);
            }

            // If User has ban members permission
            if (((LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.BanMembers) && LocalState.Guilds[App.CurrentGuildId].GetHighestRole(member.Roles).Position < LocalState.Guilds[App.CurrentGuildId].GetHighestRole(LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles).Position) || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id && member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add "Ban Member" button
                MenuFlyoutItem banMember = new MenuFlyoutItem()
                {
                    Text       = App.GetString("/Flyouts/BanMember"),
                    Tag        = member.User.Id,
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                    Icon       = new SymbolIcon(Symbol.BlockContact)
                };
                banMember.Click += FlyoutManager.BanMember;
                menu.Items.Add(banMember);
            }

            // If member is a bot
            if (member.User.Bot)
            {
                // Add Separator
                menu.Items.Add(new MenuFlyoutSeparator());

                // Add extra bot specific stuff
                foreach (var feature in BotExtrasManager.GetBotFeatures(member.User.Id))
                {
                    MenuFlyoutItem link = new MenuFlyoutItem()
                    {
                        Text = feature.Name,
                        Tag  = feature.Url,
                        Icon = new FontIcon()
                        {
                            Glyph = feature.Icon
                        }
                    };
                    link.Click += FlyoutManager.OpenURL;
                    menu.Items.Add(link);
                }
            }

            return(menu);
        }
コード例 #47
0
ファイル: GuildMember.cs プロジェクト: CptDefault/ggj2016
    private void DisplayChatMessage(string[] messages, GuildMember member)
    {
        var message = messages[Random.Range(0, messages.Length)];

        DamageNumberManager.DisplayMessage(message, member.gameObject.transform);

        ChatBox.Instance.AddChatMessage(string.Format("[{0}]{1}[-]: {2}", ColorToHex(member.Config.Color), member.Name, message));
    }