250501 커밋

This commit is contained in:
2025-05-01 07:23:28 +09:00
parent 98bb2e3c5c
commit 23176551b7
353 changed files with 9972 additions and 6652 deletions

View File

@@ -14,6 +14,7 @@ using META_ID = System.UInt32;
using BEACON_GUID = System.String;
using ITEM_GUID = System.String;
using USER_GUID = System.String;
using Amazon.S3.Model;
namespace GameServer;
@@ -74,11 +75,6 @@ public class BeaconShopAction : EntityActionBase
}
}
public bool hasBeaconShopSoldRecord(BEACON_GUID beaconGuid)
{
return m_beacon_shop_sold_records.TryGetValue(beaconGuid, out var record);
}
public async Task<Result> AddBeaconShopSoldRecordsFromDocs(List<BeaconShopSoldRecordDoc> beaconShopSoldRecordDocs)
{
var result = new Result();
@@ -174,6 +170,13 @@ public class BeaconShopAction : EntityActionBase
return result;
}
if (isRentalSafeTime(ugc_npc) == false)
{
err_msg = $"Rental Safe Time is over - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopOverRentalSafeTime, err_msg);
return result;
}
var fn_start_register_beacon_shop_item = async delegate ()
{
var result = new Result();
@@ -280,7 +283,7 @@ public class BeaconShopAction : EntityActionBase
);
if (result.isFail()) { return result; }
var task_log_data = BeaconShopBusinessLogHelper.toLogInfo(beaconShopMongoDoc);
var task_log_data = BeaconShopBusinessLogHelper.toLogInfo(beaconShopMongoDoc, beacon_shop_attribute.IsActiveSelling);
invokers.Add(new BeaconShopBusinessLog(task_log_data));
result = await m_beacon_shop_repository.insert(beaconShopMongoDoc);
@@ -317,7 +320,9 @@ public class BeaconShopAction : EntityActionBase
return result;
}
BeaconShopHelper.send_GS2GS_NTF_UPDATE_BEACON_SHOP_ITEM(player.getUserGuid(), BeaconGuid);
var hasBeaconShopItem = ugc_npc_beacon_shop_action.hasBeaconShopItem();
BeaconShopHelper.send_GS2GS_NTF_UPDATE_BEACON_SHOP_ITEM(player.getUserGuid(), BeaconGuid, hasBeaconShopItem);
PacketHandler.BeaconShopRegisterItemPacketHandler.send_S2C_ACK_BEACON_SHOP_REGISTER_ITEM(player, result, beacon_shop_item, found_transaction_runner.getCommonResult());
return result;
@@ -352,6 +357,31 @@ public class BeaconShopAction : EntityActionBase
return result;
}
var ugc_npc_beacon_shop_action = found_ugc_npc.getEntityAction<UgcNpcBeaconShopAction>();
//1. 아이템 찾기
var found_item = ugc_npc_beacon_shop_action.getBeaconShopItem(itemGuid);
if (found_item == null)
{
err_msg = $"Failed to tryGetItemByItemGuid BeaconShopItem !!! : itemGuid : {itemGuid}, {player.toBasicString()}";
result.setFail(ServerErrorCode.ItemNotFound, err_msg);
PacketHandler.BeaconShopReturnItemPacketHandler.send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(player, result);
return result;
}
//2. 판매 아이템 활성화 확인
var beacon_shop_item_attribute = found_item.getEntityAttribute<BeaconShopItemAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_attribute, () => $"beacon_shop_item_attribute is null !!! - {player.toBasicString()}");
if (beacon_shop_item_attribute.IsActiveSelling == true)
{
if (isRentalSafeTime(found_ugc_npc) == false)
{
err_msg = $"Rental Safe Time is over - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopOverRentalSafeTime, err_msg);
return result;
}
}
var fn_start_return_item = async delegate ()
{
using (var runner_with_scope = new EntityTransactionRunnerWithScopLock(found_ugc_npc))
@@ -455,7 +485,7 @@ public class BeaconShopAction : EntityActionBase
{
PacketHandler.BeaconShopReturnItemPacketHandler.send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(player, result);
ugc_npc_beacon_shop_action.setUpdateBeaconShopItem();
player.send_S2C_NTF_BEACON_SHOP_REFRESH(beaconGuid);
player.send_S2C_NTF_BEACON_SHOP_REFRESH(beaconGuid, BoolType.True);
return result;
}
@@ -493,6 +523,39 @@ public class BeaconShopAction : EntityActionBase
return result;
}
var ugc_npc_beacon_shop_action = found_ugc_npc.getEntityAction<UgcNpcBeaconShopAction>();
var beacon_shop_item = ugc_npc_beacon_shop_action.getBeaconShopItem(itemGuid);
if (beacon_shop_item == null)
{
err_msg = $"Not found Beacon Shop Item !!! : itemGuid:{itemGuid} beaconOwner:{beaconOwnerGuid} - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopNotFoundItem, err_msg);
return result;
}
// 판매 아이템 활성화 확인
var beacon_shop_item_attribute = beacon_shop_item.getEntityAttribute<BeaconShopItemAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_attribute, () => $"beacon_shop_item_attribute is null !!! - {player.toBasicString()}");
if (beacon_shop_item_attribute.IsActiveSelling == false)
{
err_msg = $"Is Deactive Selling Item !! - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopDeactiveItemForSell, err_msg);
return result;
}
if (isRentalMyhome(found_ugc_npc) == false)
{
err_msg = $"Beacon is not in myHome !!! - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopBeaconIsNotInRentalHome, err_msg);
return result;
}
if (isRentalSafeTime(found_ugc_npc) == false)
{
err_msg = $"Rental Safe Time is over - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopOverRentalSafeTime, err_msg);
return result;
}
var fn_start_purchase_item = async delegate ()
{
var result = new Result();
@@ -677,7 +740,7 @@ public class BeaconShopAction : EntityActionBase
{
PacketHandler.BeaconShopReturnItemPacketHandler.send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(player, result);
ugc_npc_beacon_shop_action.setUpdateBeaconShopItem();
player.send_S2C_NTF_BEACON_SHOP_REFRESH(beaconGuid);
player.send_S2C_NTF_BEACON_SHOP_REFRESH(beaconGuid, BoolType.True);
return result;
}
@@ -702,7 +765,9 @@ public class BeaconShopAction : EntityActionBase
PacketHandler.BeaconShopPurchaseItemPacketHandler.send_S2C_ACK_BEACON_SHOP_PURCHASE_ITEM(player, result, itemGuid, beaconGuid, left_item_stack_count, found_transaction_runner.getCommonResult());
BeaconShopHelper.send_GS2GS_NTF_UPDATE_BEACON_SHOP_ITEM(beacon_owner_guid, beaconGuid);
var hasBeaconShopItem = ugc_npc_beacon_shop_action.hasBeaconShopItem();
BeaconShopHelper.send_GS2GS_NTF_UPDATE_BEACON_SHOP_ITEM(beacon_owner_guid, beaconGuid, hasBeaconShopItem);
var player_manager = server_logic.getPlayerManager();
if (player_manager.tryGetUserByPrimaryKey(beacon_owner_guid, out var found_user) == true)
@@ -724,6 +789,91 @@ public class BeaconShopAction : EntityActionBase
return result;
}
private bool isRentalMyhome(UgcNpc ugcNpc)
{
var player = getOwner() as Player;
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
var beacon_attribute = ugcNpc.getEntityAttribute<UgcNpcAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_attribute, () => $"beacon_attribute is null !!!");
var rental_agent_action = player.getEntityAction<RentalAgentAction>();
if (beacon_attribute.State != EntityStateType.UsingByMyHome ||
rental_agent_action.isRentalMyhome(beacon_attribute.LocatedInstanceGuid) == false)
{
return false;
}
return true;
}
// 랜탈 기간이 안전한 시간 내 인지 확인
private bool isRentalSafeTime(UgcNpc ugcNpc)
{
var player = getOwner() as Player;
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
var beacon_attribute = ugcNpc.getEntityAttribute<UgcNpcAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_attribute, () => $"beacon_attribute is null !!!");
var rental_agent_action = player.getEntityAction<RentalAgentAction>();
var rental_finish_time = rental_agent_action.getRentalMyhomeFinishTime(beacon_attribute.LocatedInstanceGuid);
if (rental_finish_time.HasValue == false)
{
return false;
}
var now = DateTime.UtcNow;
if (rental_finish_time.Value.AddSeconds(-5) < now)
{
return false;
}
return true;
}
public async Task<Result> BeaconShopDeactiveItems(BEACON_GUID beaconGuid, USER_GUID beaconOwnerGuid, List<ILogInvoker> invokers)
{
var result = new Result();
var err_msg = string.Empty;
var player = getOwner() as Player;
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
// 1. 아이템 비활성화
(result, var found_ugc_npc, var ugc_npc_owner) = await NpcHelper.findUgcNpc(beaconGuid, beaconOwnerGuid);
if (found_ugc_npc == null)
{
if (result.isSuccess())
result.setFail(ServerErrorCode.UgcNpcNotFound, err_msg);
err_msg = $"Not found Beacon !!! : beaconOwner:{beaconOwnerGuid} - {player.toBasicString()}";
return result;
}
var ugc_npc_attribute = found_ugc_npc.getEntityAttribute<UgcNpcAttribute>();
NullReferenceCheckHelper.throwIfNull(ugc_npc_attribute, () => $"ugc_npc_attribute is null !!! - {player.toBasicString()}");
var ugc_npc_beacon_shop_action = found_ugc_npc.getEntityAction<UgcNpcBeaconShopAction>();
ugc_npc_beacon_shop_action.setDeactiveAllItems();
//2. mongo에서 제거 & 비지니스 로그 작성
var beacon_shop_item_list = ugc_npc_beacon_shop_action.getHasBeaconShopItem();
foreach (var beacon_shop_item in beacon_shop_item_list)
{
var beacon_shop_item_attribute = beacon_shop_item.getEntityAttribute<BeaconShopItemAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_attribute, () => $"beacon_shop_item_attribute is null !!! - {toBasicString()}");
await m_beacon_shop_repository.delete(beacon_shop_item_attribute.ItemGuid);
var task_log_data = BeaconShopBusinessLogHelper.toLogInfo(beacon_shop_item_attribute, ugc_npc_attribute, player.getUserGuid());
invokers.Add(new BeaconShopBusinessLog(task_log_data));
}
return result;
}
private (Result, DynamoDbItemRequestQueryContext?) BeaconShopSoldPriceUpdate(string combinationKeyForPK, string combinationKeyForSK, double givenPrice, double taxPrice, int numOfReceiptNotReceived)
{
var result = new Result();
@@ -1062,19 +1212,24 @@ public class BeaconShopAction : EntityActionBase
return result;
}
int numOfReceiptNotReceived = 0;
if (m_beacon_shop_sold_price.TryGetValue(beaconGuid, out var beaconShopSoldPrice) == true)
{
var beacon_shop_sold_price_attribute = beaconShopSoldPrice.getEntityAttribute<BeaconShopSoldPriceAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_sold_price_attribute, () => $"beacon_shop_sold_price_attribute is null !!! - {player.toBasicString()}");
numOfReceiptNotReceived = beacon_shop_sold_price_attribute.NumOfReceiptNotReceived;
}
int numOfReceiptNotReceived = getBeaconShopNumOfReceiptNotReceived(beaconGuid);
PacketHandler.BeaconShopGetItemInfosPacketHandler.send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(player, result, beacon_shop_item_reload_data, beacon_shop_profile_attribute.DailyRegisterCount, numOfReceiptNotReceived);
return result;
}
public int getBeaconShopNumOfReceiptNotReceived(BEACON_GUID beaconGuid)
{
if (m_beacon_shop_sold_price.TryGetValue(beaconGuid, out var beaconShopSoldPrice) == true)
{
var beacon_shop_sold_price_attribute = beaconShopSoldPrice.getEntityAttribute<BeaconShopSoldPriceAttribute>();
NullReferenceCheckHelper.throwIfNull(beacon_shop_sold_price_attribute, () => $"beacon_shop_sold_price_attribute is null !!! - {getOwner().toBasicString()}");
return beacon_shop_sold_price_attribute.NumOfReceiptNotReceived;
}
return 0;
}
private async Task<Result> ProcessUpdateDailyRegisterCount(UgcNpc found_ugc_npc)
{
var result = new Result();
@@ -1134,10 +1289,7 @@ public class BeaconShopAction : EntityActionBase
NullReferenceCheckHelper.throwIfNull(beacon_attribute, () => $"beacon_attribute is null !!!");
// 1. 비컨 체크
var rental_agent_action = player.getEntityAction<RentalAgentAction>();
if (beacon_attribute.State != EntityStateType.UsingByMyHome ||
rental_agent_action.isRentalMyhome(beacon_attribute.LocatedInstanceGuid) == false)
if (isRentalMyhome(ugcNpc) == false)
{
err_msg = $"Beacon is not in myHome !!! : beacon State:{beacon_attribute.State} - {player.toBasicString()}";
result.setFail(ServerErrorCode.BeaconShopBeaconIsNotInRentalHome, err_msg);

View File

@@ -89,12 +89,13 @@ namespace GameServer
beacon_shop_attribute.BeaconGuid = beacon_guid;
beacon_shop_attribute.SellingFinishTime = selling_finish_time;
beacon_shop_attribute.PriceForUnit = price_for_unit;
beacon_shop_attribute.IsActiveSelling = true;
beacon_shop_attribute.ItemMetaId = deleted_item_attribute.ItemMetaId;
beacon_shop_attribute.ItemStackCount = amount;
beacon_shop_attribute.Level = deleted_item_attribute.Level;
beacon_shop_attribute.Attributes = deleted_item_attribute.Attributes.Select(x => x).ToList();
beacon_shop_attribute.EquipedIvenType = deleted_item_attribute.EquipedIvenType;
beacon_shop_attribute.EquipedInvenType = deleted_item_attribute.EquipedInvenType;
beacon_shop_attribute.EquipedPos = deleted_item_attribute.EquipedPos;
beacon_shop_attribute.newEntityAttribute();
@@ -132,6 +133,7 @@ namespace GameServer
beacon_shop_4_client.ItemMetaid = (int)beacon_shop_attribute.ItemMetaId;
beacon_shop_4_client.SellingFinishTime = Timestamp.FromDateTime(beacon_shop_attribute.SellingFinishTime);
beacon_shop_4_client.PriceForUnit = beacon_shop_attribute.PriceForUnit;
beacon_shop_4_client.IsActiveSelling = beacon_shop_attribute.IsActiveSelling == true ? BoolType.True : BoolType.False;
beacon_shop_4_client.Amount = beacon_shop_attribute.ItemStackCount;
return beacon_shop_4_client;

View File

@@ -10,6 +10,41 @@ namespace GameServer
{
internal static class BeaconShopHelper
{
public static async Task<Result> DeactiveBeaconShopItems(string beaconGuid)
{
var server_logic = GameServerApp.getServerLogic();
var dynamo_db_client = server_logic.getDynamoDbClient();
var (result, primary_key_object) = await DynamoDBDocBaseHelper.makePrimaryKey<BeaconShopItemDoc>(beaconGuid);
if (result.isFail() || primary_key_object == null)
{
return result;
}
var query_config = dynamo_db_client.makeQueryConfigForReadByPKOnly(primary_key_object.PK);
(result, var read_docs) = await dynamo_db_client.simpleQueryDocTypesWithQueryOperationConfig<BeaconShopItemDoc>(query_config);
if (result.isFail())
{
return result;
}
foreach (var beacon_shop_item_doc in read_docs)
{
var beaconShopItemAttrib = beacon_shop_item_doc.getAttrib<BeaconShopItemAttrib>();
NullReferenceCheckHelper.throwIfNull(beaconShopItemAttrib, () => $"beaconShopItemAttrib is null !!");
beaconShopItemAttrib.IsActiveSelling = false;
beacon_shop_item_doc.setQueryType(QueryType.Update);
result = await dynamo_db_client.simpleUpdateDocumentWithDocType(beacon_shop_item_doc);
if (result.isFail())
{
return result;
}
}
return result;
}
public static BeaconShopItemBoardInfo toBeaconShopItemMongoDataClient(this BeaconShopMongoDoc beaconShopMongoDoc)
{
var beacon_shop_4_client = new BeaconShopItemBoardInfo();
@@ -81,7 +116,7 @@ namespace GameServer
rabbit_mq_4_game.SendMessage(targetServer, ntf_packet);
}
public static void send_GS2GS_NTF_UPDATE_BEACON_SHOP_ITEM(USER_GUID targetUserGuid, BEACON_GUID targetBeaconGuid)
public static void send_GS2GS_NTF_UPDATE_BEACON_SHOP_ITEM(USER_GUID targetUserGuid, BEACON_GUID targetBeaconGuid, bool hasBeaconShopItem)
{
var server_logic = GameServerApp.getServerLogic();
@@ -94,6 +129,7 @@ namespace GameServer
ntf_update_beacon_shop_item.TargetUserGuid = targetUserGuid;
ntf_update_beacon_shop_item.TargetBeaconGuid = targetBeaconGuid;
ntf_update_beacon_shop_item.HasBeaconShopItem = hasBeaconShopItem == true ? BoolType.True : BoolType.False;
rabbit_mq_4_game.sendMessageToExchangeAllGame(ntf_packet);
}
@@ -112,7 +148,7 @@ namespace GameServer
item_attrib.ItemStackCount = itemStackCount;
item_attrib.Level = beacon_shop_item_attrib.Level;
item_attrib.Attributes = beacon_shop_item_attrib.Attributes.Select(x => x).ToList();
item_attrib.EquipedIvenType = beacon_shop_item_attrib.EquipedIvenType;
item_attrib.EquipedInvenType = beacon_shop_item_attrib.EquipedInvenType;
item_attrib.EquipedPos = beacon_shop_item_attrib.EquipedPos;
return itemDoc;

View File

@@ -6,14 +6,14 @@ namespace GameServer
{
static public class BeaconShopBusinessLogHelper
{
static public BeaconShopLogData toLogInfo(BeaconShopMongoDoc beaconShopMongoDoc)
static public BeaconShopLogData toLogInfo(BeaconShopMongoDoc beaconShopMongoDoc, bool isActiveSelling)
{
var logData = new BeaconShopLogData();
logData.setInfo(beaconShopMongoDoc);
logData.setInfo(beaconShopMongoDoc, isActiveSelling);
return logData;
}
static public void setInfo(this BeaconShopLogData logData, BeaconShopMongoDoc beaconShopMongoDoc)
static public void setInfo(this BeaconShopLogData logData, BeaconShopMongoDoc beaconShopMongoDoc, bool isActiveSelling)
{
logData.ItemGuid = beaconShopMongoDoc.ItemGuid;
logData.TagId = beaconShopMongoDoc.TagId;
@@ -28,6 +28,7 @@ namespace GameServer
logData.BeaconMyHomeGuid = beaconShopMongoDoc.BeaconMyHomeGuid;
logData.SellingFinishTime = beaconShopMongoDoc.SellingFinishTime;
logData.BuyerGuid = string.Empty;
logData.IsActiveSelling = isActiveSelling;
}
static public BeaconShopLogData toLogInfo(BeaconShopItemAttribute beaconShopItemAttribute, UgcNpcAttribute ugcNpcAttribute, string buyerGuid)
@@ -51,6 +52,7 @@ namespace GameServer
logData.BeaconMyHomeGuid = ugcNpcAttribute.LocatedInstanceGuid;
logData.SellingFinishTime = beaconShopItemAttribute.SellingFinishTime;
logData.BuyerGuid = buyerGuid;
logData.IsActiveSelling = beaconShopItemAttribute.IsActiveSelling;
}
static public BeaconShopSoldRecordLogData toLogInfo(BeaconShopSoldRecordAttribute beaconShopSoldRecordAttribute)

View File

@@ -5,9 +5,9 @@ namespace GameServer
{
public static class BeaconShopNotifyHelper
{
public static bool send_S2C_NTF_BEACON_SHOP_REFRESH(this Player player, BEACON_GUID beaconGuid)
public static bool send_S2C_NTF_BEACON_SHOP_REFRESH(this Player player, BEACON_GUID beaconGuid, BoolType hasBeaconShopItem)
{
var noti_packet = makeAckBeaconShopRefreshPacket(beaconGuid);
var noti_packet = makeAckBeaconShopRefreshPacket(beaconGuid, hasBeaconShopItem);
if (false == GameServerApp.getServerLogic().onSendPacket(player, noti_packet))
{
@@ -17,13 +17,14 @@ namespace GameServer
return true;
}
public static ClientToGame makeAckBeaconShopRefreshPacket(BEACON_GUID beaconGuid)
public static ClientToGame makeAckBeaconShopRefreshPacket(BEACON_GUID beaconGuid, BoolType hasBeaconShopItem)
{
var noti_packet = new ClientToGame();
noti_packet.Message = new();
noti_packet.Message.NtfBeaconShopRefresh = new();
noti_packet.Message.NtfBeaconShopRefresh.BeaconGuid = beaconGuid;
noti_packet.Message.NtfBeaconShopRefresh.HasBeaconShopItem = hasBeaconShopItem;
return noti_packet;
}