Exemplo n.º 1
0
 private static void PrintCharacterList(CharacterListResponse characterResp)
 {
     foreach (var character in characterResp.Characters.OrderBy(c => c.Name))
     {
         Console.WriteLine(character.Name);
     }
 }
Exemplo n.º 2
0
        public async Task <object> CharacterList(string id)
        {
            var response = new CharacterListResponse();

            if (!long.TryParse(id, out var userId))
            {
                response.FailedReason = "invalid id";

                return(response);
            }

            await using var ctx = new UchuContext();

            var user = await ctx.Users.FirstOrDefaultAsync(u => u.Id == userId);

            if (user == default)
            {
                response.FailedReason = "not found";

                return(response);
            }

            var characters = await ctx.Characters.Where(c => c.UserId == user.Id).ToArrayAsync();

            response.Success = true;

            response.UserId = userId;

            response.Characters = characters.Select(c => c.Id.ToString()).ToList();

            return(response);
        }
        private async Task HandleCharacterList(CharacterListRequest request)
        {
            var response      = new CharacterListResponse();
            var characterList = await ShardSession.GetCharacterList();

            // TODO: this equipment list obviously needs revisited once items are implemented
            var equipmentCount          = Enum.GetValues(typeof(EquipmentSlot)).Length;
            var equipmentDisplayIds     = new int[equipmentCount];
            var equipmentInventoryTypes = new byte[equipmentCount];

            foreach (var character in characterList)
            {
                response.AddCharacter(character.Id, character.Name, character.Race, character.Class, character.Sex, character.Skin, character.Face, character.HairStyle,
                                      character.HairColor, character.FacialHair, character.Level, character.ZoneId, character.MapId, character.Position, 0, 0, true, 0, 0, 0, 0, 0, equipmentDisplayIds, equipmentInventoryTypes);
            }

            ForwardPacket(response);
        }
Exemplo n.º 4
0
        public string GetCharacterList(string username)
        {
            CharacterListResponse response = new CharacterListResponse();

            if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result) &&
                RestUtilities.ValidateJSONRequestSessionLoggedInAsUser(Session, username, out response.result))
            {
                if (CharacterQueries.GetAccountCharacterList(
                        ApplicationConstants.CONNECTION_STRING,
                        RestUtilities.GetSessionAccountID(Session),
                        out response.character_list,
                        out response.result))
                {
                    response.result = SuccessMessages.GENERAL_SUCCESS;
                }
            }

            return(JSONUtilities.SerializeJSONResponse <CharacterListResponse>(response));
        }
Exemplo n.º 5
0
 public SpPlayerList(int index, Player player, CharacterListResponse resp)
 {
     Index    = index;
     Player   = player;
     Response = resp;
 }
Exemplo n.º 6
0
 public SpPlayerList(int index, Player player, CharacterListResponse resp)
 {
     Index = index;
     Player = player;
     Response = resp;
 }