From 49a13effca3635da8ed36b68d5f62c7fd9a054d0 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Mon, 21 Mar 2016 11:42:27 -0400 Subject: [PATCH] Fleshed out the quest actor and added a place to store the current active quest actors in the Player actor. --- .../actors/chara/player/Player.cs | 4 + FFXIVClassic Map Server/actors/quest/Quest.cs | 74 ++++++++++++++++++- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index d1c617d0..7617882c 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -118,6 +118,10 @@ namespace FFXIVClassic_Map_Server.Actors private int lastPosition = 0; private int lastStep = 0; + //Quest Actors (MUST MATCH playerWork.questScenario/questGuildleve) + public Quest[] questScenario = new Quest[16]; + public Quest[] questGuildleve = new Quest[8]; + public PlayerWork playerWork = new PlayerWork(); public ConnectedPlayer playerSession; diff --git a/FFXIVClassic Map Server/actors/quest/Quest.cs b/FFXIVClassic Map Server/actors/quest/Quest.cs index e15fb7bd..c125548e 100644 --- a/FFXIVClassic Map Server/actors/quest/Quest.cs +++ b/FFXIVClassic Map Server/actors/quest/Quest.cs @@ -1,13 +1,14 @@ -using System; +using FFXIVClassic_Lobby_Server.common; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FFXIVClassic_Map_Server.Actors { class Quest : Actor { + private int currentPhase = 0; + private uint questFlags = 0; + private Dictionary questData = new Dictionary(); public Quest(uint actorID, string name) : base(actorID) @@ -15,5 +16,70 @@ namespace FFXIVClassic_Map_Server.Actors actorName = name; } + public void InitQuestData(string dataName, object initialValue) + { + questData[dataName] = initialValue; + } + + public void UpdateQuestData(string dataName, object data) + { + if (questData.ContainsKey(dataName)) + questData[dataName] = data; + + //Inform update + } + + public object GetQuestData(string dataName) + { + if (questData.ContainsKey(dataName)) + return questData[dataName]; + else + return null; + } + + public uint GetQuestId() + { + return actorId; + } + + public void SetQuestFlag(int bitIndex, bool value) + { + if (bitIndex >= 32) + { + Log.error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); + return; + } + + int mask = 1 << bitIndex; + + if (value) + questFlags |= (uint)(1 << bitIndex); + else + questFlags &= (uint)~(1 << bitIndex); + + //Inform update + } + + public bool GetQuestFlag(int bitIndex) + { + if (bitIndex >= 32) + { + Log.error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); + return false; + } + else + return (questFlags & (1 << bitIndex)) == 1; + } + + public int GetPhase() + { + return currentPhase; + } + + public void NextPhase() + { + currentPhase++; + } + } }