Ejemplo n.º 1
0
 /// <summary>
 /// Loads a quest from the databaseobject and assigns it to a player
 /// </summary>
 /// <param name="targetPlayer">Player to assign the loaded quest</param>
 /// <param name="dbTask">Quest to load</param>
 /// <returns>The created quest</returns>
 public static AbstractTask LoadFromDatabase(GamePlayer targetPlayer, DBTask dbTask)
 {
     // if we have a active task load it, else the taksdone will be updated on creation of first task instance in AbstractTask(GamePlayer) constructor
     if (dbTask.TaskType!=null && dbTask.TaskType!= "")
     {
         Type taskType = null;
         foreach (Assembly asm in ScriptMgr.Scripts)
         {
             taskType = asm.GetType(dbTask.TaskType);
             if (taskType != null)
                 break;
         }
         if(taskType==null)
             taskType = Assembly.GetAssembly(typeof(GameServer)).GetType(dbTask.TaskType);
         if(taskType==null)
         {
             if (log.IsErrorEnabled)
                 log.Error("Could not find task: "+dbTask.TaskType+"!!!");
             return null;
         }
         return (AbstractTask)Activator.CreateInstance(taskType, new object[] { targetPlayer, dbTask });
     }
     else
     {
         return null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs a new Quest
        /// </summary>
        /// <param name="taskPlayer">The player doing this task</param>
        public AbstractTask(GamePlayer taskPlayer)
        {
            m_taskPlayer = taskPlayer;

            DBTask dbTask=null;

            // Check if player already has a task
            // if yes reuse dbtask object to keep TasksDone from old dbtask object.
            if (taskPlayer.Task!=null)
            {
                dbTask = taskPlayer.Task.m_dbTask;
            }
            else // if player has no active task, load dbtask an use tasksdone
            {
                // Load Task object of player ...
                var tasks = GameServer.Database.SelectObjects<DBTask>("Character_ID ='"+GameServer.Database.Escape(taskPlayer.QuestPlayerID)+"'");
                if (tasks.Count==1)
                {
                    dbTask = tasks[0];
                }
                else if (tasks.Count>1)
                {
                    if (log.IsErrorEnabled)
                        log.Error("More than one DBTask Object found for player "+taskPlayer.Name);
                }
            }

            // this should happen only if player never did a task and has no entry in DBTask.
            if (dbTask==null)
            {
                dbTask = new DBTask();
                dbTask.Character_ID = taskPlayer.QuestPlayerID;
            }

            dbTask.TaskType = GetType().FullName;

            m_dbTask = dbTask;

            ParseCustomProperties();
            SaveIntoDatabase();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a new Quest from a database Object
 /// </summary>
 /// <param name="taskPlayer">The player doing the quest</param>
 /// <param name="dbTask">The database object</param>
 public AbstractTask(GamePlayer taskPlayer, DBTask dbTask)
 {
     m_taskPlayer = taskPlayer;
     m_dbTask = dbTask;
     ParseCustomProperties();
     SaveIntoDatabase();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a new Task from a database Object
 /// </summary>
 /// <param name="taskPlayer">The player doing the task</param>
 /// <param name="dbTask">The database object</param>
 public CraftTask(GamePlayer taskPlayer, DBTask dbTask)
     : base(taskPlayer, dbTask)
 {
 }
Ejemplo n.º 5
0
		/// <summary>
		/// Constructs a new Quest
		/// </summary>
		/// <param name="taskPlayer">The player doing this task</param>
		public AbstractTask(GamePlayer taskPlayer)
		{
			m_taskPlayer = taskPlayer;

			DBTask dbTask=null;

			// Check if player already has a task
			// if yes reuse dbtask object to keep TasksDone from old dbtask object.
			if (taskPlayer.Task!=null)
			{
				dbTask = taskPlayer.Task.m_dbTask;
			}
			else // if player has no active task, load dbtask an use tasksdone
			{
				// Load Task object of player ...
				var tasks = GameServer.Database.FindObjectByKey<DBTask>(taskPlayer.QuestPlayerID);
				if (tasks != null)
					dbTask = tasks;
			}

			// this should happen only if player never did a task and has no entry in DBTask.
			if (dbTask==null)
			{
				dbTask = new DBTask();
				dbTask.Character_ID = taskPlayer.QuestPlayerID;
			}

			dbTask.TaskType = GetType().FullName;

			m_dbTask = dbTask;

			ParseCustomProperties();
			SaveIntoDatabase();
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Constructs a new Task from a database Object
		/// </summary>
		/// <param name="taskPlayer">The player doing the task</param>
		/// <param name="dbTask">The database object</param>
		public MoneyTask(GamePlayer taskPlayer, DBTask dbTask) : base(taskPlayer, dbTask)
		{			
		}
Ejemplo n.º 7
0
 /// <summary>
 /// Constructs a new task from a database Object
 /// </summary>
 /// <param name="taskPlayer">The player doing the task</param>
 /// <param name="dbTask">The database object</param>
 public KillTask(GamePlayer taskPlayer, DBTask dbTask)
     : base(taskPlayer, dbTask)
 {
 }