108 lines
4.4 KiB
C#
108 lines
4.4 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|