Пример #1
0
        /// <summary>
        /// Retuns the requested target
        ///
        /// Since the mission in progress is needed for the target we return that as well to avoid further lookups
        /// </summary>
        /// <returns></returns>
        private bool GetTargetInProgress_and_missionInProgress(Character character, int targetId, int missionId, Guid missionGuid, out MissionTargetInProgress targetInProgress, out MissionInProgress missionInProgress)
        {
            targetInProgress = null;

            // oldschool version
            //
            //myMissionAdministrator.FindMissionInProgressByMissionId(character, missionId, out missionInProgress);

            MissionAdministrator.FindMissionInProgressByMissionGuid(character, missionGuid, out missionInProgress);

            if (missionInProgress == null)
            {
                Logger.Warning("mission was not found for character: " + character.Id + " missionID:" + missionId);
                return(false);
            }

            if (missionInProgress.MissionId != missionId)
            {
                Logger.Warning("WTF??!!! " + missionInProgress);
            }

            if (!missionInProgress.GetTargetInProgress(targetId, out targetInProgress))
            {
                Logger.Error("mission target was not found for caharcter: " + character.Id + " missionID:" + missionId + " targetID:" + targetId);
                return(false);
            }

            if (targetInProgress.completed)
            {
                Logger.Info("target already completed. missionID: " + missionId + " targetID:" + targetId + " characterID:" + character.Id);
                return(false);
            }

            return(true);
        }
        public void AbortMissionByRequest(Character character, Guid missionGuid, ErrorCodes errorToInfo)
        {
            Logger.Info("Aborting mission " + missionGuid + " character: " + character.Id);

            (MissionAdministrator.RunningMissionsCount(character) == 0).ThrowIfTrue(ErrorCodes.ItemNotFound);

            MissionInProgress missionInProgress;

            MissionAdministrator.FindMissionInProgressByMissionGuid(character, missionGuid, out missionInProgress).ThrowIfFalse(ErrorCodes.ItemNotFound);

            missionInProgress?.OnMissionAbort(this, errorToInfo);
        }