초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
using USER_GUID = System.String;
namespace GameServer.PacketHandler;
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.PartyVoteReq), typeof(PartyVotePacketHandler), typeof(GameLoginListener))]
public class PartyVotePacketHandler : PacketRecvHandler
{
private static void send_S2C_ACK_PARTY_VOTE(Player? owner, Result result)
{
ArgumentNullException.ThrowIfNull(owner);
var ack_packet = new ClientToGame
{
Response = new ClientToGameRes
{
ErrorCode = result.ErrorCode,
PartyVoteRes = new()
}
};
GameServerApp.getServerLogic().onSendPacket(owner, ack_packet);
}
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
{
var result = new Result();
string err_msg;
var entity_player = entityWithSession as Player;
ArgumentNullException.ThrowIfNull(entity_player);
// 1. 기본 정보 체크
var request = (recvMessage as ClientToGame)?.Request.PartyVoteReq;
if (null == request)
{
err_msg = $"Failed to get request type !!! : {nameof(ClientToGame.Request.PartyVoteReq)}";
result.setFail(ServerErrorCode.InvalidArgument, err_msg);
Log.getLogger().error(result.toBasicString());
send_S2C_ACK_PARTY_VOTE(entity_player, result);
return result;
}
// 2. 소속 파티 Guid 조회
var personal_party_action = entity_player.getEntityAction<PersonalPartyAction>();
ArgumentNullException.ThrowIfNull(personal_party_action);
var personal_party = personal_party_action.getPersonalParty();
if (null == personal_party)
{
err_msg = $"Failed to get party info !!! - not party member - {entity_player.getUserGuid()}";
result.setFail(ServerErrorCode.NotParty, err_msg);
Log.getLogger().error(err_msg);
send_S2C_ACK_PARTY_VOTE(entity_player, result);
return result;
}
var global_party = GameServerApp.getServerLogic().findGlobalEntity<GlobalParty>();
ArgumentNullException.ThrowIfNull(global_party);
var party = global_party.getParty(personal_party.getPartyGuid());
ArgumentNullException.ThrowIfNull(party);
// 3. 파티장 체크
var party_action = party.getEntityAction<GlobalPartyDetailAction>();
ArgumentNullException.ThrowIfNull(party_action);
var is_leader = party_action.isLeader(entity_player.getUserGuid());
if (!is_leader)
{
err_msg = $"Failed to summon party member !!! : not party leader - {entity_player.getUserGuid()}";
result.setFail(ServerErrorCode.NotPartyLeader, err_msg);
Log.getLogger().error(err_msg);
send_S2C_ACK_PARTY_VOTE(entity_player, result);
return result;
}
// 4. Vote 시작
var party_info_action = party.getEntityAction<GlobalPartyDetailInfoAction>();
ArgumentNullException.ThrowIfNull(party_info_action);
var start_vote = await party_info_action.registerPartyVote(request.VoteInfo, DateTime.UtcNow.ToTimestamp(), true);
if (start_vote.result.isFail())
{
send_S2C_ACK_PARTY_VOTE(entity_player, start_vote.result);
return result;
}
NullReferenceCheckHelper.throwIfNull(start_vote.vote, () => $"start_vote.vote is null !!!");
// 4. vote 시작 알림 ( to server )
var server_message = new ServerMessage();
server_message.PartyVoteNoti = new();
server_message.PartyVoteNoti.PartyGuid = party.PartyGuid;
server_message.PartyVoteNoti.VoteTitle = start_vote.vote.VoteTitle;
server_message.PartyVoteNoti.VoteStartTime = start_vote.vote.StartVoteTime;
PartyHelper.BroadcastToServers(party, server_message, true);
// 5. vote 시작 알림 ( to client )
var client_message = new ClientToGame();
client_message.Message = new();
client_message.Message.PartyVoteNoti = new();
client_message.Message.PartyVoteNoti.VoteTitle = start_vote.vote.VoteTitle;
client_message.Message.PartyVoteNoti.VoteStartTime = start_vote.vote.StartVoteTime;
PartyHelper.BroadcastToClients(party, client_message, new List<USER_GUID>());
// 6. business log 기록
writeBusinessLog(entity_player, party.PartyGuid);
return result;
}
private void writeBusinessLog(Player owner, string partyGuid)
{
var log_invokers = new List<ILogInvoker>(2);
// 1. 파티 정보
var party_log_data = PartyBusinessLogHelper.toPartyLogData(partyGuid, false);
ArgumentNullException.ThrowIfNull(party_log_data);
var party_business_log = new PartyBusinessLog(party_log_data);
log_invokers.Add(party_business_log);
// 2. 파티 투표 정보
var party_vote_log_data = PartyBusinessLogHelper.toPartyVoteLogData(partyGuid, true);
ArgumentNullException.ThrowIfNull(party_vote_log_data);
var party_vote_business_log = new PartyVoteBusinessLog(party_vote_log_data);
log_invokers.Add(party_vote_business_log);
BusinessLogger.collectLogs(new LogActionEx(LogActionType.StartPartyVote), owner, log_invokers);
}
}