コード例 #1
0
        public void avatarfindfriend(string username, string token, string friendname)
        {
            var pattern = @"/(" + friendname + @")/gi";
            var filter  = Builders <BsonDocument> .Filter.Regex(InfoNameDefs.AvatarName
                                                                , pattern);

            var res = dbavatar.FindManyData(TableName, filter, ADBAccessor.projections(InfoNameDefs.AvatarName
                                                                                       , InfoNameDefs.AvatarHead
                                                                                       , InfoNameDefs.Username));

            if (res != null && res.Count > 0)
            {
                var lres = new List <List <string> >();
                foreach (var r in res)
                {
                    var l = new List <string>();
                    l.Add(InfoNameDefs.AvatarName);
                    l.Add(r[InfoNameDefs.AvatarName].AsString);
                    l.Add(InfoNameDefs.AvatarHead);
                    l.Add(r.Contains(InfoNameDefs.AvatarHead) ? r[InfoNameDefs.AvatarHead].AsInt32.ToString() : "0");
                    l.Add("accid");
                    l.Add(r[InfoNameDefs.Username].AsString);
                    lres.Add(l);
                }
                SendError("names", AWebServerUtils.ToJsonArray(lres.ToArray()));
            }
            else
            {
                SendError(ErrorDefs.FindNone);
            }
        }
コード例 #2
0
        public void avatargetrank(string username, string token, string ranktype, string count)
        {
            int icount = typeParser.intParse(count);

            if (icount <= 0 || icount > 100)
            {
                SendError("Invalid count " + count);
                return;
            }
            var iranktype = typeParser.intParse(ranktype);

            if (iranktype < 0 || iranktype >= (int)ERankType.RankNum)
            {
                SendError("Invalid ranktype " + ranktype);
                return;
            }
            var a = GetAvatar(username, token);

            if (a != null)
            {
                switch ((ERankType)iranktype)
                {
                case ERankType.Money:
                    var res = dbavatar.FindManyData(TableName, null
                                                    , ADBAccessor.projections(InfoNameDefs.AvatarName, InfoNameDefs.AvatarMoney, InfoNameDefs.AvatarHead)
                                                    , icount, 0, ADBAccessor.sort_Descending(InfoNameDefs.AvatarMoney));
                    var lres = new List <List <string> >();
                    foreach (var r in res)
                    {
                        var l = new List <string>();
                        l.Add(InfoNameDefs.AvatarName);
                        l.Add(r[InfoNameDefs.AvatarName].AsString);
                        if (r.Contains(InfoNameDefs.AvatarMoney))
                        {
                            l.Add(InfoNameDefs.AvatarMoney);
                            l.Add(r[InfoNameDefs.AvatarMoney].ToString());
                        }
                        if (r.Contains(InfoNameDefs.AvatarHead))
                        {
                            l.Add(InfoNameDefs.AvatarHead);
                            l.Add(r[InfoNameDefs.AvatarHead].AsInt32.ToString());
                        }
                        lres.Add(l);
                    }
                    SendError("rs", AWebServerUtils.ToJsonArray(lres.ToArray()));
                    return;
                }
                SendError("Invalid ranktype " + ranktype);
            }
        }
コード例 #3
0
        public void avataraddfriend(string username, string token, string friendname)
        {
            var a = GetAvatar(username, token);

            if (a != null)
            {
                if (a.AvatarName == friendname)
                {
                    SendError(ErrorDefs.CannotAddYourSelf);
                    return;
                }
                var myfriends = AFriendManager.Instance.OnGetFriends(a.AvatarName);
                if (myfriends.Count >= InitValueDefs.MaxFriends)
                {
                    SendError(ErrorDefs.TooManyFriends);
                    return;
                }
                var targetfriends = AFriendManager.Instance.OnGetFriends(friendname);
                if (targetfriends.Count >= InitValueDefs.MaxFriends)
                {
                    SendError(ErrorDefs.TargetTooManyFriends);
                    return;
                }
                var friend = dbavatar.FindOneData(TableName
                                                  , ADBAccessor.filter_eq(InfoNameDefs.AvatarName, friendname)
                                                  , ADBAccessor.projections(InfoNameDefs.AvatarName));
                if (friend == null)
                {
                    SendError(ErrorDefs.NoSuchUser);
                    return;
                }
                var added = AFriendManager.Instance.OnAddFriend(a.AvatarName, friendname);
                if (added == 0)
                {
                    var friends = AFriendManager.Instance.OnGetFriends(a.AvatarName);
                    SendError("friends", AFriendManager.ToJson(a.AvatarName, friends.Values.ToList()));
                }
                else if (added == -1)
                {
                    SendError(ErrorDefs.WaitingForResponse);
                }
                else if (added == 1)
                {
                    SendError(ErrorDefs.AlreadyFriends);
                }
            }
        }
コード例 #4
0
        AWikiCell OnLoadWikiCellWithoutContent(string id)
        {
            var       i    = typeParser.intParse(id);
            AWikiCell cell = OnGetWiki(id);

            if (cell == null)
            {
                var r = adb.FindOneData(TableName, ADBAccessor.filter_eq("i", i)
                                        , ADBAccessor.projections("i", "s", "t"));
                if (r == null)
                {
                    SendError("1");
                    return(null);
                }
                cell         = new AWikiCell();
                cell.id      = i;
                cell.time    = r["t"].AsString;
                cell.subject = r["s"].AsString;
                dWikis.Add(cell.id, cell);
            }
            return(cell);
        }
コード例 #5
0
        public void wikilist(string page, string count)
        {
            var ipage  = typeParser.intParse(page);
            var icount = typeParser.intParse(count);
            List <List <string> > lr = new List <List <string> >();

            for (var i = (ipage + 1) * icount; i > ipage * icount; i--)
            {
                AWikiCell cell = null;
                if (dWikis.ContainsKey(i))
                {
                    cell = dWikis[i];
                }
                else
                {
                    var r = adb.FindOneData(TableName
                                            , ADBAccessor.filter_eq("i", i)
                                            , ADBAccessor.projections("i", "s", "t"));
                    if (r == null)
                    {
                        continue;
                    }
                    cell         = new AWikiCell();
                    cell.id      = r["i"].AsInt32;
                    cell.subject = r["s"].AsString;
                    cell.time    = r["t"].AsString;
                }

                var l = new List <string>();
                l.Add("i");
                l.Add(cell.id.ToString());
                l.Add("s");
                l.Add(cell.subject);
                l.Add("t");
                l.Add(cell.time);
                lr.Add(l);
            }
            SendError("r", AWebServerUtils.ToJsonArray(lr.ToArray()));
        }
コード例 #6
0
        AWikiCell OnLoadWikiCellWithContent(string id)
        {
            var       i    = typeParser.intParse(id);
            AWikiCell cell = OnGetWiki(id);

            if (cell == null || string.IsNullOrEmpty(cell.content))
            {
                var r = adb.FindOneData(TableName, ADBAccessor.filter_eq("i", i)
                                        , ADBAccessor.projections("s", "c", "t"));
                if (r == null)
                {
                    SendError("1");
                    return(null);
                }
                if (cell == null)
                {
                    cell = new AWikiCell();
                }
                cell.id      = i;
                cell.content = r["c"].AsString;
                cell.time    = r["t"].AsString;
                cell.subject = r["s"].AsString;
                if (r.Contains("lt"))
                {
                    cell.lastmodifytime = r["lt"].AsString;
                }
                if (dWikis.ContainsKey(cell.id))
                {
                    dWikis[cell.id] = cell;
                }
                else
                {
                    dWikis.Add(cell.id, cell);
                }
            }
            return(cell);
        }
コード例 #7
0
    public AFriend(string f1, string f2)
    {
        friend1 = f1;
        friend2 = f2;

        if (!dFriendInfos.ContainsKey(f1))
        {
            var res = ADatabaseConfigsManager.avatarDB.FindOneData(ADatabaseConfigsManager.tAvatarData
                                                                   , ADBAccessor.filter_eq(InfoNameDefs.AvatarName, f1), ADBAccessor.projections(InfoNameDefs.AvatarHead, InfoNameDefs.Username));
            if (res != null)
            {
                var info = new AFriendInfo();
                info.name = f1;
                if (res.Contains(InfoNameDefs.AvatarHead))
                {
                    info.head = res[InfoNameDefs.AvatarHead].AsInt32;
                }
                if (res.Contains(InfoNameDefs.Username))
                {
                    info.accid = res[InfoNameDefs.Username].AsString;
                }
                dFriendInfos.Add(f1, info);
            }
        }
        if (!dFriendInfos.ContainsKey(f2))
        {
            var res = ADatabaseConfigsManager.avatarDB.FindOneData(ADatabaseConfigsManager.tAvatarData
                                                                   , ADBAccessor.filter_eq(InfoNameDefs.AvatarName, f2), ADBAccessor.projections(InfoNameDefs.AvatarHead, InfoNameDefs.Username));
            if (res != null)
            {
                var info = new AFriendInfo();
                info.name = f2;
                if (res.Contains(InfoNameDefs.AvatarHead))
                {
                    info.head = res[InfoNameDefs.AvatarHead].AsInt32;
                }
                if (res.Contains(InfoNameDefs.Username))
                {
                    info.accid = res[InfoNameDefs.Username].AsString;
                }
                dFriendInfos.Add(f2, info);
            }
        }
    }
コード例 #8
0
        private void GameHandler_CreateAvatar(IResponer responer, PktCreateAvatarRequest vo)
        {
            var player = APlayerManager.Instance.OnGetPlayerByConn(responer.playerConnDesc);

            if (player == null)
            {
                return;
            }
            var res = new PktCreateAvatarResult();
            {
                var dbr = ADBManager.Get(InitValueDefs.dbconnect, InitValueDefs.dbname).FindOneData(ParamNameDefs.TableAvatar
                                                                                                    , ADBAccessor.filter_eq(ParamNameDefs.AvatarName, vo.avatarName)
                                                                                                    | ADBAccessor.filter_eq(ParamNameDefs.UnionID, player.unionid)
                                                                                                    , ADBAccessor.projections(ParamNameDefs.AvatarLevel));
                if (dbr != null)
                {
                    res.eResult = PktCreateAvatarResult.EResult.SameName;
                    responer.Response(res);
                    return;
                }
            }
            {
                var dbr = ADBManager.Get(InitValueDefs.dbconnect, InitValueDefs.dbname).FindOneData(ParamNameDefs.TableAvatar
                                                                                                    , ADBAccessor.filter_eq(ParamNameDefs.UnionID, player.unionid), ADBAccessor.projections(ParamNameDefs.AvatarLevel));
                if (dbr != null)
                {
                    res.eResult = PktCreateAvatarResult.EResult.MaxCount;
                    responer.Response(res);
                    return;
                }
            }
            var psid = ObjectId.GenerateNewId().ToString();
            var cake = new CakeAvatar(psid);

            cake.Create(player.unionid, player.ePartnerID, vo.avatarName, vo.sex);
            APlayerManager.Instance.OnAddAvatar(cake, player);
            res.info    = cake.ToPkt();
            res.eResult = PktCreateAvatarResult.EResult.Success;
            responer.Response(res);
        }
コード例 #9
0
    internal bool OnAnswer(string answer)
    {
        var res = ADatabaseConfigsManager.avatarDB.FindOneData(ADatabaseConfigsManager.tAvatarData
                                                               , ADBAccessor.filter_eq(InfoNameDefs.Username, username), ADBAccessor.projections("qa"));

        if (res != null && res.Contains("qa"))
        {
            var a = res["qa"].ToString();
            if (a == answer)
            {
                OnAddExp(AvatarLevel);
                return(true);
            }
        }
        return(false);
    }
コード例 #10
0
        public HttpResponseMessage GetTopGold(string count)
        {
            var icount = typeParser.intParse(count);

            if (icount > 10 || icount < 1)
            {
                icount = 10;
            }
            var ttop = ADatabaseConfigsManager.avatarDB.FindManyData(ADatabaseConfigsManager.tAvatarData, ADBAccessor.filter_Gte(InfoNameDefs.AvatarLevel, 0), ADBAccessor.projections(InfoNameDefs.AvatarName, InfoNameDefs.AvatarGold), icount, 0, ADBAccessor.sort_Descending(InfoNameDefs.AvatarGold));
            List <List <string> > lresults = new List <List <string> >();

            foreach (var t in ttop)
            {
                if (t.Contains(InfoNameDefs.AvatarGold) && t.Contains(InfoNameDefs.AvatarName))
                {
                    var l = new List <string>();
                    l.Add(InfoNameDefs.AvatarName);
                    l.Add(t[InfoNameDefs.AvatarName].ToString());
                    l.Add("value");
                    l.Add(t[InfoNameDefs.AvatarGold].ToString());
                    lresults.Add(l);
                }
            }
            return(ResultToJson.GetJsonResponse(ResultToJson.JsonFormatArray("r", lresults)));
        }