초기커밋
This commit is contained in:
204
GameServer/Global/LandAuction/Helper/LandAuctionNotifyHelper.cs
Normal file
204
GameServer/Global/LandAuction/Helper/LandAuctionNotifyHelper.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameMessage.Types;
|
||||
using static ServerMessage.Types;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
using USER_NICKNAME = System.String;
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public static class LandAuctionNotifyHelper
|
||||
{
|
||||
public static bool send_GS2C_NTF_LAND_AUCTION_ALL_LOAD(Player player, List<LandAuctionSummary>? landAuctionSummaries)
|
||||
{
|
||||
if(null == landAuctionSummaries)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
|
||||
var ntf_msg = new GS2C_NTF_LAND_AUCTION_ALL_LOAD();
|
||||
ntf_packet.Message.NtfLandAuctionAllLoad = ntf_msg;
|
||||
|
||||
ntf_msg.LandAuctionsSummaries.AddRange(landAuctionSummaries.ToList());
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
|
||||
{
|
||||
Log.getLogger().warn($"Failed to onSendPacket() !!! : {ntf_packet.toBasicString()} - {player.toBasicString()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool broadcast_GS2C_NTF_LAND_AUCTION_SUMMARY(LandAuctionSummary landAuctionSummary)
|
||||
{
|
||||
var log_msg = $"call send_GS2C_NTF_LAND_AUCTION_SUMMARY() : {landAuctionSummary.LandAuctionInfo.toBasicString()}";
|
||||
Log.getLogger().debug(log_msg);
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var users = server_logic.getPlayerManager().getUsers();
|
||||
if (0 >= users.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
|
||||
var ntf_msg = new GS2C_NTF_LAND_AUCTION_SUMMARY();
|
||||
ntf_packet.Message.NtfLandAuctionSummary = ntf_msg;
|
||||
|
||||
ntf_msg.LandAuctionSummary = landAuctionSummary;
|
||||
|
||||
var players = users.Values.ToArray();
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(players, ntf_packet))
|
||||
{
|
||||
Log.getLogger().warn($"Failed to onSendPacket() !!! : {ntf_packet.toBasicString()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool broadcast_GS2GS_NTF_LAND_AUCTION_HIGHEST_BIDDER_CHANGE( USER_GUID receiverUserGuid, BoolType hasReceivedRefundMail
|
||||
, META_ID landMetaId
|
||||
, CurrencyType currencyType, double highestBidPrice
|
||||
, USER_GUID highestBidUserGuid, USER_NICKNAME highestBidUserNickname )
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var message = new ServerMessage();
|
||||
var ntf_msg = new GS2GS_NTF_LAND_AUCTION_HIGHEST_BIDDER_CHANGE();
|
||||
message.NtfLandAuctionHighestBidderChange = ntf_msg;
|
||||
|
||||
ntf_msg.ReceiverUserGuid = receiverUserGuid;
|
||||
ntf_msg.HasReceivedRefundMail = hasReceivedRefundMail;
|
||||
ntf_msg.LandMetaId = (Int32)landMetaId;
|
||||
|
||||
ntf_msg.CurrencyType = currencyType;
|
||||
ntf_msg.HighestBidPrice = highestBidPrice;
|
||||
ntf_msg.HighestBidUserGuid = highestBidUserGuid;
|
||||
ntf_msg.HighestBidUserNickname = highestBidUserNickname;
|
||||
|
||||
var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game;
|
||||
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!");
|
||||
|
||||
rabbit_mq.sendMessageToExchangeAllGame(message);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool send_GS2C_NTF_LAND_AUCTION_HIGHEST_BIDDER_CHANGE( Player player
|
||||
, META_ID landMetaId
|
||||
, CurrencyType bidCurrencyType, double highestBidPrice
|
||||
, USER_GUID highestUserGuid, USER_NICKNAME highestUserNickname )
|
||||
{
|
||||
var log_msg = $"call send_GS2C_NTF_LAND_AUCTION_HIGHEST_BIDDER_CHANGE !!! : landMetaId:{landMetaId}, highestBidPrice:{highestBidPrice}, highestUserNickname:{highestUserNickname}";
|
||||
Log.getLogger().debug(log_msg);
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new();
|
||||
|
||||
var ntf_msg = new GS2C_NTF_LAND_AUCTION_HIGHEST_BIDDER_CHANGE();
|
||||
ntf_packet.Message.NtfLandAuctionHighestBidderChange = ntf_msg;
|
||||
|
||||
ntf_msg.LandMetaId = (Int32)landMetaId;
|
||||
ntf_msg.CurrencyType = bidCurrencyType;
|
||||
ntf_msg.HighestBidPrice = highestBidPrice;
|
||||
ntf_msg.HighestBidUserGuid = highestUserGuid;
|
||||
ntf_msg.HighestBidUserNickname = highestUserNickname;
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
|
||||
{
|
||||
Log.getLogger().warn($"Failed to onSendPacket() !!! : {ntf_packet.toBasicString()} - {player.toBasicString()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool broadcast_GS2C_NTF_LAND_AUCTION_WINNING_BID(USER_NICKNAME winningUserNickname, META_ID landMetaId)
|
||||
{
|
||||
var log_msg = $"call broadcast_GS2C_NTF_LAND_AUCTION_WINNING_BID !!! : winningUserNickname:{winningUserNickname}, landMetaId:{landMetaId}";
|
||||
Log.getLogger().debug(log_msg);
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var users = server_logic.getPlayerManager().getUsers();
|
||||
var players = users.Values.ToArray();
|
||||
|
||||
if (players.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var ntf_packet = new ClientToGame();
|
||||
ntf_packet.Message = new ClientToGameMessage();
|
||||
|
||||
var ntf_msg = new GS2C_NTF_LAND_AUCTION_WINNING_BID();
|
||||
ntf_packet.Message.NtfLandAuctionWinningBid = ntf_msg;
|
||||
ntf_msg.WinningUserNickname = winningUserNickname;
|
||||
ntf_msg.LandMetaId = (int)landMetaId;
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(players, ntf_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void broadcast_GS2GS_NTF_LAND_AUCTION_WINNING_BID( USER_GUID winningUserGuid, USER_NICKNAME winningUserNickname
|
||||
, META_ID landMetaId, List<META_ID> buildingMetaIds
|
||||
, BoolType isNewRecvMail = BoolType.True)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var message = new ServerMessage();
|
||||
var ntf_msg = new GS2GS_NTF_LAND_AUCTION_WINNING_BID();
|
||||
message.NtfLandAuctionWinningBid = ntf_msg;
|
||||
|
||||
ntf_msg.WinningUserGuid = winningUserGuid;
|
||||
ntf_msg.WinningUserNickname = winningUserNickname;
|
||||
ntf_msg.LandMetaId = (int)landMetaId;
|
||||
ntf_msg.BuildingMetaIds.AddRange( Array.ConvertAll<META_ID, int>(buildingMetaIds.ToArray(), Convert.ToInt32).ToList());
|
||||
ntf_msg.IsNewRecvMail = isNewRecvMail;
|
||||
|
||||
var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game;
|
||||
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!");
|
||||
|
||||
rabbit_mq.sendMessageToExchangeAllGame(message);
|
||||
}
|
||||
|
||||
public static void broadcast_GS2GS_NTF_LAND_AUCTION_RESERVATION(List<META_ID> toAddActivitings)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var message = new ServerMessage();
|
||||
var ntf_msg = new GS2GS_NTF_LAND_AUCTION_RESERVATION();
|
||||
message.NtfLandAuctionReservation = ntf_msg;
|
||||
|
||||
ntf_msg.ToAddActivitings.AddRange(Array.ConvertAll<META_ID, int>(toAddActivitings.ToArray(), Convert.ToInt32).ToList());
|
||||
|
||||
var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game;
|
||||
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!");
|
||||
|
||||
rabbit_mq.sendMessageToExchangeAllGame(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public static class LandAuctionReservationHelper
|
||||
{
|
||||
//=========================================================================================
|
||||
// 예약된 랜드 경매 정보가 있는지 확인하고
|
||||
// 있다면 활성화중인 랜드 경매의 종료 상태를 확인하여
|
||||
// 종료 상태라면 LandAuctionActivityDoc.AuctionNumber를 예약된 정보로 변경 및 저장 한다.
|
||||
//=========================================================================================
|
||||
public static async Task<(Result, bool)> configureNextLandAuctionToDb(META_ID landMetaId)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var db_connector = server_logic.getDynamoDbClient();
|
||||
|
||||
var last_auction_number = 0;
|
||||
|
||||
(result, var found_activity_doc) = await LandAuctionDbHelper.readLandAuctionActivityDocFromDb(landMetaId, false);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to readLandAuctionActivityDocFromDb() !!! : {result.toBasicString()} - landMetaId:{landMetaId}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, false);
|
||||
}
|
||||
if (null != found_activity_doc)
|
||||
{
|
||||
// 현재 활성화중인 랜드 경매 종료 상태를 체크 한다.
|
||||
var curr_activity_attrib = found_activity_doc.getAttrib<LandAuctionActivityAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(curr_activity_attrib, () => $"curr_activity_attrib is null !!! - landMetaId:{landMetaId}");
|
||||
var activity_auction_number = curr_activity_attrib.AuctionNumber;
|
||||
ConditionValidCheckHelper.throwIfFalseWithCondition( () => 0 < activity_auction_number
|
||||
, () => $"Invalid AuctionNubmer !!! : 0 < activityAuctionNumber:{activity_auction_number}"
|
||||
+ $" - landMetaId:{landMetaId}");
|
||||
last_auction_number = activity_auction_number;
|
||||
|
||||
(result, var last_registry_doc) = await LandAuctionDbHelper.readLandAuctionRegistryDocFromDb(landMetaId, last_auction_number);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to readLandAuctionRegistryDocFromDb() !!! : {result.toBasicString()} - landMetaId:{landMetaId}, lastAuctionNumber:{last_auction_number}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, false);
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(last_registry_doc, () => $"last_registry_doc is null !!! - landMetaId:{landMetaId}, lastAuctionNumber:{last_auction_number}");
|
||||
var last_registry_attrib = last_registry_doc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(last_registry_attrib, () => $"last_registry_attrib is null !!! - landMetaId:{landMetaId}, lastAuctionNumber:{last_auction_number}");
|
||||
|
||||
if(LandAuctionResult.None == last_registry_attrib.LandAuctionResult)
|
||||
{
|
||||
if (true == LandAuctionManager.It.hasActivitingLandAuction(landMetaId))
|
||||
{
|
||||
// 아직 경매 처리 진행전 이다 !!!
|
||||
return (result, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 활성화 목록에 로딩을 해야 한다 !!!
|
||||
return (result, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 다음 예약된 경매가 있는지 체크 한다.
|
||||
// 있다면 LandAuctionActivityDoc.AuctionNumber에 설정 한다. !!!
|
||||
var next_auction_number = last_auction_number + 1;
|
||||
(result, var found_registry_doc) = await LandAuctionDbHelper.readLandAuctionRegistryDocFromDb(landMetaId, next_auction_number, false);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to readLandAuctionRegistryDocFromDb() !!! : {result.toBasicString()} - landMetaId:{landMetaId}, auctionNumber:{next_auction_number}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, false);
|
||||
}
|
||||
if (null == found_registry_doc)
|
||||
{
|
||||
return (result, false);
|
||||
}
|
||||
var registry_attrib = found_registry_doc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(registry_attrib, () => $"registry_attrib is null !!! - landMetaId:{landMetaId}, auctionNumber:{next_auction_number}");
|
||||
|
||||
result = registry_attrib.checkValidLandAuctionRegistry();
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, false);
|
||||
}
|
||||
|
||||
if (null == found_activity_doc)
|
||||
{
|
||||
var new_activity_doc = new LandAuctionActivityDoc(landMetaId);
|
||||
found_activity_doc = new_activity_doc;
|
||||
}
|
||||
|
||||
var activity_attrib = found_activity_doc.getAttrib<LandAuctionActivityAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(activity_attrib, () => $"activity_attrib is null !!! - landMetaId:{landMetaId}");
|
||||
|
||||
if (next_auction_number <= activity_attrib.AuctionNumber)
|
||||
{
|
||||
// 이미 next_auction_number이상으로 설정 되었다면 갱신할 필요가 없다 !!!
|
||||
return (result, false);
|
||||
}
|
||||
|
||||
activity_attrib.AuctionNumber = next_auction_number;
|
||||
|
||||
result = await db_connector.simpleUpsertDocumentWithDocType(found_activity_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to simpleInsertDocumentWithDocType<LandAuctionActivityDoc> !!! : {result.toBasicString()}, auctionNumber:{next_auction_number} - landMetaId:{landMetaId}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, false);
|
||||
}
|
||||
|
||||
LandAuctionBusinessLogHelper.writeBusinessLogByLandAuctionActivity(found_activity_doc);
|
||||
|
||||
err_msg = $"Configure Next LandAuctionKey !!!, nextAuctionNumber:{next_auction_number} - landMetaId:{landMetaId}";
|
||||
Log.getLogger().debug(err_msg);
|
||||
|
||||
return (result, true);
|
||||
}
|
||||
|
||||
public static async Task<(Result, Int32)> getNextLandAuctionNumber(META_ID landMetaId)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var db_connector = server_logic.getDynamoDbClient();
|
||||
|
||||
var last_auction_number = 0;
|
||||
|
||||
(result, var found_activity_doc) = await LandAuctionDbHelper.readLandAuctionActivityDocFromDb(landMetaId, false);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to readLandAuctionActivityDocFromDb() !!! : {result.toBasicString()} - landMetaId:{landMetaId}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, 0);
|
||||
}
|
||||
if (null != found_activity_doc)
|
||||
{
|
||||
var activity_attrib = found_activity_doc.getAttrib<LandAuctionActivityAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(activity_attrib, () => $"activity_attrib is null !!! - landMetaId:{landMetaId}");
|
||||
var activity_auction_number = activity_attrib.AuctionNumber;
|
||||
ConditionValidCheckHelper.throwIfFalseWithCondition( () => 0 < activity_auction_number
|
||||
, () => $"Invalid AuctionNubmer !!! : 0 < activityAuctionNumber:{activity_auction_number}"
|
||||
+ $" - landMetaId:{landMetaId}" );
|
||||
last_auction_number = activity_auction_number;
|
||||
}
|
||||
|
||||
var next_auction_number = 0;
|
||||
var is_continue = true;
|
||||
|
||||
while (is_continue)
|
||||
{
|
||||
next_auction_number = last_auction_number + 1;
|
||||
|
||||
(result, var found_registry_doc) = await LandAuctionDbHelper.readLandAuctionRegistryDocFromDb(landMetaId, next_auction_number, false);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to readLandAuctionRegistryDocFromDb() !!! : {result.toBasicString()} - landMetaId:{landMetaId}, auctionNumber:{next_auction_number}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, 0);
|
||||
}
|
||||
|
||||
if (null == found_registry_doc)
|
||||
{
|
||||
is_continue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
last_auction_number = next_auction_number;
|
||||
}
|
||||
|
||||
return (result, next_auction_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user