Example #1
0
        private async Task <string> OnHandleServerRoleNameToUUID(JObject obj)
        {
            var role_uuid = obj["role"].ToString();

            role_uuid = await GetRoleUUID(role_uuid);

            if (!string.IsNullOrEmpty(role_uuid))
            {
                //TODO 接口不支持多用户暂时写死
                if (role_uuid.Length < 36)
                {
                    role_uuid = await RPGServerPersistenceManager.Instance.GetRoleUUIDByNameAsync(role_uuid, this);
                }

                if (!string.IsNullOrEmpty(role_uuid))
                {
                    TLRoleSnap roleSnap = await this.queryRoleSnap.LoadDataAsync(role_uuid) as TLRoleSnap;

                    //var param_list = new Dictionary<string, object>();
                    //if (roleSnap.account_uuid.IndexOf(':') != -1)
                    //{
                    //    var new_account = roleSnap.account_uuid.Split(':');
                    //    param_list.Add("account_id", new_account[1]);
                    //}
                    //else
                    //{
                    //    param_list.Add("account_id", roleSnap.account_uuid);
                    //}
                    //param_list.Add("server_id", roleSnap.server_id);
                    //param_list.Add("role_uuid", role_uuid);
                    return(CustomResult(true, roleSnap));
                }
            }

            return(CustomResult(false, null, "role_name_not_exist"));
        }
Example #2
0
        private async Task <string> OnHandleServerRoleBagModify(JObject obj)
        {
            try
            {
                var role_uuid = obj["role"].ToString();

                var bag_type = obj["bagType"].ToString();

                var action = obj["action"].ToString();

                var entry_key = obj.Value <int?>("entryKey") ?? -1;

                var val = obj.Value <uint?>("value") ?? 0;

                role_uuid = await GetRoleUUID(role_uuid);

                if (!string.IsNullOrEmpty(role_uuid))
                {
                    TLRoleSnap roleSnap = await this.queryRoleSnap.LoadDataAsync(role_uuid) as TLRoleSnap;

                    if (roleSnap.onlineState == RoleState.STATE_ONLINE)
                    {
                        return(CustomResult(false, null, "role_still_online"));
                    }
                }

                if (!string.IsNullOrEmpty(role_uuid))
                {
                    var mapping      = new BagStoreDataMapping(bag_type, role_uuid, this);
                    var BagStoreData = await mapping.LoadDataAsync();

                    if (BagStoreData != null && BagStoreData.Slots != null && BagStoreData.Slots.Count > 0)
                    {
                        if (BagStoreData.Slots.ContainsKey(entry_key))
                        {
                            if (action == "remove")
                            {
                                BagStoreData.Slots.Remove(entry_key);
                            }
                            else
                            {
                                BagStoreData.Slots[entry_key].Count = val;
                            }
                        }

                        await mapping.SaveDataAsync();

                        return(CustomResult(true, null));
                    }

                    return(CustomResult(false, null, "page_gmt_command_unknown_error"));
                }
                else
                {
                    return(CustomResult(false, null, "role_name_not_exist"));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(CustomResult(false, null, "page_gmt_command_unknown_error"));
            }
        }