Skip to content

Commit f65c4ce

Browse files
committed
rename QuestBase -> QuestDescriptor, QuestBase.QuestTask -> QuestTaskDescriptor
1 parent 171ca7f commit f65c4ce

File tree

26 files changed

+240
-231
lines changed

26 files changed

+240
-231
lines changed

Framework/Intersect.Framework.Core/Descriptors/GameObjectType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public enum GameObjectType
2626
[GameObjectInfo(typeof(ProjectileDescriptor), "projectiles")]
2727
Projectile,
2828

29-
[GameObjectInfo(typeof(QuestBase), "quests")]
29+
[GameObjectInfo(typeof(QuestDescriptor), "quests")]
3030
Quest,
3131

3232
[GameObjectInfo(typeof(ResourceBase), "resources")]

Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs renamed to Framework/Intersect.Framework.Core/GameObjects/Quests/QuestDescriptor.cs

Lines changed: 57 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,15 @@
44
using Intersect.Framework.Core.GameObjects.Events;
55
using Intersect.Framework.Core.GameObjects.Items;
66
using Intersect.Framework.Core.GameObjects.NPCs;
7+
using Intersect.Framework.Core.GameObjects.Quests;
78
using Intersect.Framework.Core.Serialization;
89
using Intersect.Localization;
910
using Intersect.Models;
1011
using Newtonsoft.Json;
1112

1213
namespace Intersect.GameObjects;
1314

14-
public enum QuestProgressState
15-
{
16-
OnAnyTask = 0,
17-
18-
BeforeTask = 1,
19-
20-
AfterTask = 2,
21-
22-
OnTask = 3,
23-
}
24-
25-
public partial class QuestProgress
26-
{
27-
public bool Completed;
28-
29-
public Guid TaskId;
30-
31-
public int TaskProgress;
32-
33-
public QuestProgress(string data)
34-
{
35-
JsonConvert.PopulateObject(data, this);
36-
}
37-
}
38-
39-
public partial class QuestBase : DatabaseObject<QuestBase>, IFolderable
15+
public partial class QuestDescriptor : DatabaseObject<QuestDescriptor>, IFolderable
4016
{
4117
[NotMapped]
4218
[JsonIgnore]
@@ -48,16 +24,16 @@ public partial class QuestBase : DatabaseObject<QuestBase>, IFolderable
4824
public List<Guid> RemoveEvents { get; set; } = [];
4925

5026
[NotMapped]
51-
public List<QuestTask> Tasks { get; set; } = [];
27+
public List<QuestTaskDescriptor> Tasks { get; set; } = [];
5228

5329
[JsonConstructor]
54-
public QuestBase(Guid Id) : base(Id)
30+
public QuestDescriptor(Guid Id) : base(Id)
5531
{
5632
Name = "New Quest";
5733
}
5834

5935
//Parameterless EF Constructor
60-
public QuestBase()
36+
public QuestDescriptor()
6137
{
6238
Name = "New Quest";
6339
}
@@ -118,7 +94,7 @@ public EventDescriptor EndEvent
11894
public string TasksJson
11995
{
12096
get => JsonConvert.SerializeObject(Tasks);
121-
set => Tasks = JsonConvert.DeserializeObject<List<QuestTask>>(value);
97+
set => Tasks = JsonConvert.DeserializeObject<List<QuestTaskDescriptor>>(value);
12298
}
12399

124100
[NotMapped]
@@ -192,7 +168,7 @@ public int GetTaskIndex(Guid taskId)
192168
return -1;
193169
}
194170

195-
public QuestTask FindTask(Guid taskId)
171+
public QuestTaskDescriptor FindTask(Guid taskId)
196172
{
197173
for (var i = 0; i < Tasks.Count; i++)
198174
{
@@ -204,66 +180,67 @@ public QuestTask FindTask(Guid taskId)
204180

205181
return null;
206182
}
183+
}
207184

208-
public partial class QuestTask
209-
{
210-
[NotMapped]
211-
[JsonIgnore]
212-
public EventDescriptor EditingEvent;
185+
public partial class QuestTaskDescriptor
186+
{
187+
[NotMapped]
188+
[JsonIgnore]
189+
[Obsolete("Windows Editor only")]
190+
public EventDescriptor EditingEvent { get; set; }
213191

214-
public QuestTask(Guid id)
215-
{
216-
Id = id;
217-
}
192+
public QuestTaskDescriptor(Guid id)
193+
{
194+
Id = id;
195+
}
218196

219-
public Guid Id { get; set; }
197+
public Guid Id { get; set; }
220198

221-
public Guid CompletionEventId { get; set; }
199+
public Guid CompletionEventId { get; set; }
222200

223-
[JsonIgnore]
224-
public EventDescriptor CompletionEvent
225-
{
226-
get => EventDescriptor.Get(CompletionEventId);
227-
set => CompletionEventId = value.Id;
228-
}
201+
[JsonIgnore]
202+
public EventDescriptor CompletionEvent
203+
{
204+
get => EventDescriptor.Get(CompletionEventId);
205+
set => CompletionEventId = value.Id;
206+
}
229207

230-
//# of npcs to kill, # of X item to collect, or for event driven this value should be 1
231-
public QuestObjective Objective { get; set; } = QuestObjective.EventDriven;
208+
//# of npcs to kill, # of X item to collect, or for event driven this value should be 1
209+
public QuestObjective Objective { get; set; } = QuestObjective.EventDriven;
232210

233-
public Guid TargetId { get; set; }
211+
public Guid TargetId { get; set; }
234212

235-
public int Quantity { get; set; }
213+
public int Quantity { get; set; }
236214

237-
public string Description { get; set; } = string.Empty;
215+
public string Description { get; set; } = string.Empty;
238216

239-
public string GetTaskString(Dictionary<int, LocalizedString> descriptions)
217+
public string GetTaskString(Dictionary<int, LocalizedString> descriptions)
218+
{
219+
var taskString = string.Empty;
220+
switch (Objective)
240221
{
241-
var taskString = string.Empty;
242-
switch (Objective)
243-
{
244-
case QuestObjective.EventDriven: //Event Driven
245-
taskString = descriptions[(int)Objective].ToString(Description);
246-
247-
break;
248-
case QuestObjective.GatherItems: //Gather Items
249-
taskString = descriptions[(int)Objective].ToString(
250-
ItemDescriptor.GetName(TargetId),
251-
Quantity,
252-
Description
253-
);
254-
255-
break;
256-
case QuestObjective.KillNpcs: //Kill Npcs
257-
taskString = descriptions[(int)Objective].ToString(
258-
NPCDescriptor.GetName(TargetId),
259-
Quantity,
260-
Description
261-
);
262-
263-
break;
264-
}
265-
266-
return taskString;
222+
case QuestObjective.EventDriven: //Event Driven
223+
taskString = descriptions[(int)Objective].ToString(Description);
224+
225+
break;
226+
case QuestObjective.GatherItems: //Gather Items
227+
taskString = descriptions[(int)Objective].ToString(
228+
ItemDescriptor.GetName(TargetId),
229+
Quantity,
230+
Description
231+
);
232+
233+
break;
234+
case QuestObjective.KillNpcs: //Kill Npcs
235+
taskString = descriptions[(int)Objective].ToString(
236+
NPCDescriptor.GetName(TargetId),
237+
Quantity,
238+
Description
239+
);
240+
241+
break;
267242
}
243+
244+
return taskString;
268245
}
269246
}

Framework/Intersect.Framework.Core/GameObjects/Quests/QuestObjective.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Intersect.Enums;
1+
namespace Intersect.Framework.Core.GameObjects.Quests;
22

33
public enum QuestObjective
44
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Intersect.GameObjects;
4+
5+
public partial class QuestProgress
6+
{
7+
public bool Completed;
8+
9+
public Guid TaskId;
10+
11+
public int TaskProgress;
12+
13+
public QuestProgress(string data)
14+
{
15+
JsonConvert.PopulateObject(data, this);
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Intersect.GameObjects;
2+
3+
public enum QuestProgressState
4+
{
5+
OnAnyTask = 0,
6+
7+
BeforeTask = 1,
8+
9+
AfterTask = 2,
10+
11+
OnTask = 3,
12+
}

Intersect.Client.Core/Interface/Game/GameInterface.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public void Update(TimeSpan elapsed, TimeSpan total)
350350
mQuestOfferWindow.Hide();
351351
}
352352
}
353-
else if (QuestBase.TryGet(questDescriptorId, out var questDescriptor))
353+
else if (QuestDescriptor.TryGet(questDescriptorId, out var questDescriptor))
354354
{
355355
mQuestOfferWindow.Update(questDescriptor);
356356
}

Intersect.Client.Core/Interface/Game/QuestOfferWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void _acceptButton_Clicked(Base sender, MouseButtonState arguments)
7777
}
7878
}
7979

80-
public void Update(QuestBase quest)
80+
public void Update(QuestDescriptor quest)
8181
{
8282
if (quest == null)
8383
{

Intersect.Client.Core/Interface/Game/QuestsWindow.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Intersect.Enums;
1010
using Intersect.Framework.Core.GameObjects.Items;
1111
using Intersect.Framework.Core.GameObjects.NPCs;
12+
using Intersect.Framework.Core.GameObjects.Quests;
1213
using Intersect.GameObjects;
1314
using Intersect.Utilities;
1415

@@ -37,7 +38,7 @@ public partial class QuestsWindow
3738

3839
private readonly Button mQuitButton;
3940

40-
private QuestBase mSelectedQuest;
41+
private QuestDescriptor mSelectedQuest;
4142

4243
//Init
4344
public QuestsWindow(Canvas gameCanvas)
@@ -177,11 +178,11 @@ private void UpdateQuestList()
177178
_questList.RemoveAllRows();
178179
if (Globals.Me != null)
179180
{
180-
var quests = QuestBase.Lookup.Values;
181+
var quests = QuestDescriptor.Lookup.Values;
181182

182-
var dict = new Dictionary<string, List<Tuple<QuestBase, int, Color>>>();
183+
var dict = new Dictionary<string, List<Tuple<QuestDescriptor, int, Color>>>();
183184

184-
foreach (QuestBase quest in quests)
185+
foreach (QuestDescriptor quest in quests)
185186
{
186187
if (quest != null)
187188
{
@@ -215,7 +216,7 @@ private void UpdateQuestList()
215216
}
216217
}
217218

218-
private void AddQuestToDict(Dictionary<string, List<Tuple<QuestBase, int, Color>>> dict, QuestBase quest)
219+
private void AddQuestToDict(Dictionary<string, List<Tuple<QuestDescriptor, int, Color>>> dict, QuestDescriptor quest)
219220
{
220221
var category = string.Empty;
221222
var add = false;
@@ -269,10 +270,10 @@ private void AddQuestToDict(Dictionary<string, List<Tuple<QuestBase, int, Color>
269270
{
270271
if (!dict.ContainsKey(category))
271272
{
272-
dict.Add(category, new List<Tuple<QuestBase, int, Color>>());
273+
dict.Add(category, new List<Tuple<QuestDescriptor, int, Color>>());
273274
}
274275

275-
dict[category].Add(new Tuple<QuestBase, int, Color>(quest, orderVal, color));
276+
dict[category].Add(new Tuple<QuestDescriptor, int, Color>(quest, orderVal, color));
276277
}
277278
}
278279

@@ -306,7 +307,7 @@ private void QuestListItem_Clicked(Base sender, MouseButtonState arguments)
306307
return;
307308
}
308309

309-
if (!QuestBase.TryGet(questId, out var questDescriptor))
310+
if (!QuestDescriptor.TryGet(questId, out var questDescriptor))
310311
{
311312
_questList.UnselectAll();
312313
return;

Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,20 +1236,20 @@ private static string GetCommandText(StartQuestCommand command, MapInstance map)
12361236
if (!command.Offer)
12371237
{
12381238
return Strings.EventCommandList.startquest.ToString(
1239-
QuestBase.GetName(command.QuestId), Strings.EventCommandList.forcedstart
1239+
QuestDescriptor.GetName(command.QuestId), Strings.EventCommandList.forcedstart
12401240
);
12411241
}
12421242
else
12431243
{
12441244
return Strings.EventCommandList.startquest.ToString(
1245-
QuestBase.GetName(command.QuestId), Strings.EventCommandList.showoffer
1245+
QuestDescriptor.GetName(command.QuestId), Strings.EventCommandList.showoffer
12461246
);
12471247
}
12481248
}
12491249

12501250
private static string GetCommandText(CompleteQuestTaskCommand command, MapInstance map)
12511251
{
1252-
var quest = QuestBase.Get(command.QuestId);
1252+
var quest = QuestDescriptor.Get(command.QuestId);
12531253
if (quest != null)
12541254
{
12551255
//Try to find task
@@ -1258,14 +1258,14 @@ private static string GetCommandText(CompleteQuestTaskCommand command, MapInstan
12581258
if (task.Id == command.TaskId)
12591259
{
12601260
return Strings.EventCommandList.completetask.ToString(
1261-
QuestBase.GetName(command.QuestId), task.GetTaskString(Strings.TaskEditor.descriptions)
1261+
QuestDescriptor.GetName(command.QuestId), task.GetTaskString(Strings.TaskEditor.descriptions)
12621262
);
12631263
}
12641264
}
12651265
}
12661266

12671267
return Strings.EventCommandList.completetask.ToString(
1268-
QuestBase.GetName(command.QuestId), Strings.EventCommandList.taskundefined
1268+
QuestDescriptor.GetName(command.QuestId), Strings.EventCommandList.taskundefined
12691269
);
12701270
}
12711271

@@ -1274,12 +1274,12 @@ private static string GetCommandText(EndQuestCommand command, MapInstance map)
12741274
if (!command.SkipCompletionEvent)
12751275
{
12761276
return Strings.EventCommandList.endquest.ToString(
1277-
QuestBase.GetName(command.QuestId), Strings.EventCommandList.runcompletionevent
1277+
QuestDescriptor.GetName(command.QuestId), Strings.EventCommandList.runcompletionevent
12781278
);
12791279
}
12801280

12811281
return Strings.EventCommandList.endquest.ToString(
1282-
QuestBase.GetName(command.QuestId), Strings.EventCommandList.skipcompletionevent
1282+
QuestDescriptor.GetName(command.QuestId), Strings.EventCommandList.skipcompletionevent
12831283
);
12841284
}
12851285

0 commit comments

Comments
 (0)