초기커밋
This commit is contained in:
192
GameServer/Contents/Quest/Action/EndQuestAction.cs
Normal file
192
GameServer/Contents/Quest/Action/EndQuestAction.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using Amazon.S3.Model;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class EndQuestAction : EntityActionBase
|
||||
{
|
||||
private ConcurrentDictionary<(UInt32, UInt32/*questid, revision*/), ServerCommon.EndQuest> m_end_quests = new();
|
||||
|
||||
|
||||
public EndQuestAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_end_quests.Clear();
|
||||
}
|
||||
|
||||
public async Task<Result> loadEndQuests()
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.None
|
||||
, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQEndQuestsReadAll(owner.getUserGuid()));
|
||||
}
|
||||
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addEndQuest(ServerCommon.EndQuest endQuest)
|
||||
{
|
||||
if (endQuest is null)
|
||||
{
|
||||
Log.getLogger().error("endQuest is null !!!");
|
||||
return;
|
||||
}
|
||||
var end_quest_attribute = endQuest.getEntityAttribute<EndQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attribute, () => $"end_quest_attribute is null !!!");
|
||||
|
||||
_ = m_end_quests.TryAdd((end_quest_attribute.QuestId, end_quest_attribute.QuestRevision), endQuest);
|
||||
|
||||
//if (false == m_end_quests.TryAdd((end_quest_attribute.QuestId, end_quest_attribute.QuestRevision), endQuest))
|
||||
//{
|
||||
// Log.getLogger().error($"endQuest TryAdd fail !!! quest : {JsonConvert.SerializeObject(endQuest)}");
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
|
||||
public Result setEndQuestsFromDoc(EndQuestDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var end_quest_attrib = doc.getAttrib<EndQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attrib, () => $"end_quest_attrib is null !!!");
|
||||
|
||||
ServerCommon.EndQuest end_quest = new ServerCommon.EndQuest(owner, owner.getUserGuid(), end_quest_attrib.m_quest_id, end_quest_attrib.m_quest_revision);
|
||||
|
||||
var attribute = end_quest.getEntityAttribute<EndQuestAttribute>();
|
||||
if (attribute is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttribute";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (false == doc.getAttribWrappers().TryGetValue(typeof(EndQuestAttrib), out var to_copy_doc_attrib))
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
var doc_attrib = attrib_base as EndQuestAttrib;
|
||||
if (doc_attrib is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
attribute.QuestId = doc_attrib.m_quest_id;
|
||||
attribute.EndCount = doc_attrib.m_end_count;
|
||||
attribute.LastEndTime = doc_attrib.m_last_end_time;
|
||||
|
||||
if (false == m_end_quests.TryAdd((attribute.QuestId, attribute.QuestRevision), end_quest))
|
||||
{
|
||||
var err_msg = $"m_end_quest try Add Fail";
|
||||
result.setFail(ServerErrorCode.ServerLogicError, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<(UInt32, UInt32), ServerCommon.EndQuest> getEndQuests()
|
||||
{
|
||||
return m_end_quests;
|
||||
}
|
||||
|
||||
public ServerCommon.EndQuest? getEndQuest(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
if (m_end_quests.TryGetValue((questId, questRevision), out var end_quest))
|
||||
{
|
||||
return end_quest;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Result endQuestCheck(MetaAssets.EQuestType questType, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//normal은 체크안한다.
|
||||
if (questType == MetaAssets.EQuestType.NORMAL) return result;
|
||||
|
||||
if (true == m_end_quests.ContainsKey((questId, questRevision)))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAlreadyEnded, $"Quest Already End. QuestID : {questId}");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool hasEndQuest(UInt32 questId, UInt32 questRevision = 0)
|
||||
{
|
||||
return m_end_quests.ContainsKey((questId, questRevision));
|
||||
}
|
||||
|
||||
public List<QuestEndInfo> makeQuestEndInfo(List<(UInt32, UInt32)> questIdAndRevisions)
|
||||
{
|
||||
|
||||
var infos = new List<QuestEndInfo>();
|
||||
foreach (var quest_id_revision in questIdAndRevisions)
|
||||
{
|
||||
if (false == m_end_quests.TryGetValue(quest_id_revision, out var end_quest))
|
||||
{
|
||||
Log.getLogger().error($"makeQuestEndInfo End Quest Not Found. QuestID : {quest_id_revision}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var end_quest_attribute = end_quest.getEntityAttribute<EndQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attribute, () => $"end_quest_attribute is null !!!");
|
||||
|
||||
var quest_id = quest_id_revision.Item1;
|
||||
var quest_revision = quest_id_revision.Item2;
|
||||
var ugq_quest_id = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(quest_id, quest_revision);
|
||||
|
||||
var info = new QuestEndInfo();
|
||||
info.ComposedQuestId = ugq_quest_id;
|
||||
info.EndCount = end_quest_attribute.EndCount;
|
||||
info.LastEndTime = Timestamp.FromDateTime(end_quest_attribute.LastEndTime);
|
||||
|
||||
infos.Add(info);
|
||||
}
|
||||
|
||||
return infos;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
60
GameServer/Contents/Quest/Action/QuestAbandonAction.cs
Normal file
60
GameServer/Contents/Quest/Action/QuestAbandonAction.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestAbandonAction : EntityActionBase
|
||||
{
|
||||
public QuestAbandonAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public async Task<Result> abandonQuestConditionCheck(UInt32 questId)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
ArgumentNullException.ThrowIfNull(owner);
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
ArgumentNullException.ThrowIfNull(quest_action);
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (result.isFail()) return result;
|
||||
var quest_type = EnumHelper.convertEnumValueStringToEnum(quest_base_info.QuestType, MetaAssets.EQuestType.NORMAL);
|
||||
|
||||
result = quest_action.hasQuest(quest_type, questId);
|
||||
if(result.isFail()) return result;
|
||||
|
||||
if (quest_base_info.QuestType.Equals(nameof(MetaAssets.EQuestType.TUTORIAL)))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAbandonOnlyNormal, $"Epic Quest cannot abandon Data QuestID : {questId}");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
327
GameServer/Contents/Quest/Action/QuestAcceptAction.cs
Normal file
327
GameServer/Contents/Quest/Action/QuestAcceptAction.cs
Normal file
@@ -0,0 +1,327 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class AcceptQuestVariable
|
||||
{
|
||||
public QuestBaseInfo? m_quest_base_info_nullable { get; set; } = null;
|
||||
public bool m_is_mail_quest { get; set; } = false;
|
||||
public ServerCommon.Quest? m_new_quest_nullable { get; set; } = null;
|
||||
public MetaAssets.EQuestType m_quest_type { get; set; } = MetaAssets.EQuestType.NONE;
|
||||
public Int32 m_quest_cost { get; set; } = 0;
|
||||
|
||||
//public CommonResult m_common_result { get; set; } = new();
|
||||
public List<UInt32> assignable_quests { get; set; } = new();
|
||||
|
||||
|
||||
public AcceptQuestVariable()
|
||||
{
|
||||
m_quest_base_info_nullable = null;
|
||||
m_is_mail_quest = false;
|
||||
m_quest_type = MetaAssets.EQuestType.NONE;
|
||||
m_new_quest_nullable = null;
|
||||
}
|
||||
|
||||
public AcceptQuestVariable(QuestBaseInfo metaInfo, bool isMailQuest, ServerCommon.Quest quest, Int32 questCost = 0)
|
||||
{
|
||||
m_quest_base_info_nullable = metaInfo;
|
||||
m_is_mail_quest = isMailQuest;
|
||||
m_new_quest_nullable = quest;
|
||||
|
||||
if (false == EnumHelper.tryParse(metaInfo.QuestType, out MetaAssets.EQuestType quest_type))
|
||||
{
|
||||
m_quest_type = MetaAssets.EQuestType.NONE;
|
||||
}
|
||||
else m_quest_type = quest_type;
|
||||
|
||||
m_quest_cost = questCost;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class QuestAcceptAction : EntityActionBase
|
||||
{
|
||||
public QuestAcceptAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public async Task<Result> acceptQuestConditionCheck(UInt32 questId, AcceptQuestVariable acceptQuestVar)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
var end_quest_action = owner.getEntityAction<EndQuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action);
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_action);
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_action);
|
||||
|
||||
|
||||
|
||||
//해당 퀘스트 정보 불러오기
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
acceptQuestVar.m_quest_base_info_nullable = quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(acceptQuestVar.m_quest_base_info_nullable, () => $"acceptQuestVar.m_quest_base_info_nullable is null !!!");
|
||||
if (false == EnumHelper.tryParse(acceptQuestVar.m_quest_base_info_nullable.QuestType, out MetaAssets.EQuestType quest_type))
|
||||
{
|
||||
result.setFail(ServerErrorCode.ServerLogicError, $"QuestType Parse Failed : {acceptQuestVar.m_quest_base_info_nullable.QuestType}");
|
||||
return result;
|
||||
}
|
||||
acceptQuestVar.m_quest_type = quest_type;
|
||||
|
||||
//현재 보유중인 퀘스트인지 체크
|
||||
quest_action.getQuest(quest_type, questId, out var existedQuest);
|
||||
if (existedQuest is not null)
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAlreadyExist, $"Quest Already Exist quest Type : {acceptQuestVar.m_quest_base_info_nullable.QuestType}, questId : {questId}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//메일로 받는 경우 메일 가지고 있는지 체크
|
||||
acceptQuestVar.m_is_mail_quest = acceptQuestVar.m_quest_base_info_nullable.AssignType.Equals(MetaAssets.EAssignType.MAIL.ToString());
|
||||
if (acceptQuestVar.m_is_mail_quest)
|
||||
{
|
||||
result = quest_mail_action.hasQuestMail(quest_type, questId, true);
|
||||
if (result.isFail()) return result;
|
||||
}
|
||||
|
||||
//이미 완료한 퀘스트 인지 체크
|
||||
result = end_quest_action.endQuestCheck(quest_type, questId, 0);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
|
||||
//내가 들고 있는 퀘스트의 전체 타입 수를 정리 하고 이미 퀘스트가 꽉차서 받을 수 없으면 에러 처리
|
||||
result = quest_action.assignableQuestCheckByQuestType(acceptQuestVar.m_quest_type);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public (Result, AcceptQuestVariable) acceptQuestByNpcDialogue(QuestBaseInfo questMetaInfo)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
ArgumentNullException.ThrowIfNull(owner);
|
||||
|
||||
var new_quest = new ServerCommon.Quest(owner, owner.getUserGuid());
|
||||
ArgumentNullException.ThrowIfNull(new_quest);
|
||||
|
||||
var quest_attribute = new_quest.getEntityAttribute<QuestAttribute>();
|
||||
ArgumentNullException.ThrowIfNull(quest_attribute);
|
||||
AcceptQuestVariable acceptQuestVar = new(questMetaInfo, false, new_quest);
|
||||
|
||||
var result = newQuestAssign(ref acceptQuestVar);
|
||||
|
||||
if (result.isFail()) { return (result, acceptQuestVar); }
|
||||
|
||||
return (result, acceptQuestVar);
|
||||
}
|
||||
|
||||
public async Task<(Result, AcceptQuestVariable?)> questAccept(UInt32 questId)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner);
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action);
|
||||
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return (result, null);
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
var new_quest = new ServerCommon.Quest(owner, owner.getUserGuid());
|
||||
|
||||
AcceptQuestVariable acceptQuestVar = new(quest_base_info, false, new_quest);
|
||||
result = newQuestAssign(ref acceptQuestVar);
|
||||
if (result.isFail()) return (result, null);
|
||||
|
||||
return (result, acceptQuestVar);
|
||||
}
|
||||
|
||||
public Result makeNewQuestAssignInfo(ref AcceptQuestVariable acceptQuestVar, Int32 cost = 0)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner);
|
||||
|
||||
var quest_meta = acceptQuestVar.m_quest_base_info_nullable;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_meta, () => $"quest_meta is null !!!");
|
||||
acceptQuestVar.m_new_quest_nullable = new ServerCommon.Quest(owner, owner.getUserGuid());
|
||||
|
||||
var quest_attribute = acceptQuestVar.m_new_quest_nullable.getEntityAttribute<QuestAttribute>();
|
||||
ArgumentNullException.ThrowIfNull(quest_attribute);
|
||||
|
||||
DateTime nowDt = DateTimeHelper.Current;
|
||||
|
||||
quest_attribute.QuestId = quest_meta.QuestId;
|
||||
quest_attribute.QuestType = acceptQuestVar.m_quest_type;
|
||||
quest_attribute.UgqInfo.QuestRevision = quest_meta.QuestRevision;
|
||||
quest_attribute.UgqInfo.QuestCost = cost;
|
||||
quest_attribute.UgqInfo.UqgState = quest_meta.UgqState;
|
||||
quest_attribute.QuestAssignTime = nowDt;
|
||||
quest_attribute.CurrentTaskNum = 1;
|
||||
quest_attribute.CurrentTaskComplete = 0;
|
||||
quest_attribute.TaskStartTime = nowDt;
|
||||
quest_attribute.QuestCompleteTime = nowDt;
|
||||
quest_attribute.IsComplete = 0;
|
||||
quest_attribute.HasTimer = 0;
|
||||
quest_attribute.TimerCompleteTime = nowDt;
|
||||
quest_attribute.CompletedIdxStrings = new();
|
||||
|
||||
if (false == quest_meta.QuestTaskGroupList.TryGetValue(quest_attribute.CurrentTaskNum, out var quest_task_info))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestInvalidValue, $"questEventInfo InvalidData questId = {quest_attribute.QuestId}, info.CurrentTaskNum : {quest_attribute.CurrentTaskNum}");
|
||||
return result;
|
||||
}
|
||||
|
||||
quest_attribute.ActiveEvents.AddRange(QuestManager.It.getActiveEventStrings(quest_attribute, quest_task_info));
|
||||
|
||||
if (quest_task_info.HasCounter)
|
||||
{
|
||||
quest_attribute.HasCounter = (quest_task_info.HasCounter ? 1 : 0);
|
||||
quest_attribute.MinCounter = quest_task_info.MinCounter;
|
||||
quest_attribute.MaxCounter = quest_task_info.MaxCounter;
|
||||
quest_attribute.CurrentCounter = quest_task_info.MinCounter;
|
||||
}
|
||||
if (quest_task_info.HasTimer)
|
||||
{
|
||||
quest_attribute.HasCounter = (quest_task_info.HasCounter ? 1 : 0);
|
||||
quest_attribute.TimerCompleteTime = nowDt.AddSeconds(quest_task_info.RemainTime);
|
||||
}
|
||||
|
||||
if (quest_task_info.HasAssignableQuest)
|
||||
{
|
||||
acceptQuestVar.assignable_quests.AddRange(quest_task_info.AssignableQuestIds);
|
||||
|
||||
}
|
||||
quest_attribute.newEntityAttribute();
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<Result> reAssignQuest(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
(var result, var quest) = await questAcceptWithTransaction(questId, questRevision, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<(Result, ServerCommon.Quest?)> questAcceptWithTransaction(UInt32 questId, UInt32 questRevision, int recursiveCount)
|
||||
{
|
||||
var result = new Result();
|
||||
if (recursiveCount > 10)
|
||||
{
|
||||
var err_msg = $"recursiveCount > 10 !!! : {recursiveCount}";
|
||||
Log.getLogger().error(err_msg);
|
||||
result.setFail(ServerErrorCode.ServerLogicError, err_msg);
|
||||
return (result, null);
|
||||
}
|
||||
recursiveCount += 1;
|
||||
|
||||
var player = getOwner() as Player;
|
||||
ArgumentNullException.ThrowIfNull(player);
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
ArgumentNullException.ThrowIfNull(quest_action);
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(player, questId, questRevision);
|
||||
if (result.isFail()) return (result, null);
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
NullReferenceCheckHelper.throwIfNull(server_logic);
|
||||
var new_quest = new ServerCommon.Quest(player, player.getUserGuid());
|
||||
NullReferenceCheckHelper.throwIfNull(new_quest);
|
||||
AcceptQuestVariable acceptQuestVar = new(quest_base_info, false, new_quest);
|
||||
|
||||
var fn_quest_accept = async delegate ()
|
||||
{
|
||||
var result = new Result();
|
||||
result = newQuestAssign(ref acceptQuestVar);
|
||||
if (result.isFail()) return result;
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.None, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLog(new QuestAcceptBusinessLog(questId, questRevision, acceptQuestVar.m_quest_type));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "QuestAcceptWithTran", fn_quest_accept);
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, null);
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(acceptQuestVar.m_new_quest_nullable, () => $"acceptQuestVar.m_new_quest_nullable is null !!!");
|
||||
|
||||
quest_action.addNewQuest(questId, acceptQuestVar.m_new_quest_nullable);
|
||||
await player.send_GS2C_NTF_QUEST_UPDATE(questId, questRevision, new(), true);
|
||||
await QuestManager.It.QuestCheck(player, new QuestMail(EQuestEventTargetType.QUEST, EQuestEventNameType.ACTIVED, ""));
|
||||
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
ArgumentNullException.ThrowIfNull(quest_mail_action);
|
||||
quest_mail_action.GS2C_NTF_DELETE_QUEST_MAIL_NOTI(questId);
|
||||
|
||||
|
||||
foreach(var additional_quest_id in acceptQuestVar.assignable_quests)
|
||||
{
|
||||
await questAcceptWithTransaction(additional_quest_id, 0, recursiveCount);
|
||||
}
|
||||
|
||||
return (result, new_quest);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Result newQuestAssign(ref AcceptQuestVariable acceptQuestVar)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
ArgumentNullException.ThrowIfNull(owner);
|
||||
//퀘스트 객체 데이터 채우기
|
||||
var result = makeNewQuestAssignInfo(ref acceptQuestVar);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
948
GameServer/Contents/Quest/Action/QuestAction.cs
Normal file
948
GameServer/Contents/Quest/Action/QuestAction.cs
Normal file
@@ -0,0 +1,948 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestAction : EntityActionBase
|
||||
{
|
||||
private ConcurrentDictionary<(EQuestType, UInt32), ServerCommon.Quest> m_quests = new();
|
||||
|
||||
public QuestAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_quests.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public void removeQuest(ServerCommon.Quest quest)
|
||||
{
|
||||
if (quest is null)
|
||||
{
|
||||
Log.getLogger().error("quest is null !!!");
|
||||
return;
|
||||
}
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
var quest_id = quest_attribute.QuestId;
|
||||
var quest_type = quest_attribute.QuestType;
|
||||
|
||||
if (false == m_quests.TryRemove((quest_type, quest_id), out _))
|
||||
{
|
||||
Log.getLogger().error($"quest TryRemove fail !!! quest : {JsonConvert.SerializeObject(quest)}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Result hasQuest(EQuestType questType, UInt32 questId, UInt32 questRevision = 0)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (false == m_quests.ContainsKey((questType, questId)))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAbadonNotExistQuest, $"Quest Not Exist QuestID : {questId}, questRevision : {questRevision}");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public Result hasQuest(string questType, UInt32 questId, UInt32 questRevision = 0)
|
||||
{
|
||||
var result = new Result();
|
||||
if (false == checkHasQuest(questType, questId))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAbadonNotExistQuest, $"Quest Not Exist QuestID : {questId}, questRevision : {questRevision}");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public bool checkHasQuest(EQuestType questType, UInt32 questId)
|
||||
{
|
||||
return m_quests.ContainsKey((questType, questId));
|
||||
}
|
||||
|
||||
public bool checkHasQuest(string questType, UInt32 questId)
|
||||
{
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(questType, EQuestType.NORMAL);
|
||||
return m_quests.ContainsKey((quest_type, questId));
|
||||
}
|
||||
|
||||
|
||||
public Result deleteQuest(EQuestType questType, UInt32 questId)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
if (false == m_quests.TryRemove((questType, questId), out var quest))
|
||||
{
|
||||
var err_msg = $"Quest Not Exist QuestID : {questId}, owner : {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.QuestAbadonNotExistQuest, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//public void deleteQuestFromdDictionary(Int32 questId, Int32 questRevision = 0)
|
||||
//{
|
||||
// var quest_key = QuestMetaHelper.makeQuestsDictionaryKey(questId, questRevision);
|
||||
// m_quests.TryRemove(quest_key, out var _);
|
||||
//}
|
||||
|
||||
public async Task<Result> setQuestsFromDoc(QuestDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
ServerCommon.Quest quest = new ServerCommon.Quest(owner, owner.getUserGuid());
|
||||
|
||||
var attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
|
||||
if (attribute is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttribute";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (false == doc.getAttribWrappers().TryGetValue(typeof(QuestAttrib), out var to_copy_doc_attrib))
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
var doc_attrib = attrib_base as QuestAttrib;
|
||||
if (doc_attrib is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
attribute.QuestId = doc_attrib.m_quest_id;
|
||||
attribute.QuestType = doc_attrib.m_quest_type;
|
||||
attribute.UgqInfo.QuestRevision = doc_attrib.m_ugq_quest_info.QuestRevision;
|
||||
attribute.UgqInfo.QuestCost = doc_attrib.m_ugq_quest_info.QuestCost;
|
||||
attribute.UgqInfo.UqgState = doc_attrib.m_ugq_quest_info.UqgState;
|
||||
attribute.QuestAssignTime = doc_attrib.m_quest_assign_time;
|
||||
attribute.CurrentTaskNum = doc_attrib.m_current_task_num;
|
||||
attribute.TaskStartTime = doc_attrib.m_task_start_time;
|
||||
attribute.QuestCompleteTime = doc_attrib.m_quest_complete_time;
|
||||
attribute.ActiveEvents = doc_attrib.m_active_events;
|
||||
attribute.HasCounter = doc_attrib.m_has_counter;
|
||||
attribute.MinCounter = doc_attrib.m_min_counter;
|
||||
attribute.MaxCounter = doc_attrib.m_max_counter;
|
||||
attribute.CurrentCounter = doc_attrib.m_current_counter;
|
||||
attribute.IsComplete = doc_attrib.m_is_complete;
|
||||
attribute.ReplacedRewardGroupId = doc_attrib.m_replaced_reward_group_id;
|
||||
attribute.HasTimer = doc_attrib.m_has_timer;
|
||||
attribute.TimerCompleteTime = doc_attrib.m_timer_complete_time;
|
||||
attribute.CurrentTaskComplete = doc_attrib.m_is_current_task_complete;
|
||||
attribute.CompletedIdxStrings = doc_attrib.m_completed_idx_strings;
|
||||
attribute.m_quest_doc_nullable = doc;
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(owner, doc_attrib.m_quest_id, doc_attrib.m_ugq_quest_info.QuestRevision, attribute.UgqInfo.UqgState);
|
||||
if(result.isFail())
|
||||
{
|
||||
if (attribute.UgqInfo.UqgState == UgqStateType.Test)
|
||||
{
|
||||
var ugq_test_action = owner.getEntityAction<UgqTestAction>();
|
||||
var copy_doc = await attribute.toDocBase();
|
||||
|
||||
_ = await ugq_test_action.ugqTestDelete(attribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
var err_msg = $"getQuestMeta result fail, owner : {owner.toBasicString()}, quest_id : {doc_attrib.m_quest_id}, questRevision : {doc_attrib.m_ugq_quest_info.QuestRevision}, " +
|
||||
$"state : {attribute.UgqInfo.UqgState}, result : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!! - {owner.toBasicString()}");
|
||||
if (false == EnumHelper.tryParse(quest_base_info.QuestType, out MetaAssets.EQuestType quest_type))
|
||||
{
|
||||
attribute.QuestType = MetaAssets.EQuestType.NONE;
|
||||
}
|
||||
else attribute.QuestType = quest_type;
|
||||
|
||||
|
||||
if (false == m_quests.TryAdd((attribute.QuestType, attribute.QuestId), quest))
|
||||
{
|
||||
var err_msg = $"m_quest try Add Fail type : {attribute.QuestType}, quest Id : {attribute.QuestId}, questRevision : {attribute.UgqInfo.QuestRevision}, state : {attribute.UgqInfo.UqgState}";
|
||||
result.setFail(ServerErrorCode.ServerLogicError, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Result assignableQuestCheckByQuestType(EQuestType questType)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
bool is_max = false;
|
||||
|
||||
Int32 epic_quest_count = 0;
|
||||
Int32 tutorial_quest_count = 0;
|
||||
Int32 normal_quest_count = 0;
|
||||
Int32 ugq_quest_count = 0;
|
||||
foreach (var quest in m_quests)
|
||||
{
|
||||
var quest_type = quest.Key.Item1;
|
||||
if (quest_type.Equals(EQuestType.EPIC)) epic_quest_count++;
|
||||
else if (quest_type.Equals(EQuestType.TUTORIAL)) tutorial_quest_count++;
|
||||
else if (quest_type.Equals(EQuestType.NORMAL)) normal_quest_count++;
|
||||
else if (quest_type.Equals(EQuestType.UGQ)) ugq_quest_count++;
|
||||
}
|
||||
|
||||
switch (questType)
|
||||
{
|
||||
case MetaAssets.EQuestType.NORMAL:
|
||||
if (normal_quest_count >= MetaHelper.GameConfigMeta.MaxNormalQuest) is_max = true;
|
||||
break;
|
||||
case MetaAssets.EQuestType.EPIC:
|
||||
if (epic_quest_count >= MetaHelper.GameConfigMeta.MaxEpicQuest) is_max = true;
|
||||
break;
|
||||
case MetaAssets.EQuestType.TUTORIAL:
|
||||
if (tutorial_quest_count >= MetaHelper.GameConfigMeta.MaxTutorialQuest) is_max = true;
|
||||
break;
|
||||
case MetaAssets.EQuestType.UGQ:
|
||||
if (tutorial_quest_count >= MetaHelper.GameConfigMeta.MaxUGQuest) is_max = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_max)
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestTypeAssignCountMax, $"Quest is Max questType : {questType.ToString()}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// private List<QuestMetaInfo> makeQuestMetaInfoData(List<UserQuestInfo> infos)
|
||||
// {
|
||||
// List<QuestMetaInfo> metaInfos = new List<QuestMetaInfo>();
|
||||
// foreach (UserQuestInfo info in infos)
|
||||
// {
|
||||
// if (!MetaData.Instance._QuestScriptMetaTable.TryGetValue(info.m_quest_id, out var questScripts))
|
||||
// {
|
||||
// Log.getLogger().error($"QuestMetaInfoData Not Exist questId : {info.m_quest_id}");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// foreach (var script in questScripts.Values)
|
||||
// {
|
||||
// var meta = QuestNotifyHelper.fillQuestMetaInfo(script);
|
||||
// metaInfos.Add(meta);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return metaInfos;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Result getQuest(string questType, UInt32 questId, out ServerCommon.Quest? quest)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(questType, EQuestType.NORMAL);
|
||||
if (false == m_quests.TryGetValue((quest_type, questId), out quest))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAssingDataNotExist, $"Quest Not Exist QuestID : {questId}");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result getQuest(EQuestType questType, UInt32 questId, out ServerCommon.Quest? quest)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (false == m_quests.TryGetValue((questType, questId), out quest))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAssingDataNotExist, $"Quest Not Exist QuestID : {questId}");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<(Result, ServerCommon.Quest?)> getQuest(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var result = new Result();
|
||||
////(result, var quest_base_info) = QuestMetaHelper.getQuestMetaInfo(questId, questRevision);
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(player, questId, questRevision);
|
||||
if (result.isFail()) return (result, null!);
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
if (false == m_quests.TryGetValue((quest_type, questId), out var quest))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAssingDataNotExist, $"Quest Not Exist QuestID : {questId}");
|
||||
return (result, null);
|
||||
}
|
||||
return (result, quest);
|
||||
}
|
||||
|
||||
|
||||
public ConcurrentDictionary<(EQuestType, UInt32), ServerCommon.Quest> getQuests()
|
||||
{
|
||||
return m_quests;
|
||||
}
|
||||
|
||||
|
||||
public List<ServerCommon.Quest> getUgqQuests()
|
||||
{
|
||||
List<ServerCommon.Quest> ugq_quests = new List<ServerCommon.Quest>();
|
||||
foreach (var quest in m_quests)
|
||||
{
|
||||
var quest_type = quest.Key.Item1;
|
||||
var quest_id = quest.Key.Item2;
|
||||
var quest_attribute = quest.Value.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
if (quest_attribute.UgqInfo.QuestRevision > 0)
|
||||
{
|
||||
ugq_quests.Add(quest.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return ugq_quests;
|
||||
}
|
||||
|
||||
public List<ServerCommon.Quest> getSystemQuests()
|
||||
{
|
||||
List < ServerCommon.Quest > system_quests = new List<ServerCommon.Quest>();
|
||||
foreach (var quest in m_quests.Values)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
if (quest_attribute.UgqInfo.QuestRevision == 0)
|
||||
{
|
||||
system_quests.Add(quest);
|
||||
}
|
||||
}
|
||||
|
||||
return system_quests;
|
||||
}
|
||||
|
||||
public List<UInt32> getSystemQuestIds()
|
||||
{
|
||||
List<UInt32> quest_ids = new ();
|
||||
foreach (var quest in m_quests)
|
||||
{
|
||||
var quest_attribute = quest.Value.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
if (quest_attribute.UgqInfo.QuestRevision == 0)
|
||||
{
|
||||
quest_ids.Add(quest.Key.Item2);
|
||||
}
|
||||
}
|
||||
|
||||
return quest_ids;
|
||||
}
|
||||
|
||||
|
||||
public async Task<Result> questForceAcceptWithTransaction(UInt32 questId)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
AcceptQuestVariable? accept_quest_var = null;
|
||||
var quest_accept_action = player.getEntityAction<QuestAcceptAction>();
|
||||
var fn_quest_force_accept = async delegate ()
|
||||
{
|
||||
var fn_result = new Result();
|
||||
|
||||
(fn_result, accept_quest_var) = await quest_accept_action.questAccept(questId);
|
||||
if (fn_result.isFail()) return fn_result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(accept_quest_var, () => $"accept_quest_var is null !!!");
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestMainAssignForce, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLog(new QuestAcceptBusinessLog(questId, 0, accept_quest_var.m_quest_type));
|
||||
|
||||
fn_result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
return fn_result;
|
||||
};
|
||||
|
||||
var result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "QuestForceAccept", fn_quest_force_accept);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (null != accept_quest_var)
|
||||
{
|
||||
var quest = accept_quest_var.m_new_quest_nullable;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(accept_quest_var.m_quest_base_info_nullable, () => $"accept_quest_var.m_quest_base_info_nullable is null !!!");
|
||||
|
||||
var quest_id = accept_quest_var.m_quest_base_info_nullable.QuestId;
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
quest_action.addNewQuest(quest_id, quest);
|
||||
await player.send_GS2C_NTF_QUEST_UPDATE(quest_id, 0, new(), true);
|
||||
|
||||
foreach (var assignable_quest_id in accept_quest_var.assignable_quests)
|
||||
{
|
||||
await quest_accept_action.questAcceptWithTransaction(assignable_quest_id, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<ServerCommon.Quest>> makeNewQuestByCreateUser(List<UInt32> forceAcceptQuestIds)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner);
|
||||
var quest_accept_action = owner.getEntityAction<QuestAcceptAction>();
|
||||
|
||||
List<ServerCommon.Quest> new_quests = new List<ServerCommon.Quest>();
|
||||
|
||||
foreach (var questId in forceAcceptQuestIds)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) continue;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
AcceptQuestVariable accept_quest_var = new();
|
||||
accept_quest_var.m_is_mail_quest = false;
|
||||
accept_quest_var.m_quest_base_info_nullable = quest_base_info;
|
||||
|
||||
result = quest_accept_action.makeNewQuestAssignInfo(ref accept_quest_var);
|
||||
if (result.isFail()) continue;
|
||||
|
||||
var new_quest = accept_quest_var.m_new_quest_nullable;
|
||||
NullReferenceCheckHelper.throwIfNull(new_quest, () => $"new_quest is null !!! - {owner.toBasicString()}");
|
||||
new_quests.Add(new_quest);
|
||||
}
|
||||
|
||||
return new_quests;
|
||||
|
||||
}
|
||||
|
||||
public async Task cheatResetAllQuests()
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "ResetAllQuests", delegateDeleteAllQuests);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
async Task<Result> delegateDeleteAllQuests() => await deleteAllQuests();
|
||||
|
||||
onClear();
|
||||
var end_quest_action = player.getEntityAction<EndQuestAction>();
|
||||
end_quest_action.onClear();
|
||||
|
||||
player.send_GS2C_NTF_QUEST_UPDATE_EMPTY();
|
||||
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
(var mail_quest_ids, var force_accept_quest_ids) = await quest_mail_action.makeQuestMailDocByType(EAssignRequireType.PlayerInitial);
|
||||
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "CheatAccecptQuests", delegateCheatAcceptQuests);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
async Task<Result> delegateCheatAcceptQuests() => await cheatAcceptQuests(force_accept_quest_ids);
|
||||
|
||||
foreach (var quest_id in force_accept_quest_ids)
|
||||
{
|
||||
await player.send_GS2C_NTF_QUEST_UPDATE(quest_id, 0, new(), true);
|
||||
}
|
||||
|
||||
player.send_GS2C_NTF_END_QUESTS();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task<Result> cheatAcceptQuests(List<UInt32> force_accept_quest_ids)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var quest_accept_action = player.getEntityAction<QuestAcceptAction>();
|
||||
|
||||
List<AcceptQuestVariable> accept_quest_vars = new List<AcceptQuestVariable>();
|
||||
List<ILogInvoker> invokers = new();
|
||||
foreach (var quest_id in force_accept_quest_ids)
|
||||
{
|
||||
(var accept_result, var quest_accept_var) = await quest_accept_action.questAccept(quest_id);
|
||||
if (accept_result.isFail()) continue;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_accept_var, () => $"quest_accept_var is null !!!");
|
||||
|
||||
accept_quest_vars.Add(quest_accept_var);
|
||||
|
||||
var business_log = new QuestAcceptBusinessLog(quest_id, 0, quest_accept_var.m_quest_type);
|
||||
invokers.Add(business_log);
|
||||
}
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandQuestAccept, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLogs(invokers);
|
||||
|
||||
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
|
||||
foreach (var quest_var in accept_quest_vars)
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(quest_var.m_quest_base_info_nullable, () => $"quest_var.m_quest_base_info_nullable is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(quest_var.m_new_quest_nullable, () => $"quest_var.m_new_quest_nullable is null !!!");
|
||||
|
||||
quest_action.addNewQuest(quest_var.m_quest_base_info_nullable.QuestId, quest_var.m_new_quest_nullable);
|
||||
await player.send_GS2C_NTF_QUEST_UPDATE(quest_var.m_quest_base_info_nullable.QuestId, 0, new(), true);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private async Task<Result> deleteAllQuests()
|
||||
{
|
||||
var result = new Result();
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
foreach (var quest in m_quests.Values)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
quest_attribute.deleteEntityAttribute();
|
||||
}
|
||||
|
||||
var end_quest_action = player.getEntityAction<EndQuestAction>();
|
||||
var end_quests = end_quest_action.getEndQuests();
|
||||
|
||||
var log_invokers = new List<ILogInvoker>();
|
||||
|
||||
foreach (var end_quest in end_quests.Values)
|
||||
{
|
||||
var end_quest_attribute = end_quest.getEntityAttribute<EndQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attribute, () => $"end_quest_attribute is null !!!");
|
||||
end_quest_attribute.deleteEntityAttribute();
|
||||
|
||||
log_invokers.Add(new EndQuestDeleteBusinessLog(end_quest_attribute.QuestId, end_quest_attribute.QuestRevision));
|
||||
}
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandResetAllQuest, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
batch.appendBusinessLogs(log_invokers);
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task questComplete(UInt32 questId)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "cheatQuestComplete", delegateCheatQuestComplete);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
async Task<Result> delegateCheatQuestComplete() => await cheatQuestComplete(questId);
|
||||
|
||||
await player.send_GS2C_NTF_QUEST_UPDATE(questId, 0, new(), false);
|
||||
|
||||
await QuestManager.It.QuestCheck(player, new QuestActiveQuest(EQuestEventTargetType.QUEST, EQuestEventNameType.COMPLETED, questId));
|
||||
}
|
||||
|
||||
private async Task<Result> cheatQuestComplete(UInt32 questId)
|
||||
{
|
||||
var result = new Result();
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
result = getQuest(quest_base_info.QuestType, questId, out var quest);
|
||||
if(result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
quest_attribute.IsComplete = 1;
|
||||
quest_attribute.ActiveEvents.Clear();
|
||||
quest_attribute.modifiedEntityAttribute();
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandQuestComplete, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
batch.appendBusinessLog(new QuestCompleteBusinessLog(questId, 0));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task cheatAcceptQuest(UInt32 questId)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
|
||||
result = hasQuest(quest_base_info.QuestType, questId);
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
if (result.isSuccess())
|
||||
{
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "cheatDeleteQuest", delegatecheatDeleteQuest);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
async Task<Result> delegatecheatDeleteQuest() => await cheatDeleteQuest(quest_type, questId);
|
||||
m_quests.TryRemove((quest_type, questId), out var _);
|
||||
}
|
||||
|
||||
var quest_accept_action = player.getEntityAction<QuestAcceptAction>();
|
||||
await quest_accept_action.questAcceptWithTransaction(questId, 0, 0);
|
||||
}
|
||||
|
||||
private async Task<Result> cheatDeleteQuest(EQuestType questType, UInt32 questId, UInt32 questRevision = 0)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
m_quests.TryGetValue((questType, questId), out var quest);
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
quest_attribute.deleteEntityAttribute();
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandDeleteQuest, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
batch.appendBusinessLog(new QuestDeleteBusinessLog(questId, questRevision));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<Result> questAssignableItemConditionCheck(ItemMetaData itemMeta)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
|
||||
var normal_mails = await quest_mail_action.getNormalMailSet();
|
||||
var normal_mail_count = normal_mails.Count;
|
||||
var quest_id = (UInt32)itemMeta.Register_id;
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(quest_id);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
//진행중인 퀘스트가 있어서 아이템 사용 불가
|
||||
if (true == checkHasQuest(quest_base_info.QuestType, quest_id))
|
||||
{
|
||||
var err_msg = $"Item Use : Already Has Quest quest_id : {quest_id}, player : {player.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ItemUseAlreadyHasQuest, err_msg);
|
||||
Log.getLogger().warn(err_msg);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<(Result, HashSet<UInt32>)> resetQuestCoolTimeConditionCheck()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
|
||||
var my_normal_quest_mails = await quest_mail_action.getNormalMailSet();
|
||||
var my_normal_quest_mail_count = my_normal_quest_mails.Count;
|
||||
|
||||
HashSet<UInt32> assignable_mail_set = await quest_mail_action.getAssignableMailSet();
|
||||
|
||||
//퀘스트메일이 가득차서 아이템 사용 불가
|
||||
if (MetaHelper.GameConfigMeta.MaxQuestSendMail <= my_normal_quest_mail_count)
|
||||
{
|
||||
var err_msg = $"Item Use : Assignable QuestMail is Max, my_normal_quest_mail_count : {my_normal_quest_mail_count} normal_mails : {JsonConvert.SerializeObject(my_normal_quest_mails)}, player : {player.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ItemUseQuestMailCountMax, err_msg);
|
||||
Log.getLogger().warn(err_msg);
|
||||
return (result, assignable_mail_set);
|
||||
}
|
||||
//할당가능한 퀘스트 메일이 없다.
|
||||
if (assignable_mail_set.Count < 1)
|
||||
{
|
||||
var err_msg = $"Item Use : Assignable QuestMail is none, normal_mails : {JsonConvert.SerializeObject(my_normal_quest_mails)}, player : {player.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ItemUseNotExistAssignableQuest, err_msg);
|
||||
Log.getLogger().warn(err_msg);
|
||||
return (result, assignable_mail_set);
|
||||
}
|
||||
|
||||
return (result, assignable_mail_set);
|
||||
|
||||
}
|
||||
|
||||
public async Task<(Result, AcceptQuestVariable?)> questAssignByItem(ItemMetaData itemMeta)
|
||||
{
|
||||
var result = new Result();
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var quest_id = (UInt32)itemMeta.Register_id;
|
||||
|
||||
var quest_accept_action = player.getEntityAction<QuestAcceptAction>();
|
||||
|
||||
(result , var accept_quest_var) = await quest_accept_action.questAccept(quest_id);
|
||||
|
||||
return (result, accept_quest_var);
|
||||
}
|
||||
|
||||
public void addNewQuest(UInt32 questId, ServerCommon.Quest quest)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
var key = (quest_attribute.QuestType, questId);
|
||||
m_quests.TryAdd(key, quest);
|
||||
}
|
||||
|
||||
|
||||
public async Task cheatDeleteQuestAction(EQuestType questType, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "cheatDeleteQuest", delegatecheatDeleteQuest);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
async Task<Result> delegatecheatDeleteQuest() => await cheatDeleteQuest(questType, questId, questRevision);
|
||||
|
||||
m_quests.TryRemove((questType, questId), out var _);
|
||||
}
|
||||
|
||||
public Dictionary<UInt32, ServerCommon.Quest> getTestUgqs()
|
||||
{
|
||||
Dictionary<UInt32, ServerCommon.Quest> test_ugq_ids = new();
|
||||
foreach (var quest in m_quests.Values)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
if (quest_attribute.QuestType == EQuestType.UGQ && quest_attribute.UgqInfo.UqgState == UgqStateType.Test)
|
||||
{
|
||||
test_ugq_ids.Add(quest_attribute.QuestId, quest);
|
||||
}
|
||||
}
|
||||
|
||||
return test_ugq_ids;
|
||||
}
|
||||
|
||||
|
||||
public Result setQuestCheckFromDoc(DailyQuestCheckDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var daily_quest_check_attribute = owner.getEntityAttribute<DailyQuestCheckAttribute>();
|
||||
|
||||
if (daily_quest_check_attribute is null)
|
||||
{
|
||||
var err_msg = $"Fail to get daily_quest_check_attribute";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (false == doc.getAttribWrappers().TryGetValue(typeof(DailyQuestCheckAttrib), out var to_copy_doc_attrib))
|
||||
{
|
||||
var err_msg = $"Fail to get DailyQuestCheckAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
var doc_attrib = attrib_base as DailyQuestCheckAttrib;
|
||||
if (doc_attrib is null)
|
||||
{
|
||||
var err_msg = $"Fail to get RentalInstanceVisitAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var id in doc_attrib.m_daily_sended_quest)
|
||||
{
|
||||
daily_quest_check_attribute.m_daily_sended_quest.Add(id);
|
||||
}
|
||||
|
||||
|
||||
daily_quest_check_attribute.m_next_refresh_time = doc_attrib.m_next_refresh_time;
|
||||
daily_quest_check_attribute.m_daily_quest_check_doc_nullable = doc;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result setPeriodRepeatQuestFromDoc(QuestPeriodRepeatCheckDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var period_repeat_quest_attribute = owner.getEntityAttribute<QuestPeriodRepeatCheckAttribute>();
|
||||
|
||||
if (period_repeat_quest_attribute is null)
|
||||
{
|
||||
var err_msg = $"Fail to get period_repeat_quest_attribute";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (false == doc.getAttribWrappers().TryGetValue(typeof(QuestPeriodRepeatAttrib), out var to_copy_doc_attrib))
|
||||
{
|
||||
var err_msg = $"Fail to get QuestPeriodRepeatAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
var doc_attrib = attrib_base as QuestPeriodRepeatAttrib;
|
||||
if (doc_attrib is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestPeriodRepeatAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var info in doc_attrib.m_period_repeat_quests)
|
||||
{
|
||||
QuestPeriodRepeatInfo repeat_info = new();
|
||||
|
||||
//repeat_info.m_next_refresh_time = info.m_sen;
|
||||
|
||||
foreach (var send_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
repeat_info.m_sended_quest.TryAdd(send_quest.Key, send_quest.Value);
|
||||
}
|
||||
|
||||
if (false == period_repeat_quest_attribute.m_period_repeat_quests.TryAdd(info.Key, repeat_info))
|
||||
{
|
||||
Log.getLogger().warn($"m_period_repeat_quests add Fail info.key : {info.Key}, value : {JsonConvert.SerializeObject(info.Value)}");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
38
GameServer/Contents/Quest/Action/QuestCheatAction.cs
Normal file
38
GameServer/Contents/Quest/Action/QuestCheatAction.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestCheatAction : EntityActionBase
|
||||
{
|
||||
public QuestCheatAction(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task cheatSendQuestMail(UInt32 questId)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
|
||||
await quest_mail_action.sendQuestMailsWithTransaction(new List<UInt32>() { questId });
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
722
GameServer/Contents/Quest/Action/QuestMailAction.cs
Normal file
722
GameServer/Contents/Quest/Action/QuestMailAction.cs
Normal file
@@ -0,0 +1,722 @@
|
||||
using Amazon.S3.Model;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MetaAssets;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using ServerCore; using ServerBase;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestMailAction : EntityActionBase
|
||||
{
|
||||
private ConcurrentDictionary<(EQuestType, UInt32) /*quest_type, quest_id*/, ServerCommon.QuestMail> m_quest_mails = new();
|
||||
private bool m_is_quest_mail_loaded = false;
|
||||
|
||||
public QuestMailAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public Result hasQuestMail(EQuestType questType, UInt32 questId, bool needLog = false)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (false == m_quest_mails.ContainsKey((questType, questId)))
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var err_msg = $"Quest Mail Not Exist, questId : {questId}, owner : {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.QuestMailNotExist, err_msg);
|
||||
if (needLog)
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
result.setSuccess();
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Result> loadQuestMails()
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.None
|
||||
, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQQuestMailsReadAll(owner.getUserGuid()));
|
||||
}
|
||||
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<QuestMailInfo> getQuestMailsInfo()
|
||||
{
|
||||
return convertQuestMailsToProtoQuestMailInfo();
|
||||
|
||||
}
|
||||
|
||||
public (Result, ServerCommon.QuestMail) getQuestMail(EQuestType questType, UInt32 questId)
|
||||
{
|
||||
var result = new Result();
|
||||
if (false == m_quest_mails.TryGetValue((questType, questId), out var quest_mail))
|
||||
{
|
||||
var err_msg = $"Quest Mail Not Exist, questType : {questType}, questId : {questId}";
|
||||
result.setFail(ServerErrorCode.QuestMailNotExist, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, null!);
|
||||
}
|
||||
return (result, quest_mail);
|
||||
}
|
||||
|
||||
public List<ServerCommon.QuestMail> makeNewSystemQuestMail(List<(UInt32, EQuestType)> mailQuestIds)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
List < ServerCommon.QuestMail > quest_mails = new();
|
||||
|
||||
foreach (var quest_id in mailQuestIds)
|
||||
{
|
||||
(var quest_mail, var log_invoker) = createQuestMail(quest_id.Item1, 0, false);
|
||||
if (quest_mail is not null) quest_mails.Add(quest_mail);
|
||||
}
|
||||
return quest_mails;
|
||||
}
|
||||
|
||||
public async Task<(List<(UInt32, EQuestType)>, List<UInt32>)> makeQuestMailDocByType(EAssignRequireType type)
|
||||
{
|
||||
if (QuestManager.It._QuestReqTypeGroup.TryGetValue(type.ToString(), out var quest_ids) == false)
|
||||
{
|
||||
Log.getLogger().error($"SendQuestMailByType - QuestReqTypeGroup not found. type : {type}, " +
|
||||
$"groupInfo : {JsonConvert.SerializeObject(QuestManager.It._QuestReqTypeGroup)}");
|
||||
return (new(), new());
|
||||
}
|
||||
List<(UInt32, EQuestType)> mail_quests = new();
|
||||
List<UInt32> force_accept_quests = new();
|
||||
|
||||
foreach (var quest_id in quest_ids)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(quest_id);
|
||||
if (result.isFail()) continue;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (quest_base_info.AssignType.Equals(nameof(EAssignType.MAIL)) && quest_base_info.ForceAccept == false)
|
||||
{
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
mail_quests.Add((quest_id, quest_type));
|
||||
continue;
|
||||
}
|
||||
else if (quest_base_info.AssignType.Equals(nameof(EAssignType.MAIL)) && quest_base_info.ForceAccept == true)
|
||||
{
|
||||
force_accept_quests.Add(quest_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return (mail_quests, force_accept_quests);
|
||||
}
|
||||
|
||||
public async Task<Result> readQuestMail(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var result = new Result();
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var quest_type = await QuestMetaHelper.getQuestType(player, questId, questRevision);
|
||||
|
||||
if (false == m_quest_mails.TryGetValue((quest_type, questId), out var quest_mail))
|
||||
{
|
||||
var err_msg = $"Quest Mail Not Exist, questId : {questId}";
|
||||
Log.getLogger().error(err_msg);
|
||||
result.setFail(ServerErrorCode.QuestMailNotExist, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_mail_attribute = quest_mail.getEntityAttribute<QuestMailAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attribute, () => $"quest_mail_attribute is null !!!");
|
||||
|
||||
quest_mail_attribute.IsRead = 1;
|
||||
quest_mail_attribute.modifiedEntityAttribute();
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public async Task<QuestMailInfo?> convertQuestMailsToProtoQuestMailInfo(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
QuestMailInfo info = new();
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var quest_type = await QuestMetaHelper.getQuestType(player, questId, questRevision);
|
||||
|
||||
if (false == m_quest_mails.TryGetValue((quest_type, questId), out var questMail))
|
||||
{
|
||||
Log.getLogger().error($"QuestInfo {questId} not exist, {player.toBasicString()}");
|
||||
return null;
|
||||
}
|
||||
|
||||
(var result, var quest_mail_attibute) = getQuestMailAttribFromAttribute(questMail);
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"QuestInfo {questId} Attrivute not exist, {player.toBasicString()}");
|
||||
return null;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attibute, () => $"quest_mail_attibute is null !!!");
|
||||
|
||||
info.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(quest_mail_attibute.QuestId, quest_mail_attibute.QuestRevision);
|
||||
info.CreateTime = Timestamp.FromDateTime(quest_mail_attibute.CreateTime);
|
||||
info.IsRead = quest_mail_attibute.IsRead;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public List<QuestMailInfo> convertQuestMailsToProtoQuestMailInfo()
|
||||
{
|
||||
List<QuestMailInfo> quest_mails = new();
|
||||
|
||||
|
||||
foreach (var quest_mail in m_quest_mails)
|
||||
{
|
||||
QuestMailInfo info = new();
|
||||
(var result, var quest_mail_attibute) = getQuestMailAttribFromAttribute(quest_mail.Value);
|
||||
if (result.isFail())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attibute, () => $"quest_mail_attibute is null !!!");
|
||||
|
||||
info.ComposedQuestId = quest_mail_attibute.QuestId;
|
||||
info.CreateTime = Timestamp.FromDateTime(quest_mail_attibute.CreateTime);
|
||||
info.IsRead = quest_mail_attibute.IsRead;
|
||||
|
||||
quest_mails.Add(info);
|
||||
}
|
||||
return quest_mails;
|
||||
}
|
||||
|
||||
|
||||
private (Result, QuestMailAttribute?) getQuestMailAttribFromAttribute(ServerCommon.QuestMail questMail)
|
||||
{
|
||||
var attribute = questMail.getEntityAttribute<QuestMailAttribute>();
|
||||
var result = new Result();
|
||||
if (attribute is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestMailAttribute";
|
||||
Log.getLogger().error(err_msg);
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return (result, null);
|
||||
}
|
||||
return (result, attribute);
|
||||
}
|
||||
|
||||
public Result setEndQuestsFromDoc(QuestMailDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner();
|
||||
|
||||
// ServerCommon.QuestMail quest_mail = new ServerCommon.QuestMail(owner);
|
||||
//
|
||||
// var attribute = quest_mail.getEntityAttribute<QuestMailAttribute>();
|
||||
// if (attribute is null)
|
||||
// {
|
||||
// var err_msg = $"Fail to get QuestMailAttribute";
|
||||
// result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// if (false == doc.getAttribWrappers().TryGetValue(typeof(QuestMailAttrib), out var to_copy_doc_attrib))
|
||||
// {
|
||||
// var err_msg = $"Fail to get QuestMailAttrib";
|
||||
// result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
// return result;
|
||||
// }
|
||||
// var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
// var doc_attrib = attrib_base as QuestMailAttrib;
|
||||
// if (doc_attrib is null)
|
||||
// {
|
||||
// var err_msg = $"Fail to get FriendAttrib";
|
||||
// result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// attribute.QuestId = doc_attrib.QuestId;
|
||||
// attribute.CreateTime = doc_attrib.CreateTime;
|
||||
// attribute.IsRead = doc_attrib.IsRead;
|
||||
//
|
||||
//
|
||||
// if (false == m_quest_mails.TryAdd(attribute.QuestId, quest_mail))
|
||||
// {
|
||||
// var err_msg = $"m_quest_mails try Add Fail";
|
||||
// result.setFail(ServerErrorCode.ServerLogicError, err_msg);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public bool GS2C_NTF_DELETE_QUEST_MAIL_NOTI(UInt32 questId)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
ClientToGame ntf_packet = new();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.DeleteQuestMailNoti = new();
|
||||
ntf_packet.Message.DeleteQuestMailNoti.QuestId = questId;
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ntf_packet)) return false;
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<Result> normalMailActiveCheck()
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var normal_mail_set = await getNormalMailSet();
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//메일이 삭제 됐으니 무조건 보낼수 있다. 단, 컨피그 데이터에서 최대 메일수를 줄여버리면 몇개 거절해도 할당 되면 안되니 여기서 리턴
|
||||
if (MetaHelper.GameConfigMeta.MaxQuestSendMail <= normal_mail_set.Count) return result;
|
||||
|
||||
//메일 보낼 수 있는 퀘스트가 없으면 return;
|
||||
var assignable_mail_set = await getAssignableMailSet();
|
||||
if (assignable_mail_set.Count < 1) { return result; }
|
||||
|
||||
var repeat_quest_action = player.getEntityAction<RepeatQuestAction>();
|
||||
|
||||
//이미 체크 중이면 리턴
|
||||
if (repeat_quest_action.isChecking() == 1) return result;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var fn_transaction_runner = async delegate ()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
DateTime now_dt = DateTimeHelper.Current;
|
||||
var next_allocate_dt = now_dt.AddMinutes(MetaHelper.GameConfigMeta.CooltimeNormalQuestSendMail);
|
||||
|
||||
repeat_quest_action.setRepeatQuestInfo(next_allocate_dt, 1);
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestMainRepeatTimeRefresh, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
|
||||
batch.appendBusinessLog(new RepeatQuestBusinessLog(repeat_quest_attribute.m_next_allocate_time, repeat_quest_attribute.m_is_checking));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
return result;
|
||||
};
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "NormalMailCheckActive", fn_transaction_runner);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
QuestManager.It.m_normal_quest_check_users.TryAdd(player.getUserGuid(), 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<HashSet<UInt32>> getNormalMailSet()
|
||||
{
|
||||
HashSet<UInt32> normalMailSet = new();
|
||||
foreach (var mailQuestKey in m_quest_mails.Keys)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(mailQuestKey.Item2);
|
||||
if (result.isFail()) continue;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (quest_base_info.QuestType.Equals(MetaAssets.EQuestType.NORMAL.ToString()) && quest_base_info.OncePeriodRangeType.Equals(OncePeriodRangeType.Nolimit))
|
||||
{
|
||||
normalMailSet.Add(mailQuestKey.Item2);
|
||||
}
|
||||
}
|
||||
|
||||
return normalMailSet;
|
||||
}
|
||||
|
||||
public async Task<HashSet<UInt32>> getAssignableMailSet()
|
||||
{
|
||||
var normal_mails = await getNormalMailSet();
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
var end_quest_action = owner.getEntityAction<EndQuestAction>();
|
||||
var quest_ids = quest_action.getSystemQuestIds();
|
||||
|
||||
//var my_quest_ids = quests.Keys.ToList();
|
||||
|
||||
var end_quests = end_quest_action.getEndQuests();
|
||||
|
||||
HashSet<UInt32> assignable_quest_ids = new();
|
||||
foreach (var questGroup in QuestManager.It._QuestNormalGroup)
|
||||
{
|
||||
if (questGroup.Key == 0 || end_quests.ContainsKey((questGroup.Key, 0)))
|
||||
{
|
||||
foreach (var quest_id in questGroup.Value.ToList())
|
||||
{
|
||||
//메일에 있으니 continue
|
||||
if (normal_mails.Contains(quest_id)) continue;
|
||||
if (quest_ids.Contains(quest_id)) continue;
|
||||
|
||||
assignable_quest_ids.Add(quest_id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return assignable_quest_ids;
|
||||
|
||||
}
|
||||
|
||||
public async Task<(Result, List<ServerCommon.QuestMail>, List<ILogInvoker>)> sendQuestMails(List<UInt32> questIds)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
List<ServerCommon.QuestMail> quest_mails = new();
|
||||
List<ILogInvoker> log_invokers = new();
|
||||
foreach (var quest_id in questIds)
|
||||
{
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(quest_id);
|
||||
if (result.isFail()) continue;
|
||||
|
||||
//여기에 Revision이 들어야가되면 0 대신 revision 값 셋팅 해야함
|
||||
(var quest_mail, var log_invoker) = createQuestMail(quest_id, 0, true);
|
||||
if (quest_mail is null) continue;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(log_invoker, () => $"log_invoker is null !!!");
|
||||
|
||||
quest_mails.Add(quest_mail);
|
||||
log_invokers.Add(log_invoker);
|
||||
}
|
||||
|
||||
return (result, quest_mails, log_invokers);
|
||||
}
|
||||
|
||||
public async Task<(Result, List<ServerCommon.QuestMail>)> sendQuestMailsWithTransaction(List<UInt32> questIds)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
List<ServerCommon.QuestMail> quest_mails = new();
|
||||
var fn_transaction_runner = async delegate ()
|
||||
{
|
||||
(var result, quest_mails, var log_invokers) = await sendQuestMails(questIds);
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.None, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLogs(log_invokers);
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "SendQuestMails", fn_transaction_runner);
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, new());
|
||||
}
|
||||
|
||||
await addNewQuestMails(quest_mails);
|
||||
await send_NTF_RECEIVED_QUEST_MAIL(player, questIds);
|
||||
await QuestManager.It.QuestCheck(player, new QuestMail(EQuestEventTargetType.MAIL, EQuestEventNameType.RECEIVED, ""));
|
||||
|
||||
|
||||
return (result, quest_mails);
|
||||
|
||||
}
|
||||
|
||||
public async Task send_NTF_RECEIVED_QUEST_MAIL(Player owner, List<UInt32> questIds)
|
||||
{
|
||||
List<QuestMailInfo> infos = new();
|
||||
foreach (var id in questIds)
|
||||
{
|
||||
var quest_mail_info = await getQuestMailInfo(id);
|
||||
if (quest_mail_info is null) continue;
|
||||
infos.Add(quest_mail_info);
|
||||
}
|
||||
|
||||
ClientToGame clientToGameNoti = new();
|
||||
clientToGameNoti.Message = new();
|
||||
clientToGameNoti.Message.ReceiveQuestMailNoti = new();
|
||||
clientToGameNoti.Message.ReceiveQuestMailNoti.QuestMailInfo.AddRange(infos);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, clientToGameNoti))
|
||||
{
|
||||
Log.getLogger().error($"NTF_RECEIVED_QUEST_MAIL send error questIds = {JsonConvert.SerializeObject(questIds)}");
|
||||
}
|
||||
|
||||
}
|
||||
private async Task<QuestMailInfo?> getQuestMailInfo(UInt32 questId)
|
||||
{
|
||||
//여기에 Revision이 들어야가되면 0 대신 revision 값 셋팅 해야함
|
||||
return await convertQuestMailsToProtoQuestMailInfo(questId, 0);
|
||||
}
|
||||
|
||||
public async Task<Result> deleteQuestMail(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var quest_type = await QuestMetaHelper.getQuestType(player, questId, questRevision);
|
||||
var result = new Result();
|
||||
if (false == m_quest_mails.TryRemove((quest_type, questId), out var quest_mail))
|
||||
{
|
||||
var err_msg = $"deleteQuestMail, Quest Mail Not Exist, questId : {questId}";
|
||||
result.setFail(ServerErrorCode.QuestMailNotExist, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private (ServerCommon.QuestMail?, ILogInvokerEx?) createQuestMail(UInt32 questId, UInt32 questRevision, bool checkPeriod)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
DateTime now_dt = DateTimeHelper.Current;
|
||||
|
||||
var quest_mail = new ServerCommon.QuestMail(owner);
|
||||
//await quest_mail.onInit();
|
||||
var attribute = quest_mail.getEntityAttribute<QuestMailAttribute>();
|
||||
if (attribute is null)
|
||||
{
|
||||
return (null, null);
|
||||
}
|
||||
attribute.QuestId = questId;
|
||||
attribute.CreateTime = now_dt;
|
||||
attribute.IsRead = 0;
|
||||
attribute.QuestRevision = questRevision;
|
||||
|
||||
//checkPeriod == false면 기간을 체크하지 않는다.
|
||||
if (checkPeriod && MetaHelper.GameConfigMeta.QuestMailStoragePeriod > 0)
|
||||
{
|
||||
attribute.ExpireTime = now_dt.AddSeconds(MetaHelper.GameConfigMeta.QuestMailStoragePeriod);
|
||||
}
|
||||
|
||||
attribute.newEntityAttribute();
|
||||
|
||||
var log_invoker = new QuestMailBusinessLog(attribute, QuestMailLogType.Create);
|
||||
|
||||
return (quest_mail, log_invoker);
|
||||
}
|
||||
|
||||
|
||||
public async Task<Result> setQuestMailFromDoc(QuestMailDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
var quest_mail_attrib = doc.getAttrib<QuestMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attrib, () => $"quest_mail_attrib is null !!!");
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
ServerCommon.QuestMail mail = new ServerCommon.QuestMail (owner);
|
||||
//await mail.onInit();
|
||||
var mail_attribute = mail.getEntityAttribute<QuestMailAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(mail_attribute, () => $"mail_attribute is null !!!");
|
||||
|
||||
mail_attribute.QuestId = quest_mail_attrib.QuestId;
|
||||
mail_attribute.QuestRevision = quest_mail_attrib.QuestRevision;
|
||||
mail_attribute.CreateTime = quest_mail_attrib.CreateTime;
|
||||
mail_attribute.ExpireTime = quest_mail_attrib.ExpireTime;
|
||||
mail_attribute.IsRead = quest_mail_attrib.IsRead;
|
||||
|
||||
mail_attribute.syncOriginDocBaseWithNewDoc<QuestMailAttribute>(doc);
|
||||
|
||||
var quest_type = await QuestMetaHelper.getQuestType(owner, quest_mail_attrib.QuestId, quest_mail_attrib.QuestRevision);
|
||||
m_quest_mails.TryAdd((quest_type, quest_mail_attrib.QuestId), mail);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task addNewQuestMails(List<ServerCommon.QuestMail> questMails)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
foreach (var quest_mail in questMails)
|
||||
{
|
||||
var quest_mail_attribute = quest_mail.getEntityAttribute<QuestMailAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attribute, () => $"quest_mail_attribute is null !!!");
|
||||
//여기에 Revision이 들어야가되면 0 대신 revision 값 셋팅 해야함
|
||||
var quest_type = await QuestMetaHelper.getQuestType(player, quest_mail_attribute.QuestId, 0);
|
||||
m_quest_mails.TryAdd((quest_type, quest_mail_attribute.QuestId), quest_mail);
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuestMailLoadedAll()
|
||||
{
|
||||
m_is_quest_mail_loaded = true;
|
||||
}
|
||||
|
||||
public bool isMailLoadedAll()
|
||||
{
|
||||
return m_is_quest_mail_loaded;
|
||||
}
|
||||
|
||||
public Result GS2C_NTF_RECEIVED_QUEST_MAIL(QuestMailInfo mailInfo)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
ClientToGame ntf_packet = new();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.ReceiveQuestMailNoti = new();
|
||||
ntf_packet.Message.ReceiveQuestMailNoti.QuestMailInfo.Add(mailInfo);
|
||||
|
||||
|
||||
GameServerApp.getServerLogic().onSendPacket(owner, ntf_packet);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<(Result, ServerCommon.QuestMail, ILogInvoker)> sendQuestMail(UInt32 questId)
|
||||
{
|
||||
(var result, var quest_mails, var log_invokers) = await sendQuestMails(new List<UInt32>() { questId } );
|
||||
return (result, quest_mails[0], log_invokers[0]);
|
||||
}
|
||||
|
||||
|
||||
public async Task<(List<AcceptQuestVariable>, List<ServerCommon.QuestMail>, List<ILogInvoker>)> questMailSendOrForceAccept(List<UInt32> questIds)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
List<UInt32> mail_quests = new();
|
||||
|
||||
List<AcceptQuestVariable> accept_quest_variables = new();
|
||||
List<ServerCommon.QuestMail> send_quest_mails = new();
|
||||
List<ILogInvoker> log_invokers = new();
|
||||
var result = new Result();
|
||||
foreach (var quest_id in questIds)
|
||||
{
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(quest_id);
|
||||
if (result.isFail()) continue;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (quest_base_info.AssignType.Equals(nameof(EAssignType.MAIL)) && quest_base_info.ForceAccept == false)
|
||||
{
|
||||
mail_quests.Add(quest_id);
|
||||
continue;
|
||||
}
|
||||
else if (quest_base_info.AssignType.Equals(nameof(EAssignType.MAIL)) && quest_base_info.ForceAccept == true)
|
||||
{
|
||||
var quest_accept_action = player.getEntityAction<QuestAcceptAction>();
|
||||
(result, var quest_var) = await quest_accept_action.questAccept(quest_id);
|
||||
if (result.isFail()) continue;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_var, () => $"quest_var is null !!!");
|
||||
accept_quest_variables.Add(quest_var);
|
||||
}
|
||||
}
|
||||
if (mail_quests.Count > 0)
|
||||
{
|
||||
(result, var quest_mails, log_invokers) = await sendQuestMails(mail_quests);
|
||||
if(result.isSuccess()) send_quest_mails.AddRange(quest_mails);
|
||||
}
|
||||
|
||||
return (accept_quest_variables, send_quest_mails, log_invokers);
|
||||
}
|
||||
|
||||
public async Task questMailSendOrForceAcceptWithTransaction(QuestRewardHandler questRewardHandler, List<UInt32> questIds)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
List<UInt32> mail_quests = new();
|
||||
|
||||
foreach (UInt32 quest_id in questIds)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(quest_id);
|
||||
if (result.isFail()) continue;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (quest_base_info.QuestType.Equals(nameof(MetaAssets.EQuestType.NORMAL)) && quest_base_info.OncePeriodRangeType.Equals(OncePeriodRangeType.Nolimit))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Nolimit 아님 Normal 중에 이미 한번 받은 이력있는건 더 못받는다..
|
||||
if (quest_base_info.QuestType.Equals(nameof(MetaAssets.EQuestType.NORMAL)) && questRewardHandler.m_has_already_end_quest)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (quest_base_info.AssignType.Equals(nameof(MetaAssets.EAssignType.MAIL)) && quest_base_info.ForceAccept == false)
|
||||
{
|
||||
mail_quests.Add(quest_id);
|
||||
continue;
|
||||
}
|
||||
else if (quest_base_info.AssignType.Equals(nameof(MetaAssets.EAssignType.MAIL)) && quest_base_info.ForceAccept == true)
|
||||
{
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
await quest_action.questForceAcceptWithTransaction(quest_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mail_quests.Count > 0)
|
||||
{
|
||||
(var result, var quest_mails) = await sendQuestMailsWithTransaction(mail_quests);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
107
GameServer/Contents/Quest/Action/QuestNPCDialogueAction.cs
Normal file
107
GameServer/Contents/Quest/Action/QuestNPCDialogueAction.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using Amazon.CloudWatchLogs.Model;
|
||||
using MetaAssets;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestNPCDialogueAction : EntityActionBase
|
||||
{
|
||||
public QuestNPCDialogueAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
public async Task<Result> checkQuestDialogue(string dialogue, string dialogueResult)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (false == QuestManager.It._QuestDialogueGroup.TryGetValue((dialogue, dialogueResult), out var questIds)) return result;
|
||||
|
||||
foreach (var questId in questIds)
|
||||
{
|
||||
await questAcceptByNpcDialogue(questId, dialogue, dialogueResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task questAcceptByNpcDialogue(UInt32 questId, string dialogue, string dialogueresult)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var end_quest_action = owner.getEntityAction<EndQuestAction>();
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
|
||||
//해당 퀘스트를 내가 완료했는지 체크, 재할당 가능한지는 확인 필요하다
|
||||
result = end_quest_action.endQuestCheck(quest_type, questId, 0);
|
||||
if(result.isFail()) return;
|
||||
|
||||
result = quest_action.hasQuest(quest_type, questId);
|
||||
if (result.isFail()) return;
|
||||
|
||||
result = quest_action.assignableQuestCheckByQuestType(quest_type);
|
||||
if (result.isFail()) return;
|
||||
|
||||
|
||||
//데이터 할당
|
||||
result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "QuestAcceptByNpcDialogue", delegateQuestAcceptByNpcDialogue);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
async Task<Result> delegateQuestAcceptByNpcDialogue() => await questAcceptByNpcDialogue(owner, quest_base_info, dialogue, dialogueresult);
|
||||
}
|
||||
|
||||
private async Task<Result> questAcceptByNpcDialogue(Player owner, QuestBaseInfo questMetaInfo, string dialogue, string dialogueresult)
|
||||
{
|
||||
var quest_accept_action = owner.getEntityAction<QuestAcceptAction>();
|
||||
(var result, var quest_accept_var) = quest_accept_action.acceptQuestByNpcDialogue(questMetaInfo);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_accept_var.m_new_quest_nullable, () => $"quest_accept_var.m_new_quest_nullable is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.QuestMainAssignByDialogue, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
batch.appendBusinessLog(new QuestAcceptByDialogueBusinessLog(questMetaInfo.QuestId, questMetaInfo.QuestRevision, dialogue, dialogueresult));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
quest_action.addNewQuest(questMetaInfo.QuestId, quest_accept_var.m_new_quest_nullable);
|
||||
await owner.send_GS2C_NTF_QUEST_UPDATE(questMetaInfo.QuestId, 0, new(), true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
63
GameServer/Contents/Quest/Action/QuestRefuseAction.cs
Normal file
63
GameServer/Contents/Quest/Action/QuestRefuseAction.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using MetaAssets;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestRefuseAction : EntityActionBase
|
||||
{
|
||||
public QuestRefuseAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public async Task<Result> refuseQuestConditionCheck(UInt32 questId)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (false == quest_base_info.QuestType.Equals(nameof(EQuestType.NORMAL)))
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestRefuseOnlyNormal, $"QuestID : {questId}, questType not normal");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (true == quest_base_info.AssignType.Equals(EAssignType.MAIL.ToString()))
|
||||
{
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
result = quest_mail_action.hasQuestMail(quest_type, questId, true);
|
||||
if (result.isFail()) return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
270
GameServer/Contents/Quest/Action/QuestRewardAction.cs
Normal file
270
GameServer/Contents/Quest/Action/QuestRewardAction.cs
Normal file
@@ -0,0 +1,270 @@
|
||||
|
||||
using ServerBase;
|
||||
using ServerCore;
|
||||
using ServerCommon;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using static ClientToGameMessage.Types;
|
||||
|
||||
|
||||
using Guid = System.Guid;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
internal class QuestRewardAction : EntityActionBase
|
||||
{
|
||||
public QuestRewardAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task processAfterReward(QuestRewardHandler questRewardHandler)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var quest_base_info = questRewardHandler.m_quest_meta_info;
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
var assignable_quests = quest_base_info.AssignableQuestsAfterEnd;
|
||||
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
await quest_mail_action.questMailSendOrForceAcceptWithTransaction(questRewardHandler, assignable_quests);
|
||||
|
||||
|
||||
//api 서버에 ugq complete 전송
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var ugq_api_manager = server_logic.GetUqgApiManager();
|
||||
|
||||
var quest_id = questRewardHandler.m_quest_id;
|
||||
var quest_revision = questRewardHandler.m_quest_revision;
|
||||
|
||||
if (questRewardHandler.m_ugq_game_data is not null && questRewardHandler.m_is_repeat_ugq_quest == false)
|
||||
{
|
||||
var cost = questRewardHandler.m_ugq_game_data.Cost;
|
||||
var api_result = await ugq_api_manager.setUgqQuestCompleted(player.getUserGuid(), quest_id, quest_revision, cost, player.getLanguageType());
|
||||
if (api_result.isFail())
|
||||
{
|
||||
//로그만 남긴다.
|
||||
Log.getLogger().error($"Failed to setUgqQuestCompleted : {api_result.toBasicString()} - {player.toBasicString()}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public async Task normalQuestCheckInitialize()
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
|
||||
//메일 지급 가능한 퀘스트 체크
|
||||
var my_normal_mail_cnt = (await quest_mail_action.getNormalMailSet()).Count;
|
||||
HashSet<UInt32> assignable_mail_set = await quest_mail_action.getAssignableMailSet();
|
||||
|
||||
//메일 보낼 수 있는 퀘스트가 없으면 return;
|
||||
if (assignable_mail_set.Count < 1) { return; }
|
||||
|
||||
//메일 보낼 수 있는 퀘스트가 있지만 이미 메일이 꽉찼으면 활성화 안해준다.
|
||||
if (MetaHelper.GameConfigMeta.MaxQuestSendMail <= my_normal_mail_cnt) return;
|
||||
|
||||
//이미 리프레시 체크 중인 유저는 그냥 리턴
|
||||
if (QuestManager.It.m_normal_quest_check_users.ContainsKey(owner.getUserGuid())) return;
|
||||
|
||||
var repeat_quest_action = owner.getEntityAction<RepeatQuestAction>();
|
||||
|
||||
DateTime nowDT = DateTime.UtcNow;
|
||||
var nextTime = nowDT.AddMinutes(MetaHelper.GameConfigMeta.CooltimeNormalQuestSendMail);
|
||||
|
||||
var fn_quest_task_update = async delegate ()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
Int32 is_checking = 1;
|
||||
repeat_quest_action.setRepeatQuestInfo(nextTime, is_checking);
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>( owner
|
||||
, LogActionType.QuestMainRepeatTimeInit
|
||||
, server_logic.getDynamoDbClient() );
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLog(new RepeatQuestBusinessLog(nextTime, is_checking));
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "RepeatQuestInfoUpdate", fn_quest_task_update);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
//여기서, 활성화 되고 체킹중인 유저에 대해서 QuestManager 에 추가(Initialize 시점이니 여기서 셋팅)
|
||||
QuestManager.It.m_normal_quest_check_users.TryAdd(owner.getUserGuid(), 1);
|
||||
}
|
||||
|
||||
public Result questRewardConditionCheck(ref QuestRewardHandler questRewardHandler)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
|
||||
var quest_id = questRewardHandler.m_quest_id;
|
||||
var quest_revision = questRewardHandler.m_quest_revision;
|
||||
var quest = questRewardHandler.m_quest;
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
if (quest_attribute.IsComplete == 0)
|
||||
{
|
||||
var err_msg = $"Quest Not Completed QuestID : {quest_id}, owner : {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.QuestNotComplete, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
//대체 보상있는 경우 해당 보상정보로 변경
|
||||
if (quest_attribute.ReplacedRewardGroupId != 0) questRewardHandler.m_replaced_reward_group_id = quest_attribute.ReplacedRewardGroupId;
|
||||
|
||||
List<RewardMetaData> reward_meta_datas = new List<RewardMetaData>();
|
||||
//Meta에 보상 정보 없는 경우 에러 처리
|
||||
if (false == MetaData.Instance._RewardMetaTable.TryGetValue(questRewardHandler.m_replaced_reward_group_id, out var rewardList))
|
||||
{
|
||||
//ugq에서 m_replaced_reward_group_id 이 0일 수 있다... 일단 여기에 넣고 나중에 reward 관련 일반화 다시 해야될듯...
|
||||
if (questRewardHandler.m_replaced_reward_group_id == 0)
|
||||
{
|
||||
reward_meta_datas = new();
|
||||
}
|
||||
else
|
||||
{
|
||||
var err_msg = $"_RewardDataTable not exist info rewardGroupId = {questRewardHandler.m_replaced_reward_group_id}, owner : {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.RewardInfoNotExist, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reward_meta_datas.AddRange(rewardList);
|
||||
//endquest가 존재(반복진행)하고 퀘스트가 ugq이면 보상 그룹은 0으로 처리...아 이것도 코드 바꾸고 싶다...
|
||||
var end_quest_action = owner.getEntityAction<EndQuestAction>();
|
||||
var end_quest = end_quest_action.getEndQuest(quest_id, quest_revision);
|
||||
bool is_already_cleared_ugq = (end_quest is not null && end_quest.isUgq() == true);
|
||||
if (is_already_cleared_ugq)
|
||||
{
|
||||
questRewardHandler.m_is_repeat_ugq_quest = true;
|
||||
questRewardHandler.m_replaced_reward_group_id = 0;
|
||||
reward_meta_datas = new();
|
||||
}
|
||||
dailyRewardCountCheck(ref questRewardHandler, is_already_cleared_ugq);
|
||||
}
|
||||
|
||||
foreach (var reward in reward_meta_datas)
|
||||
{
|
||||
questRewardHandler.m_rewards.Add(reward.Reward);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void dailyRewardCountCheck(ref QuestRewardHandler questRewardHandler, bool isAlreadyClearedUgq)
|
||||
{
|
||||
if (isAlreadyClearedUgq) return;
|
||||
|
||||
if (questRewardHandler.m_ugq_game_data is null) return;
|
||||
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(questRewardHandler.m_quest_meta_info, () => $"questRewardHandler.m_quest_meta_info is null !!!");
|
||||
|
||||
if (questRewardHandler.m_quest_meta_info.QuestRevision == 0) return;
|
||||
//ugq daily 반복보상 체크
|
||||
var ugq_daily_reward_count_attribute = getOwner().getEntityAttribute <UgqDailyRewardCountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugq_daily_reward_count_attribute, () => $"ugq_daily_reward_count_attribute is null !!!");
|
||||
|
||||
int max_cnt = 10;
|
||||
var bonus_cnt= ugq_daily_reward_count_attribute.getDailyRewardByGrade(questRewardHandler.m_ugq_game_data.GradeType);
|
||||
|
||||
(max_cnt, questRewardHandler.m_ugq_daily_bonus_gold) = UgqMetaHelper.getUgqDailyRewardMaxCountByGrade(questRewardHandler.m_ugq_game_data.GradeType);
|
||||
|
||||
if (bonus_cnt < max_cnt)
|
||||
{
|
||||
questRewardHandler.m_has_ugq_daily_reward = true;
|
||||
|
||||
RewardMutable reward_mutable = new RewardMutable();
|
||||
reward_mutable.Currency = new CurrencyRewardMutable()
|
||||
{
|
||||
Id = (int)CurrencyType.Gold,
|
||||
Value = questRewardHandler.m_ugq_daily_bonus_gold
|
||||
};
|
||||
|
||||
MetaAssets.Reward reward_gold = new MetaAssets.Reward(reward_mutable);
|
||||
questRewardHandler.m_rewards.Add(reward_gold);
|
||||
}
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public Result setUgqDailyRewardCountFromDoc(UgqDailyRewardCountDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var ugq_daily_reward_attribute = owner.getEntityAttribute<UgqDailyRewardCountAttribute>();
|
||||
|
||||
if (ugq_daily_reward_attribute is null)
|
||||
{
|
||||
var err_msg = $"Fail to get ugq_daily_reward_attribute";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (false == doc.getAttribWrappers().TryGetValue(typeof(UgqDailyRewardCountAttrib), out var to_copy_doc_attrib))
|
||||
{
|
||||
var err_msg = $"Fail to get UgqDailyRewardCountAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
var doc_attrib = attrib_base as UgqDailyRewardCountAttrib;
|
||||
if (doc_attrib is null)
|
||||
{
|
||||
var err_msg = $"Fail to get UgqDailyRewardCountAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var reward_cnt in doc_attrib.m_ugq_daily_reward_count)
|
||||
{
|
||||
ugq_daily_reward_attribute.m_ugq_daily_reward_count.AddOrUpdate(reward_cnt.Key, reward_cnt.Value, (key, oldValue) => reward_cnt.Value);
|
||||
}
|
||||
|
||||
ugq_daily_reward_attribute.m_next_refresh_time = doc_attrib.m_next_refresh_time;
|
||||
ugq_daily_reward_attribute.m_ugq_daily_reward_count_doc_nullable = doc;
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
263
GameServer/Contents/Quest/Action/QuestTaskUpdateAction.cs
Normal file
263
GameServer/Contents/Quest/Action/QuestTaskUpdateAction.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
using Amazon.CloudWatchLogs.Model;
|
||||
using Amazon.Runtime.Internal;
|
||||
using Amazon.S3.Model;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MetaAssets;
|
||||
using Newtonsoft.Json;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestTaskUpdateAction : EntityActionBase
|
||||
{
|
||||
public QuestTaskUpdateAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
private Result taskFunctionProgress(QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(questTaskUpdateHandler.m_quest, () => $"questTaskUpdateHandler.m_quest is null !!!");
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_task = new QuestClientSide(owner);
|
||||
var quest = questTaskUpdateHandler.m_quest;
|
||||
|
||||
var result = quest_task.questTaskFunctionProgress(owner, ref questTaskUpdateHandler);
|
||||
if(result.isFail()) return result;
|
||||
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
if (quest_attribute.CurrentTaskComplete == 1 && quest_attribute.IsComplete == 0)
|
||||
{
|
||||
result = questNextTaskUpdate(questTaskUpdateHandler);
|
||||
if(result.isFail()) return result;
|
||||
}
|
||||
quest_attribute.modifiedEntityAttribute();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<Result> rewardUpdate(QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
IReward reward_proc = new QuestTaskReward(owner, owner.getUserGuid(), questTaskUpdateHandler);
|
||||
|
||||
var result = await RewardManager.It.proceedRewardProcess(reward_proc);
|
||||
if (result.isFail()) return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<Result> delteItemUpdate(QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//아이템 삭제 처리
|
||||
var delete_items = questTaskUpdateHandler.m_deletable_items;
|
||||
foreach (var item in delete_items)
|
||||
{
|
||||
var item_id = item.Key;
|
||||
var item_count = item.Value;
|
||||
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var inventory_action = owner.getEntityAction<InventoryActionBase>();
|
||||
(result, var deleted_item) = await inventory_action.tryDeleteItemByMetaId((uint)item_id, (ushort)item_count);
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"delteItemUpdate error delteitem : {JsonConvert.SerializeObject(item)}, owner : {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
questTaskUpdateHandler.m_deleted_items.AddRange(deleted_item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result questNextTaskUpdate(QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(questTaskUpdateHandler.m_quest_meta_info, () => $"questTaskUpdateHandler.m_quest_meta_info is null !!!");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(questTaskUpdateHandler.m_quest, () => $"questTaskUpdateHandler.m_quest is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//var task_group = questTaskUpdateHandler.m_quest_task_group;
|
||||
var next_task_num = questTaskUpdateHandler.m_next_task_number;
|
||||
|
||||
var task_group_list = questTaskUpdateHandler.m_quest_meta_info.QuestTaskGroupList;
|
||||
if (false == task_group_list.TryGetValue(next_task_num, out var questTaskInfo))
|
||||
{
|
||||
var err_msg = $"questEventInfo InvalidData questId = {questTaskUpdateHandler.m_quest_id}, next_task_num : {next_task_num}";
|
||||
result.setFail(ServerErrorCode.QuestInvalidValue, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_attribute = questTaskUpdateHandler.m_quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
quest_attribute.CurrentTaskNum = next_task_num;
|
||||
quest_attribute.CurrentTaskComplete = 0;
|
||||
|
||||
DateTime now = DateTime.UtcNow;
|
||||
quest_attribute.TaskStartTime = now;
|
||||
quest_attribute.ActiveEvents.Clear();
|
||||
quest_attribute.ActiveEvents.AddRange(questTaskInfo.EventStringList);
|
||||
quest_attribute.HasTimer = 0;
|
||||
quest_attribute.TimerCompleteTime = now;
|
||||
quest_attribute.CompletedIdxStrings.Clear();
|
||||
|
||||
if (questTaskInfo.HasCounter)
|
||||
{
|
||||
quest_attribute.HasCounter = 1;
|
||||
quest_attribute.MaxCounter = questTaskInfo.MaxCounter;
|
||||
quest_attribute.MinCounter = questTaskInfo.MinCounter;
|
||||
quest_attribute.CurrentCounter = questTaskInfo.MinCounter;
|
||||
}
|
||||
else
|
||||
{
|
||||
quest_attribute.HasCounter = 0;
|
||||
quest_attribute.MaxCounter = 0;
|
||||
quest_attribute.MinCounter = 0;
|
||||
quest_attribute.CurrentCounter = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public Result taskUpdateConditionCheck(ref QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(questTaskUpdateHandler.m_quest_meta_info, () => $"questTaskUpdateHandler.m_quest_meta_info is null !!!");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(questTaskUpdateHandler.m_quest, () => $"questTaskUpdateHandler.m_quest is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_id = questTaskUpdateHandler.m_quest_id;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
|
||||
var quest_type = questTaskUpdateHandler.m_quest_type;
|
||||
var quest = questTaskUpdateHandler.m_quest;
|
||||
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
if (quest_attribute.IsComplete == 1)
|
||||
{
|
||||
result.setFail(ServerErrorCode.QuestAlreadyComplete, $"Already Complete Quest QuestID : {quest_id}");
|
||||
return result;
|
||||
}
|
||||
|
||||
var active_event = questTaskUpdateHandler.m_active_event;
|
||||
if (false == quest_attribute.ActiveEvents.Contains(active_event))
|
||||
{
|
||||
string err_msg = $"ActiveIdxList info Invalie questId : {quest_id}, activeEvent : {active_event} User QuestInfo : {JsonConvert.SerializeObject(quest_attribute)}";
|
||||
result.setFail(ServerErrorCode.QuestMailNotExist, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
if (false == questTaskUpdateHandler.m_quest_meta_info.QuestTaskGroupList.TryGetValue(quest_attribute.CurrentTaskNum, out var questTaskInfo))
|
||||
{
|
||||
string err_msg = $"questBaseInfo.QuestTaskGroupList InvalidData CurrentTaskNum : {quest_attribute.CurrentTaskNum}";
|
||||
result.setFail(ServerErrorCode.QuestInvalidValue, err_msg);
|
||||
return result;
|
||||
}
|
||||
questTaskUpdateHandler.m_quest_task_group = questTaskInfo;
|
||||
|
||||
result = QuestMetaHelper.getQuestTaskEventGroupByEventString(questTaskInfo, active_event, out var questEventInfo);
|
||||
if(result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(questEventInfo, () => $"questEventInfo is null !!!");
|
||||
|
||||
EQuestEventTargetType targetType = EnumHelper.convertEnumTypeAndValueStringToEnum(questEventInfo.EventTarget, EQuestEventTargetType.NONE);
|
||||
EQuestEventNameType nameType = EnumHelper.convertEnumTypeAndValueStringToEnum(questEventInfo.EventName, EQuestEventNameType.NONE);
|
||||
|
||||
if (false == checkClientSideEvent(targetType, nameType))
|
||||
{
|
||||
string err_msg = $"scriptDataList does not match EQuestEventTargetType questId : {quest_id}, targetType : {targetType.ToString()}, nameType : {nameType.ToString()}";
|
||||
result.setFail(ServerErrorCode.QuestInvalidValue, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
questTaskUpdateHandler.m_target_type = targetType;
|
||||
questTaskUpdateHandler.m_name_type = nameType;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public bool checkClientSideEvent(EQuestEventTargetType target, EQuestEventNameType nameType)
|
||||
{
|
||||
if (target.Equals(EQuestEventTargetType.GUI) && nameType.Equals(EQuestEventNameType.POPUP)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.CONCERT) && nameType.Equals(EQuestEventNameType.STARTED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.CONCERT) && nameType.Equals(EQuestEventNameType.ENDED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.CUTSCENE)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.DIALOGUE)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.MANNEQUIN) && nameType.Equals(EQuestEventNameType.USED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.MOVEMENT) && nameType.Equals(EQuestEventNameType.FEVER)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.MOVEMENT)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.NPC)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.SOCIALACTION) && nameType.Equals(EQuestEventNameType.ACTIVED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.SPECIALGUIDE)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.TAXI) && nameType.Equals(EQuestEventNameType.USED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.TRIGGER)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.VIDEO)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.INTERIORMODE) && nameType.Equals(EQuestEventNameType.STOPPED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.BEACONDIALOGUE) && nameType.Equals(EQuestEventNameType.SENDED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.BEACONDIALOGUE) && nameType.Equals(EQuestEventNameType.RECEIVED)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.WAITING)) return true;
|
||||
if (target.Equals(EQuestEventTargetType.PROP) && nameType.Equals(EQuestEventNameType.SWITCHED)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<Result> questTaskUpdate(QuestTaskUpdateHandler questTaskUpdateDataRef)
|
||||
{
|
||||
var result = new Result();
|
||||
result = taskFunctionProgress(questTaskUpdateDataRef);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
result = await rewardUpdate(questTaskUpdateDataRef);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
result = await delteItemUpdate(questTaskUpdateDataRef);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
109
GameServer/Contents/Quest/Action/RepeatQuestAction.cs
Normal file
109
GameServer/Contents/Quest/Action/RepeatQuestAction.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class RepeatQuestAction : EntityActionBase
|
||||
{
|
||||
public RepeatQuestAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public Int32 isChecking()
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
|
||||
return repeat_quest_attribute.m_is_checking;
|
||||
}
|
||||
|
||||
public DateTime getNextAllocateTime()
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
|
||||
return repeat_quest_attribute.m_next_allocate_time;
|
||||
}
|
||||
|
||||
public void setRepeatQuestInfo(DateTime nextAllocateTime, Int32 isChecking)
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
repeat_quest_attribute.m_next_allocate_time = nextAllocateTime;
|
||||
repeat_quest_attribute.m_is_checking = isChecking;
|
||||
repeat_quest_attribute.modifiedEntityAttribute();
|
||||
}
|
||||
|
||||
public Result setRepeatQuestFromDoc(RepeatQuestDoc doc)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
if (false == doc.getAttribWrappers().TryGetValue(typeof(RepeatQuestAttrib), out var to_copy_doc_attrib))
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib_base = to_copy_doc_attrib.getAttribBase();
|
||||
var doc_attrib = attrib_base as RepeatQuestAttrib;
|
||||
if (doc_attrib is null)
|
||||
{
|
||||
var err_msg = $"Fail to get QuestAttrib";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var repeat_quest_attribute = owner.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
|
||||
repeat_quest_attribute.m_next_allocate_time = doc_attrib.m_next_allocate_time;
|
||||
repeat_quest_attribute.m_is_checking = doc_attrib.m_is_checking;
|
||||
|
||||
repeat_quest_attribute.syncOriginDocBaseWithNewDoc<RepeatQuestAttribute>(doc);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
public void checkAndAddNormalQuestCheckPool()
|
||||
{
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
|
||||
if (repeat_quest_attribute.m_is_checking == 1)
|
||||
{
|
||||
QuestManager.It.m_normal_quest_check_users.TryAdd(player.getUserGuid(), 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
125
GameServer/Contents/Quest/DBQQuery/DBQAbandonQuest.cs
Normal file
125
GameServer/Contents/Quest/DBQQuery/DBQAbandonQuest.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MetaAssets;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQAbandonQuest : QueryExecutorBase
|
||||
{
|
||||
private string m_my_combination_key_for_pk = string.Empty;
|
||||
private string m_my_combination_key_for_sk = string.Empty;
|
||||
private UInt32 m_quest_id = 0;
|
||||
private UInt32 m_quest_revision = 0;
|
||||
|
||||
private QuestDoc? m_quest_doc_nullable = null;
|
||||
|
||||
private string m_pk = string.Empty;
|
||||
private string m_sk = string.Empty;
|
||||
|
||||
public DBQAbandonQuest(string myGuid, UInt32 questId, UInt32 questRevision)
|
||||
: base(typeof(DBQAbandonQuest).Name)
|
||||
{
|
||||
m_my_combination_key_for_pk = myGuid;
|
||||
m_quest_id = questId;
|
||||
m_quest_revision = questRevision;
|
||||
m_my_combination_key_for_sk = QuestDoc.makeQuestSKString(m_quest_id, m_quest_revision);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
m_quest_doc_nullable = new QuestDoc(m_my_combination_key_for_pk, m_quest_id, m_quest_revision);
|
||||
m_quest_doc_nullable.setCombinationKeyForPKSK(m_my_combination_key_for_pk, m_my_combination_key_for_sk);
|
||||
|
||||
var error_code = m_quest_doc_nullable.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! my_error_code : {error_code.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = m_quest_doc_nullable.getPK();
|
||||
m_sk = m_quest_doc_nullable.getSK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_doc_nullable, () => $"m_quest_doc_nullable is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
(result, var quest_doc) = await m_quest_doc_nullable.onCopyToDocument();
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to m_quest_doc_nullable.onCopyToDocument() !!! : {result.toBasicString()}, m_my_pk:{m_pk}, m_sk:{m_sk} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var table = db_connector.getTableByDoc<QuestDoc>();
|
||||
await table.simpleDeleteDocumentsWithBatchWrite([quest_doc], query_batch.getTransId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
//여기서 메모리 업데이트
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action, () => $"quest_action is null !!!");
|
||||
|
||||
//이거 안필요 할 수 도 잇다. (다시 바꿔보자..)
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(m_quest_id);
|
||||
if (result.isFail()) return;
|
||||
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
if (quest_base_info == null)
|
||||
return;
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
quest_action.deleteQuest(quest_type, m_quest_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
|
||||
198
GameServer/Contents/Quest/DBQQuery/DBQAcceptQuest.cs
Normal file
198
GameServer/Contents/Quest/DBQQuery/DBQAcceptQuest.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQAcceptQuest : QueryExecutorBase
|
||||
{
|
||||
private string m_my_combination_key_for_pk = string.Empty;
|
||||
private UInt32 m_my_combination_key_for_sk = 0;
|
||||
private AcceptQuestVariable m_accept_quest_var = new();
|
||||
|
||||
private QuestDoc? m_quest_doc_nullable = null;
|
||||
private QuestMailDoc? m_quest_mail_doc_nullable = null;
|
||||
|
||||
private string m_quest_pk = string.Empty;
|
||||
private string m_quest_mail_pk = string.Empty;
|
||||
|
||||
public DBQAcceptQuest(string myGuid, AcceptQuestVariable acceptQuestVar)
|
||||
: base(typeof(DBQAcceptQuest).Name)
|
||||
{
|
||||
m_my_combination_key_for_pk = myGuid;
|
||||
m_accept_quest_var = acceptQuestVar;
|
||||
|
||||
var quest_base_info = acceptQuestVar.m_quest_base_info_nullable;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
m_my_combination_key_for_sk = quest_base_info.QuestId;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(m_accept_quest_var.m_quest_base_info_nullable, () => "m_accept_quest_var.m_quest_base_info_nullable is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(m_accept_quest_var.m_new_quest_nullable, () => "m_accept_quest_var.m_new_quest_nullable is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => "player is null !!!");
|
||||
|
||||
var user_guid = player.getUserGuid();
|
||||
var quest_id = m_accept_quest_var.m_quest_base_info_nullable.QuestId;
|
||||
var quest = m_accept_quest_var.m_new_quest_nullable;
|
||||
|
||||
var questAttribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(questAttribute, () => "questAttribute is null !!!");
|
||||
|
||||
m_quest_doc_nullable = questAttribute.m_quest_doc_nullable;
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_doc_nullable, () => "m_quest_doc_nullable is null !!!");
|
||||
|
||||
m_quest_doc_nullable.setCombinationKeyForPKSK(m_my_combination_key_for_pk, m_my_combination_key_for_sk.ToString());
|
||||
|
||||
var quest_error = m_quest_doc_nullable.onApplyPKSK();
|
||||
var mail_error = ServerErrorCode.Success;
|
||||
|
||||
if (m_accept_quest_var.m_is_mail_quest)
|
||||
{
|
||||
m_quest_mail_doc_nullable = new QuestMailDoc(user_guid, quest_id, 0);
|
||||
m_quest_mail_doc_nullable.setCombinationKeyForPKSK(m_my_combination_key_for_pk, m_my_combination_key_for_sk.ToString());
|
||||
mail_error = m_quest_mail_doc_nullable.onApplyPKSK();
|
||||
}
|
||||
|
||||
if (quest_error.isFail() || mail_error.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! quest_error : {quest_error.toBasicString()}, mail_error : {mail_error.toBasicString()} - {player.toBasicString()}";
|
||||
result.setFail(quest_error, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_quest_pk = m_quest_doc_nullable.getPK();
|
||||
|
||||
if (m_accept_quest_var.m_is_mail_quest)
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_mail_doc_nullable, () => "m_quest_mail_doc_nullable is null !!!");
|
||||
|
||||
m_quest_mail_pk = m_quest_mail_doc_nullable.getPK();
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_doc_nullable, () => "m_quest_doc_nullable is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_mail_doc_nullable, () => "m_quest_mail_doc_nullable is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
var ctxs = new List<DynamoDbDocumentQueryContext>();
|
||||
|
||||
(result, var quest_document) = await m_quest_doc_nullable.onCopyToDocument();
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onCopyToDocument() !!! : {result.toBasicString()}, m_quest_pk:{m_quest_pk} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var table = db_connector.getTableByDoc<QuestDoc>();
|
||||
var quest_docmument_ctx = new DynamoDbDocumentQueryContext(table.TableName, quest_document, QueryType.Insert);
|
||||
ctxs.Add(quest_docmument_ctx);
|
||||
|
||||
if (m_accept_quest_var.m_is_mail_quest)
|
||||
{
|
||||
(result, var mail_document) = await m_quest_mail_doc_nullable.onCopyToDocument();
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onCopyToDocument() !!! : {result.toBasicString()}, m_quest_mail_pk:{m_quest_mail_pk} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_mail_docmument_ctx = new DynamoDbDocumentQueryContext(table.TableName, mail_document, QueryType.Delete);
|
||||
ctxs.Add(quest_mail_docmument_ctx);
|
||||
}
|
||||
|
||||
(result, _) = await table.simpleTransactWriteWithDocument(ctxs, 2, query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to simpleTransactWriteWithDocument() !!! : {result.toBasicString()}, m_quest_pk:{m_quest_pk}, m_quest_mail_pk:{m_quest_mail_pk} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(m_accept_quest_var.m_new_quest_nullable, () => "m_accept_quest_var.m_new_quest_nullable is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(m_accept_quest_var.m_quest_base_info_nullable, () => "m_accept_quest_var.m_quest_base_info_nullable is null !!!");
|
||||
|
||||
//여기서 메모리 업데이트
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action, () => "quest_action is null !!!");
|
||||
|
||||
var quests = quest_action.getQuests();
|
||||
var quest_meta = m_accept_quest_var.m_quest_base_info_nullable;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_meta, () => "quest_meta is null !!!");
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_meta.QuestType, EQuestType.NORMAL);
|
||||
|
||||
if (false == quests.TryAdd((quest_type, quest_meta.QuestId), m_accept_quest_var.m_new_quest_nullable))
|
||||
{
|
||||
var err_msg = $"new quest try add fail QuestId = {m_accept_quest_var.m_quest_base_info_nullable.QuestId}, quests = {JsonConvert.SerializeObject(quests)} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
116
GameServer/Contents/Quest/DBQQuery/DBQDailyQuestCheckReadAll.cs
Normal file
116
GameServer/Contents/Quest/DBQQuery/DBQDailyQuestCheckReadAll.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQDailyQuestCheckReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
private readonly List<DailyQuestCheckDoc> m_to_read_daily_quest_check_doc = new();
|
||||
|
||||
public DBQDailyQuestCheckReadAll(string combinationKeyForPK /*onwer_guid*/)
|
||||
: base(typeof(DBQDailyQuestCheckReadAll).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var doc = new DailyQuestCheckDoc(m_combination_key_for_pk);
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {player.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => "query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var daily_quest_check_attribute = owner.getEntityAttribute<DailyQuestCheckAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(daily_quest_check_attribute, () => "daily_quest_check_attribute is null !!!");
|
||||
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<DailyQuestCheckDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
//데이터 없으면 여기서 그냥 메모리에만 넣어준다.
|
||||
Log.getLogger().warn($"DailyQuestCheckDoc not exitst, so make new Data {result.toBasicString()}");
|
||||
|
||||
return new();
|
||||
}
|
||||
m_to_read_daily_quest_check_doc.AddRange(read_docs);
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action, () => "quest_action is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var set_result = quest_action.setQuestCheckFromDoc(read_doc);
|
||||
if (set_result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
104
GameServer/Contents/Quest/DBQQuery/DBQEndQuestsReadAll.cs
Normal file
104
GameServer/Contents/Quest/DBQQuery/DBQEndQuestsReadAll.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class DBQEndQuestsReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
//private readonly List<EndQuestDoc> m_to_read_end_quest_docs = new();
|
||||
|
||||
public DBQEndQuestsReadAll(string combinationKeyForPK /*onwer_guid*/)
|
||||
: base(typeof(DBQEndQuestsReadAll).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var doc = new EndQuestDoc();
|
||||
doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => "query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKOnly(m_pk);
|
||||
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<EndQuestDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var end_quest_action = owner.getEntityAction<EndQuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_action, () => "end_quest_action is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var set_result = end_quest_action.setEndQuestsFromDoc(read_doc);
|
||||
if (set_result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
}
|
||||
127
GameServer/Contents/Quest/DBQQuery/DBQQuestMailSend.cs
Normal file
127
GameServer/Contents/Quest/DBQQuery/DBQQuestMailSend.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQQuestMailSend : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
|
||||
private readonly List<QuestMailDoc> m_quest_mail_docs = new();
|
||||
|
||||
public DBQQuestMailSend(string combinationKeyForPK, List<QuestMailDoc> docs)
|
||||
: base(typeof(DBQQuestMailSend).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
m_quest_mail_docs = docs;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
foreach (var quest_mail_doc in m_quest_mail_docs)
|
||||
{
|
||||
var mail_attrib = quest_mail_doc.getAttrib<QuestMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(mail_attrib, () => $"mail_attrib is null !!!");
|
||||
|
||||
quest_mail_doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
quest_mail_doc.setCombinationKeyForSK(mail_attrib.QuestId.ToString());
|
||||
|
||||
var error_code = quest_mail_doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
var query_contexts = new List<DynamoDbDocumentQueryContext>();
|
||||
|
||||
foreach (var doc in m_quest_mail_docs)
|
||||
{
|
||||
(result, var quest_mail_document) = await doc.onCopyToDocument();
|
||||
if(result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onCopyToDocument() !!! : {result.toBasicString()}, m_pk:{m_pk} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
continue;
|
||||
}
|
||||
var docmument_ctx = new DynamoDbDocumentQueryContext(db_connector.getTableFullName(doc.TableName), quest_mail_document, QueryType.Insert);
|
||||
query_contexts.Add(docmument_ctx);
|
||||
}
|
||||
|
||||
var table = db_connector.getTableByDoc<QuestMailDoc>();
|
||||
(result, _) = await table.simpleTransactWriteWithDocument(query_contexts, 2, query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to simpleTransactWrite !!! : {result.toBasicString()}, m_pk:{m_pk}, {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_action, () => $"quest_mail_action is null !!!");
|
||||
|
||||
foreach (var doc in m_quest_mail_docs)
|
||||
{
|
||||
await quest_mail_action.setQuestMailFromDoc(doc);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
110
GameServer/Contents/Quest/DBQQuery/DBQQuestMailsReadAll.cs
Normal file
110
GameServer/Contents/Quest/DBQQuery/DBQQuestMailsReadAll.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class DBQQuestMailsReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
|
||||
public DBQQuestMailsReadAll(string combinationKeyForPK /*onwer_guid*/)
|
||||
: base(typeof(DBQQuestMailsReadAll).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var doc = new QuestMailDoc();
|
||||
doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKOnly(m_pk);
|
||||
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<QuestMailDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_action, () => $"quest_mail_action is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var set_result = await quest_mail_action.setQuestMailFromDoc(read_doc);
|
||||
if (set_result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_action, () => $"quest_mail_action is null !!!");
|
||||
|
||||
quest_mail_action.setQuestMailLoadedAll();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQQuestPeriodRepeatReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
private readonly List<QuestPeriodRepeatCheckDoc> m_to_quest_period_repeat_doc = new();
|
||||
|
||||
public DBQQuestPeriodRepeatReadAll(string combinationKeyForPK /*onwer_guid*/)
|
||||
: base(typeof(DBQQuestPeriodRepeatReadAll).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var doc = new QuestPeriodRepeatCheckDoc(m_combination_key_for_pk);
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {player.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => "query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var quest_period_repeat_check_attribute = owner.getEntityAttribute<QuestPeriodRepeatCheckAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_period_repeat_check_attribute, () => "quest_period_repeat_check_attribute is null !!!");
|
||||
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<QuestPeriodRepeatCheckDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
//데이터 없으면 여기서 그냥 메모리에만 넣어준다.
|
||||
Log.getLogger().warn($"QuestPeriodRepeatCheckDoc not exitst, so make new Data {result.toBasicString()}");
|
||||
|
||||
return new();
|
||||
}
|
||||
m_to_quest_period_repeat_doc.AddRange(read_docs);
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action, () => "quest_action is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var set_result = quest_action.setPeriodRepeatQuestFromDoc(read_doc);
|
||||
if (set_result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
119
GameServer/Contents/Quest/DBQQuery/DBQQuestsReadAll.cs
Normal file
119
GameServer/Contents/Quest/DBQQuery/DBQQuestsReadAll.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class DBQQuestsReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
private readonly List<QuestDoc> m_to_read_quest_docs = new();
|
||||
|
||||
public DBQQuestsReadAll(string combinationKeyForPK /*onwer_guid*/)
|
||||
: base(typeof(DBQQuestsReadAll).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var doc = new QuestDoc();
|
||||
doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKOnly(m_pk);
|
||||
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<QuestDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail()) return result;
|
||||
|
||||
m_to_read_quest_docs.AddRange(read_docs);
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_action, () => $"quest_action is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var set_result = await quest_action.setQuestsFromDoc(read_doc);
|
||||
if (set_result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
//ugq가 중복이 있는 경우 오래된건 삭제 처리 해줄수 있도록 처리
|
||||
//quest_attribute.UgqInfo.UqgState == UgqStateType.Test
|
||||
//var owner = getOwner();
|
||||
//NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
//var quest_action = owner.getEntityAction<QuestAction>();
|
||||
//NullReferenceCheckHelper.throwIfNull(quest_action, () => $"quest_action is null !!!");
|
||||
|
||||
//var ugq_questst = quest_action.getUgqQuests();
|
||||
//dsfds
|
||||
// if (set_result.isFail())
|
||||
// {
|
||||
// Log.getLogger().error(result.toBasicString());
|
||||
// }
|
||||
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
}
|
||||
125
GameServer/Contents/Quest/DBQQuery/DBQRefuseQuestMail.cs
Normal file
125
GameServer/Contents/Quest/DBQQuery/DBQRefuseQuestMail.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Amazon.OpenSearchService.Model.Internal.MarshallTransformations;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQRefuseQuestMail : QueryExecutorBase
|
||||
{
|
||||
private string m_my_combination_key_for_pk = string.Empty;
|
||||
private UInt32 m_quest_id = 0;
|
||||
private UInt32 m_quest_revision = 0;
|
||||
|
||||
private QuestMailDoc? m_quest_mail_doc_nullable = null;
|
||||
private string m_pk = string.Empty;
|
||||
private string m_sk = string.Empty;
|
||||
|
||||
public DBQRefuseQuestMail(string myGuid, UInt32 questId, UInt32 questRevision)
|
||||
: base(typeof(DBQRefuseQuestMail).Name)
|
||||
{
|
||||
m_my_combination_key_for_pk = myGuid;
|
||||
m_quest_id = questId;
|
||||
m_quest_revision = questRevision;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
m_quest_mail_doc_nullable = new QuestMailDoc(m_my_combination_key_for_pk, m_quest_id, m_quest_revision);
|
||||
|
||||
var sk = $"{m_quest_id}#{m_quest_revision}";
|
||||
m_quest_mail_doc_nullable.setCombinationKeyForPKSK(m_my_combination_key_for_pk, sk);
|
||||
|
||||
var error_code = m_quest_mail_doc_nullable.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! my_error_code : {error_code.toBasicString()} - {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = m_quest_mail_doc_nullable.getPK();
|
||||
m_sk = m_quest_mail_doc_nullable.getSK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_mail_doc_nullable, () => $"m_quest_mail_doc_nullable is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
(result, var quest_mail_doc) = await m_quest_mail_doc_nullable.onCopyToDocument();
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onCopyToDocument() !!! : {result.toBasicString()}, m_my_pk:{m_pk}, m_sk:{m_sk} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var table = db_connector.getTableByDoc<QuestMailDoc>();
|
||||
result = await table.simpleDeleteDocumentsWithBatchWrite([quest_mail_doc], query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to simpleDeleteDocumentsWithBatchWrite() !!! : {result.toBasicString()}, {quest_mail_doc.toPKSK()} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
//여기서 메모리 업데이트
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_action, () => $"quest_mail_action is null !!!");
|
||||
|
||||
await quest_mail_action.deleteQuestMail(m_quest_id, m_quest_revision);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
118
GameServer/Contents/Quest/DBQQuery/DBQRepeatQuestRead.cs
Normal file
118
GameServer/Contents/Quest/DBQQuery/DBQRepeatQuestRead.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using Amazon.S3.Model;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class DBQRepeatQuestRead : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
|
||||
private readonly List<RepeatQuestDoc> m_to_read_repeat_quest_docs = new();
|
||||
|
||||
public DBQRepeatQuestRead(string combinationKeyForPK /*onwer_guid*/)
|
||||
: base(typeof(DBQRepeatQuestRead).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//===================================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var doc = new RepeatQuestDoc(m_combination_key_for_pk);
|
||||
//doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
||||
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<RepeatQuestDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
m_to_read_repeat_quest_docs.AddRange(read_docs);
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var repeat_quest_action = owner.getEntityAction<RepeatQuestAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_action, () => $"repeat_quest_action is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var set_result = repeat_quest_action.setRepeatQuestFromDoc(read_doc);
|
||||
if (set_result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
var player = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
|
||||
|
||||
if (repeat_quest_attribute.m_is_checking == 1)
|
||||
{
|
||||
QuestManager.It.m_normal_quest_check_users.TryAdd(player.getUserGuid(), 1);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//===================================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
}
|
||||
153
GameServer/Contents/Quest/Helper/QuestMetaHelper.cs
Normal file
153
GameServer/Contents/Quest/Helper/QuestMetaHelper.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Microsoft.AspNetCore.SignalR.Protocol;
|
||||
using RabbitMQ.Client;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using UGQDatabase.Models;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public static class QuestMetaHelper
|
||||
{
|
||||
public static Result getQuestTaskEventGroupByEventString(QuestTaskGroup questTaskInfo, string eventString, [MaybeNullWhen(false)] out QuestEventInfo? questEventInfo)
|
||||
{
|
||||
var result = new Result();
|
||||
if (false == questTaskInfo.QuestEventGroupByEventString.TryGetValue(eventString, out questEventInfo))
|
||||
{
|
||||
var err_msg = $"activeEnvent info not match current task !!!, eventString : {eventString}, questTaskInfo = {JsonConvert.SerializeObject(questTaskInfo)}";
|
||||
result.setFail(ServerErrorCode.QuestInvalidValue, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
questEventInfo = null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<(Result, QuestInfo?)> makeQuestInfoData(ServerCommon.Quest quest)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
QuestInfo questInfo = new QuestInfo();
|
||||
var quest_id = quest_attribute.QuestId;
|
||||
var quest_revision = quest_attribute.UgqInfo.QuestRevision;
|
||||
|
||||
(var result, var quest_task_info) = await getQuestTaskGroupFromQuest(quest);
|
||||
if (result.isFail()) return (result, null);
|
||||
|
||||
|
||||
questInfo.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(quest_id, quest_revision);
|
||||
questInfo.QuestAssignTime = Timestamp.FromDateTime(quest_attribute.QuestAssignTime);
|
||||
questInfo.CurrentTaskNum = quest_attribute.CurrentTaskNum;
|
||||
questInfo.TaskStartTime = Timestamp.FromDateTime(quest_attribute.TaskStartTime);
|
||||
questInfo.QuestCompleteTime = Timestamp.FromDateTime(quest_attribute.QuestCompleteTime);
|
||||
questInfo.HasCounter = quest_attribute.HasCounter;
|
||||
questInfo.MinCounter = quest_attribute.MinCounter;
|
||||
questInfo.MaxCounter = quest_attribute.MaxCounter;
|
||||
questInfo.CurrentCounter = quest_attribute.CurrentCounter;
|
||||
questInfo.IsComplete = quest_attribute.IsComplete;
|
||||
questInfo.ReplacedRewardGroupId = quest_attribute.ReplacedRewardGroupId;
|
||||
questInfo.HasTimer = quest_attribute.HasTimer;
|
||||
questInfo.TimerCompleteTime = Timestamp.FromDateTime(quest_attribute.TimerCompleteTime);
|
||||
questInfo.ActiveEvents.AddRange(quest_attribute.ActiveEvents);
|
||||
|
||||
return (result, questInfo);
|
||||
|
||||
}
|
||||
|
||||
public static async Task<(Result, QuestTaskGroup?)> getQuestTaskGroupFromQuest(ServerCommon.Quest quest)
|
||||
{
|
||||
var player = quest.getRootParent() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
var quest_id = quest_attribute.QuestId;
|
||||
var quest_revision = quest_attribute.UgqInfo.QuestRevision;
|
||||
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(player, quest_id, quest_revision, quest_attribute.UgqInfo.UqgState);
|
||||
if (result.isFail()) return (result, null);
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
if (false == quest_base_info.QuestTaskGroupList.TryGetValue(quest_attribute.CurrentTaskNum, out var quest_task_info))
|
||||
{
|
||||
string err_msg = $"NotExist Quest Task Group Data QuestID : {quest_attribute.QuestId}, TaskNum : {quest_attribute.CurrentTaskNum}";
|
||||
result.setFail(ServerErrorCode.QuestInvalidTaskNum, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return (result, null);
|
||||
}
|
||||
return (result, quest_task_info);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static async Task<List<QuestInfo>> makeQuestInfoData(List<ServerCommon.Quest> quests)
|
||||
{
|
||||
List<QuestInfo> questInfos = new List<QuestInfo>();
|
||||
|
||||
foreach (var quest in quests)
|
||||
{
|
||||
(var result, var quest_info) = await makeQuestInfoData(quest);
|
||||
if (result.isFail()) continue;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_info, () => $"quest_info is null !!!");
|
||||
questInfos.Add(quest_info);
|
||||
}
|
||||
return questInfos;
|
||||
|
||||
}
|
||||
|
||||
public static async Task<EQuestType> getQuestType(Player player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
if (questRevision > 0)
|
||||
{
|
||||
return EQuestType.UGQ;
|
||||
}
|
||||
else
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(player, questId, questRevision);
|
||||
if (result.isFail()) return EQuestType.NORMAL;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(quest_base_info.QuestType, EQuestType.NORMAL);
|
||||
return quest_type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string convertFarmingSummonedEntityTypeToQuestEntityType(FarmingSummonedEntityType entityType)
|
||||
{
|
||||
switch (entityType)
|
||||
{
|
||||
case FarmingSummonedEntityType.User:
|
||||
return "MYSELF";
|
||||
case FarmingSummonedEntityType.Beacon:
|
||||
return "BEACON";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
396
GameServer/Contents/Quest/Helper/QuestNotifyHelper.cs
Normal file
396
GameServer/Contents/Quest/Helper/QuestNotifyHelper.cs
Normal file
@@ -0,0 +1,396 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MetaAssets;
|
||||
using Nettention.Proud;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public static class QuestNotifyHelper
|
||||
{
|
||||
public static async Task<ClientToGame> makeQuestUpdateNotify(Player player, UInt32 questId, ServerCommon.Quest assigned_quest, bool isNewQuest = false)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
ClientToGame ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ();
|
||||
ntf_packet.Message.QuestUpdateNoti = new();
|
||||
|
||||
List<ServerCommon.Quest> quests = new();
|
||||
quests.Add(assigned_quest);
|
||||
|
||||
ntf_packet.Message.QuestUpdateNoti.Quests.AddRange(await QuestMetaHelper.makeQuestInfoData(quests));
|
||||
|
||||
if (isNewQuest)
|
||||
{
|
||||
ntf_packet.Message.QuestUpdateNoti.QuestMetaInfos.AddRange(makeQuestMetaInfoData(new List<UInt32>() { questId }));
|
||||
}
|
||||
|
||||
return ntf_packet;
|
||||
}
|
||||
|
||||
//public static void send_GS2C_NTF_QUEST_UPDATE_ALL(this Player player)
|
||||
//{
|
||||
// var quest_action = player.getEntityAction<QuestAction>();
|
||||
// var quests = quest_action.getQuests();
|
||||
// foreach(var quest_key in quests.Keys)
|
||||
// {
|
||||
// var quest_id = quest_key.Item2;
|
||||
// send_GS2C_NTF_QUEST_UPDATE(player, quest_id, false);
|
||||
// }
|
||||
//}
|
||||
|
||||
public static async Task<Result> send_GS2C_NTF_QUEST_UPDATE_ALL(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
var quests = quest_action.getQuests();
|
||||
foreach (var quest in quests.Values)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
await player.send_GS2C_NTF_QUEST_UPDATE(quest_attribute.QuestId, quest_attribute.UgqInfo.QuestRevision);
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
|
||||
public static async Task<Result> send_GS2C_NTF_QUEST_UPDATE(this Player player, UInt32 questId, UInt32 questRevision, CommonResult? commonResult = null, bool isNewQuest = false)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
ClientToGame ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.QuestUpdateNoti = new ClientToGameMessage.Types.QuestList();
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(player, questId, questRevision);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
result = quest_action.getQuest(quest_base_info.QuestType, questId, out var quest);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
|
||||
List<ServerCommon.Quest> quests = new();
|
||||
quests.Add(quest);
|
||||
ntf_packet.Message.QuestUpdateNoti.Quests.AddRange(await QuestMetaHelper.makeQuestInfoData(quests));
|
||||
if (isNewQuest)
|
||||
{
|
||||
ntf_packet.Message.QuestUpdateNoti.QuestMetaInfos.AddRange(makeQuestMetaInfoData(new List<UInt32>() { questId }));
|
||||
}
|
||||
|
||||
ntf_packet.Message.QuestUpdateNoti.CommonResult = commonResult;
|
||||
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static Result send_GS2C_NTF_QUEST_UPDATE_EMPTY(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
ClientToGame ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.QuestUpdateNoti = new ClientToGameMessage.Types.QuestList();
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
return new();
|
||||
|
||||
}
|
||||
|
||||
public static void send_GS2C_NTF_SYSTEM_QUEST_METAS(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
int quest_meta_count = MetaData.Instance.m_quest_assign_meta_infos.Count;
|
||||
int quest_task_meta_count = MetaData.Instance.m_quest_task_meta_infos.Count;
|
||||
int batch_size = 500;
|
||||
|
||||
for (int i = 0; i < quest_meta_count; i += batch_size)
|
||||
{
|
||||
var splited_infos = MetaData.Instance.m_quest_assign_meta_infos.GetRange(i, Math.Min(batch_size, quest_meta_count - i));
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.NtfQuestAssignMetaInfo = new();
|
||||
ntf_packet.Message.NtfQuestAssignMetaInfo.QuestAssignMeteInfos.AddRange(splited_infos);
|
||||
//ntf_packet.Message.NtfQuestAssignMetaInfo.QuestTaskMetaInfos.AddRange(MetaData.Instance.m_quest_task_meta_infos);
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
for (int i = 0; i < quest_task_meta_count; i += batch_size)
|
||||
{
|
||||
var splited_infos = MetaData.Instance.m_quest_task_meta_infos.GetRange(i, Math.Min(batch_size, quest_task_meta_count - i));
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.NtfQuestAssignMetaInfo = new();
|
||||
//ntf_packet.Message.NtfQuestAssignMetaInfo.QuestAssignMeteInfos.AddRange(splited_infos);
|
||||
ntf_packet.Message.NtfQuestAssignMetaInfo.QuestTaskMetaInfos.AddRange(splited_infos);
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
// var ntf_packet = new ClientToGame();
|
||||
// ntf_packet.Message = new();
|
||||
// ntf_packet.Message.NtfQuestAssignMetaInfo = new();
|
||||
// ntf_packet.Message.NtfQuestAssignMetaInfo.QuestAssignMeteInfos.AddRange(MetaData.Instance.m_quest_assign_meta_infos);
|
||||
// ntf_packet.Message.NtfQuestAssignMetaInfo.QuestTaskMetaInfos.AddRange(MetaData.Instance.m_quest_task_meta_infos);
|
||||
// server_logic.onSendPacket(player, ntf_packet);
|
||||
|
||||
}
|
||||
|
||||
public static async Task send_GS2C_NTF_SYSTEM_QUESTS(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.QuestInfoNoti = new();
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
var quests = quest_action.getSystemQuests();
|
||||
|
||||
ntf_packet.Message.QuestInfoNoti.Quests.AddRange(await QuestMetaHelper.makeQuestInfoData(quests));
|
||||
|
||||
List<UInt32> quest_ids = new();
|
||||
|
||||
foreach (var quest in quests)
|
||||
{
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
quest_ids.Add(quest_attribute.QuestId);
|
||||
}
|
||||
|
||||
ntf_packet.Message.QuestInfoNoti.QuestMetaInfos.AddRange(makeQuestMetaInfoData(quest_ids));
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
|
||||
public static void send_GS2C_NTF_END_QUESTS(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.QuestEndInfoNoti = new();
|
||||
|
||||
var end_quest_action = player.getEntityAction<EndQuestAction>();
|
||||
var end_quests = end_quest_action.getEndQuests();
|
||||
|
||||
var infos = end_quest_action.makeQuestEndInfo(end_quests.Keys.ToList());
|
||||
|
||||
ntf_packet.Message.QuestEndInfoNoti.EndQuests.AddRange(infos);
|
||||
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
|
||||
public static async Task send_GS2C_NTF_UGQS(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var ugq_info_action = player.getEntityAction<UgqInfoAction>();
|
||||
var all_infos = await ugq_info_action.makeUqgInfosForClient();
|
||||
|
||||
foreach (var info in all_infos)
|
||||
{
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.NtfUgqQuests = new();
|
||||
|
||||
ntf_packet.Message.NtfUgqQuests.AllUgqInfos.Add(info);
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static async Task send_GS2C_NTF_UGQ(this Player player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.NtfUgqQuests = new();
|
||||
|
||||
var ugq_info_action = player.getEntityAction<UgqInfoAction>();
|
||||
var all_infos = await ugq_info_action.makeUqgInfoForClient(questId, questRevision);
|
||||
|
||||
ntf_packet.Message.NtfUgqQuests.AllUgqInfos.AddRange(all_infos);
|
||||
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
public static async Task send_GS2C_NTF_UGQ_DAILY_REWARD(this Player player)
|
||||
{
|
||||
//보내기 전에 여기에 리프레시 하는것 추가
|
||||
var ugq_reward_action = player.getEntityAction<UgqRewardAction>();
|
||||
await ugq_reward_action.uggDailyRewardRefresh();
|
||||
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var daily_reward_attribute = player.getEntityAttribute<UgqDailyRewardCountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(daily_reward_attribute, () => $"daily_reward_attribute is null !!!");
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.NtfUgqDailyRewardCounts = new();
|
||||
ntf_packet.Message.NtfUgqDailyRewardCounts.NextRefreshTime = daily_reward_attribute.m_next_refresh_time.ToTimestamp();
|
||||
|
||||
var reward_counts = daily_reward_attribute.getDailyRewardCount();
|
||||
foreach(var reward_cnt in reward_counts)
|
||||
{
|
||||
UgqDailyRewardCount usg_daily_reward_count = new();
|
||||
usg_daily_reward_count.GradeType = reward_cnt.Key;
|
||||
usg_daily_reward_count.CurrentCount = reward_cnt.Value;
|
||||
|
||||
(var max_cnt, _) = UgqMetaHelper.getUgqDailyRewardMaxCountByGrade(reward_cnt.Key);
|
||||
usg_daily_reward_count.DailyMaxCount = max_cnt;
|
||||
|
||||
ntf_packet.Message.NtfUgqDailyRewardCounts.UgqDailyRewardCounts.Add(usg_daily_reward_count);
|
||||
}
|
||||
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
|
||||
public static List<QuestMetaInfo> makeQuestMetaInfoData(List<UInt32> questIds)
|
||||
{
|
||||
List<QuestMetaInfo> metaInfos = new List<QuestMetaInfo>();
|
||||
|
||||
foreach(var questId in questIds)
|
||||
{
|
||||
if (!MetaData.Instance._QuestScriptMetaTable.TryGetValue(questId, out var questScripts))
|
||||
{
|
||||
Log.getLogger().error($"QuestMetaInfoData Not Exist questId : {questId}");
|
||||
continue;
|
||||
}
|
||||
foreach (var script in questScripts.Values)
|
||||
{
|
||||
var meta = fillQuestMetaInfo(script);
|
||||
metaInfos.Add(meta);
|
||||
}
|
||||
}
|
||||
return metaInfos;
|
||||
}
|
||||
|
||||
public static List<QuestMetaInfo> fillQuestMetaInfos(List<MetaAssets.QuestScriptMetaData> datas)
|
||||
{
|
||||
List<QuestMetaInfo> metaInfos = new List<QuestMetaInfo>();
|
||||
foreach (var script in datas)
|
||||
{
|
||||
var meta = fillQuestMetaInfo(script);
|
||||
metaInfos.Add(meta);
|
||||
}
|
||||
|
||||
return metaInfos;
|
||||
}
|
||||
|
||||
public static QuestMetaInfo fillQuestMetaInfo(MetaAssets.QuestScriptMetaData data)
|
||||
{
|
||||
QuestMetaInfo meta = new QuestMetaInfo();
|
||||
meta.Index = data.Index;
|
||||
|
||||
meta.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(data.QuestId, 0);
|
||||
meta.EventTarget = data.EventTarget;
|
||||
meta.EventName = data.Event;
|
||||
meta.EventCondition1 = data.EventCondition1;
|
||||
meta.EventCondition2 = data.EventCondition2;
|
||||
if (data.EventCondition2.Equals("0"))
|
||||
{
|
||||
meta.EventCondition2 = "";
|
||||
}
|
||||
meta.EventCondition3 = data.EventCondition3;
|
||||
meta.FunctionTarget = data.FunctionTarget;
|
||||
meta.FunctionName = data.Function;
|
||||
meta.FunctionCondition1 = data.FunctionCondition1;
|
||||
meta.FunctionCondition2 = data.FunctionCondition2;
|
||||
meta.FunctionCondition3 = data.FunctionCondition3;
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
public static async Task<Result> sendRedisQuestNotifyRequest(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var result = new Result();
|
||||
if (questTaskUpdateHandler is null)
|
||||
{
|
||||
var err_msg = $"quest notify redis regist fail questTaskUpdateHandler is null";
|
||||
result.setFail(ServerErrorCode.QuestNotifyRedisRegistFail, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_id = questTaskUpdateHandler.m_quest_id;
|
||||
var quest_revision = questTaskUpdateHandler.m_quest_revision;
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
QuestNotifyCacheRequest cache = new QuestNotifyCacheRequest(player, player.getUserGuid(), quest_id, quest_revision, server_logic.getRedisConnector());
|
||||
|
||||
result = await cache.addQuestNotify();
|
||||
if(result.isFail())
|
||||
{
|
||||
var err_msg = $"addQuestNotify fail";
|
||||
result.setFail(ServerErrorCode.RedisHashesWriteFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<Result> send_GS2C_NTF_QUEST_UPDATE_BY_SERVER_MOVE(this Player player)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
QuestNotifyCacheRequest cache = new QuestNotifyCacheRequest(player, player.getUserGuid(), server_logic.getRedisConnector());
|
||||
|
||||
var notify_caches = await cache.getQuestNotifyAll();
|
||||
|
||||
foreach (var notify_cache in notify_caches)
|
||||
{
|
||||
var quest_id = notify_cache.m_quest_id;
|
||||
var quest_revision = notify_cache.m_quest_revision;
|
||||
|
||||
await send_GS2C_NTF_QUEST_UPDATE(player, quest_id, quest_revision, new(), false);
|
||||
await cache.deleteQuestNotify(quest_id, quest_revision);
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
public static Result send_GS2C_NTF_QUEST_REWARD(Player player, CommonResult commonResult)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
ClientToGame ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.NtfQuestReward = new ClientToGameMessage.Types.GS2C_NTF_QUEST_REWARD();
|
||||
ntf_packet.Message.NtfQuestReward.CommonResult = commonResult;
|
||||
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
return new();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
33
GameServer/Contents/Quest/Log/EndQuestDeleteBusinessLog.cs
Normal file
33
GameServer/Contents/Quest/Log/EndQuestDeleteBusinessLog.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class EndQuestDeleteBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private QuestIdLogInfo m_info;
|
||||
|
||||
public EndQuestDeleteBusinessLog(UInt32 questId, UInt32 questRevision) : base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestIdLogInfo(this, questId, questRevision);
|
||||
}
|
||||
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
49
GameServer/Contents/Quest/Log/QueatDailyCheckBusinessLog.cs
Normal file
49
GameServer/Contents/Quest/Log/QueatDailyCheckBusinessLog.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
public class QueatDailyCheckBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private List<QuestDailyCheckLogInfo> m_info;
|
||||
|
||||
public QueatDailyCheckBusinessLog(Dictionary<OncePeriodRangeType, QuestPeriodRepeatInfo> infos) : base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new();
|
||||
|
||||
foreach (var info in infos)
|
||||
{
|
||||
QuestDailyCheckLogInfo log_info = new();
|
||||
log_info.period_type = info.Key;
|
||||
|
||||
foreach (var sended_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
log_info.sended_quest_check.TryAdd(sended_quest.Key, sended_quest.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
foreach(var info in m_info)
|
||||
{
|
||||
body.append(info);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
34
GameServer/Contents/Quest/Log/QuestAbandonBusinessLog.cs
Normal file
34
GameServer/Contents/Quest/Log/QuestAbandonBusinessLog.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestAbandonBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private QuestIdLogInfo m_info;
|
||||
|
||||
public QuestAbandonBusinessLog(UInt32 questId, UInt32 questRevision) : base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestIdLogInfo(this, questId, questRevision);
|
||||
}
|
||||
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
34
GameServer/Contents/Quest/Log/QuestAcceptBusinessLog.cs
Normal file
34
GameServer/Contents/Quest/Log/QuestAcceptBusinessLog.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestAcceptBusinessLog : ILogInvokerEx
|
||||
{
|
||||
QuestAcceptLogInfo m_info;
|
||||
|
||||
public QuestAcceptBusinessLog(UInt32 questId, UInt32 questRevision, EQuestType questType)
|
||||
: base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestAcceptLogInfo(this, questId, questRevision, questType);
|
||||
}
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestAcceptByDialogueBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private QuestAcceptByDialogueLogInfo m_info;
|
||||
|
||||
public QuestAcceptByDialogueBusinessLog(UInt32 questId, UInt32 questRevision, string dialogue, string dialogueResult) : base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestAcceptByDialogueLogInfo(this, questId, questRevision, dialogue, dialogueResult);
|
||||
}
|
||||
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
33
GameServer/Contents/Quest/Log/QuestCompleteBusinessLog.cs
Normal file
33
GameServer/Contents/Quest/Log/QuestCompleteBusinessLog.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestCompleteBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private QuestIdLogInfo m_info;
|
||||
|
||||
public QuestCompleteBusinessLog(UInt32 questId, UInt32 questRevision) : base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestIdLogInfo(this, questId, questRevision);
|
||||
}
|
||||
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
35
GameServer/Contents/Quest/Log/QuestDeleteBusinessLog.cs
Normal file
35
GameServer/Contents/Quest/Log/QuestDeleteBusinessLog.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
internal class QuestDeleteBusinessLog : ILogInvokerEx
|
||||
{
|
||||
QuestIdLogInfo m_info;
|
||||
|
||||
public QuestDeleteBusinessLog(UInt32 questId, UInt32 questRevision)
|
||||
: base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestIdLogInfo(this, questId, questRevision);
|
||||
}
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
GameServer/Contents/Quest/Log/QuestRefuseBusinessLog.cs
Normal file
33
GameServer/Contents/Quest/Log/QuestRefuseBusinessLog.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestRefuseBusinessLog : ILogInvokerEx
|
||||
{
|
||||
QuestIdLogInfo m_info;
|
||||
|
||||
public QuestRefuseBusinessLog(UInt32 questId, UInt32 questRevision)
|
||||
: base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new QuestIdLogInfo(this, questId, questRevision);
|
||||
}
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
|
||||
}
|
||||
33
GameServer/Contents/Quest/Log/RepeatQuestBusinessLog.cs
Normal file
33
GameServer/Contents/Quest/Log/RepeatQuestBusinessLog.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class RepeatQuestBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private RepeatQuestLogInfo m_info;
|
||||
|
||||
public RepeatQuestBusinessLog(DateTime nextAllocatedTime, Int32 isChecking)
|
||||
: base(LogDomainType.QuestMain)
|
||||
{
|
||||
m_info = new RepeatQuestLogInfo(this, nextAllocatedTime, isChecking);
|
||||
}
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.GetQuestMailReq), typeof(GetQuestMailsPacketHandler), typeof(GameLoginListener))]
|
||||
public class GetQuestMailsPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var owner = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"Player is null !!!");
|
||||
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_action, () => $"QuestMailAction is null !!! - player:{owner.toBasicString()}");
|
||||
|
||||
var result = await quest_mail_action.loadQuestMails();
|
||||
if (result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_MAILS(owner, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_mail_infos = quest_mail_action.getQuestMailsInfo();
|
||||
send_GS2C_ACK_QUEST_MAILS(owner, result, quest_mail_infos);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static Result send_GS2C_ACK_QUEST_MAILS(Player owner, Result result)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.GetQuestMailRes = new ClientToGameRes.Types.GetQuestMailRes();
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet))
|
||||
{
|
||||
string err_msg = $"send_GS2C_ACK_FRIENDS Fail !!! : owner:{owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ProudNetException, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result send_GS2C_ACK_QUEST_MAILS(Player owner, Result result, List<QuestMailInfo> questMails)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.GetQuestMailRes = new ClientToGameRes.Types.GetQuestMailRes();
|
||||
ack_packet.Response.GetQuestMailRes.QuestMailList.AddRange(questMails);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet))
|
||||
{
|
||||
string err_msg = $"send_GS2C_ACK_FRIENDS Fail !!! : owner:{owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ProudNetException, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Google.Protobuf;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.QuestAbandonReq), typeof(QuestAbandonPacketHandler), typeof(GameLoginListener))]
|
||||
public class QuestAbandonPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var owner = session as Player;
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.QuestAbandonReq;
|
||||
|
||||
(var quest_id, var quest_revision) = QuestHelper.convertUgqQuestIdToQuestIdAndRevision(request.ComposedQuestId);
|
||||
var quest_abandon_action = owner.getEntityAction<QuestAbandonAction>();
|
||||
ArgumentNullException.ThrowIfNull(quest_abandon_action);
|
||||
|
||||
var result = await quest_abandon_action.abandonQuestConditionCheck(quest_id);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_ABANDON(owner, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await questAbandon(owner, quest_id, quest_revision);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
send_GS2C_ACK_QUEST_ABANDON(owner, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
//성공 후 처리
|
||||
send_GS2C_ACK_QUEST_ABANDON(owner, result, quest_id, quest_revision);
|
||||
|
||||
await postActionAfterSend(owner, quest_id, quest_revision);
|
||||
|
||||
return result;
|
||||
}
|
||||
private async Task<Result> questAbandon(Player owner, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
ArgumentNullException.ThrowIfNull(server_logic);
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.QuestMainAbort, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQAbandonQuest(owner.getUserGuid(), questId, questRevision));
|
||||
}
|
||||
batch.appendBusinessLog(new QuestAbandonBusinessLog(questId, questRevision));
|
||||
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
ArgumentNullException.ThrowIfNull(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<Result> postActionAfterSend(Player owner, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//퀘스트 삭제 처리 된 후 재할당 처리 해야함
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(questId);
|
||||
if (result.isFail()) return result;
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(quest_base_info, () => $"quest_base_info is null !!!");
|
||||
|
||||
//에픽이 아니면 재할당 처리 필요 없다.
|
||||
if (false == quest_base_info.QuestType.Equals(nameof(MetaAssets.EQuestType.EPIC))) return result;
|
||||
|
||||
result = await reAssignQuestByAbandon(owner, quest_base_info);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<Result> reAssignQuestByAbandon(Player owner, QuestBaseInfo questMetaInfo)
|
||||
{
|
||||
QuestMailInfo mailInfo = new();
|
||||
Document doc = new();
|
||||
var result = new Result();
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
var quest_accept_action = owner.getEntityAction<QuestAcceptAction>();
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var quest_id = questMetaInfo.QuestId;
|
||||
ArgumentNullException.ThrowIfNull(quest_action);
|
||||
ArgumentNullException.ThrowIfNull(quest_accept_action);
|
||||
ArgumentNullException.ThrowIfNull(server_logic);
|
||||
|
||||
|
||||
if (true == questMetaInfo.ForceAccept)
|
||||
{
|
||||
result = await quest_accept_action.reAssignQuest(quest_id, questMetaInfo.QuestRevision);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to reAssignQuest() !!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
ArgumentNullException.ThrowIfNull(quest_mail_action);
|
||||
await quest_mail_action.sendQuestMailsWithTransaction(new List<UInt32>() { quest_id });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_ABANDON(Player owner, Result result, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.QuestAbandonRes = new();
|
||||
ack_packet.Response.QuestAbandonRes.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, questRevision);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.QuestAcceptReq), typeof(QuestAcceptPacketHandler), typeof(GameLoginListener))]
|
||||
public class QuestAcceptPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var owner = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
NullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.QuestAcceptReq;
|
||||
|
||||
(var quest_id, var quest_revision) = QuestHelper.convertUgqQuestIdToQuestIdAndRevision(request.ComposedQuestId);
|
||||
|
||||
var accept_quest_action = owner.getEntityAction<QuestAcceptAction>();
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
|
||||
AcceptQuestVariable accept_quest_var = new();
|
||||
|
||||
var result = await accept_quest_action.acceptQuestConditionCheck(quest_id, accept_quest_var);
|
||||
if(result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_ACCEPT(owner, result, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "AcceptQuest", delegateAcceptQuest);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_ACCEPT(owner, result, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(accept_quest_var.m_new_quest_nullable, () => $"accept_quest_var.m_new_quest_nullable is null !!!");
|
||||
|
||||
var new_quest_attribute = accept_quest_var.m_new_quest_nullable.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(new_quest_attribute);
|
||||
var taskNum = new_quest_attribute.CurrentTaskNum;
|
||||
var quest_meta_infos = QuestNotifyHelper.makeQuestMetaInfoData(new List<UInt32>() { quest_id });
|
||||
send_GS2C_ACK_QUEST_ACCEPT(owner, result, quest_id, quest_revision, taskNum, quest_meta_infos);
|
||||
|
||||
//Send 해주고 체크해야 될것듯
|
||||
if (true == accept_quest_var.m_is_mail_quest)
|
||||
{
|
||||
quest_mail_action.GS2C_NTF_DELETE_QUEST_MAIL_NOTI(quest_id);
|
||||
}
|
||||
|
||||
await QuestNotifyHelper.send_GS2C_NTF_QUEST_UPDATE(owner, quest_id, quest_revision, new(), false);
|
||||
|
||||
await QuestManager.It.QuestCheck(owner, new QuestActiveQuest(EQuestEventTargetType.QUEST, EQuestEventNameType.ACTIVED, quest_id));
|
||||
await quest_mail_action.normalMailActiveCheck();
|
||||
|
||||
return result;
|
||||
|
||||
async Task<Result> delegateAcceptQuest() => await acceptQuest(owner, quest_id, quest_revision, accept_quest_var);
|
||||
|
||||
}
|
||||
|
||||
private async Task<Result> acceptQuest(Player owner, UInt32 questId, UInt32 questRevision, AcceptQuestVariable acceptQuestVar)
|
||||
{
|
||||
var accept_quest_action = owner.getEntityAction<QuestAcceptAction>();
|
||||
var quest_action = owner.getEntityAction<QuestAction>();
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
|
||||
accept_quest_action.makeNewQuestAssignInfo(ref acceptQuestVar);
|
||||
|
||||
if (acceptQuestVar.m_is_mail_quest)
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(acceptQuestVar.m_quest_base_info_nullable, () => $"acceptQuestVar.m_quest_base_info_nullable is null !!!");
|
||||
|
||||
var quest_type = EnumHelper.convertEnumValueStringToEnum(acceptQuestVar.m_quest_base_info_nullable.QuestType, MetaAssets.EQuestType.NORMAL);
|
||||
(var mail_result, var quest_mail) = quest_mail_action.getQuestMail(quest_type, questId);
|
||||
if (mail_result.isFail()) return mail_result;
|
||||
|
||||
var quest_mail_attribute = quest_mail.getEntityAttribute<QuestMailAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attribute, () => $"quest_mail_attribute is null !!!");
|
||||
quest_mail_attribute.deleteEntityAttribute();
|
||||
}
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.QuestMainAssign, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
var log_invoker = new QuestAcceptBusinessLog(questId, questRevision, acceptQuestVar.m_quest_type);
|
||||
batch.appendBusinessLog(log_invoker);
|
||||
|
||||
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(acceptQuestVar.m_new_quest_nullable, () => $"acceptQuestVar.m_new_quest_nullable is null !!!");
|
||||
quest_action.addNewQuest(questId, acceptQuestVar.m_new_quest_nullable);
|
||||
if (true == acceptQuestVar.m_is_mail_quest)
|
||||
{
|
||||
await quest_mail_action.deleteQuestMail(questId, questRevision);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_ACCEPT(Player owner, Result result, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.QuestAcceptRes = new();
|
||||
ack_packet.Response.QuestAcceptRes.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, questRevision);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_ACCEPT(Player owner, Result result, UInt32 questId, UInt32 questRevision, Int32 taskNum, List<QuestMetaInfo> questMetaInfos)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.QuestAcceptRes = new();
|
||||
ack_packet.Response.QuestAcceptRes.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, questRevision);
|
||||
ack_packet.Response.QuestAcceptRes.TaskNum = taskNum;
|
||||
ack_packet.Response.QuestAcceptRes.QuestMetaInfos.AddRange(questMetaInfos);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_NPC_DIALOGUE), typeof(QuestNPCDialoguePacketHandler), typeof(GameLoginListener))]
|
||||
public class QuestNPCDialoguePacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var owner = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
NullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.ReqNPCDialogue;
|
||||
|
||||
var dialogue = request.Dialogue;
|
||||
var dialogue_result = request.DialogueResult;
|
||||
|
||||
var result = new Result();
|
||||
send_GS2C_ACK_NPC_DIALOGUE(owner, result, dialogue, dialogue_result);
|
||||
|
||||
|
||||
var dialogue_action = owner.getEntityAction<QuestNPCDialogueAction>();
|
||||
await dialogue_action.checkQuestDialogue(dialogue, dialogue_result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static bool send_GS2C_ACK_NPC_DIALOGUE(Player owner, Result result, string dialogue, string dialogueResult)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckNPCDialogue = new();
|
||||
ack_packet.Response.AckNPCDialogue.Dialogue = dialogue;
|
||||
ack_packet.Response.AckNPCDialogue.DialogueResult = dialogueResult;
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.QuestRefuseReq), typeof(QuestRefusePacketHandler), typeof(GameLoginListener))]
|
||||
public class QuestRefusePacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
|
||||
var owner = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
NullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.QuestRefuseReq;
|
||||
(var quest_id, var quest_revision) = QuestHelper.convertUgqQuestIdToQuestIdAndRevision(request.ComposedQuestId);
|
||||
|
||||
var quest_refuse_action = owner.getEntityAction<QuestRefuseAction>();
|
||||
var result = await quest_refuse_action.refuseQuestConditionCheck(quest_id);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_REFUSE(owner, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
|
||||
result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "RefuseQuest", delegateRefuseQuest);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_REFUSE(owner, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
send_GS2C_ACK_QUEST_REFUSE(owner, result, quest_id, quest_revision);
|
||||
quest_mail_action.GS2C_NTF_DELETE_QUEST_MAIL_NOTI(quest_id);
|
||||
|
||||
await quest_mail_action.normalMailActiveCheck();
|
||||
return result;
|
||||
|
||||
|
||||
async Task<Result> delegateRefuseQuest() => await refuseQuest(owner, quest_id, quest_revision);
|
||||
}
|
||||
|
||||
private async Task<Result> refuseQuest(Player player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var quest_mail_action = player.getEntityAction<QuestMailAction>();
|
||||
|
||||
|
||||
(var result, var quest_mail) = quest_mail_action.getQuestMail(MetaAssets.EQuestType.NORMAL, questId);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
var quest_mail_attribute = quest_mail.getEntityAttribute<QuestMailAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attribute, () => $"quest_mail_attribute is null !!!");
|
||||
quest_mail_attribute.deleteEntityAttribute();
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestMainRefuse, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLog(new QuestRefuseBusinessLog(questId, questRevision));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if(result.isFail()) return result;
|
||||
|
||||
result = await quest_mail_action.deleteQuestMail(questId, questRevision);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_REFUSE(Player owner, Result result, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.QuestRefuseRes = new();
|
||||
ack_packet.Response.QuestRefuseRes.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, questRevision);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
|
||||
using Guid = System.Guid;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.QuestRewardReq), typeof(QuestRewardPacketHandler), typeof(GameLoginListener))]
|
||||
public class QuestRewardPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var player = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var ugq_reward_action = player.getEntityAction<UgqRewardAction>();
|
||||
await ugq_reward_action.uggDailyRewardRefresh();
|
||||
|
||||
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
NullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.QuestRewardReq;
|
||||
(var quest_id, var quest_revision) = QuestHelper.convertUgqQuestIdToQuestIdAndRevision(request.ComposedQuestId);
|
||||
|
||||
var end_quest_action = player.getEntityAction<EndQuestAction>();
|
||||
var quest_reward_action = player.getEntityAction<QuestRewardAction>();
|
||||
var account_attribute = player.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_attribute, () => $"account_attribute is null !!!");
|
||||
|
||||
QuestRewardHandler quest_reward_handler = new QuestRewardHandler(player, quest_id, quest_revision);
|
||||
await quest_reward_handler.init();
|
||||
|
||||
var result = quest_reward_action.questRewardConditionCheck(ref quest_reward_handler);
|
||||
if(result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_REWARD(player, result);
|
||||
return result;
|
||||
}
|
||||
IReward reward_proc = new RewardQuest(player, player.getUserGuid(), quest_reward_handler);
|
||||
|
||||
//UGQ 반복 진행 시에는 이용자의 이용료 지불과 지급 보상 없음
|
||||
|
||||
CommonResult common_result = new();
|
||||
var fn_quest_reward = async delegate ()
|
||||
{
|
||||
|
||||
var result = await RewardManager.It.proceedRewardProcess(reward_proc);
|
||||
|
||||
|
||||
if (result.isFail()) return result;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestMainReward, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLog(new QuestRewardBusinessLog(quest_id, quest_revision, quest_reward_handler.m_replaced_reward_group_id));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
var found_transaction_runner = player.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
NullReferenceCheckHelper.throwIfNull(found_transaction_runner, () => $"found_transaction_runner is null !!! - {player.toBasicString()}");
|
||||
common_result = found_transaction_runner.getCommonResult();
|
||||
|
||||
if (result.isFail()) return result;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
//퀘스트는 삭제처리, EndQuest에 추가처리, 아이템 추가 처리
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "QuestReward", fn_quest_reward);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
send_GS2C_ACK_QUEST_REWARD(player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
|
||||
//메모리 업데이트
|
||||
NullReferenceCheckHelper.throwIfNull(quest_reward_handler.m_quest, () => $"quest_reward_handler.m_quest is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(quest_reward_handler.m_end_quest, () => $"quest_reward_handler.m_end_quest is null !!!");
|
||||
|
||||
quest_action.removeQuest(quest_reward_handler.m_quest);
|
||||
|
||||
end_quest_action.addEndQuest(quest_reward_handler.m_end_quest);
|
||||
|
||||
//Res 패킷 전달
|
||||
send_GS2C_ACK_QUEST_REWARD(player, result, quest_reward_handler, common_result);
|
||||
|
||||
reward_proc.postRewardProcess();
|
||||
await QuestManager.It.QuestCheck(player, new QuestActiveQuest(EQuestEventTargetType.QUEST, EQuestEventNameType.ENDED, quest_id));
|
||||
//Log.getLogger().debug($"QuestCheck QUEST ENDED Player : {player.getAccountId()}, questId = {quest_id}");
|
||||
|
||||
await QuestManager.It.QuestCheck(player, new QuestReward(EQuestEventTargetType.REWARD, EQuestEventNameType.RECEIVED, quest_reward_handler.m_replaced_reward_group_id));
|
||||
//Log.getLogger().debug($"QuestCheck REWARD RECEIVED Player : {player.getAccountId()}, questId = {quest_id}");
|
||||
|
||||
if (quest_reward_handler.m_ugq_game_data is not null)
|
||||
{
|
||||
var grade_type = quest_reward_handler.m_ugq_game_data.GradeType;
|
||||
var grade_string = QuestHelper.convertUgqGradeToQuestCheckGrade(grade_type);
|
||||
await QuestManager.It.QuestCheck(player, new QuestUgq(EQuestEventTargetType.UGQ, EQuestEventNameType.COMPLETED, grade_string));
|
||||
}
|
||||
|
||||
//퀘스트가 끝나고 다음 퀘스트 진행할게 있으면 처리
|
||||
await quest_reward_action.processAfterReward(quest_reward_handler);
|
||||
await quest_reward_action.normalQuestCheckInitialize();
|
||||
|
||||
await player.send_GS2C_NTF_UGQ_DAILY_REWARD();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_REWARD(Player owner, Result result)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.QuestRewardRes = new();
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_REWARD(Player owner, Result result, QuestRewardHandler questRewardHandler, CommonResult commonResult)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.QuestRewardRes = new();
|
||||
ack_packet.Response.QuestRewardRes.ReplacedRewardGroupId = questRewardHandler.m_replaced_reward_group_id;
|
||||
ack_packet.Response.QuestRewardRes.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questRewardHandler.m_quest_id, questRewardHandler.m_quest_revision);
|
||||
ack_packet.Response.QuestRewardRes.CommonResult = commonResult;
|
||||
|
||||
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_QUEST_TASK_UPDATE), typeof(QuestTaskUpdatePacketHandler), typeof(GameLoginListener))]
|
||||
public class QuestTaskUpdatePacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var player = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
NullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.ReqQuestTaskUpdate;
|
||||
|
||||
string active_event = request.ActiveEvent;
|
||||
(var quest_id, var quest_revision) = QuestHelper.convertUgqQuestIdToQuestIdAndRevision(request.ComposedQuestId);
|
||||
|
||||
QuestTaskUpdateHandler quest_task_update_handler = new QuestTaskUpdateHandler(player, quest_id, quest_revision, active_event);
|
||||
var result = await quest_task_update_handler.init();
|
||||
if (result.isFail())
|
||||
{
|
||||
send_GS2C_ACK_QUEST_TASK_UPDATE_ERROR(player, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_task_update_action = player.getEntityAction<QuestTaskUpdateAction>();
|
||||
result = quest_task_update_action.taskUpdateConditionCheck(ref quest_task_update_handler);
|
||||
if(result.isFail())
|
||||
{
|
||||
//트리거 엔터 2번 호출에 대한 예외 코드 나중에 수정후 삭체 필요
|
||||
if (result.getErrorCode() == ServerErrorCode.QuestMailNotExist)
|
||||
{
|
||||
send_GS2C_ACK_QUEST_TASK_UPDATE_TEMP(player, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
send_GS2C_ACK_QUEST_TASK_UPDATE_ERROR(player, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "QuestTaskUpdate", delegateQuestTaskUpdate);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
send_GS2C_ACK_QUEST_TASK_UPDATE_ERROR(player, result, quest_id, quest_revision);
|
||||
return result;
|
||||
}
|
||||
|
||||
//서버이동 동기화 이슈 때문에 넣어놓는다.
|
||||
await QuestManager.It.checkNotifyByServerChange(player, quest_task_update_handler, active_event);
|
||||
|
||||
//성공 처리
|
||||
send_GS2C_ACK_QUEST_TASK_UPDATE(player, result, quest_task_update_handler);
|
||||
|
||||
var quest_type = quest_task_update_handler.m_quest_type;
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
result = quest_action.getQuest(quest_type, quest_id, out var questInfo);
|
||||
|
||||
if (result.isSuccess())
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(questInfo, () => $"questInfo is null !!!");
|
||||
var quest_attribute = questInfo.getEntityAttribute<QuestAttribute>();
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
// rank 누적 ( ugcNpc 제공 ugq quest 만 )
|
||||
if (quest_attribute.UgqInfo.QuestRevision > 0 && quest_attribute.IsComplete == 1)
|
||||
{
|
||||
var ugq_info_action = player.getEntityAction<UgqInfoAction>();
|
||||
|
||||
(result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(player, quest_attribute.QuestId, quest_attribute.UgqInfo.QuestRevision, quest_attribute.UgqInfo.UqgState);
|
||||
if (result.isFail()) return result;
|
||||
var game_quest_data = quest_meta_all_base_info.m_quest_data_entity;
|
||||
NullReferenceCheckHelper.throwIfNull(game_quest_data, () => $"game_quest_data is null !!!");
|
||||
|
||||
var quest_base_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
if (string.IsNullOrEmpty(game_quest_data.UgcBeaconGuid)) return result;
|
||||
|
||||
var rank_entity = GameServerApp.getServerLogic().findGlobalEntity<UgcNpcRankEntity>();
|
||||
NullReferenceCheckHelper.throwIfNull(rank_entity, () => $"rank_entity is null !!!");
|
||||
var quest_rank_action = rank_entity.getEntityAction<UgcNpcQuestRankAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_rank_action, () => $"quest_rank_action is null !!!");
|
||||
|
||||
await quest_rank_action.setRankScore(player.getUserGuid(), game_quest_data.UserGuid, game_quest_data.UgcBeaconGuid, true);
|
||||
}
|
||||
|
||||
|
||||
if (quest_attribute.IsComplete == 1)
|
||||
{
|
||||
await QuestManager.It.QuestCheck(player, new QuestActiveQuest(EQuestEventTargetType.QUEST, EQuestEventNameType.COMPLETED, quest_id));
|
||||
}
|
||||
|
||||
await QuestManager.It.checkLastFunction(player, quest_task_update_handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (quest_task_update_handler.m_need_counter_check)
|
||||
{
|
||||
QuestTaskUpdateHandler sequential_quest_update_handler = new(player, quest_id, quest_revision, "");
|
||||
result = await sequential_quest_update_handler.init(player, questInfo);
|
||||
if (result.isFail()) return result;
|
||||
IQuest sequential_quest_base = new QuestCount(EQuestEventTargetType.COUNTER, EQuestEventNameType.MAX);
|
||||
await QuestManager.It.QuestSequentialCheck(player, sequential_quest_base, false, sequential_quest_update_handler);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
Task<Result> delegateQuestTaskUpdate() => questTaskUpdate(player, quest_task_update_handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task<Result> questTaskUpdate(Player player, QuestTaskUpdateHandler questTaskUpdateDataRef)
|
||||
{
|
||||
var quest_task_update_action = player.getEntityAction<QuestTaskUpdateAction>();
|
||||
var result = await quest_task_update_action.questTaskUpdate(questTaskUpdateDataRef);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestTaskUpdate, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
List<ItemBase> delete_items = new();
|
||||
|
||||
foreach (var item in questTaskUpdateDataRef.m_deleted_items)
|
||||
{
|
||||
delete_items.Add(item as ItemBase);
|
||||
}
|
||||
batch.appendBusinessLog(new QuestTaskUpdateBusinessLog(questTaskUpdateDataRef));
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
var found_transaction_runner = player.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
NullReferenceCheckHelper.throwIfNull(found_transaction_runner, () => $"found_transaction_runner is null !!! - {player.toBasicString()}");
|
||||
var common_result = found_transaction_runner.getCommonResult();
|
||||
questTaskUpdateDataRef.m_common_result = common_result;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_TASK_UPDATE(Player owner, Result result, QuestTaskUpdateHandler? questTaskUpdateHandler = null)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.getErrorCode();
|
||||
ack_packet.Response.AckQuestTaskUpdate = new();
|
||||
|
||||
if (questTaskUpdateHandler != null)
|
||||
{
|
||||
ack_packet.Response.AckQuestTaskUpdate.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questTaskUpdateHandler.m_quest_id, questTaskUpdateHandler.m_quest_revision);
|
||||
|
||||
var quest = questTaskUpdateHandler.m_quest;
|
||||
NullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
ack_packet.Response.AckQuestTaskUpdate.ActiveEventList.AddRange(quest_attribute.ActiveEvents);
|
||||
ack_packet.Response.AckQuestTaskUpdate.HasCounter = quest_attribute.HasCounter;
|
||||
ack_packet.Response.AckQuestTaskUpdate.CurrentCounter = quest_attribute.CurrentCounter;
|
||||
ack_packet.Response.AckQuestTaskUpdate.CurrentTaskNum = quest_attribute.CurrentTaskNum;
|
||||
ack_packet.Response.AckQuestTaskUpdate.CommonResult = questTaskUpdateHandler.m_common_result;
|
||||
|
||||
}
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_TASK_UPDATE_ERROR(Player owner, Result result, UInt32 questId, UInt32 quuestRevision)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.getErrorCode();
|
||||
ack_packet.Response.AckQuestTaskUpdate = new();
|
||||
ack_packet.Response.AckQuestTaskUpdate.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, quuestRevision);
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_QUEST_TASK_UPDATE_TEMP(Player owner, Result result, UInt32 questId, UInt32 quuestRevision)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.getErrorCode();
|
||||
//ack_packet.Response.AckQuestTaskUpdate = new();
|
||||
//ack_packet.Response.AckQuestTaskUpdate.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, quuestRevision);
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_NTF_QUEST_TASK_REWARD(Player owner, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var rewarded_items = questTaskUpdateHandler.m_rewarded_items;
|
||||
var rewarded_money = questTaskUpdateHandler.m_rewarded_money;
|
||||
|
||||
|
||||
|
||||
ClientToGame ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.NtfQuestTaskReward = new ClientToGameMessage.Types.GS2C_NTF_QUEST_TASK_REWARD();
|
||||
//var items = RewardManager.Instance.convertItemAndMoneyToItem(rewarded_items, rewarded_money);
|
||||
//ntf_packet.Message.NtfQuestTaskReward.RewardItems.AddRange(items);
|
||||
|
||||
ntf_packet.Message.NtfQuestTaskReward.CommonResult = questTaskUpdateHandler.m_common_result;
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ntf_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_NTF_QUEST_TASK_REMOVED_ITEMS(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var deleted_items = questTaskUpdateHandler.m_deleted_items;
|
||||
if(deleted_items.Count == 0) return true;
|
||||
|
||||
var inventory_action = player.getEntityAction<InventoryActionBase>();
|
||||
|
||||
foreach (var item in deleted_items)
|
||||
{
|
||||
ClientToGame clientToGame = new();
|
||||
clientToGame.Response = new();
|
||||
clientToGame.Response.RemoveItemsRes = new();
|
||||
|
||||
var itemMeta = item.getItemMeta();
|
||||
NullReferenceCheckHelper.throwIfNull(itemMeta, () => $"itemMeta is null !!!");
|
||||
|
||||
(var result, _, var bag_tab_type) = inventory_action.toBagTypeAndTabType(itemMeta);
|
||||
clientToGame.Response.RemoveItemsRes.Index = (int)bag_tab_type + 1;
|
||||
clientToGame.Response.RemoveItemsRes.Item.Add(item.toItemData4Client());
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, clientToGame))
|
||||
{
|
||||
Log.getLogger().error($"m_deletable_items onSendPacket fail item_id : {JsonConvert.SerializeObject(item)} ref : {JsonConvert.SerializeObject(questTaskUpdateHandler)}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.ReadQuestMailReq), typeof(ReadQuestMailPacketHandler), typeof(GameLoginListener))]
|
||||
public class ReadQuestMailPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var owner = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var recv_msg = recvMessage as ClientToGame;
|
||||
NullReferenceCheckHelper.throwIfNull(recv_msg, () => $"recv_msg is null !!!");
|
||||
var request = recv_msg.Request.ReadQuestMailReq;
|
||||
|
||||
(var quest_id, var quest_revision) = QuestHelper.convertUgqQuestIdToQuestIdAndRevision(request.ComposedQuestId);
|
||||
|
||||
var result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "ReadQuestMail", delegateReadQuestMail);
|
||||
if (result.isFail())
|
||||
{
|
||||
string err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
send_GS2C_ACK_READ_QUEST_MAIL(owner, result);
|
||||
return result;
|
||||
|
||||
async Task<Result> delegateReadQuestMail() => await readQuestMail(owner, quest_id, quest_revision);
|
||||
}
|
||||
|
||||
private async Task<Result> readQuestMail(Player owner, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var quest_mail_action = owner.getEntityAction<QuestMailAction>();
|
||||
var result = await quest_mail_action.readQuestMail(questId, questRevision);
|
||||
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.None
|
||||
, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"holdFriendFolder fail. {result.ErrorCode}");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool send_GS2C_ACK_READ_QUEST_MAIL(Player owner, Result result)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.ReadQuestMailRes = new();
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
208
GameServer/Contents/Quest/QuestCheat.cs
Normal file
208
GameServer/Contents/Quest/QuestCheat.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
[ChatCommandAttribute("questreset", typeof(ChatCommandQuestReset), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandQuestReset : ChatCommandBase
|
||||
{
|
||||
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
await quest_action.cheatResetAllQuests();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[ChatCommandAttribute("questaccept", typeof(ChatCommandQuestAccept), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandQuestAccept : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
Log.getLogger().error($"Invalid Argument");
|
||||
return;
|
||||
}
|
||||
if (false == uint.TryParse(args[0], out var questId))
|
||||
{
|
||||
Log.getLogger().error($"HandleQuestAccept param parsing Error args : {args[0]}");
|
||||
return;
|
||||
}
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
await quest_action.cheatAcceptQuest(questId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[ChatCommandAttribute("questcomplete", typeof(ChatCommandQuestComplete), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandQuestComplete : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
Log.getLogger().error($"Invalid Argument");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uint.TryParse(args[0], out var questId))
|
||||
{
|
||||
Log.getLogger().error($"questcomplete param parsing Error args : {args[0]}");
|
||||
return;
|
||||
}
|
||||
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
|
||||
await quest_action.questComplete(questId);
|
||||
}
|
||||
}
|
||||
|
||||
[ChatCommandAttribute("questmailsend", typeof(ChatCommandQuestMailSend), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandQuestMailSend : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
Log.getLogger().error($"Invalid Argument");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uint.TryParse(args[0], out var questId))
|
||||
{
|
||||
Log.getLogger().error($"questmailsend param parsing Error args : {args[0]}");
|
||||
return;
|
||||
}
|
||||
|
||||
var quest_mail_action = player.getEntityAction<QuestCheatAction>();
|
||||
await quest_mail_action.cheatSendQuestMail(questId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[ChatCommandAttribute("methodtest", typeof(ChatCommandMethodTest), AuthAdminLevelType.Developer)]
|
||||
internal class ChatCommandMethodTest : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
|
||||
var arg = args[0];
|
||||
|
||||
var id = int.Parse(args[0]);
|
||||
|
||||
if (id == 1)
|
||||
{
|
||||
|
||||
// var packet = new ClientToGame();
|
||||
// packet.Request = new ClientToGameReq();
|
||||
// var req_msg = new ClientToGameReq.Types.C2GS_REQ_JOIN_BATTLE_INSTANCE();
|
||||
// packet.Request.ReqJoinBattleInstance = req_msg;
|
||||
//
|
||||
// packet.Request.ReqJoinBattleInstance.EventId = 13;
|
||||
|
||||
|
||||
// var packet = new ClientToGame();
|
||||
// packet.Request = new ClientToGameReq();
|
||||
// var req_msg = new ClientToGameReq.Types.C2GS_REQ_BATTLE_PLAYER_DEATH();
|
||||
// packet.Request.ReqBattlePlayerDeath = req_msg;
|
||||
//
|
||||
// packet.Request.ReqBattlePlayerDeath.KillerGuid = 13;
|
||||
//
|
||||
// var result = await GameServerApp.getServerLogic().onCallProtocolHandler(player, packet);
|
||||
// if (result.isFail())
|
||||
// {
|
||||
// //err_msg = $"Failed to onCallProtocolHandler() !!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
// //Log.getLogger().error(err_msg);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
else if (id == 2)
|
||||
{
|
||||
// var server_logic = GameServerApp.getServerLogic();
|
||||
// var systemMailManager = server_logic.getSystemMailManager();
|
||||
// await systemMailManager.CheatFuncSaveSystemMetaMail();
|
||||
}
|
||||
else if (id == 3)
|
||||
{
|
||||
// var server_logic = GameServerApp.getServerLogic();
|
||||
// var cToG_req = new ClientToGame();
|
||||
// cToG_req.Request = new();
|
||||
// cToG_req.Request.ChatReq = new();
|
||||
//
|
||||
//
|
||||
// cToG_req.Request.ChatReq.Message = "AAAAAAAAABBBBBBBBCCCCCCCCCCCCDDDDDDD";
|
||||
// cToG_req.Request.ChatReq.Type = ChatType.Normal;
|
||||
// cToG_req.Request.ChatReq.ToNickName = "khlee103";
|
||||
//
|
||||
// ClientToGameReq.Types.ChatReq req_temp = new();
|
||||
//
|
||||
// //여기서 쪼개서 테스트
|
||||
// var byte_string = cToG_req.ToByteString();
|
||||
// byte[] byteArray = byte_string.ToByteArray();
|
||||
//
|
||||
// int chunkSize = 14;
|
||||
// int numberOfChunks = (int)Math.Ceiling((double)byteArray.Length / chunkSize);
|
||||
//
|
||||
// var uid = KeyGeneration.GenerateRandomKey(20);
|
||||
// var otp_encoding_by_base32 = Base32Encoding.ToString(uid);
|
||||
// List<IMessage> msgs = new();
|
||||
// for (int i = 0; i < numberOfChunks; i++)
|
||||
// {
|
||||
// int startIndex = i * chunkSize;
|
||||
// int length = Math.Min(chunkSize, byteArray.Length - startIndex);
|
||||
//
|
||||
// byte[] chunk = new byte[length];
|
||||
// Array.Copy(byteArray, startIndex, chunk, 0, length);
|
||||
//
|
||||
// ByteString chunkByteString = ByteString.CopyFrom(chunk);
|
||||
//
|
||||
// var cToG = new ClientToGame();
|
||||
// cToG.Request = new();
|
||||
// cToG.Request.ReqLargePacket = new();
|
||||
//
|
||||
// cToG.Request.ReqLargePacket.PacketIndex = i;
|
||||
// cToG.Request.ReqLargePacket.Uid = otp_encoding_by_base32;
|
||||
// cToG.Request.ReqLargePacket.Data = chunkByteString;
|
||||
// cToG.Request.ReqLargePacket.TotalPacketCount = numberOfChunks;
|
||||
// var chunk_msg = cToG as IMessage;
|
||||
// msgs.Add(chunk_msg);
|
||||
// }
|
||||
//
|
||||
// foreach (var msg in msgs)
|
||||
// {
|
||||
// await server_logic.onCallLargeSizeProtocolHandler(player, msg);
|
||||
//}
|
||||
}
|
||||
else if (id == 4)
|
||||
{
|
||||
//13번 숍
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var cToG_req = new ClientToGame();
|
||||
cToG_req.Request = new();
|
||||
cToG_req.Request.GetShopProductListReq = new();
|
||||
cToG_req.Request.GetShopProductListReq.ShopID = 13;
|
||||
await server_logic.onCallProtocolHandler(player, cToG_req);
|
||||
|
||||
// var cToG_req_renewal = new ClientToGame();
|
||||
// cToG_req_renewal.Request = new();
|
||||
// cToG_req_renewal.Request.ReqRenewalShopProducts = new();
|
||||
//
|
||||
//
|
||||
// cToG_req_renewal.Request.ReqRenewalShopProducts.ShopID = 13;
|
||||
// await server_logic.onCallProtocolHandler(player, cToG_req_renewal);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
14
GameServer/Contents/Quest/QuestChecker/IQuest.cs
Normal file
14
GameServer/Contents/Quest/QuestChecker/IQuest.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public interface IQuest
|
||||
{
|
||||
bool checkValidTaskScript(QuestAttribute questAttribute, QuestTaskUpdateHandler questTaskUpdateHandler);
|
||||
|
||||
Result questTaskFunctionProgress(Player player, ref QuestTaskUpdateHandler questTaskUpdateHandler);
|
||||
Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler);
|
||||
|
||||
}
|
||||
}
|
||||
18
GameServer/Contents/Quest/QuestChecker/QuestActiveQuest.cs
Normal file
18
GameServer/Contents/Quest/QuestChecker/QuestActiveQuest.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestActiveQuest : QuestBase
|
||||
{
|
||||
public QuestActiveQuest(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, UInt32 questId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = questId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
GameServer/Contents/Quest/QuestChecker/QuestAvatarProfile.cs
Normal file
12
GameServer/Contents/Quest/QuestChecker/QuestAvatarProfile.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestAvatarProfile : QuestBase
|
||||
{
|
||||
public QuestAvatarProfile(EQuestEventTargetType targetType, EQuestEventNameType eventNameType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
215
GameServer/Contents/Quest/QuestChecker/QuestBase.cs
Normal file
215
GameServer/Contents/Quest/QuestChecker/QuestBase.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using Amazon.DynamoDBv2.Model.Internal.MarshallTransformations;
|
||||
using GameServer;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MetaAssets;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Intrinsics.Arm;
|
||||
|
||||
// TODO: spooky000 테이블 코드 교체 작업으로 인해 현재 안 쓰는 코드는 주석 처리해 둠.
|
||||
// questTaskFunctionProgress 함수 호출되지 않아 reward 관련 코드 주석 처리.
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public abstract class QuestBase : IQuest
|
||||
{
|
||||
public EQuestEventTargetType m_target_type;
|
||||
public EQuestEventNameType m_name_type;
|
||||
|
||||
public int m_request_idx { get; set; }
|
||||
public string m_active_event_string { get; set; } = string.Empty;
|
||||
public string m_condition_1 { get; set; } = string.Empty;
|
||||
public string m_condition_2 { get; set; } = string.Empty;
|
||||
public string m_condition_3 { get; set; } = string.Empty;
|
||||
|
||||
public QuestBase(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int requestIdx, string cond1, string cond2, string cond3)
|
||||
{
|
||||
m_target_type = targetType;
|
||||
m_name_type = eventNameType;
|
||||
|
||||
m_request_idx = requestIdx;
|
||||
m_condition_1 = cond1;
|
||||
m_condition_2 = cond2;
|
||||
m_condition_3 = cond3;
|
||||
}
|
||||
|
||||
public QuestBase(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string eventString, string cond1, string cond2, string cond3)
|
||||
{
|
||||
m_target_type = targetType;
|
||||
m_name_type = eventNameType;
|
||||
|
||||
m_active_event_string = eventString;
|
||||
m_condition_1 = cond1;
|
||||
m_condition_2 = cond2;
|
||||
m_condition_3 = cond3;
|
||||
}
|
||||
|
||||
|
||||
public virtual bool checkValidTaskScript(QuestAttribute questAttribute, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var quest_task = questTaskUpdateHandler.m_quest_task_group;
|
||||
var event_string = questTaskUpdateHandler.m_active_event;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_task, () => $"quest_task is null !!!");
|
||||
|
||||
var result = QuestMetaHelper.getQuestTaskEventGroupByEventString(quest_task, event_string, out var events);
|
||||
if (result.isFail()) return false;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(events, () => $"events is null !!!");
|
||||
|
||||
if (!events.EventTarget.Equals(m_target_type.ToString()) || !events.EventName.Equals(m_name_type.ToString())) return false;
|
||||
|
||||
bool subCheck = checkSubValidTaskScript(questAttribute, events);
|
||||
return subCheck;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events) { return true; }
|
||||
|
||||
public virtual async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return new Result();
|
||||
}
|
||||
|
||||
|
||||
public virtual Result questTaskFunctionProgress(Player player, ref QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var quest_action = player.getEntityAction<QuestAction>();
|
||||
var quest_id = questTaskUpdateHandler.m_quest_id;
|
||||
|
||||
var quest = questTaskUpdateHandler.m_quest;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest, () => $"quest is null !!!");
|
||||
|
||||
var quest_attribute = quest.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!!");
|
||||
|
||||
var active_evnet = questTaskUpdateHandler.m_active_event;
|
||||
var quest_task_group = questTaskUpdateHandler.m_quest_task_group;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(quest_task_group, () => $"quest_task_group is null !!!");
|
||||
|
||||
var result = QuestMetaHelper.getQuestTaskEventGroupByEventString(quest_task_group, active_evnet, out var questEventInfo);
|
||||
if(result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(questEventInfo, () => $"questEventInfo is null !!!");
|
||||
|
||||
result = functionCheck(player, questEventInfo, quest_attribute, ref questTaskUpdateHandler);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
quest_attribute.ActiveEvents.Remove(active_evnet);
|
||||
|
||||
//패러럴일경우 문자열을 가지고 있는다.
|
||||
if (quest_task_group.EventStringList.Count >= 2)
|
||||
{
|
||||
string str = MetaData.Instance.makeEventScriptStringByEventInfo(questEventInfo);
|
||||
quest_attribute.CompletedIdxStrings.Add(str);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Result functionCheck(Player player, QuestEventInfo questEventInfo, QuestAttribute quest_attribute, ref QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
foreach (var funcInfo in questEventInfo.QuestEventFunctionList)
|
||||
{
|
||||
if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.QUEST)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.COMPLETE)))
|
||||
{
|
||||
quest_attribute.IsComplete = true ? 1 : 0;
|
||||
quest_attribute.ActiveEvents.Clear();
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.COUNTER)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.INCREASE)))
|
||||
{
|
||||
int counter = int.Parse(funcInfo.FunctionCondition1);
|
||||
quest_attribute.CurrentCounter += counter;
|
||||
|
||||
questTaskUpdateHandler.m_need_counter_check = true;
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.TASK)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.COMPLETE)))
|
||||
{
|
||||
quest_attribute.CurrentTaskComplete = 1;
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.TASK)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.ACTIVE)))
|
||||
{
|
||||
questTaskUpdateHandler.m_next_task_number = int.Parse(funcInfo.FunctionCondition1);
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.REWARD)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.SET)))
|
||||
{
|
||||
quest_attribute.ReplacedRewardGroupId = int.Parse(funcInfo.FunctionCondition1);
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.TIMER)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.START)))
|
||||
{
|
||||
quest_attribute.HasTimer = 1;
|
||||
if (long.TryParse(funcInfo.FunctionCondition1, out long elapsedTime) == false)
|
||||
{
|
||||
Log.getLogger().error($"{funcInfo.FunctionCondition1} is not number");
|
||||
elapsedTime = 10000000;
|
||||
}
|
||||
DateTime now = DateTime.UtcNow;
|
||||
quest_attribute.TimerCompleteTime = now.AddSeconds(elapsedTime);
|
||||
QuestManager.It.m_timer_check_users.TryAdd(player.getUserGuid(), string.Empty);
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.ITEM)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.GIVE)))
|
||||
{
|
||||
(result, var reward) = RewardManager.It.makeRewardFromItemStr(funcInfo.FunctionCondition1, funcInfo.FunctionCondition2);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(reward, () => $"reward is null !!!");
|
||||
questTaskUpdateHandler.m_rewards.Add(reward);
|
||||
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.ITEM)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.DELETE)))
|
||||
{
|
||||
if (false == int.TryParse(funcInfo.FunctionCondition1, out int delete_item_id))
|
||||
{
|
||||
string err_msg = $"delete item id is not number : {funcInfo.FunctionCondition1}";
|
||||
result.setFail(ServerErrorCode.ItemParsingFromStringToIntErorr, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
if (false == int.TryParse(funcInfo.FunctionCondition2, out int delete_item_cnt))
|
||||
{
|
||||
string err_msg = $"delete item id is not number : {funcInfo.FunctionCondition2}";
|
||||
result.setFail(ServerErrorCode.ItemParsingFromStringToIntErorr, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
questTaskUpdateHandler.m_deletable_items.TryAdd(delete_item_id, delete_item_cnt);
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.REWARD)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.GIVE)))
|
||||
{
|
||||
(var resutlt, var reward_metas) = RewardManager.It.makeRewardsInfo(funcInfo.FunctionCondition1);
|
||||
if (resutlt.isFail())
|
||||
{
|
||||
return resutlt;
|
||||
}
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(reward_metas, () => $"reward_metas is null !!!");
|
||||
|
||||
foreach (var meta in reward_metas)
|
||||
{
|
||||
questTaskUpdateHandler.m_rewards.Add(meta.Reward);
|
||||
}
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.QUEST)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.ASSIGN)))
|
||||
{
|
||||
questTaskUpdateHandler.m_last_check_functions.Add(funcInfo);
|
||||
}
|
||||
else if (funcInfo.FunctionTarget.Equals(nameof(EQuestFunctionTargetType.PROP)) && funcInfo.FunctionName.Equals(nameof(EQuestFunctionNameType.SWITCH)))
|
||||
{
|
||||
questTaskUpdateHandler.m_last_check_functions.Add(funcInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
GameServer/Contents/Quest/QuestChecker/QuestBuff.cs
Normal file
25
GameServer/Contents/Quest/QuestChecker/QuestBuff.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestBuff : QuestBase
|
||||
{
|
||||
public QuestBuff(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int buffId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = buffId.ToString();
|
||||
}
|
||||
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
23
GameServer/Contents/Quest/QuestChecker/QuestChair.cs
Normal file
23
GameServer/Contents/Quest/QuestChecker/QuestChair.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestChair : QuestBase
|
||||
{
|
||||
public QuestChair(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int tableId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = tableId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
GameServer/Contents/Quest/QuestChecker/QuestChannel.cs
Normal file
11
GameServer/Contents/Quest/QuestChecker/QuestChannel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer.Quest
|
||||
{
|
||||
public class QuestChannel : QuestBase
|
||||
{
|
||||
public QuestChannel(EQuestEventTargetType targetType, EQuestEventNameType eventNameType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
21
GameServer/Contents/Quest/QuestChecker/QuestChat.cs
Normal file
21
GameServer/Contents/Quest/QuestChecker/QuestChat.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestChat : QuestBase
|
||||
{
|
||||
public QuestChat(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string chatType, string msg) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = chatType;
|
||||
m_condition_2 = msg;
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (!events.EventCondition1.Equals(m_condition_1)) return false;
|
||||
|
||||
if (m_condition_2.ToUpper().Contains(events.EventCondition2.ToUpper())) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
GameServer/Contents/Quest/QuestChecker/QuestClaim.cs
Normal file
24
GameServer/Contents/Quest/QuestChecker/QuestClaim.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestClaim : QuestBase
|
||||
{
|
||||
public QuestClaim(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string type) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = type;
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1) || events.EventCondition1.Equals("ALL")) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
GameServer/Contents/Quest/QuestChecker/QuestClientSide.cs
Normal file
15
GameServer/Contents/Quest/QuestChecker/QuestClientSide.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestClientSide : QuestBase
|
||||
{
|
||||
public QuestClientSide(Player owner) : base(EQuestEventTargetType.NONE, EQuestEventNameType.NONE, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
24
GameServer/Contents/Quest/QuestChecker/QuestConcert.cs
Normal file
24
GameServer/Contents/Quest/QuestChecker/QuestConcert.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestConcert : QuestBase
|
||||
{
|
||||
public QuestConcert(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int concertId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = concertId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
88
GameServer/Contents/Quest/QuestChecker/QuestCostume.cs
Normal file
88
GameServer/Contents/Quest/QuestChecker/QuestCostume.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System.Text.Json;
|
||||
using static ClientToGameReq.Types;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestCostume : QuestBase
|
||||
{
|
||||
ClothInfo changedClothInfo = new();
|
||||
public QuestCostume(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, ClothInfo cloth) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
Log.getLogger().debug($"QuestCostume Constructor Call", JsonConvert.SerializeObject(cloth));
|
||||
changedClothInfo = cloth.Clone();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
/*
|
||||
cloth_avatar = 5;
|
||||
cloth_headwear = 6;
|
||||
cloth_mask = 7;
|
||||
cloth_bag = 8;
|
||||
cloth_shoes = 9;
|
||||
cloth_outer = 10;
|
||||
cloth_tops = 11;
|
||||
cloth_bottoms = 12;
|
||||
cloth_gloves = 13;
|
||||
cloth_earrings = 14;
|
||||
cloth_neckless = 15;
|
||||
cloth_socks = 16;
|
||||
*/
|
||||
if (events.EventCondition1.Equals(ClothSlotType.Avatar.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothAvatar) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Headwear.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothHeadwear) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Mask.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothMask) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Bag.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothBag) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Shoes.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothShoes) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Outer.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothOuter) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Tops.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothTops) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Bottoms.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothBottoms) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Gloves.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothGloves) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Earrings.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothEarrings) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Neckless.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothNeckless) return true;
|
||||
}
|
||||
else if (events.EventCondition1.Equals(ClothSlotType.Socks.ToString().ToUpper()))
|
||||
{
|
||||
if (int.Parse(events.EventCondition2) == changedClothInfo.ClothSocks) return true;
|
||||
}
|
||||
|
||||
Log.getLogger().error($"{events.EventCondition1} does Not Match");
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
19
GameServer/Contents/Quest/QuestChecker/QuestCount.cs
Normal file
19
GameServer/Contents/Quest/QuestChecker/QuestCount.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestCount : QuestBase
|
||||
{
|
||||
public QuestCount(EQuestEventTargetType targetType, EQuestEventNameType eventNameType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (questAttribute.MaxCounter <= questAttribute.CurrentCounter) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
GameServer/Contents/Quest/QuestChecker/QuestCrafting.cs
Normal file
19
GameServer/Contents/Quest/QuestChecker/QuestCrafting.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
public class QuestCrafting : QuestBase
|
||||
{
|
||||
public QuestCrafting(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, Int32 craftingId) : base(targetType, eventNameType, 0, craftingId.ToString(), string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
23
GameServer/Contents/Quest/QuestChecker/QuestDressRoom.cs
Normal file
23
GameServer/Contents/Quest/QuestChecker/QuestDressRoom.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestDressRoom : QuestBase
|
||||
{
|
||||
public QuestDressRoom(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string enterType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = enterType;
|
||||
}
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
GameServer/Contents/Quest/QuestChecker/QuestEmpty.cs
Normal file
32
GameServer/Contents/Quest/QuestChecker/QuestEmpty.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using GameServer;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
//치트용을 위한 클래스 추후 구조개선때 수정 필요
|
||||
public class QuestEmpty : QuestBase
|
||||
{
|
||||
public QuestEmpty() : base(EQuestEventTargetType.NONE, EQuestEventNameType.NONE, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool checkValidTaskScript(QuestAttribute questAttribute, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
GameServer/Contents/Quest/QuestChecker/QuestFarming.cs
Normal file
22
GameServer/Contents/Quest/QuestChecker/QuestFarming.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestFarming : QuestBase
|
||||
{
|
||||
public QuestFarming(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string farmingPropId, string entityType) : base(targetType, eventNameType, 0, farmingPropId, entityType, string.Empty)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1) && events.EventCondition2.Equals(m_condition_2)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
17
GameServer/Contents/Quest/QuestChecker/QuestFriend.cs
Normal file
17
GameServer/Contents/Quest/QuestChecker/QuestFriend.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestFriend : QuestBase
|
||||
{
|
||||
public QuestFriend(EQuestEventTargetType targetType, EQuestEventNameType eventNameType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
GameServer/Contents/Quest/QuestChecker/QuestInstance.cs
Normal file
35
GameServer/Contents/Quest/QuestChecker/QuestInstance.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestInstance : QuestBase
|
||||
{
|
||||
public QuestInstance(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int landId, int floorId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = landId.ToString();
|
||||
m_condition_2 = floorId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
switch (m_name_type)
|
||||
{
|
||||
case EQuestEventNameType.ENTERED:
|
||||
if (events.EventCondition1.Equals(m_condition_1) && events.EventCondition2.Equals(m_condition_2)) return true;
|
||||
break;
|
||||
case EQuestEventNameType.EXITED:
|
||||
if (events.EventCondition2.Equals(m_condition_2)) return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
GameServer/Contents/Quest/QuestChecker/QuestInteriroMode.cs
Normal file
37
GameServer/Contents/Quest/QuestChecker/QuestInteriroMode.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestInteriroMode : QuestBase
|
||||
{
|
||||
private Int32 m_count = 0;
|
||||
public QuestInteriroMode(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string typeName, int count) : base(targetType, eventNameType, 0, typeName, count.ToString(), string.Empty)
|
||||
{
|
||||
m_count = count;
|
||||
if (count == 0)
|
||||
{
|
||||
m_condition_2 = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
|
||||
if (false == events.EventCondition1.Equals(m_condition_1)) return false;
|
||||
if(events.EventCondition2.Equals(string.Empty)) return true;
|
||||
|
||||
if (false == int.TryParse(events.EventCondition2, out var cond2)) return false;
|
||||
if (cond2 > m_count) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
36
GameServer/Contents/Quest/QuestChecker/QuestItem.cs
Normal file
36
GameServer/Contents/Quest/QuestChecker/QuestItem.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestItem : QuestBase
|
||||
{
|
||||
List<int> m_item_ids = new List<int>();
|
||||
public QuestItem(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int itemId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_item_ids = new List<int>();
|
||||
m_item_ids.Add(itemId);
|
||||
}
|
||||
|
||||
public QuestItem(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, List<int> itemIds) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_item_ids = new List<int>();
|
||||
m_item_ids.AddRange(itemIds);
|
||||
}
|
||||
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
foreach (int itemId in m_item_ids)
|
||||
{
|
||||
if (events.EventCondition3.Equals(itemId.ToString())) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
GameServer/Contents/Quest/QuestChecker/QuestMail.cs
Normal file
26
GameServer/Contents/Quest/QuestChecker/QuestMail.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using ServerCommon;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestMail : QuestBase
|
||||
{
|
||||
public QuestMail(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string msg) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = msg;
|
||||
}
|
||||
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
switch (m_name_type)
|
||||
{
|
||||
case EQuestEventNameType.RECEIVED:
|
||||
return true;
|
||||
case EQuestEventNameType.SENDED:
|
||||
if (m_condition_1.Contains(events.EventCondition1)) return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
GameServer/Contents/Quest/QuestChecker/QuestMannequin.cs
Normal file
30
GameServer/Contents/Quest/QuestChecker/QuestMannequin.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestMannequin : QuestBase
|
||||
{
|
||||
List<int> m_items = new List<int>();
|
||||
public QuestMannequin(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, List<int> items) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_items = items;
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (!int.TryParse(events.EventCondition2, out var itemId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_items.Contains(itemId)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
GameServer/Contents/Quest/QuestChecker/QuestMyHome.cs
Normal file
30
GameServer/Contents/Quest/QuestChecker/QuestMyHome.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestMyHome : QuestBase
|
||||
{
|
||||
public QuestMyHome(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string type) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = type;
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
GameServer/Contents/Quest/QuestChecker/QuestParty.cs
Normal file
22
GameServer/Contents/Quest/QuestChecker/QuestParty.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestParty : QuestBase
|
||||
{
|
||||
public QuestParty(EQuestEventTargetType targetType, EQuestEventNameType eventNameType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
GameServer/Contents/Quest/QuestChecker/QuestProp.cs
Normal file
24
GameServer/Contents/Quest/QuestChecker/QuestProp.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestProp : QuestBase
|
||||
{
|
||||
public QuestProp(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int itemId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = itemId.ToString();
|
||||
}
|
||||
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
GameServer/Contents/Quest/QuestChecker/QuestRentalVisit.cs
Normal file
34
GameServer/Contents/Quest/QuestChecker/QuestRentalVisit.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Concurrent;
|
||||
using GameServer;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
public class QuestRentalVisit : QuestBase
|
||||
{
|
||||
private string m_pair_guid { get; set; } = string.Empty;
|
||||
private RentalInstanceVisitAttribute m_attribute_nullable { get; }
|
||||
|
||||
public QuestRentalVisit(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string myhomeGuid, string ownerGuid, RentalInstanceVisitAttribute attribute) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_pair_guid = myhomeGuid + ":" + ownerGuid;
|
||||
m_attribute_nullable = attribute;
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (true == m_attribute_nullable.m_rental_instance_visit.ContainsKey(m_pair_guid)) return false;
|
||||
|
||||
var now = DateTimeHelper.Current;
|
||||
m_attribute_nullable.m_rental_instance_visit.AddOrUpdate(m_pair_guid, now, (key, old) => now);
|
||||
m_attribute_nullable.modifiedEntityAttribute(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
return await QuestNotifyHelper.sendRedisQuestNotifyRequest(player, questTaskUpdateHandler);
|
||||
}
|
||||
}
|
||||
23
GameServer/Contents/Quest/QuestChecker/QuestReward.cs
Normal file
23
GameServer/Contents/Quest/QuestChecker/QuestReward.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestReward : QuestBase
|
||||
{
|
||||
public QuestReward(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int rewardGroupId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = rewardGroupId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
GameServer/Contents/Quest/QuestChecker/QuestSocialAction.cs
Normal file
23
GameServer/Contents/Quest/QuestChecker/QuestSocialAction.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class QuestSocialAction : QuestBase
|
||||
{
|
||||
public QuestSocialAction(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int socialActionId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = socialActionId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
GameServer/Contents/Quest/QuestChecker/QuestTaskActive.cs
Normal file
19
GameServer/Contents/Quest/QuestChecker/QuestTaskActive.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestTaskActive : QuestBase
|
||||
{
|
||||
public QuestTaskActive(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int taskId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = taskId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
GameServer/Contents/Quest/QuestChecker/QuestTaskReward.cs
Normal file
39
GameServer/Contents/Quest/QuestChecker/QuestTaskReward.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using GameServer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer;
|
||||
public class QuestTaskReward : RewardBase
|
||||
{
|
||||
QuestTaskUpdateHandler m_quest_task_update_handler;
|
||||
public QuestTaskReward(Player player, string userGuid, QuestTaskUpdateHandler questTaskUpdateHandler) : base(player, userGuid, questTaskUpdateHandler.m_rewards)
|
||||
{
|
||||
m_quest_task_update_handler = questTaskUpdateHandler;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// 보상전 처리해야되는 것들 처리
|
||||
//=====================================================================================
|
||||
public override Task<Result> prepareReward()
|
||||
{
|
||||
var result = new Result();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// 보상처리 후 필요한 로직들 처리
|
||||
//=====================================================================================
|
||||
public override Task<Result> finalizeReward()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
m_quest_task_update_handler.m_rewarded_money.AddRange(getRewardedMoneys());
|
||||
m_quest_task_update_handler.m_rewarded_items.AddRange(getRewardedItems());
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
}
|
||||
37
GameServer/Contents/Quest/QuestChecker/QuestTaskSave.cs
Normal file
37
GameServer/Contents/Quest/QuestChecker/QuestTaskSave.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestTaskSave : RewardBase
|
||||
{
|
||||
public QuestTaskSave(Player player, string userGuid, List<MetaAssets.RewardMetaData> rewarDatas) : base(player, userGuid)
|
||||
{
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// 보상전 처리해야되는 것들 처리
|
||||
//=====================================================================================
|
||||
public override Task<Result> prepareReward()
|
||||
{
|
||||
return Task.FromResult(new Result());
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// 보상처리 후 필요한 로직들 처리
|
||||
//=====================================================================================
|
||||
public override Task<Result> finalizeReward()
|
||||
{
|
||||
var result = new Result();
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
24
GameServer/Contents/Quest/QuestChecker/QuestTattoo.cs
Normal file
24
GameServer/Contents/Quest/QuestChecker/QuestTattoo.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestTattoo : QuestBase
|
||||
{
|
||||
public QuestTattoo(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int itemId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = itemId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
GameServer/Contents/Quest/QuestChecker/QuestTaxi.cs
Normal file
24
GameServer/Contents/Quest/QuestChecker/QuestTaxi.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestTaxi : QuestBase
|
||||
{
|
||||
public QuestTaxi(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int arrivedTaxiId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = arrivedTaxiId.ToString();
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
38
GameServer/Contents/Quest/QuestChecker/QuestTimer.cs
Normal file
38
GameServer/Contents/Quest/QuestChecker/QuestTimer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using GameServer;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestTimer : QuestBase
|
||||
{
|
||||
public QuestTimer(EQuestEventTargetType targetType, EQuestEventNameType eventNameType) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
DateTime nowDt = DateTimeHelper.Current;
|
||||
|
||||
if (questAttribute.TimerCompleteTime <= nowDt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<Result> postProcess(Player player, QuestTaskUpdateHandler questTaskUpdateHandler)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
if (player is not null)
|
||||
{
|
||||
QuestManager.It.m_timer_check_users.TryRemove(player.getUserGuid(), out _);
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
}
|
||||
}
|
||||
24
GameServer/Contents/Quest/QuestChecker/QuestTool.cs
Normal file
24
GameServer/Contents/Quest/QuestChecker/QuestTool.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ServerCommon;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class QuestTool : QuestBase
|
||||
{
|
||||
public QuestTool(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int toolId) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_condition_1 = toolId.ToString();
|
||||
}
|
||||
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if (events.EventCondition1.Equals(m_condition_1)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
GameServer/Contents/Quest/QuestChecker/QuestTpsPlayerKill.cs
Normal file
22
GameServer/Contents/Quest/QuestChecker/QuestTpsPlayerKill.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestTpsPlayerKill : QuestBase
|
||||
{
|
||||
private Int32 m_kill_count = 0;
|
||||
public QuestTpsPlayerKill(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, int killCount) : base(targetType, eventNameType, 0, string.Empty, string.Empty, string.Empty)
|
||||
{
|
||||
m_kill_count = killCount;
|
||||
}
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
var kill_count = int.Parse(events.EventCondition1);
|
||||
|
||||
if (m_kill_count >= kill_count) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
27
GameServer/Contents/Quest/QuestChecker/QuestUgq.cs
Normal file
27
GameServer/Contents/Quest/QuestChecker/QuestUgq.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using ServerCommon;
|
||||
using ServerCore;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
public class QuestUgq : QuestBase
|
||||
{
|
||||
private string m_ugq_grade = string.Empty;
|
||||
public QuestUgq(EQuestEventTargetType targetType, EQuestEventNameType eventNameType, string ugqGrade)
|
||||
: base(targetType, eventNameType, 0, ugqGrade, string.Empty, string.Empty)
|
||||
{
|
||||
m_ugq_grade = ugqGrade;
|
||||
}
|
||||
|
||||
|
||||
public override bool checkSubValidTaskScript(QuestAttribute questAttribute, QuestEventInfo events)
|
||||
{
|
||||
if(events.EventCondition1.Equals(QuestUgqGradeConditionType.ALL.ToString())) return true;
|
||||
if (events.EventCondition1.Equals(m_ugq_grade)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
1356
GameServer/Contents/Quest/QuestHandler/QuestManager.cs
Normal file
1356
GameServer/Contents/Quest/QuestHandler/QuestManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
73
GameServer/Contents/Quest/QuestHandler/QuestRewardHandler.cs
Normal file
73
GameServer/Contents/Quest/QuestHandler/QuestRewardHandler.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using UGQDatabase.Models;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestRewardHandler
|
||||
{
|
||||
public readonly Player m_player;
|
||||
public UInt32 m_quest_id { get; set; } = 0;
|
||||
public UInt32 m_quest_revision { get; set; } = 0;
|
||||
public EQuestType m_quest_type { get; set; } = EQuestType.NONE;
|
||||
public GameQuestDataEntity? m_ugq_game_data { get; set; } = null;
|
||||
|
||||
public bool m_is_repeat_ugq_quest { get; set; } = false;
|
||||
|
||||
public QuestBaseInfo? m_quest_meta_info { get; set; } = null;
|
||||
public ServerCommon.Quest? m_quest { get; set; } = null;
|
||||
public ServerCommon.EndQuest? m_end_quest { get; set; } = null;
|
||||
|
||||
public bool m_has_ugq_daily_reward { get; set; } = false;
|
||||
public Int32 m_ugq_daily_bonus_gold { get; set; } = 0;
|
||||
|
||||
public Int32 m_replaced_reward_group_id { get; set; } = 0;
|
||||
public List<MetaAssets.Reward> m_rewards { get; set; } = new();
|
||||
|
||||
public List<MetaAssets.Reward> m_rewarded_money { get; set; } = new();
|
||||
public List<Item> m_rewarded_items { get; set; } = new();
|
||||
|
||||
public bool m_has_already_end_quest { get; set; } = false;
|
||||
|
||||
public QuestRewardHandler(Player player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
m_player = player;
|
||||
m_quest_id = questId;
|
||||
m_quest_revision = questRevision;
|
||||
}
|
||||
|
||||
public async Task<Result> init()
|
||||
{
|
||||
var quest_action = m_player.getEntityAction<QuestAction>();
|
||||
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(m_player, m_quest_id, m_quest_revision);
|
||||
if (result.isFail()) return result;
|
||||
m_quest_meta_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_meta_info, () => $"player is null !!!");
|
||||
|
||||
if (quest_meta_all_base_info.m_quest_data_entity is not null)
|
||||
{
|
||||
m_ugq_game_data = quest_meta_all_base_info.m_quest_data_entity;
|
||||
}
|
||||
|
||||
m_replaced_reward_group_id = m_quest_meta_info.RewardGroupId;
|
||||
result = quest_action.getQuest(m_quest_meta_info.QuestType, m_quest_id, out var quest);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
m_quest = quest;
|
||||
|
||||
var end_quest_action = m_player.getEntityAction<EndQuestAction>();
|
||||
m_has_already_end_quest = end_quest_action.hasEndQuest(m_quest_id, m_quest_revision);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Player getPlayer() => m_player;
|
||||
}
|
||||
145
GameServer/Contents/Quest/QuestHandler/QuestTaskUpdateHandler.cs
Normal file
145
GameServer/Contents/Quest/QuestHandler/QuestTaskUpdateHandler.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using ServerCommon;
|
||||
using System.Collections.Concurrent;
|
||||
using ServerCore; using ServerBase;
|
||||
using MetaAssets;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestTaskUpdateHandler
|
||||
{
|
||||
private Player m_player;
|
||||
public UInt32 m_quest_id { get; set; } = 0;
|
||||
public UInt32 m_quest_revision { get; set; } = 0;
|
||||
public EQuestType m_quest_type { get; set; } = EQuestType.NONE;
|
||||
public QuestBaseInfo? m_quest_meta_info { get; set; } = null;
|
||||
public GameQuestDataEntity? m_game_quest_data { get; set; } = null;
|
||||
public QuestTaskGroup? m_quest_task_group { get; set; } = null;
|
||||
public ServerCommon.Quest? m_quest { get; set; } = null;
|
||||
public string m_active_event { get; set; } = string.Empty;
|
||||
public EQuestEventTargetType m_target_type { get; set; } = EQuestEventTargetType.NONE;
|
||||
public EQuestEventNameType m_name_type { get; set; } = EQuestEventNameType.NONE;
|
||||
|
||||
public List<MetaAssets.Reward> m_rewards { get; set; } = new();
|
||||
public ConcurrentDictionary<int, int> m_deletable_items { get; set; } = new();
|
||||
|
||||
|
||||
public List<MetaAssets.Reward> m_rewarded_money { get; set; } = new();
|
||||
public List<Item> m_rewarded_items { get; set; } = new();
|
||||
public List<Item> m_deleted_items { get; set; } = new();
|
||||
|
||||
public List<QuestEventFunction> m_last_check_functions { get; set; } = new();
|
||||
|
||||
public bool m_need_counter_check { get; set; } = false;
|
||||
public int m_next_task_number { get; set; } = 0;
|
||||
|
||||
public CommonResult m_common_result { get; set; } = new();
|
||||
|
||||
public List<ILogInvoker> m_log_invokers { get; set; } = new();
|
||||
|
||||
|
||||
public QuestTaskUpdateHandler(Player player, UInt32 questId, UInt32 questRevision, string activeEvent)
|
||||
{
|
||||
m_player = player;
|
||||
m_quest_id = questId;
|
||||
m_quest_revision = questRevision;
|
||||
m_active_event = activeEvent;
|
||||
}
|
||||
|
||||
public async Task<Result> init()
|
||||
{
|
||||
var quest_action = m_player.getEntityAction<QuestAction>();
|
||||
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(m_player, m_quest_id, m_quest_revision);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
m_quest_meta_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_meta_info, () => $"m_quest_meta_info is null !!!");
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(m_quest_meta_info.QuestType, EQuestType.NORMAL);
|
||||
m_quest_type = quest_type;
|
||||
result = quest_action.getQuest(quest_type, m_quest_id, out var quest);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
m_quest = quest;
|
||||
|
||||
if (m_quest_revision > 0)
|
||||
{
|
||||
var game_quest_data = quest_meta_all_base_info.m_quest_data_entity;
|
||||
NullReferenceCheckHelper.throwIfNull(game_quest_data, () => $"game_quest_data is null !!!");
|
||||
if (game_quest_data.UgqGameQuestDataForClient.UgqStateType == UgqStateType.Standby)
|
||||
{
|
||||
result.setFail(ServerErrorCode.UgqQuestShutdowned);
|
||||
return result;
|
||||
}
|
||||
else if (game_quest_data.UgqGameQuestDataForClient.UgqStateType == UgqStateType.Shutdown || game_quest_data.Shutdown == true)
|
||||
{
|
||||
result.setFail(ServerErrorCode.UgqQuestShutdowned);
|
||||
return result;
|
||||
}
|
||||
else if (game_quest_data.UgqGameQuestDataForClient.UgqStateType == UgqStateType.RevisionChanged)
|
||||
{
|
||||
result.setFail(ServerErrorCode.UgqQuestRevisionChanged);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Result> init(Player player, ServerCommon.Quest quest)
|
||||
{
|
||||
(var result, var quest_meta_all_base_info) = await QuestMetaManager.It.getQuestMeta(m_player, m_quest_id, m_quest_revision);
|
||||
if (result.isFail()) return result;
|
||||
//var game_quest_data = quest_meta_all_base_info.m_quest_data_entity;
|
||||
m_quest_meta_info = quest_meta_all_base_info.m_quest_base_info;
|
||||
NullReferenceCheckHelper.throwIfNull(m_quest_meta_info, () => $"m_quest_meta_info is null !!!");
|
||||
|
||||
var quest_type = EnumHelper.convertEnumTypeAndValueStringToEnum(m_quest_meta_info.QuestType, EQuestType.NORMAL);
|
||||
m_quest_type = quest_type;
|
||||
m_quest = quest;
|
||||
if (result.isFail()) return result;
|
||||
|
||||
|
||||
if (m_quest_revision > 0)
|
||||
{
|
||||
var game_quest_data = quest_meta_all_base_info.m_quest_data_entity;
|
||||
NullReferenceCheckHelper.throwIfNull(game_quest_data, () => $"game_quest_data is null !!!");
|
||||
if (game_quest_data.UgqGameQuestDataForClient.UgqStateType == UgqStateType.Shutdown)
|
||||
{
|
||||
result.setFail(ServerErrorCode.UgqQuestShutdowned);
|
||||
send_NTF_UGQ_STATE_CHANGED(player, result, m_quest_id, m_quest_revision);
|
||||
return result;
|
||||
}
|
||||
else if (game_quest_data.UgqGameQuestDataForClient.UgqStateType == UgqStateType.RevisionChanged)
|
||||
{
|
||||
result.setFail(ServerErrorCode.UgqQuestRevisionChanged);
|
||||
send_NTF_UGQ_STATE_CHANGED(player, result, m_quest_id, m_quest_revision);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void send_NTF_UGQ_STATE_CHANGED(Player player, Result result, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
if (result.getErrorCode() != ServerErrorCode.UgqQuestRevisionChanged && result.getErrorCode() != ServerErrorCode.UgqQuestShutdowned) return;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
ntf_packet.Message.NtfUgqStateChanged = new();
|
||||
ntf_packet.Message.NtfUgqStateChanged.ComposedQuestId = QuestHelper.convertQuestIdAndRevisionToUgqQuestId(questId, questRevision);
|
||||
|
||||
ntf_packet.Message.NtfUgqStateChanged.State = UgqStateType.Shutdown;
|
||||
if (result.getErrorCode() == ServerErrorCode.UgqQuestRevisionChanged)
|
||||
{
|
||||
ntf_packet.Message.NtfUgqStateChanged.State = UgqStateType.RevisionChanged;
|
||||
}
|
||||
|
||||
server_logic.onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
}
|
||||
11
GameServer/Contents/Quest/QuestMetaBase/IQuestMeta.cs
Normal file
11
GameServer/Contents/Quest/QuestMetaBase/IQuestMeta.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using ServerCommon;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public interface IQuestMeta
|
||||
{
|
||||
Task<(Result, QuestMetaAllBaseInfo)> getQuestMetaInfo(Player? player, UInt32 questId, UInt32 questRevision);
|
||||
|
||||
|
||||
}
|
||||
69
GameServer/Contents/Quest/QuestMetaBase/QuestMetaBase.cs
Normal file
69
GameServer/Contents/Quest/QuestMetaBase/QuestMetaBase.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using ServerCommon;
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public abstract class QuestMetaBase : IQuestMeta
|
||||
{
|
||||
protected readonly UgqStateType m_ugq_state = UgqStateType.Live;
|
||||
protected readonly QuestContentState m_quest_content_state = QuestContentState.Live;
|
||||
|
||||
public QuestMetaBase()
|
||||
{
|
||||
m_ugq_state = UgqStateType.None;
|
||||
m_quest_content_state = QuestContentState.None;
|
||||
}
|
||||
|
||||
public QuestMetaBase(UgqStateType ugqState, QuestContentState questContentState)
|
||||
{
|
||||
m_ugq_state = ugqState;
|
||||
m_quest_content_state = questContentState;
|
||||
}
|
||||
public abstract Task<(Result, QuestMetaAllBaseInfo)> getQuestMetaInfo(Player? player, UInt32 questId, UInt32 questRevision);
|
||||
}
|
||||
|
||||
|
||||
public class QuestMetaAllBaseInfo
|
||||
{
|
||||
private readonly UgqStateType m_ugq_state = UgqStateType.None;
|
||||
private readonly QuestContentState m_quest_content_state = QuestContentState.None;
|
||||
|
||||
public QuestBaseInfo? m_quest_base_info { get; set; } = null;
|
||||
public GameQuestDataEntity? m_quest_data_entity { get; set; } = null;
|
||||
|
||||
public QuestMetaAllBaseInfo(UgqStateType ugqState, QuestContentState questContentState)
|
||||
{
|
||||
m_ugq_state = ugqState;
|
||||
m_quest_content_state = questContentState;
|
||||
}
|
||||
public QuestMetaAllBaseInfo(QuestBaseInfo questBaseInfo)
|
||||
{
|
||||
m_ugq_state = UgqStateType.None;
|
||||
m_quest_content_state = QuestContentState.None;
|
||||
m_quest_base_info = questBaseInfo;
|
||||
m_quest_data_entity = null!;
|
||||
}
|
||||
|
||||
|
||||
public QuestMetaAllBaseInfo(UgqStateType ugqState, QuestContentState questContentState, QuestBaseInfo questBaseInfo, GameQuestDataEntity gameQuestData)
|
||||
{
|
||||
m_ugq_state = ugqState;
|
||||
m_quest_content_state = questContentState;
|
||||
m_quest_base_info = questBaseInfo;
|
||||
m_quest_data_entity = gameQuestData;
|
||||
}
|
||||
/*
|
||||
public QuestMetaAllBaseInfo(QuestBaseInfo questBaseInfo, GameQuestDataEntity gameQuestData)
|
||||
{
|
||||
m_ugq_state = UgqStateType.None;
|
||||
m_quest_content_state = QuestContentState.None;
|
||||
m_quest_base_info = questBaseInfo;
|
||||
m_quest_data_entity = gameQuestData;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
126
GameServer/Contents/Quest/QuestMetaBase/QuestMetaManager.cs
Normal file
126
GameServer/Contents/Quest/QuestMetaBase/QuestMetaManager.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestMetaManager : Singleton<QuestMetaManager>
|
||||
{
|
||||
IQuestMeta m_system_quest_meta;
|
||||
IQuestMeta m_ugq_live_quest_meta;
|
||||
IQuestMeta m_ugq_test_quest_meta;
|
||||
public QuestMetaManager()
|
||||
{
|
||||
m_system_quest_meta = new QuestSystemMeta();
|
||||
m_ugq_live_quest_meta = new QuestUgqLiveMeta();
|
||||
m_ugq_test_quest_meta = new QuestUgqTestMeta();
|
||||
}
|
||||
|
||||
//system quest일때 사용
|
||||
public async Task<(Result, QuestMetaAllBaseInfo)> getQuestMeta(UInt32 questId)
|
||||
{
|
||||
return await m_system_quest_meta.getQuestMetaInfo(null, questId, 0);
|
||||
}
|
||||
|
||||
//시스템 퀘스트 인지 아닌지 잘 모를때 사용
|
||||
public async Task<(Result, QuestMetaAllBaseInfo)> getQuestMeta(Player player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
(var result, IQuestMeta i_quest_meta) = await getIUgqMeta(questId, questRevision);
|
||||
return await i_quest_meta.getQuestMetaInfo(player, questId, questRevision);
|
||||
}
|
||||
|
||||
//Ugq 퀘스트를 명시적으로 호출할때 사용
|
||||
public async Task<(Result, QuestMetaAllBaseInfo)> getQuestMeta(Player player, UInt32 questId, UInt32 questRevision, QuestContentState contentState)
|
||||
{
|
||||
(var result, IQuestMeta i_quest_meta) = getIUgqMeta(questRevision, contentState);
|
||||
return await i_quest_meta.getQuestMetaInfo(player, questId, questRevision);
|
||||
}
|
||||
|
||||
//Ugq 퀘스트를 명시적으로 호출할때 사용
|
||||
public async Task<(Result, QuestMetaAllBaseInfo)> getQuestMeta(Player player, UInt32 questId, UInt32 questRevision, UgqStateType UgqStateState)
|
||||
{
|
||||
(var result, IQuestMeta i_quest_meta) = getIUgqMeta(questRevision, UgqStateState);
|
||||
return await i_quest_meta.getQuestMetaInfo(player, questId, questRevision);
|
||||
}
|
||||
|
||||
|
||||
private (Result, IQuestMeta) getIUgqMeta(UInt32 questRevision, QuestContentState contentState)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (questRevision == 0)
|
||||
{
|
||||
return (result, m_system_quest_meta);
|
||||
}
|
||||
|
||||
switch (contentState)
|
||||
{
|
||||
case QuestContentState.Live:
|
||||
return (result, m_ugq_live_quest_meta);
|
||||
case QuestContentState.Test:
|
||||
return (result, m_ugq_test_quest_meta);
|
||||
default:
|
||||
var err_msg = $"Not Support QuestContentState : {contentState}";
|
||||
result.setFail(ServerErrorCode.MetaInfoException, err_msg);
|
||||
return (result, null!);
|
||||
}
|
||||
}
|
||||
|
||||
private (Result, IQuestMeta) getIUgqMeta(UInt32 questRevision, UgqStateType ugqQuestType)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (questRevision == 0)
|
||||
{
|
||||
return (result, m_system_quest_meta);
|
||||
}
|
||||
|
||||
switch (ugqQuestType)
|
||||
{
|
||||
case UgqStateType.Live:
|
||||
return (result, m_ugq_live_quest_meta);
|
||||
case UgqStateType.Test:
|
||||
return (result, m_ugq_test_quest_meta);
|
||||
default:
|
||||
var err_msg = $"Not Support ugqQuestType : {ugqQuestType}";
|
||||
result.setFail(ServerErrorCode.MetaInfoException, err_msg);
|
||||
return (result, null!);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<(Result, IQuestMeta)> getIUgqMeta(UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
var result = new Result();
|
||||
if(questRevision == 0)
|
||||
{
|
||||
return (result, m_system_quest_meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Live 상태가 많을 것으로 생각해서 많은것 먼저조회 해서 가져 오도록 하자.
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var ugq_api_manager = server_logic.GetUqgApiManager();
|
||||
|
||||
(result, var simple_game_quest_data) = await ugq_api_manager.getUgqQuestSimpleInfo(questId, questRevision, QuestContentState.Live);
|
||||
if (result.isSuccess() && simple_game_quest_data is not null)
|
||||
return (result, m_ugq_live_quest_meta);
|
||||
|
||||
(result, simple_game_quest_data) = await ugq_api_manager.getUgqQuestSimpleInfo(questId, questRevision, QuestContentState.Test);
|
||||
if (result.isSuccess() && simple_game_quest_data is not null)
|
||||
return (result, m_ugq_test_quest_meta);
|
||||
|
||||
//여기까지 오면 에러...
|
||||
var err_msg = $"Not Exist QuestUgqMetaInfo QuestID : {questId} - QuestRevision : {questRevision}";
|
||||
result.setFail(ServerErrorCode.MetaInfoException, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return (result, null!);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
33
GameServer/Contents/Quest/QuestMetaBase/QuestSystemMeta.cs
Normal file
33
GameServer/Contents/Quest/QuestMetaBase/QuestSystemMeta.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Amazon.CloudWatchLogs.Model;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestSystemMeta : QuestMetaBase
|
||||
{
|
||||
public QuestSystemMeta() : base()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override async Task<(Result, QuestMetaAllBaseInfo)> getQuestMetaInfo(Player? player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
if (false == MetaData.Instance._QuestBaseinfoTable.TryGetValue(questId, out var quest_base_info))
|
||||
{
|
||||
string err_msg = $"NotExist Quest Assign Data QuestID : {questId}";
|
||||
result.setFail(ServerErrorCode.QuestAssingDataNotExist, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return (result, null!);
|
||||
}
|
||||
QuestMetaAllBaseInfo info = new QuestMetaAllBaseInfo(quest_base_info);
|
||||
return (result, info);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
158
GameServer/Contents/Quest/QuestMetaBase/QuestUgqLiveMeta.cs
Normal file
158
GameServer/Contents/Quest/QuestMetaBase/QuestUgqLiveMeta.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UGQDatabase.Models;
|
||||
using Newtonsoft.Json;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using ServerCommon.UGQ.Models;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
|
||||
|
||||
|
||||
public class QuestUgqLiveMeta : QuestMetaBase
|
||||
{
|
||||
private Lazy<ConcurrentDictionary<(UInt32, UInt32), QuestMetaAllBaseInfo>> m_ugq_quest_data = new Lazy<ConcurrentDictionary<(UInt32, UInt32), QuestMetaAllBaseInfo>>();
|
||||
private ConcurrentDictionary<(UInt32, UInt32), QuestMetaAllBaseInfo> UgqQuestData => m_ugq_quest_data.Value;
|
||||
|
||||
public QuestUgqLiveMeta()
|
||||
: base(UgqStateType.Live, QuestContentState.Live)
|
||||
{
|
||||
}
|
||||
public override async Task<(Result, QuestMetaAllBaseInfo)> getQuestMetaInfo(Player? player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
var result = new Result();
|
||||
|
||||
if (false == UgqQuestData.TryGetValue((questId, questRevision), out var ugq_quest_meta_collected_info))
|
||||
{
|
||||
Log.getLogger().debug($"getQuestMetaInfo not exist memory questId : {questId}, questRevision : {questRevision}");
|
||||
//서버에 캐싱이 없는 경우
|
||||
ugq_quest_meta_collected_info = new(m_ugq_state, m_quest_content_state);
|
||||
|
||||
//api서버에서 호출
|
||||
(result, var game_quest_data) = await UgqMetaHelper.loadLiveGameQuestGameDataEntity(player, questId, questRevision);
|
||||
|
||||
if (result.isFail() || game_quest_data is null)
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
//호출 해서 데이터가 없는 경우 에러 처리(무조건 있어야 된다.)
|
||||
return (result, null!);
|
||||
}
|
||||
|
||||
result = await gameQuestDataStateCheck(player, game_quest_data); //여기 result는 그냥 shutdown으로 보내는 거라서 무시
|
||||
|
||||
ugq_quest_meta_collected_info.m_quest_data_entity = game_quest_data;
|
||||
|
||||
(result, var generated_quest_base_info) = UgqMetaHelper.generateUgqQuestBaseInfo(game_quest_data);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null!);
|
||||
}
|
||||
ugq_quest_meta_collected_info.m_quest_base_info = generated_quest_base_info;
|
||||
|
||||
UgqQuestData.TryAdd((questId, questRevision), ugq_quest_meta_collected_info);
|
||||
|
||||
Log.getLogger().debug($"UgqQuestData.TryAdd questId : {questId}, questRevision : {questRevision}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//캐싱이 오래 됐을 수도 있으니 game -quest - data - simple 로 한번더 확인 필요.
|
||||
//Log.getLogger().debug($"getQuestMetaInfo exist memory questId : {questId}, questRevision : {questRevision}, player : {player.toBasicString()}");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var ugq_api_manager = server_logic.GetUqgApiManager();
|
||||
var lang_type = player.getLanguageType();
|
||||
(result, var simple_game_quest_data) = await ugq_api_manager.getUgqQuestSimpleInfo(questId, questRevision, m_quest_content_state);
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return (result, null!);
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(simple_game_quest_data, () => $"simple_game_quest_data is null !!!");
|
||||
NullReferenceCheckHelper.throwIfNull(ugq_quest_meta_collected_info.m_quest_data_entity, () => $"ugq_quest_meta_collected_info.m_quest_data_entity is null !!!");
|
||||
|
||||
ugq_quest_meta_collected_info.m_quest_data_entity.Shutdown = simple_game_quest_data.Shutdown;
|
||||
ugq_quest_meta_collected_info.m_quest_data_entity.State = simple_game_quest_data.State;
|
||||
|
||||
result = await gameQuestDataStateCheck(player, ugq_quest_meta_collected_info.m_quest_data_entity);
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return (result, null!);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UgqQuestData.TryGetValue((questId, questRevision), out ugq_quest_meta_collected_info);
|
||||
|
||||
return (result, ugq_quest_meta_collected_info!);
|
||||
|
||||
}
|
||||
|
||||
private async Task<Result> gameQuestDataStateCheck(Player player, GameQuestDataEntity gameQuestData)
|
||||
{
|
||||
//api에서 로드해서 상태 값 확인 했는데 shutdown 인 경우
|
||||
var result = new Result();
|
||||
if (gameQuestData.Shutdown == true)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var ugq_api_manager = server_logic.GetUqgApiManager();
|
||||
var lang_type = player.getLanguageType();
|
||||
|
||||
//해당 퀘스트가 Shutdown 인경우 갱신 해줘야 된다.
|
||||
(result, var latest_queat_game_data) = await ugq_api_manager.getUgqLatestQuestData((UInt32)gameQuestData.QuestId, lang_type);
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to getUgqLatestQuestData()!!! questId : {gameQuestData.QuestId} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(latest_queat_game_data, () => $"latest_queat_game_data is null !!! - {player.toBasicString()}");
|
||||
|
||||
//기존 로드된 데이터의 리비전과, 최신 리비전이 다르면 리비전이 변경이 발생한것
|
||||
if (gameQuestData.Revision != latest_queat_game_data.Revision)
|
||||
{
|
||||
Log.getLogger().info($"Revision diff gameQuestData.Revision : {gameQuestData.Revision} <-> latest_queat_game_data.Revision : {latest_queat_game_data.Revision}");
|
||||
|
||||
gameQuestData.UgqGameQuestDataForClient.UgqStateType = UgqStateType.RevisionChanged;
|
||||
gameQuestData.UgqGameQuestDataForClient.UgqGradeType = gameQuestData.GradeType;
|
||||
//최신 버전이 아닌경우
|
||||
result = updateUgqState(gameQuestData.UgqGameQuestDataForClient, UgqStateType.RevisionChanged);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private Result updateUgqState(UgqGameQuestDataForClient ugqGameQuestDataForClient, UgqStateType state)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
if (ugqGameQuestDataForClient is null)
|
||||
{
|
||||
var err_msg = $"GameQuestDataEntity NotExist ugqGameQuestDataForClientString";
|
||||
result.setFail(ServerErrorCode.UgqQuestMetaNotExist, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
ugqGameQuestDataForClient.UgqStateType = state;
|
||||
|
||||
Log.getLogger().info($"ugq_game_quest_data_for_client ugqState: {state}");
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
21
GameServer/Contents/Quest/QuestMetaBase/QuestUgqTestMeta.cs
Normal file
21
GameServer/Contents/Quest/QuestMetaBase/QuestUgqTestMeta.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using UGQDatabase.Models;
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class QuestUgqTestMeta : QuestMetaBase
|
||||
{
|
||||
public QuestUgqTestMeta()
|
||||
: base(UgqStateType.Test, QuestContentState.Test)
|
||||
{
|
||||
|
||||
}
|
||||
public override async Task<(Result, QuestMetaAllBaseInfo)> getQuestMetaInfo(Player? player, UInt32 questId, UInt32 questRevision)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var ugq_test_action = player.getEntityAction<UgqTestAction>();
|
||||
return await ugq_test_action.getUgqGameQuestTestData(questId, questRevision);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user