コード例 #1
0
ファイル: AtavismGuild.cs プロジェクト: clock2255/awagas
        public void HandleGuildData(Dictionary <string, object> props)
        {
#if AT_I2LOC_PRESET
            //ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Got guild update"));
#else
            //   ClientAPI.Write("Got guild update");
#endif
            members = new List <AtavismGuildMember>();
            ranks   = new List <AtavismGuildRank>();

            guildName = (string)props["guildName"];
            if (guildName == null)
            {
                // dispatch a ui event to tell the rest of the system
                string[] args = new string[1];
                AtavismEventSystem.DispatchEvent("GUILD_UPDATE", args);
                return;
            }
            motd  = (string)props["motd"];
            omotd = (string)props["omotd"];

            int numMembers = (int)props["numMembers"];
            for (int i = 0; i < numMembers; i++)
            {
                AtavismGuildMember member = new AtavismGuildMember();
                member.oid    = (OID)props["memberOid" + i];
                member.name   = (string)props["memberName" + i];
                member.rank   = (int)props["memberRank" + i];
                member.level  = (int)props["memberLevel" + i];
                member.zone   = (string)props["memberZone" + i];
                member.note   = (string)props["memberNote" + i];
                member.status = (int)props["memberStatus" + i];
                members.Add(member);
            }

            int numRanks = (int)props["numRanks"];
            for (int i = 0; i < numRanks; i++)
            {
                AtavismGuildRank rank = new AtavismGuildRank();
                rank.rankLevel   = (int)props["rankLevel" + i];
                rank.rankName    = (string)props["rankName" + i];
                rank.permissions = new List <AtavismGuildRankPermission>();
                int rankNumPermissions = (int)props["rankNumPermissions" + i];
                for (int j = 0; j < rankNumPermissions; j++)
                {
                    string permission = (string)props["rankNum" + i + "Permission" + j];
                    rank.permissions.Add((AtavismGuildRankPermission)Enum.Parse(typeof(AtavismGuildRankPermission), permission));
                }
                ranks.Add(rank);
            }
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("GUILD_UPDATE", event_args);
        }
コード例 #2
0
ファイル: AtavismGuild.cs プロジェクト: clock2255/awagas
        public void HandleMemberUpdate(Dictionary <string, object> props)
        {
            OID    memberOid = (OID)props["memberOid"];
            string action    = (string)props["action"];

            //ClientAPI.Write("Got Member update with action: " + action);

            AtavismGuildMember member;

            if (action == "Remove")
            {
                member = GetGuildMemberByOid(memberOid);
                if (member != null)
                {
                    members.Remove(member);
                }
                // dispatch a ui event to tell the rest of the system
                string[] event_args = new string[1];
                AtavismEventSystem.DispatchEvent("GUILD_UPDATE", event_args);
                return;
            }

            if (action == "Update")
            {
                member = GetGuildMemberByOid(memberOid);
            }
            else
            {
                member = new AtavismGuildMember();
                members.Add(member);
            }
            member.oid    = (OID)props["memberOid"];
            member.name   = (string)props["memberName"];
            member.rank   = (int)props["memberRank"];
            member.level  = (int)props["memberLevel"];
            member.zone   = (string)props["memberZone"];
            member.note   = (string)props["memberNote"];
            member.status = (int)props["memberStatus"];

            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("GUILD_UPDATE", args);
        }