public string CreateCharacter( string name, int archetype, int gender, int picture_id) { BasicResponse response = new BasicResponse(); if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result)) { int archetypeCount = EnumUtilities.GetEnumValues <GameConstants.eArchetype>().Count(); CharacterCreateRequestProcessor requestProcessor = new CharacterCreateRequestProcessor( RestUtilities.GetSessionAccountID(Session), name, (gender > 0) ? GameConstants.eGender.Male : GameConstants.eGender.Female, (GameConstants.eArchetype)Math.Max(Math.Min(archetype, archetypeCount - 1), 0), picture_id); if (requestProcessor.ProcessRequest( ApplicationConstants.CONNECTION_STRING, Application, out response.result)) { Session["CharacterIDs"] = requestProcessor.AccountCharacterIDs; response.result = SuccessMessages.GENERAL_SUCCESS; } } return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response)); }
public string DeleteCharacter(int character_id) { BasicResponse response = new BasicResponse(); if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result) && RestUtilities.ValidateJSONRequestSessionOwnsCharacter(Session, character_id, out response.result)) { CharacterDeleteRequestProcessor requestProcessor = new CharacterDeleteRequestProcessor( RestUtilities.GetSessionAccountID(Session), character_id); if (requestProcessor.ProcessRequest( ApplicationConstants.CONNECTION_STRING, Application, out response.result)) { Session["CharacterIDs"] = requestProcessor.RemainingCharacterIDs; response.result = SuccessMessages.GENERAL_SUCCESS; } } return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response)); }
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)); }
public string DeleteGame( int game_id) { BasicResponse response = new BasicResponse(); if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result)) { GameDeleteRequestProcessor requestProcessor = new GameDeleteRequestProcessor( RestUtilities.GetSessionAccountID(Session), game_id); if (requestProcessor.ProcessRequest( ApplicationConstants.CONNECTION_STRING, Application, out response.result)) { response.result = SuccessMessages.GENERAL_SUCCESS; } } return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response)); }
public string CreateGame( string game_name, int dungeon_size, int dungeon_difficulty, bool irc_enabled, string irc_server, int irc_port, bool irc_encryption_enabled) { BasicResponse response = new BasicResponse(); if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result)) { int account_id = RestUtilities.GetSessionAccountID(Session); GameCreateRequestProcessor requestProcessor = new GameCreateRequestProcessor( RestUtilities.GetSessionAccountID(Session), game_name, (GameConstants.eDungeonSize)dungeon_size, (GameConstants.eDungeonDifficulty)dungeon_difficulty, irc_enabled, irc_server, irc_port, irc_encryption_enabled); if (requestProcessor.ProcessRequest( ApplicationConstants.CONNECTION_STRING, Application, out response.result)) { response.result = SuccessMessages.GENERAL_SUCCESS; } } return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response)); }