Beispiel #1
0
        private async void Disconnect(long id)
        {
            RedisValue currentSession = await ServerAdmin.SessionDatabase.Get(id);

            if (!currentSession.IsNull)
            {
                long sessionId = long.Parse(currentSession);

                ServerMessageManager.SendMessage(new StopSessionMessage
                {
                    SessionId = sessionId
                }, ServerManager.GetProxySocket(sessionId));
            }
        }
Beispiel #2
0
        public async Task <JObject> ExecuteDebugCommand(int id, [FromQuery(Name = "userId")] long accountId, [FromQuery(Name = "pass")] string passToken)
        {
            AccountDocument accountDocument = await UserManager.GetAccount(accountId);

            if (accountDocument == null)
            {
                return(this.BuildResponse(HttpStatusCode.InternalServerError));
            }
            if (this.GetUserRole() <= UserRole.NULL && passToken != accountDocument.PassToken)
            {
                return(this.BuildResponse(HttpStatusCode.Forbidden));
            }

            RedisValue currentSession = await ServerAdmin.SessionDatabase.Get(accountDocument.Id);

            if (currentSession.IsNull)
            {
                return(this.BuildResponse(HttpStatusCode.Forbidden).AddAttribute("reason", "No client connected."));
            }

            LogicDebugCommand logicDebugCommand = null;

            switch ((DebugCommandType)id)
            {
            case DebugCommandType.FAST_FORWARD_1_HOUR:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.FAST_FORWARD_1_HOUR);
                break;

            case DebugCommandType.FAST_FORWARD_24_HOUR:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.FAST_FORWARD_24_HOUR);
                break;

            case DebugCommandType.ADD_UNITS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_UNITS);
                break;

            case DebugCommandType.ADD_RESOURCES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_RESOURCES);
                break;

            case DebugCommandType.INCREASE_XP_LEVEL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.INCREASE_XP_LEVEL);
                break;

            case DebugCommandType.UPGRADE_ALL_BUILDINGS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_ALL_BUILDINGS);
                break;

            case DebugCommandType.COMPLETE_TUTORIAL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COMPLETE_TUTORIAL);
                break;

            case DebugCommandType.UNLOCK_MAP:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UNLOCK_MAP);
                break;

            case DebugCommandType.SHIELD_TO_HALF:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SHIELD_TO_HALF);
                break;

            case DebugCommandType.FAST_FORWARD_1_MIN:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.FAST_FORWARD_1_MIN);
                break;

            case DebugCommandType.INCREASE_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.INCREASE_TROPHIES);
                break;

            case DebugCommandType.DECREASE_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.DECREASE_TROPHIES);
                break;

            case DebugCommandType.ADD_ALLIANCE_UNITS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_ALLIANCE_UNITS);
                break;

            case DebugCommandType.INCREASE_HERO_LEVELS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.INCREASE_HERO_LEVELS);
                break;

            case DebugCommandType.REMOVE_RESOURCES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_RESOURCES);
                break;

            case DebugCommandType.RESET_MAP_PROGRESS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_MAP_PROGRESS);
                break;

            case DebugCommandType.DEPLOY_ALL_TROOPS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.DEPLOY_ALL_TROOPS);
                break;

            case DebugCommandType.ADD_100_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_100_TROPHIES);
                break;

            case DebugCommandType.REMOVE_100_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_100_TROPHIES);
                break;

            case DebugCommandType.UPGRADE_TO_MAX_FOR_TH:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_TO_MAX_FOR_TH);
                break;

            case DebugCommandType.REMOVE_UNITS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_UNITS);
                break;

            case DebugCommandType.DISARM_TRAPS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.DISARM_TRAPS);
                break;

            case DebugCommandType.REMOVE_OBSTACLES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_OBSTACLES);
                break;

            case DebugCommandType.RESET_HERO_LEVELS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_HERO_LEVELS);
                break;

            case DebugCommandType.COLLECT_WAR_RESOURCES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COLLECT_WAR_RESOURCES);
                break;

            case DebugCommandType.SET_RANDOM_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SET_RANDOM_TROPHIES);
                break;

            case DebugCommandType.COMPLETE_WAR_TUTORIAL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COMPLETE_WAR_TUTORIAL);
                break;

            case DebugCommandType.ADD_WAR_RESOURCES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_WAR_RESOURCES);
                break;

            case DebugCommandType.REMOVE_WAR_RESOURCES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_WAR_RESOURCES);
                break;

            case DebugCommandType.RESET_WAR_TUTORIAL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_WAR_TUTORIAL);
                break;

            case DebugCommandType.ADD_UNIT:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_UNIT);
                break;

            case DebugCommandType.SET_MAX_UNIT_SPELL_LEVELS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SET_MAX_UNIT_SPELL_LEVELS);
                break;

            case DebugCommandType.REMOVE_ALL_AMMO:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_ALL_AMMO);
                break;

            case DebugCommandType.RESET_ALL_LAYOUTS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_ALL_LAYOUTS);
                break;

            case DebugCommandType.LOCK_CLAN_CASTLE:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.LOCK_CLAN_CASTLE);
                break;

            case DebugCommandType.RANDOM_RESOURCES_TROPHY_XP:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RANDOM_RESOURCES_TROPHY_XP);
                break;

            case DebugCommandType.LOAD_LEVEL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.LOAD_LEVEL);
                logicDebugCommand.SetDebugString(UserManager.GetPresetLevel());
                break;

            case DebugCommandType.UPGRADE_BUILDING:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_BUILDING);
                break;

            case DebugCommandType.UPGRADE_BUILDINGS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_BUILDINGS);
                break;

            case DebugCommandType.ADD_1000_CLAN_XP:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_1000_CLAN_XP);
                break;

            case DebugCommandType.RESET_ALL_TUTORIALS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_ALL_TUTORIALS);
                break;

            case DebugCommandType.ADD_1000_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_1000_TROPHIES);
                break;

            case DebugCommandType.REMOVE_1000_TROPHIES:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_1000_TROPHIES);
                break;

            case DebugCommandType.CAUSE_DAMAGE:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.CAUSE_DAMAGE);
                break;

            case DebugCommandType.SET_MAX_HERO_LEVELS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SET_MAX_HERO_LEVELS);
                break;

            case DebugCommandType.ADD_PRESET_TROOPS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_PRESET_TROOPS);
                break;

            case DebugCommandType.TOGGLE_INVULNERABILITY:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.TOGGLE_INVULNERABILITY);
                break;

            case DebugCommandType.ADD_GEMS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_GEMS);
                break;

            case DebugCommandType.PAUSE_ALL_BOOSTS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.PAUSE_ALL_BOOSTS);
                break;

            case DebugCommandType.TRAVEL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.TRAVEL);
                break;

            case DebugCommandType.TOGGLE_RED:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.TOGGLE_RED);
                break;

            case DebugCommandType.COMPLETE_HOME_TUTORIALS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COMPLETE_HOME_TUTORIALS);
                break;

            case DebugCommandType.UNLOCK_SHIPYARD:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UNLOCK_SHIPYARD);
                break;

            case DebugCommandType.GIVE_REENGAGEMENT_LOOT_FOR_30_DAYS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.GIVE_REENGAGEMENT_LOOT_FOR_30_DAYS);
                break;

            case DebugCommandType.ADD_FREE_UNITS:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_FREE_UNITS);
                break;

            case DebugCommandType.RANDOM_ALLIANCE_EXP_LEVEL:
                logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RANDOM_ALLIANCE_EXP_LEVEL);
                break;
            }

            if (logicDebugCommand == null)
            {
                return(this.BuildResponse(HttpStatusCode.InternalServerError));
            }

            long sessionId = long.Parse(currentSession);

            AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage();

            availableServerCommandMessage.SetServerCommand(logicDebugCommand);
            availableServerCommandMessage.Encode();

            ServerMessageManager.SendMessage(new ForwardLogicMessage
            {
                MessageType    = availableServerCommandMessage.GetMessageType(),
                MessageLength  = availableServerCommandMessage.GetEncodingLength(),
                MessageVersion = (short)availableServerCommandMessage.GetMessageVersion(),
                MessageBytes   = availableServerCommandMessage.GetByteStream().GetByteArray(),
                SessionId      = sessionId
            }, ServerManager.GetProxySocket(sessionId));

            return(this.BuildResponse(HttpStatusCode.OK));
        }