초기커밋
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class SwitchingPropAction : EntityActionBase
|
||||
{
|
||||
public SwitchingPropAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public async override Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public async Task<Result> updateSwitchingProp(QuestTaskUpdateHandler handler, Int32 propId, Int32 propState)
|
||||
{
|
||||
var result = new Result();
|
||||
await Task.CompletedTask;
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var fn_update_switching_prop = async delegate ()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
|
||||
var attribute = player.getEntityAttribute<SwitchingPropAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(attribute, () => $"attribute is null !!!");
|
||||
|
||||
attribute.m_switching_props.AddOrUpdate(propId, propState, (key, old) => propState);
|
||||
attribute.modifiedEntityAttribute(true);
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.SwitchingProp
|
||||
, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
var log_invoker = new SwitchingPropBusinessLog(handler.m_quest_id, propId, propState);
|
||||
batch.appendBusinessLogs(new List<ILogInvoker>(){log_invoker});
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
SwitchingPropHelper.send_GS2C_NTF_SWITCHING_PROP_STATE(player, propId, propState);
|
||||
return result;
|
||||
};
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "SwitchingProp", fn_update_switching_prop);
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
ServerCore.Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQSwitchingPropReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_pk = string.Empty;
|
||||
|
||||
|
||||
public DBQSwitchingPropReadAll(string combinationKeyForPK /*onwer_guid*/) : base(typeof(DBQSwitchingPropReadAll).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 SwitchingPropDoc(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);
|
||||
|
||||
ServerCore.Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//===================================================================================================
|
||||
public async override 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 switching_prop_attribute = owner.getEntityAttribute<SwitchingPropAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(switching_prop_attribute, () => "switching_prop_attribute is null !!!");
|
||||
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
||||
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<SwitchingPropDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
//데이터 없으면 여기서 그냥 메모리에만 넣어준다.
|
||||
ServerCore.Log.getLogger().warn($"DailyQuestCheckDoc not exitst, so make new Data {result.toBasicString()}");
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var attrib = read_doc.getAttrib<SwitchingPropAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(attrib, () => "attrib is null !!!");
|
||||
|
||||
foreach (var prop in attrib.m_switching_props)
|
||||
{
|
||||
switching_prop_attribute.m_switching_props.AddOrUpdate(prop.Key, prop.Value, (key, old) => prop.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override Task onQueryResponseCommit()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -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 static class SwitchingPropHelper
|
||||
{
|
||||
public static void send_GS2C_NTF_SWITCHING_PROP_STATE(Player player)
|
||||
{
|
||||
var attribute = player.getEntityAttribute<SwitchingPropAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(attribute, () => $"attribute is null !!! - player:{player.toBasicString()}");
|
||||
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.NtfSwitchingPropState = new();
|
||||
|
||||
foreach (var prop in attribute.m_switching_props)
|
||||
{
|
||||
SwitchingPropState state = new();
|
||||
state.SwitchingPropId = prop.Key;
|
||||
state.PropState = prop.Value;
|
||||
ntf_packet.Message.NtfSwitchingPropState.SwitchingPropState.Add(state);
|
||||
}
|
||||
GameServerApp.getServerLogic().onSendPacket(player, ntf_packet);
|
||||
}
|
||||
|
||||
public static void send_GS2C_NTF_SWITCHING_PROP_STATE(Player player, Int32 propId, Int32 propState)
|
||||
{
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
ntf_packet.Message.NtfSwitchingPropState = new();
|
||||
SwitchingPropState state = new();
|
||||
state.SwitchingPropId = propId;
|
||||
state.PropState = propState;
|
||||
ntf_packet.Message.NtfSwitchingPropState.SwitchingPropState.Add(state);
|
||||
|
||||
GameServerApp.getServerLogic().onSendPacket(player, ntf_packet);
|
||||
}
|
||||
}
|
||||
@@ -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 SwitchingPropBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private SwitchingPropLogInfo m_info;
|
||||
|
||||
public SwitchingPropBusinessLog(UInt32 questId, Int32 propId, Int32 propState)
|
||||
: base(LogDomainType.SwitchingProp)
|
||||
{
|
||||
m_info = new SwitchingPropLogInfo(this, questId, propId, propState);
|
||||
}
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(m_info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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_SWITCHING_PROP_STATE), typeof(GetSwitchingPropStatePacketHandler), typeof(GameLoginListener))]
|
||||
public class GetSwitchingPropStatePacketHandler : PacketRecvHandler
|
||||
{
|
||||
public async override Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
||||
{
|
||||
var player = session as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"Player is null !!!");
|
||||
|
||||
var attribute = player.getEntityAttribute<SwitchingPropAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(attribute, () => $"attribute is null !!! - player:{player.toBasicString()}");
|
||||
|
||||
var result = send_GS2C_ACK_SWITCHING_PROP_STATE(player, attribute);
|
||||
|
||||
await Task.CompletedTask;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result send_GS2C_ACK_SWITCHING_PROP_STATE(Player owner, SwitchingPropAttribute attribute)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
ack_packet.Response.ErrorCode = new();
|
||||
ack_packet.Response.AckSwitchingPropState = new ClientToGameRes.Types.GS2C_ACK_SWITCHING_PROP_STATE();
|
||||
|
||||
foreach (var prop in attribute.m_switching_props)
|
||||
{
|
||||
SwitchingPropState state = new();
|
||||
state.PropState = prop.Value;
|
||||
state.SwitchingPropId = prop.Key;
|
||||
ack_packet.Response.AckSwitchingPropState.SwitchingPropState.Add(state);
|
||||
}
|
||||
|
||||
var result = new Result();
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(owner, ack_packet))
|
||||
{
|
||||
string err_msg = $"send_GS2C_ACK_SWITCHING_PROP_STATE Fail !!! : owner:{owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ProudNetException, err_msg);
|
||||
ServerCore.Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user