250501 커밋
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user