초기커밋
This commit is contained in:
209
ServerCommon/Entity/Attribute/EndQuestAttribute.cs
Normal file
209
ServerCommon/Entity/Attribute/EndQuestAttribute.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class EndQuestAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public UInt32 QuestId { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public UInt32 QuestRevision { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public Int32 EndCount { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public DateTime LastEndTime { get; set; } = DateTimeHelper.MinTime;
|
||||
[JsonProperty]
|
||||
public string m_user_guid { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public EndQuestAttribute( EntityBase owner
|
||||
, string userGuid, UInt32 questId, UInt32 questRevision
|
||||
, EntityBase entityOfOwnerEntityType )
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
m_user_guid = userGuid;
|
||||
QuestId = questId;
|
||||
QuestRevision = questRevision;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_user_guid = string.Empty;
|
||||
QuestId = 0;
|
||||
QuestRevision = 0;
|
||||
EndCount = 0;
|
||||
LastEndTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var end_quest_attribute = owner.getEntityAttribute<EndQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attribute, () => $"end_quest_attribute is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as EndQuestDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new EndQuestDoc(m_user_guid, QuestId, QuestRevision);
|
||||
|
||||
var origin_doc = getOriginDocBase<EndQuestAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_quest_attrib = try_pending_doc.getAttrib<EndQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_quest_attrib, () => $"to_copy_quest_attrib is null !!!");
|
||||
|
||||
to_copy_quest_attrib.m_quest_id = end_quest_attribute.QuestId;
|
||||
to_copy_quest_attrib.m_quest_revision = end_quest_attribute.QuestRevision;
|
||||
to_copy_quest_attrib.m_end_count = end_quest_attribute.EndCount;
|
||||
to_copy_quest_attrib.m_last_end_time = end_quest_attribute.LastEndTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_docs) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new EndQuestAttribute( getOwner()
|
||||
, m_user_guid, QuestId, QuestRevision
|
||||
, entity_of_owner_entity_type );
|
||||
cloned.deepCopyFromBase(this);
|
||||
cloned.QuestId = QuestId;
|
||||
cloned.QuestRevision = QuestRevision;
|
||||
cloned.EndCount = EndCount;
|
||||
cloned.LastEndTime = LastEndTime;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
var other_attribute = otherEntityAttribute as EndQuestAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast EndQuestAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
QuestId = other_attribute.QuestId;
|
||||
QuestRevision = other_attribute.QuestRevision;
|
||||
EndCount = other_attribute.EndCount;
|
||||
LastEndTime = other_attribute.LastEndTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as EndQuestDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<EndQuestAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<EndQuestAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var end_quest_attrib = origin_doc_base.getAttrib<EndQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attrib, () => $"end_quest_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
end_quest_attrib.m_quest_id = QuestId;
|
||||
end_quest_attrib.m_quest_revision = QuestRevision;
|
||||
end_quest_attrib.m_end_count = EndCount;
|
||||
end_quest_attrib.m_last_end_time = LastEndTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new EndQuestAtrributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
public class EndQuestAtrributeTransactor : EntityAttributeTransactorBase<EndQuestAttribute>
|
||||
{
|
||||
public EndQuestAtrributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user