Skip to content

Commit

Permalink
Prevent quests from showing unnecessary progresses
Browse files Browse the repository at this point in the history
  • Loading branch information
KodamaSakuno committed Oct 14, 2016
1 parent 15707f8 commit 6e7e94d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion HeavenlyWind.Game/Services/Quest/QuestInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal QuestInfo(JToken rpJson)
if (rReward != null)
Rewards = rReward.ToObject<ExtraRewardsInfo>();

Total = (int?)rpJson["total"] ?? 1;
Total = (int?)rpJson["total"] ?? -1;
StartFrom = (int?)rpJson["start_from"] ?? 0;

IsDailyReset = (bool?)rpJson["daily_reset"] ?? false;
Expand Down
86 changes: 44 additions & 42 deletions HeavenlyWind.Game/Services/QuestProgressService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,55 +101,57 @@ void ProcessQuestList(RawQuestList rpData)
var rID = rRawQuest.ID;

QuestInfo rInfo;
ProgressInfo rProgressInfo;
ProgressInfo rProgressInfo = null;
if (!Infos.TryGetValue(rID, out rInfo))
Progresses.TryGetValue(rID, out rProgressInfo);
else
{
var rTotal = rInfo.Total;
int rProgress;

if (Progresses.TryGetValue(rID, out rProgressInfo) && rQuests.ContainsKey(rID))
{
rProgress = rProgressInfo.Progress;

if (rRawQuest.State == QuestState.Completed)
rProgress = rTotal;
else if (rID != 214)
switch (rRawQuest.Progress)
{
case QuestProgress.Progress50: rProgress = Math.Max(rProgress, (int)Math.Ceiling(rTotal * 0.5) - rInfo.StartFrom); break;
case QuestProgress.Progress80: rProgress = Math.Max(rProgress, (int)Math.Ceiling(rTotal * 0.8) - rInfo.StartFrom); break;
}

rProgressInfo.Progress = rProgress;
rProgressInfo.State = rRawQuest.State;
}
else
if (rTotal > 0)
{
rProgress = 0;

if (rRawQuest.State == QuestState.Completed)
rProgress = rTotal;
else if (rID != 214)
switch (rRawQuest.Progress)
{
case QuestProgress.Progress50: rProgress = (int)Math.Ceiling(rTotal * 0.5) - rInfo.StartFrom; break;
case QuestProgress.Progress80: rProgress = (int)Math.Ceiling(rTotal * 0.8) - rInfo.StartFrom; break;
}

Progresses.Add(rID, rProgressInfo = new ProgressInfo(rID, rRawQuest.Type, rRawQuest.State, rProgress));
int rProgress;
if (Progresses.TryGetValue(rID, out rProgressInfo) && rQuests.ContainsKey(rID))
{
rProgress = rProgressInfo.Progress;

if (rRawQuest.State == QuestState.Completed)
rProgress = rTotal;
else if (rID != 214)
switch (rRawQuest.Progress)
{
case QuestProgress.Progress50: rProgress = Math.Max(rProgress, (int)Math.Ceiling(rTotal * 0.5) - rInfo.StartFrom); break;
case QuestProgress.Progress80: rProgress = Math.Max(rProgress, (int)Math.Ceiling(rTotal * 0.8) - rInfo.StartFrom); break;
}

rProgressInfo.Progress = rProgress;
rProgressInfo.State = rRawQuest.State;
}
else
{
rProgress = 0;

if (rRawQuest.State == QuestState.Completed)
rProgress = rTotal;
else if (rID != 214)
switch (rRawQuest.Progress)
{
case QuestProgress.Progress50: rProgress = (int)Math.Ceiling(rTotal * 0.5) - rInfo.StartFrom; break;
case QuestProgress.Progress80: rProgress = (int)Math.Ceiling(rTotal * 0.8) - rInfo.StartFrom; break;
}

Progresses.Add(rID, rProgressInfo = new ProgressInfo(rID, rRawQuest.Type, rRawQuest.State, rProgress));
}

if (rID == 214)
{
OSSQuestProgressRule rOSSRule;
if (OSSQuestProgressRule.Maps.TryGetValue(214, out rOSSRule))
((OperationA)rOSSRule).UpdatePercentage(rProgressInfo);
}

if (rRawQuest.State == QuestState.Active)
RecordService.Instance.QuestProgress.InsertRecord(rRawQuest, rProgress);
}

if (rID == 214)
{
OSSQuestProgressRule rOSSRule;
if (OSSQuestProgressRule.Maps.TryGetValue(214, out rOSSRule))
((OperationA)rOSSRule).UpdatePercentage(rProgressInfo);
}

if (rRawQuest.State == QuestState.Active)
RecordService.Instance.QuestProgress.InsertRecord(rRawQuest, rProgress);
}

QuestClass rQuest;
Expand Down

0 comments on commit 6e7e94d

Please sign in to comment.