초기커밋

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,94 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
using static ClientToGameRes.Types;
namespace GameServer.PacketHandler;
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BUY_CHARGED_SEASON_PASS), typeof(BuyChargedSeasonPassPacketHandler), typeof(GameLoginListener))]
public class BuyChargedSeasonPassPacketHandler : PacketRecvHandler
{
public static bool send_S2C_ACK_BUY_CHARGED_SEASON_PASS(Player player, Result result, CommonResult? commonResult = null)
{
var ack_packet = new ClientToGame();
ack_packet.Response = new ClientToGameRes();
ack_packet.Response.ErrorCode = result.ErrorCode;
ack_packet.Response.AckBuyChargedSeasonPass = new GS2C_ACK_BUY_CHARGED_SEASON_PASS();
if (result.isSuccess() && commonResult != null)
{
ack_packet.Response.AckBuyChargedSeasonPass.CommonResult = commonResult;
}
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
{
return false;
}
return true;
}
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
{
var result = new Result();
var err_msg = string.Empty;
var entity_player = entityWithSession as Player;
NullReferenceCheckHelper.throwIfNull(entity_player, () => $"entity_player is null !!!");
var season_pass_action = entity_player.getEntityAction<SeasonPassAction>();
if (season_pass_action == null)
{
err_msg = $"Failed to get season pass action : {nameof(SeasonPassAction)}";
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
Log.getLogger().error(err_msg);
send_S2C_ACK_BUY_CHARGED_SEASON_PASS(entity_player, result);
return result;
}
var game_msg = recvMessage as ClientToGame;
if (game_msg == null)
{
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBuyChargedSeasonPass)}";
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
Log.getLogger().error(result.toBasicString());
send_S2C_ACK_BUY_CHARGED_SEASON_PASS(entity_player, result);
return result;
}
var request = game_msg.Request.ReqBuyChargedSeasonPass;
result = await season_pass_action.tryBuyChargedPass();
if (result.isFail() == true)
{
err_msg = $"Failed to tryBuyChargedPass() !!! : {result.toBasicString()} - {entity_player.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
return result;
}
public override async Task onProcessPacketException(ISession entityWithSession, IMessage recvMessage
, Result errorResult)
{
await Task.CompletedTask;
var player = entityWithSession as Player;
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!! - {entityWithSession.toBasicString()}");
send_S2C_ACK_BUY_CHARGED_SEASON_PASS(player, errorResult);
}
}

View File

@@ -0,0 +1,42 @@
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 static class SeasonPassNotifyHelper
{
public static bool send_S2C_NTF_SEASON_PASS_INFOS(this Player player)
{
var noti_packet = new ClientToGame();
noti_packet.Message = new();
noti_packet.Message.NtfSeasonPassInfo = new();
var server_logic = GameServerApp.getServerLogic();
var season_pass_manager = server_logic.getSeasonPassManager();
if (season_pass_manager.currentSeasonPass != 0)
{
var season_pass_attribute = player.getEntityAttribute<SeasonPassAttribute>();
NullReferenceCheckHelper.throwIfNull(season_pass_attribute, () => $"season_pass_attribute is null !!! - {player.toBasicString()}");
noti_packet.Message.NtfSeasonPassInfo.MetaId = season_pass_attribute.SeasonPassMetaId;
noti_packet.Message.NtfSeasonPassInfo.Exp = season_pass_attribute.Exp;
noti_packet.Message.NtfSeasonPassInfo.Grade = season_pass_attribute.Grade;
noti_packet.Message.NtfSeasonPassInfo.IsChargedPass = season_pass_attribute.IsChargedPass == true ? BoolType.True : BoolType.False;
noti_packet.Message.NtfSeasonPassInfo.TakenRewards.AddRange(season_pass_attribute.takenRewards);
}
if (false == GameServerApp.getServerLogic().onSendPacket(player, noti_packet))
{
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,78 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
using static ClientToGameRes.Types;
namespace GameServer.PacketHandler;
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_TAKE_SEASON_PASS_REWARD), typeof(TakeSeasonPassRewardPacketHandler), typeof(GameLoginListener))]
public class TakeSeasonPassRewardPacketHandler : PacketRecvHandler
{
public static bool send_S2C_ACK_TAKE_SEASON_PASS_REWARD(Player player, Result result, int taken_reward_grade = 0, CommonResult? commonResult = null)
{
var ack_packet = new ClientToGame();
ack_packet.Response = new ClientToGameRes();
ack_packet.Response.ErrorCode = result.ErrorCode;
ack_packet.Response.AckTakeSeasonPassReward = new GS2C_ACK_TAKE_SEASON_PASS_REWARD();
if (result.isSuccess() && commonResult != null)
{
ack_packet.Response.AckTakeSeasonPassReward.CommonResult = commonResult;
ack_packet.Response.AckTakeSeasonPassReward.TakenRewardGrade = taken_reward_grade;
}
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
{
return false;
}
return true;
}
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
{
var result = new Result();
var err_msg = string.Empty;
var player = entityWithSession as Player;
ArgumentNullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
var game_msg = recvMessage as ClientToGame;
ArgumentNullReferenceCheckHelper.throwIfNull(game_msg, () => $"game_msg is null !!! - {player.toBasicString()}");
var request = game_msg.Request.ReqTakeSeasonPassReward;
ArgumentNullReferenceCheckHelper.throwIfNull(request, () => $"request is null !!! - {player.toBasicString()}");
var season_pass_action = player.getEntityAction<SeasonPassAction>();
NullReferenceCheckHelper.throwIfNull(season_pass_action, () => $"season_pass_action is null !!! - {player.toBasicString()}");
result = await season_pass_action.tryTakeSeasonPassReward(request.RewardGrade);
if (result.isFail() == true)
{
err_msg = $"Failed to BuyChargedPass() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
return result;
}
public override async Task onProcessPacketException(ISession entityWithSession, IMessage recvMessage
, Result errorResult)
{
await Task.CompletedTask;
var player = entityWithSession as Player;
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!! - {entityWithSession.toBasicString()}");
send_S2C_ACK_TAKE_SEASON_PASS_REWARD(player, errorResult);
}
}