mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 21:25:42 +12:00
54 lines
1.5 KiB
C#
Executable file
54 lines
1.5 KiB
C#
Executable file
using System.Collections.Generic;
|
|
using HISP.Server;
|
|
using HISP.Util;
|
|
|
|
namespace HISP.Player
|
|
{
|
|
public class PlayerQuests
|
|
{
|
|
private ThreadSafeList<TrackedQuest> trackedQuests = new ThreadSafeList<TrackedQuest>();
|
|
public User BaseUser;
|
|
public TrackedQuest[] QuestList
|
|
{
|
|
get
|
|
{
|
|
return trackedQuests.ToArray();
|
|
}
|
|
}
|
|
public void Add(int questId, int timesCompleted)
|
|
{
|
|
TrackedQuest quest = new TrackedQuest(BaseUser.Id, questId, 0);
|
|
quest.TimesCompleted = timesCompleted;
|
|
trackedQuests.Add(quest);
|
|
}
|
|
public int GetTrackedQuestAmount(int questId)
|
|
{
|
|
foreach(TrackedQuest quest in QuestList)
|
|
{
|
|
if (quest.QuestId == questId)
|
|
return quest.TimesCompleted;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public void TrackQuest(int questId)
|
|
{
|
|
foreach (TrackedQuest quest in QuestList)
|
|
{
|
|
if (quest.QuestId == questId)
|
|
{
|
|
quest.TimesCompleted++;
|
|
return;
|
|
}
|
|
}
|
|
Add(questId, 1);
|
|
}
|
|
public PlayerQuests(User user)
|
|
{
|
|
BaseUser = user;
|
|
TrackedQuest[] quests = Database.GetTrackedQuests(user.Id);
|
|
foreach (TrackedQuest quest in quests)
|
|
trackedQuests.Add(quest);
|
|
}
|
|
}
|
|
}
|