초기커밋

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,201 @@
using ServerCommon;
using ServerCore; using ServerBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using META_ID = System.UInt32;
namespace GameServer
{
internal class LandAction : EntityActionBase
{
public LandAction(Land owner)
: base(owner)
{ }
public override async Task<Result> onInit()
{
var result = new Result();
return await Task.FromResult(result);
}
public override void onClear()
{
return;
}
public async Task<Result> tryLoadLandFromDb(int landMetaId)
{
var result = new Result();
var err_msg = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var db_client = server_logic.getDynamoDbClient();
var doc = new LandDoc();
doc.setCombinationKeyForPK(landMetaId.ToString());
var error_code = doc.onApplyPKSK();
if (error_code.isFail())
{
err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()}";
result.setFail(error_code, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
var query_config = db_client.makeQueryConfigForReadByPKSK(doc.getPK());
(result, var read_docs) = await db_client.simpleQueryDocTypesWithQueryOperationConfig<LandDoc>(query_config);
if (result.isFail())
{
err_msg = $"Failed to simpleQueryDocTypesWithQueryOperationConfig() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
foreach (var read_doc in read_docs)
{
if (!land_attribute.copyEntityAttributeFromDoc(read_doc))
{
err_msg = $"Failed to copyEntityAttributeFromDoc() !!! to:{land_attribute.getTypeName()}, from:{read_doc.getTypeName()} : {this.getTypeName()}";
result.setFail(ServerErrorCode.DynamoDbDocCopyToEntityAttributeFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
if (land_attribute.LandMetaId == 0)
{
land_attribute.LandMetaId = (uint)landMetaId;
if (read_docs.Count != 0)
{
Log.getLogger().info($"LandDoc.LandAtrib.LandMetaId is 0 !!! - landMetaId:{landMetaId}");
}
}
return result;
}
public async Task<(Result, DynamoDbDocBase?)> modifyLandInfo(string landName, string landDescription)
{
var result = new Result();
var err_msg = string.Empty;
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
land_attribute.LandName = landName;
land_attribute.Description = landDescription;
land_attribute.IsLoadFromDb = true;
land_attribute.modifiedEntityAttribute();
(result, var land_doc) = await land_attribute.toDocBase();
if (result.isFail())
{
err_msg = $"Failed to toDocBase() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return (result, null);
}
return (result, land_doc);
}
public void modifyLandInfo(LandInfo landInfo)
{
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
land_attribute.OwnerUserGuid = landInfo.OwnerUserGuid;
land_attribute.LandName = landInfo.LandName;
land_attribute.Description = landInfo.LandDescription;
land_attribute.modifiedEntityAttribute();
}
public bool isExistOwner()
{
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
return land_attribute.OwnerUserGuid != string.Empty;
}
public void setLandOwner(int landMetaId, string userGuid)
{
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
if (!land_attribute.IsLoadFromDb)
{
land_attribute.LandMetaId = (uint)landMetaId;
land_attribute.OwnerUserGuid = userGuid;
land_attribute.newEntityAttribute();
}
else
{
land_attribute.OwnerUserGuid = userGuid;
land_attribute.modifiedEntityAttribute();
}
}
public void changeOwner(string userGuid)
{
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
land_attribute.OwnerUserGuid = userGuid;
land_attribute.modifiedEntityAttribute();
}
public void initOwner()
{
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
land_attribute.OwnerUserGuid = string.Empty;
land_attribute.modifiedEntityAttribute();
}
public bool isLandOwner(string userGuid)
{
var land = getOwner() as Land;
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!!");
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
return land_attribute.OwnerUserGuid == userGuid;
}
}
}

View File

@@ -0,0 +1,30 @@
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using ServerCore; using ServerBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GameServer
{
internal static class LandBusinessLogHelper
{
public static LandLogInfo toLandLogInfo(this Land land)
{
var land_attribue = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribue, () => $"land_attribue is null !!!");
var land_log_info = new LandLogInfo();
land_log_info.setLandInfo(land_attribue);
return land_log_info;
}
public static void setLandInfo(this LandLogInfo log, LandAttribute landAttribute)
{
log.setLogProperty((int)landAttribute.LandMetaId, landAttribute.OwnerUserGuid);
}
}
}

View File

@@ -0,0 +1,216 @@
using Amazon.Runtime.Internal;
using Org.BouncyCastle.Asn1.Ocsp;
using ServerCommon;
using ServerCore; using ServerBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GameServer
{
internal static class LandHelper
{
public static async Task<LandInfo> toLandInfo(this Land land)
{
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!!");
var land_info = new LandInfo();
land_info.LandMetaId = (int)land_attribute.LandMetaId;
land_info.LandName = land_attribute.LandName;
land_info.LandDescription = land_attribute.Description;
land_info.OwnerUserGuid = land_attribute.OwnerUserGuid;
if (land_attribute.OwnerUserGuid != string.Empty)
{
var (result, nickname_attrib) = await NicknameDoc.findNicknameFromGuid(land_attribute.OwnerUserGuid);
if (result.isSuccess() && nickname_attrib != null)
{
land_info.OwnerUserNickname = nickname_attrib.Nickname;
}
}
return land_info;
}
public static async Task<(Result, Land?, OwnedLand?, DynamoDbDocBase?)> tryGainLand(Player player, int landMetaId)
{
var result = new Result();
var err_msg = string.Empty;
var server_logic = GameServerApp.getServerLogic();
if (!MetaData.Instance._LandTable.TryGetValue(landMetaId, out var land_meta_data))
{
err_msg = $"Failed to MetaData.TryGetValue() !!! : LandMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandMetaDataNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
if (land_meta_data.Editor != MetaAssets.EditorType.USER)
{
err_msg = $"Land EditorType is NOT USER !!! : LandMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandEditorIsNotUser, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
if (!MapManager.Instance.GetLandMapTree(landMetaId, out var land_map_tree))
{
err_msg = $"Failed to GetLandMapTree() !!! : LandMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandMapTreeDataNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
var land_manager = server_logic.getLandManager();
if (!land_manager.tryGetLand(landMetaId, out var land))
{
err_msg = $"Failed to tryGetLand() !!! : landMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
var land_action = land.getEntityAction<LandAction>();
NullReferenceCheckHelper.throwIfNull(land_action, () => $"land_action is null !!! - {player.toBasicString()}");
if (land_action.isExistOwner())
{
err_msg = $"Land Exist Owner !!! : landMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandExistOwner, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
var user_guid = player.getUserGuid();
land_action.setLandOwner(landMetaId, user_guid);
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!! - {player.toBasicString()}");
(result, var land_doc_base) = await land_attribute.toDocBase();
if (result.isFail())
{
err_msg = $"Failed to toDocBase() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return (result, null, null, null);
}
NullReferenceCheckHelper.throwIfNull(land_doc_base, () => $"land_doc_base is null !!! - {player.toBasicString()}");
(result, var owned_land) = await OwnedLandHelper.createOwnedLand(player, landMetaId, OwnedType.Own);
if (result.isFail())
{
err_msg = $"Failed to createOwnedLand() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return (result, null, null, null);
}
NullReferenceCheckHelper.throwIfNull(owned_land, () => $"owned_land is null !!! - {player.toBasicString()}");
return (result, land, owned_land, land_doc_base);
}
public static async Task<(Result, Land?, OwnedLand?, DynamoDbDocBase?)> tryInitMyLandOwnership(Player player, int landMetaId)
{
var result = new Result();
var err_msg = string.Empty;
var server_logic = GameServerApp.getServerLogic();
if (!MetaData.Instance._LandTable.TryGetValue(landMetaId, out var land_meta_data))
{
err_msg = $"Failed to MetaData.TryGetValue() !!! : LandMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandMetaDataNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
if (land_meta_data.Editor != MetaAssets.EditorType.USER)
{
err_msg = $"Land EditorType is NOT USER !!! : LandMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandEditorIsNotUser, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
if (!MapManager.Instance.GetLandMapTree(landMetaId, out var land_map_tree))
{
err_msg = $"Failed to GetLandMapTree() !!! : LandMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandMapTreeDataNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
var land_manager = server_logic.getLandManager();
if (!land_manager.tryGetLand(landMetaId, out var land))
{
err_msg = $"Failed to tryGetLand() !!! : landMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
var land_action = land.getEntityAction<LandAction>();
NullReferenceCheckHelper.throwIfNull(land_action, () => $"land_action is null !!! - {player.toBasicString()}");
var user_guid = player.getUserGuid();
if (!land_action.isLandOwner(user_guid))
{
err_msg = $"Land Owner is Not Match !!! : landMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.LandOwnerIsNotMatch, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
land_action.initOwner();
var land_attribute = land.getEntityAttribute<LandAttribute>();
NullReferenceCheckHelper.throwIfNull(land_attribute, () => $"land_attribute is null !!! - {player.toBasicString()}");
(result, var land_doc_base) = await land_attribute.toDocBase();
if (result.isFail())
{
err_msg = $"Failed to toDocBase() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return (result, null, null, null);
}
NullReferenceCheckHelper.throwIfNull(land_doc_base, () => $"land_doc_base is null !!! - {player.toBasicString()}");
var owned_land_agent_action = player.getEntityAction<OwnedLandAgentAction>();
NullReferenceCheckHelper.throwIfNull(owned_land_agent_action, () => $"owned_land_agent_action is null !!! - {player.toBasicString()}");
if (!owned_land_agent_action.tryGetOwnedLand(landMetaId, out var owned_land))
{
err_msg = $"Failed to tryGetOwnedLand() !!! : landMetaId:{landMetaId} - {player.toBasicString()}";
result.setFail(ServerErrorCode.OwnedLandNotFound, err_msg);
Log.getLogger().error(result.toBasicString());
return (result, null, null, null);
}
var owned_land_action = owned_land.getEntityAction<OwnedLandAction>();
NullReferenceCheckHelper.throwIfNull(owned_land_action, () => $"owned_land_action is null !!! - {player.toBasicString()}");
owned_land_action.DeleteOwnedLand();
return (result, land, owned_land, land_doc_base);
}
}
}

View File

@@ -0,0 +1,130 @@
using Microsoft.AspNetCore.Mvc;
using ServerCommon;
using ServerCore; using ServerBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading.Tasks;
using static ClientToGameMessage.Types;
using static ServerMessage.Types;
namespace GameServer
{
internal static class LandNotifyHelper
{
public static async Task<bool> send_S2C_NTF_LAND_INFOS(this Player player)
{
var server_logic = GameServerApp.getServerLogic();
var land_manager = server_logic.getLandManager();
var ntf_packet = new ClientToGame();
ntf_packet.Message = new ClientToGameMessage();
ntf_packet.Message.NtfLandInfos = new GS2C_NTF_LAND_INFOS();
var land_infos = await land_manager.getLandInfos();
foreach (var land_info in land_infos)
{
ntf_packet.Message.NtfLandInfos.LandInfos.Add(land_info.LandMetaId, land_info);
}
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
{
return false;
}
return true;
}
public static bool broadcast_S2C_NTF_LAND_INFOS(LandInfo landInfo)
{
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();
ntf_packet.Message.NtfLandInfos = new GS2C_NTF_LAND_INFOS();
ntf_packet.Message.NtfLandInfos.LandInfos.Add(landInfo.LandMetaId, landInfo);
if (false == GameServerApp.getServerLogic().onSendPacket(players, ntf_packet))
{
return false;
}
return true;
}
public static bool broadcast_S2C_NTF_LAND_INFOS(List<LandInfo> landInfos)
{
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();
ntf_packet.Message.NtfLandInfos = new GS2C_NTF_LAND_INFOS();
foreach (var landInfo in landInfos)
{
ntf_packet.Message.NtfLandInfos.LandInfos.Add(landInfo.LandMetaId, landInfo);
}
if (false == GameServerApp.getServerLogic().onSendPacket(players, ntf_packet))
{
return false;
}
return true;
}
public static bool send_GS2GS_NTF_MODIFY_LAND_INFO(List<LandInfo> landInfos)
{
var server_logic = GameServerApp.getServerLogic();
var message = new ServerMessage();
message.NtfModifyLandInfo = new GS2GS_NTF_MODIFY_LAND_INFO();
message.NtfModifyLandInfo.ExceptServerName = server_logic.getServerName();
message.NtfModifyLandInfo.LandInfos.AddRange(landInfos);
var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game;
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!");
rabbit_mq.sendMessageToExchangeAllGame(message);
return true;
}
public static async Task<bool> sendNtfModifyLandInfo(Land land)
{
var land_info = await land.toLandInfo();
var land_infos = new List<LandInfo>();
land_infos.Add(land_info);
// 현재 서버 유저
broadcast_S2C_NTF_LAND_INFOS(land_info);
// 다른 서버
send_GS2GS_NTF_MODIFY_LAND_INFO(land_infos);
return true;
}
public static bool sendNtfModifyLandInfos(List<LandInfo> landInfos)
{
broadcast_S2C_NTF_LAND_INFOS(landInfos);
send_GS2GS_NTF_MODIFY_LAND_INFO(landInfos);
return true;
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCore; using ServerBase;
using ServerCommon;
namespace GameServer
{
public class Land : EntityBase
{
public Land()
: base(EntityType.Land)
{
}
public override async Task<Result> onInit()
{
addEntityAttribute(new LandAttribute(this));
addEntityAction(new LandAction(this));
return await base.onInit();
}
public override string toBasicString()
{
return $"{this.getTypeName()}, LandMetaId:{getOriginEntityAttribute<LandAttribute>()?.LandMetaId}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}, {getEntityAttribute<LandAttribute>()?.toBasicString()}";
}
}
}

View File

@@ -0,0 +1,290 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
namespace GameServer;
[ChatCommandAttribute("gainland", typeof(LandCheatGainLand), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class LandCheatGainLand : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"Call gainland !!! - {player.toBasicString()}");
var result = new Result();
var err_msg = string.Empty;
var server_logic = GameServerApp.getServerLogic();
if (args.Length < 1)
{
err_msg = $"Not enough argument !!! : argCount:{args.Length} == 1 - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return;
}
if (!int.TryParse(args[0], out var land_meta_id))
{
err_msg = $"GainLand param parsing Error args : {args[0]}";
Log.getLogger().error(err_msg);
return;
}
var owned_land_agent_action = player.getEntityAction<OwnedLandAgentAction>();
NullReferenceCheckHelper.throwIfNull(owned_land_agent_action, () => $"owned_land_agent_action is null !!! - {player.toBasicString()}");
var owned_building_agent_action = player.getEntityAction<OwnedBuildingAgentAction>();
NullReferenceCheckHelper.throwIfNull(owned_building_agent_action, () => $"owned_building_agent_action is null !!! - {player.toBasicString()}");
var fn_gain_land = async delegate ()
{
// Land 획득
(result, var land, var owned_land, var land_doc_base) = await LandHelper.tryGainLand(player, land_meta_id);
if (result.isFail())
{
err_msg = $"Failed to tryGainLand() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(owned_land, () => $"owned_land is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(land_doc_base, () => $"land_doc_base is null !!! - {player.toBasicString()}");
var land_log_info = land.toLandLogInfo();
var land_business_log = new LandBusinessLog(land_log_info);
// Land 종속 BuildingMetaId 얻기
if (!MapManager.Instance.tryGetLandChildBuildingMetaId(land_meta_id, out var building_meta_id))
{
err_msg = $"Failed to tryGetLandChildBuildingMetaId() !!! - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
// Building 획득
(result, var building, var owned_building, var building_doc_base) = await BuildingHelper.tryGainBuilding(player, building_meta_id);
if (result.isFail())
{
err_msg = $"Failed to tryGainBuilding() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
NullReferenceCheckHelper.throwIfNull(building, () => $"building is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(owned_building, () => $"owned_building is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(building_doc_base, () => $"building_doc_base is null !!! - {player.toBasicString()}");
var building_log_info = building.toBuildingLogInfo();
var building_business_log = new BuildingBusinessLog(building_log_info);
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandGainLand, server_logic.getDynamoDbClient());
{
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
batch.addQuery(new DBQEntityWrite(land_doc_base));
batch.addQuery(new DBQEntityWrite(building_doc_base));
}
batch.appendBusinessLog(land_business_log);
batch.appendBusinessLog(building_business_log);
result = await QueryHelper.sendQueryAndBusinessLog(batch);
if (result.isFail())
{
return result;
}
// OwnedLand, OwnedBuilding Agent에 추가
owned_land_agent_action.addOwnedLand(land_meta_id, owned_land);
owned_building_agent_action.addOwnedBuilding(building_meta_id, owned_building);
// OwnedLand, OwnedBuilding Noti
player.send_S2C_NTF_OWNED_LAND_INFOS();
player.send_S2C_NTF_OWNED_BUILDING_INFOS();
// Land, Building 전서버 Noti
await LandNotifyHelper.sendNtfModifyLandInfo(land);
await BuildingNotifyHelper.sendNtfModifyBuildingInfo(building);
return result;
};
var transaction_name = "Cheat.GainLand";
result = await player.runTransactionRunnerSafelyWithTransGuid(player.getUserGuid(), TransactionIdType.PrivateContents, transaction_name, fn_gain_land);
if (result.isFail())
{
err_msg = $"Failed to runTransactionRunnerSafelyWithTransGuid() !!! : {result.toBasicString()} - transactionName:{transaction_name}, {player.toBasicString()}";
Log.getLogger().error(err_msg);
}
}
}
[ChatCommandAttribute("initmylandownership", typeof(LandCheatInitMyLandOwnership), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class LandCheatInitMyLandOwnership : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"Call initmylandownership !!! - {player.toBasicString()}");
var result = new Result();
var err_msg = string.Empty;
var server_logic = GameServerApp.getServerLogic();
if (args.Length < 1)
{
err_msg = $"Not enough argument !!! : argCount:{args.Length} == 1 - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return;
}
if (!int.TryParse(args[0], out var argument_land_meta_id))
{
err_msg = $"InitMyLandOwnership param parsing Error args : {args[0]}";
Log.getLogger().error(err_msg);
return;
}
var owned_land_agent_action = player.getEntityAction<OwnedLandAgentAction>();
NullReferenceCheckHelper.throwIfNull(owned_land_agent_action, () => $"owned_land_agent_action is null !!! - {player.toBasicString()}");
var owned_building_agent_action = player.getEntityAction<OwnedBuildingAgentAction>();
NullReferenceCheckHelper.throwIfNull(owned_building_agent_action, () => $"owned_building_agent_action is null !!! - {player.toBasicString()}");
var fn_init_my_land_ownership = async delegate ()
{
var land_meta_ids = new List<int>();
if (argument_land_meta_id == 0)
{
land_meta_ids = owned_land_agent_action.getOwnedLandMetaIds();
}
else
{
land_meta_ids.Add(argument_land_meta_id);
}
var land_infos = new List<LandInfo>();
var land_business_logs = new List<ILogInvoker>();
var land_doc_bases = new List<DynamoDbDocBase>();
var building_meta_ids = new List<int>();
foreach (var land_meta_id in land_meta_ids)
{
(result, var land, var owned_land, var land_doc_base) = await LandHelper.tryInitMyLandOwnership(player, land_meta_id);
if (result.isFail())
{
err_msg = $"Failed to tryInitMyLandOwnership() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
NullReferenceCheckHelper.throwIfNull(land, () => $"land is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(owned_land, () => $"owned_land is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(land_doc_base, () => $"land_doc_base is null !!! - {player.toBasicString()}");
var land_info = await land.toLandInfo();
land_infos.Add(land_info);
var land_log_info = land.toLandLogInfo();
var land_business_log = new LandBusinessLog(land_log_info);
land_business_logs.Add(land_business_log);
land_doc_bases.Add(land_doc_base);
if (!MapManager.Instance.tryGetLandChildBuildingMetaId(land_meta_id, out var building_meta_id))
{
err_msg = $"Failed to tryGetLandChildBuildingMetaId() !!! - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
building_meta_ids.Add(building_meta_id);
}
var building_infos = new List<BuildingInfo>();
var building_business_logs = new List<ILogInvoker>();
var building_doc_bases = new List<DynamoDbDocBase>();
foreach (var building_meta_id in building_meta_ids)
{
(result, var building, var owned_building, var building_doc_base) = await BuildingHelper.tryInitMyBuildingOwnership(player, building_meta_id);
if (result.isFail())
{
err_msg = $"Failed to tryInitMyLandOwnership() !!! : {result.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
NullReferenceCheckHelper.throwIfNull(building, () => $"building is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(owned_building, () => $"owned_building is null !!! - {player.toBasicString()}");
NullReferenceCheckHelper.throwIfNull(building_doc_base, () => $"building_doc_base is null !!! - {player.toBasicString()}");
var building_info = await building.toBuildingInfo();
building_infos.Add(building_info);
var building_log_info = building.toBuildingLogInfo();
var building_business_log = new BuildingBusinessLog(building_log_info);
building_business_logs.Add(building_business_log);
building_doc_bases.Add(building_doc_base);
}
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.CheatCommandGainLand, server_logic.getDynamoDbClient());
{
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
batch.addQuery(new DBQEntityWrite(land_doc_bases));
batch.addQuery(new DBQEntityWrite(building_doc_bases));
}
batch.appendBusinessLogs(land_business_logs);
batch.appendBusinessLogs(building_business_logs);
result = await QueryHelper.sendQueryAndBusinessLog(batch);
if (result.isFail())
{
return result;
}
// OwnedLand, OwnedBuilding Agent에서 제거
foreach (var init_land_meta_id in land_meta_ids)
{
owned_land_agent_action.removeOwnedLand(init_land_meta_id);
}
foreach (var init_building_meta_id in building_meta_ids)
{
owned_building_agent_action.removeOwnedBuilding(init_building_meta_id);
}
// OwnedLand, OwnedBuilding Noti
player.send_S2C_NTF_OWNED_LAND_INFOS();
player.send_S2C_NTF_OWNED_BUILDING_INFOS();
// Land, Building 전서버 Noti
LandNotifyHelper.sendNtfModifyLandInfos(land_infos);
BuildingNotifyHelper.sendNtfModifyBuildingInfo(building_infos);
return result;
};
var transaction_name = "Cheat.InitMyLandOwnership";
result = await player.runTransactionRunnerSafelyWithTransGuid(player.getUserGuid(), TransactionIdType.PrivateContents, transaction_name, fn_init_my_land_ownership);
if (result.isFail())
{
err_msg = $"Failed to runTransactionRunnerSafelyWithTransGuid() !!! : {result.toBasicString()} - transactionName:{transaction_name}, {player.toBasicString()}";
Log.getLogger().error(err_msg);
}
}
}