Files
caliverse_server/GameServer/z.Backup/Player.cs
2025-05-01 07:20:41 +09:00

2226 lines
87 KiB
C#

//using Amazon.DynamoDBv2.DocumentModel;
//using GameServer.World;
//using Google.Protobuf.WellKnownTypes;
//using Nettention.Proud;
//using ServerCommon;
//using ServerCommon.BusinessLogDomain;
//using ServerCommon.Redis;
//using ServerCore; using ServerBase;
//using System.Diagnostics.CodeAnalysis;
//using System.Text.RegularExpressions;
//using static ClientToGameMessage.Types;
//using static ClientToGameRes.Types;
//using GameServer.BusinessLogInvoker;
//namespace GameServer
//{
// public class Player : IActor
// {
// public enum EPlayerState
// {
// ONLINE = 0,
// SLEEP = 1,
// DONT_DISTURB = 2,
// }
// public HostID HostId { get; private set; }
// private EventCollectorInGame _eventCollector;
// public OwnedBuff _ownedBuff = new();
// public CharEntity _charEntity = new();
// public NickNameEntity _nickNameEntity = new();
// public ToolSlotEntity _toolSlotEntity = new();
// public TattooSlotEntity _tattooSlotEntity = new();
// public MinimapMarkerEntity _minimapMarkerEntity = new();
// public CharProfileEntity charProfileEntity = new();
// public OwnedBlockList ownedBlockList = new();
// public InstanceLastRoomEntity instanceLastRoomEntity = new();
// public ClaimNormalEntity claimNormalEntity = new();
// public ClaimMembershipEntity claimMembershipEntity = new();
// public OwnedQuestList ownedQuestList = new();
// public OwnedQuestMail ownedQuestMail = new();
// public EscapePisitionTimeInfo m_escape_position_time_info = new();
// public Inventory _inventory = new();
// int[] Attributes = new int[] { };
// public Dictionary<EEventType, ArchiveEventBase> archiveEvents = new();
// public string Email = string.Empty;
// public string Guid
// {
// get { return _charEntity.PK_Guid; }
// }
// public string accountId
// {
// get { return _charEntity.Id; }
// }
// public EventCollectorBase GetEventCollector()
// {
// return _eventCollector;
// }
// public CharPos CharPos { get { return _charEntity.CharPos; } }
// public float PositionX { get { return _charEntity.CharPos.Pos.X; } }
// public float PositionY { get { return _charEntity.CharPos.Pos.Y; } }
// public float PositionZ { get { return _charEntity.CharPos.Pos.Z; } }
// public int angle { get { return _charEntity.CharPos.Pos.Angle; } }
// public bool IsCESConcert { get; set; } = false;
// public string OccupiedAnchorGuid { get; set; } = string.Empty;
// //public ClientConnection Conn { get { return _conn; } }
// public Map? map;
// public LastPositionInfo LastPositionInfo { get; set; } = new LastPositionInfo();
// private EPlayerState eState = EPlayerState.ONLINE;
// public Player(HostID hostid, string email, CharEntity charEntity)
// {
// HostId = hostid;//Interlocked.Increment(ref _nextId);
// Email = email;
// _charEntity = charEntity;
// //여기에 이벤트 체커 생성
// EventAnalyzer analyzer = new EventAnalyzer();
// _eventCollector = new EventCollectorInGame(analyzer);
// }
// // IActor.toLogActor()
// public ILogActor toLogActor()
// {
// return toUserActorLog();
// }
// public UserActorLog toUserActorLog()
// {
// var log_info = new UserActorLog();
// string nickName = _charEntity.CharInfo.DisplayName ?? string.Empty;
// ServerType serverType = GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel ? ServerType.Game : ServerType.Indun;
// log_info.initLogInfo(
// // 서버 정보
// GameServerApp.Instance.Config.AWS.Region ?? string.Empty
// , (ushort)GameServer.Instance.myServerInfo.worldId
// , serverType
// , string.Empty
// // 유저 정보
// , Guid
// , accountId
// , Email
// , nickName
// , 0
// // 캐릭터 정보
// , ""
// , CharRace.None
// // 기타
// , AuthAdminLevelType.None
// , AccountType.None
// , Google.Protobuf.ByteString.Empty
// );
// return log_info;
// }
// public void SendInfo()
// {
// // LoginRes 패킷 후 전송??
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Response = new ClientToGameRes();
// clientToGame.Response.ErrorCode = ServerErrorCode.Success;
// clientToGame.Response.SelectCharRes = new SelectCharRes();
// clientToGame.Response.SelectCharRes.Id = 1;
// clientToGame.Response.SelectCharRes.CharData = MakeGameCharData();
// Send(clientToGame);
// }
// public GameCharacter MakeGameCharData()
// {
// GameCharacter data = new GameCharacter();
// data.Guid = Guid;
// data.Name = _charEntity.Id;
// try
// {
// data.CharInfo = _charEntity.CharInfo;
// data.AvatarInfo = _charEntity.AvatarInfo;
// data.CharPos = _charEntity.CharPos;
// data.ClothInfo = _charEntity.ClothInfo;
// data.EquipInfo = _charEntity.EquipInfo;
// data.Inventory = _inventory.MakePacketInventoryData();
// data.ChannelInfo = new()
// {
// Channel = GameServer.Instance.myServerInfo.channel,
// Language = (int)ServerUtil.getLanguageByChannel(GameServer.Instance.myServerInfo.channel),
// Trafficlevel = GameServer.Instance.GetTrafficLevel(ClientSessionManager.Instance.Count, Constant.g_MaxUser)
// };
// data.ToolSlot.AddRange(_toolSlotEntity.Attr.slotInfos);
// data.TattooInfoList.AddRange(MakeMyTattooInfoForPacket());
// data.SlotCount.AddRange(_inventory.MaxSlot.AsEnumerable());
// }
// catch (Exception ex)
// {
// Log.getLogger().error(ex.ToString());
// }
// return data;
// }
// public GameActor MakeGameActor()
// {
// GameActor gameActor = new();
// gameActor.ActorGuid = Guid;
// gameActor.Name = accountId;
// gameActor.AvatarInfo = _charEntity.AvatarInfo;
// gameActor.ClothInfo = ServerUtil.MakeClothInfoOfAnotherUser(_charEntity.ClothInfo);
// gameActor.Pos = ServerUtil.MakePos(PositionX, PositionY, PositionZ, angle);
// gameActor.TattooInfoList.AddRange(MakeTattooInfoForPacket());
// gameActor.BuffInfo = new();
// var buffInfo = _ownedBuff.getCopyBuff();
// foreach (var channelBuff in buffInfo)
// {
// gameActor.BuffInfo.Buff.AddRange(channelBuff.Value.Values.AsEnumerable());
// }
// gameActor.Usergroup = _charEntity.CharInfo.Usergroup;
// gameActor.Operator = _charEntity.CharInfo.Operator;
// gameActor.DisplayName = _charEntity.CharInfo.DisplayName;
// gameActor.OccupiedAnchorGuid = OccupiedAnchorGuid;
// gameActor.EquipInfo = _charEntity.EquipInfo;
// gameActor.State = (int)eState;
// //gameActor.BlockList.AddRange(MakeBlockInfoForPacket());
// return gameActor;
// }
// private void SendSetLocation(Pos pos)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.SetLocation = new ClientToGameMessage.Types.SetLocation();
// clientToGame.Message.SetLocation.Pos = pos;
// // Log.getLogger().debug(clientToGame.ToString());
// Send(clientToGame);
// }
// public void SendPos()
// {
// SendSetLocation(CharPos.Pos);
// }
// public void EnterWorld(Map newMap, bool isLogin = false)
// {
// map = newMap;
// map.Add(this, isLogin);
// }
// public void LeaveWorld()
// {
// map?.Remove(this);
// map = null;
// }
// public void EnterMap()
// {
// map?.Add(this);
// SendPos();
// }
// public void LeaveMap()
// {
// map?.Remove(this);
// }
// public bool Move(Pos pos)
// {
// map?.Relocate(this, pos);
// _charEntity.CharPos.Pos = pos;
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel && map != null)
// {
// if (map.MapFileType == MapFileType.World)
// {
// _charEntity.LastGameServerPos.MapId = map.MapMId;
// }
// _charEntity.LastGameServerPos.Pos = pos;
// }
// return true;
// }
// public void Send(ClientToGame msg)
// {
// // Log.getLogger().debug($"{msg}");
// GameServer.Instance.Send(HostId, RmiContext.ReliableSend, msg);
// }
// public void Teleport(Pos pos, bool isRandomPos = false)
// {
// if (isRandomPos)
// GameServer.Instance.Map?.SetNewPosOverlapLoctionPlayer(pos);
// GameServer.Instance.Map?.Relocate(this, pos);
// _charEntity.CharPos.Pos = pos;
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel && map != null)
// {
// if (map.MapFileType == MapFileType.World)
// {
// _charEntity.LastGameServerPos.MapId = map.MapMId;
// }
// _charEntity.LastGameServerPos.Pos = pos;
// }
// SendPos();
// }
// // 임시 사용
// public void Teleport_Taxi(Pos pos, ref Document charEntityDocument)
// {
// CharEntity charEntity = new();
// charEntity.ReadFrom(charEntityDocument);
// GameServer.Instance.Map?.Relocate(this, pos);
// charEntity.CharPos.Pos = pos;
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel && map != null)
// {
// if (map.MapFileType == MapFileType.World)
// {
// charEntity.LastGameServerPos.MapId = map.MapMId;
// }
// charEntity.LastGameServerPos.Pos = pos;
// }
// SendSetLocation(charEntity.CharPos.Pos);
// charEntityDocument = charEntity.DocumentForUpdate();
// }
// public ServerErrorCode CheckInstanceAccess(int instanceId)
// {
// if (TableData.Instance._IndunTable.TryGetValue(instanceId, out var instanceInfo) == false)
// return ServerErrorCode.NotFoundIndunData;
// if (instanceInfo.AccessType == "Item")
// {
// if (!_inventory.HasItem(instanceInfo.AccessId))
// return ServerErrorCode.NotExistInstanceTicket;
// }
// return ServerErrorCode.Success;
// }
// /*
// cloth_avatar = 5;
// cloth_headwear = 6;
// cloth_mask = 7;
// cloth_bag = 8;
// cloth_shoes = 9;
// cloth_outer = 10;
// cloth_tops = 11;
// cloth_bottoms = 12;
// cloth_gloves = 13;
// cloth_earrings = 14;
// cloth_neckless = 15;
// cloth_socks = 16;
// */
// public ServerErrorCode EquipClothSlot(int slot, string itemGuid)
// {
// if (!_inventory.GetItem(itemGuid, out var item))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// return ServerErrorCode.NotFoundItem;
// }
// switch (slot)
// {
// case 5:
// _charEntity.ClothInfo.ClothAvatarItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothAvatar = (uint)item.Attr.ItemId;
// break;
// case 6:
// _charEntity.ClothInfo.ClothHeadwearItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothHeadwear = (uint)item.Attr.ItemId;
// break;
// case 7:
// _charEntity.ClothInfo.ClothMaskItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothMask = (uint)item.Attr.ItemId;
// break;
// case 8:
// _charEntity.ClothInfo.ClothBagItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothBag = (uint)item.Attr.ItemId;
// break;
// case 9:
// _charEntity.ClothInfo.ClothShoesItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothShoes = (uint)item.Attr.ItemId;
// break;
// case 10:
// _charEntity.ClothInfo.ClothOuterItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothOuter = (uint)item.Attr.ItemId;
// break;
// case 11:
// _charEntity.ClothInfo.ClothTopsItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothTops = (uint)item.Attr.ItemId;
// break;
// case 12:
// _charEntity.ClothInfo.ClothBottomsItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothBottoms = (uint)item.Attr.ItemId;
// break;
// case 13:
// _charEntity.ClothInfo.ClothGlovesItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothGloves = (uint)item.Attr.ItemId;
// break;
// case 14:
// _charEntity.ClothInfo.ClothEarringsItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothEarrings = (uint)item.Attr.ItemId;
// break;
// case 15:
// _charEntity.ClothInfo.ClothNecklessItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothNeckless = (uint)item.Attr.ItemId;
// break;
// case 16:
// _charEntity.ClothInfo.ClothSocksItemGuid = itemGuid;
// _charEntity.ClothInfo.ClothSocks = (uint)item.Attr.ItemId;
// break;
// default:
// Log.getLogger().error($"invalid Slot:{slot}");
// return ServerErrorCode.InvalidSlotIndex;
// }
// return ServerErrorCode.Success;
// }
// public ServerErrorCode UnequipClothSlot(int clothSlot, out string oldItemGuid)
// {
// oldItemGuid = string.Empty;
// switch (clothSlot)
// {
// case 5:
// oldItemGuid = _charEntity.ClothInfo.ClothAvatarItemGuid;
// _charEntity.ClothInfo.ClothAvatarItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothAvatar = 0;
// break;
// case 6:
// oldItemGuid = _charEntity.ClothInfo.ClothHeadwearItemGuid;
// _charEntity.ClothInfo.ClothHeadwearItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothHeadwear = 0;
// break;
// case 7:
// oldItemGuid = _charEntity.ClothInfo.ClothMaskItemGuid;
// _charEntity.ClothInfo.ClothMaskItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothMask = 0;
// break;
// case 8:
// oldItemGuid = _charEntity.ClothInfo.ClothBagItemGuid;
// _charEntity.ClothInfo.ClothBagItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothBag = 0;
// break;
// case 9:
// oldItemGuid = _charEntity.ClothInfo.ClothShoesItemGuid;
// _charEntity.ClothInfo.ClothShoesItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothShoes = 0;
// break;
// case 10:
// oldItemGuid = _charEntity.ClothInfo.ClothOuterItemGuid;
// _charEntity.ClothInfo.ClothOuterItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothOuter = 0;
// break;
// case 11:
// oldItemGuid = _charEntity.ClothInfo.ClothTopsItemGuid;
// _charEntity.ClothInfo.ClothTopsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothTops = 0;
// break;
// case 12:
// oldItemGuid = _charEntity.ClothInfo.ClothBottomsItemGuid;
// _charEntity.ClothInfo.ClothBottomsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothBottoms = 0;
// break;
// case 13:
// oldItemGuid = _charEntity.ClothInfo.ClothGlovesItemGuid;
// _charEntity.ClothInfo.ClothGlovesItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothGloves = 0;
// break;
// case 14:
// oldItemGuid = _charEntity.ClothInfo.ClothEarringsItemGuid;
// _charEntity.ClothInfo.ClothEarringsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothEarrings = 0;
// break;
// case 15:
// oldItemGuid = _charEntity.ClothInfo.ClothNecklessItemGuid;
// _charEntity.ClothInfo.ClothNecklessItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothNeckless = 0;
// break;
// case 16:
// oldItemGuid = _charEntity.ClothInfo.ClothSocksItemGuid;
// _charEntity.ClothInfo.ClothSocksItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothSocks = 0;
// break;
// default:
// Log.getLogger().error($"invalid Slot:{clothSlot}");
// return ServerErrorCode.InvalidSlotIndex;
// }
// return ServerErrorCode.Success;
// }
// public bool EquipCloth(string itemGuid)
// {
// if (!_inventory.GetItem(itemGuid, out var item))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// return false;
// }
// return EquipCloth(item);
// }
// public bool EquipCloth(ItemEntity item)
// {
// if (!TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData))
// {
// Log.getLogger().error($"Not Exist itemId({item.Attr.ItemId})");
// return false;
// }
// if (itemData.TypeLarge != EItemLargeType.CLOTH)
// {
// Log.getLogger().error($"Not Cloth Item({item.Attr.ItemId})");
// return false;
// }
// switch (itemData.TypeSmall)
// {
// case EItemSmallType.CAP:
// _charEntity.ClothInfo.ClothHeadwearItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothHeadwear = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.MASK:
// case EItemSmallType.GLASSES:
// _charEntity.ClothInfo.ClothMaskItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothMask = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.EARRING:
// _charEntity.ClothInfo.ClothEarringsItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothEarrings = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.NECKLACE:
// _charEntity.ClothInfo.ClothNecklessItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothNeckless = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.SHIRT:
// case EItemSmallType.DRESS:
// _charEntity.ClothInfo.ClothTopsItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothTops = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.PANTS:
// _charEntity.ClothInfo.ClothBottomsItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothBottoms = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.SOCKS:
// case EItemSmallType.ANKLET:
// _charEntity.ClothInfo.ClothSocksItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothSocks = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.GLOVES:
// case EItemSmallType.BRACELET:
// case EItemSmallType.RING:
// _charEntity.ClothInfo.ClothGlovesItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothGloves = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.SHOES:
// _charEntity.ClothInfo.ClothShoesItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothShoes = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.OUTER:
// _charEntity.ClothInfo.ClothOuterItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothOuter = (uint)item.Attr.ItemId;
// break;
// case EItemSmallType.BACKPACK:
// case EItemSmallType.BAG:
// _charEntity.ClothInfo.ClothBagItemGuid = item.Attr.ItemGuid;
// _charEntity.ClothInfo.ClothBag = (uint)item.Attr.ItemId;
// break;
// default:
// Log.getLogger().error($"Need Case Item TypeSmall({itemData.TypeSmall})");
// return false;
// }
// return true;
// }
// public ServerErrorCode CheckEquipItem(string itemGuid)
// {
// if (!_inventory.GetItem(itemGuid, out var item))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// return ServerErrorCode.NotFoundItem;
// }
// if (!TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData))
// {
// Log.getLogger().error($"Not Exist itemId({item.Attr.ItemId})");
// return ServerErrorCode.NotFoundTable;
// }
// if (itemData.TypeLarge == EItemLargeType.CLOTH)
// {
// switch (itemData.TypeSmall)
// {
// case EItemSmallType.CAP:
// if(itemGuid == _charEntity.ClothInfo.ClothHeadwearItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.MASK:
// case EItemSmallType.GLASSES:
// if (itemGuid == _charEntity.ClothInfo.ClothMaskItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.EARRING:
// if (itemGuid == _charEntity.ClothInfo.ClothEarringsItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.NECKLACE:
// if (itemGuid == _charEntity.ClothInfo.ClothNecklessItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.SHIRT:
// case EItemSmallType.DRESS:
// if (itemGuid == _charEntity.ClothInfo.ClothTopsItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.PANTS:
// if (itemGuid == _charEntity.ClothInfo.ClothBottomsItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.SOCKS:
// case EItemSmallType.ANKLET:
// if (itemGuid == _charEntity.ClothInfo.ClothSocksItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.GLOVES:
// case EItemSmallType.BRACELET:
// if (itemGuid == _charEntity.ClothInfo.ClothGlovesItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.SHOES:
// if (itemGuid == _charEntity.ClothInfo.ClothShoesItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.OUTER:
// if (itemGuid == _charEntity.ClothInfo.ClothOuterItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// case EItemSmallType.BACKPACK:
// case EItemSmallType.BAG:
// if (itemGuid == _charEntity.ClothInfo.ClothBagItemGuid) return ServerErrorCode.IsEquipItem;
// break;
// default:
// Log.getLogger().error($"Need Case Item TypeSmall({itemData.TypeSmall})");
// return ServerErrorCode.TableError;
// }
// }
// else if(itemData.TypeLarge == EItemLargeType.TOOL)
// {
// if(itemGuid == _charEntity.EquipInfo.ToolItemGuid) return ServerErrorCode.IsEquipItem;
// }
// else if(itemData.TypeLarge == EItemLargeType.TATTOO)
// {
// foreach(var tattooInfo in _tattooSlotEntity.Attr.slotInfos)
// {
// if (itemGuid == tattooInfo.ItemGuid) return ServerErrorCode.IsEquipItem;
// }
// }
// return ServerErrorCode.Success;
// }
// public bool UnequipCloth(string itemGuid)
// {
// if (!_inventory.GetItem(itemGuid, out var item))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// return false;
// }
// if (!TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData))
// {
// Log.getLogger().error($"Not Exist itemId({item.Attr.ItemId})");
// return false;
// }
// if (itemData.TypeLarge != EItemLargeType.CLOTH)
// {
// Log.getLogger().error($"Not Cloth Item({item.Attr.ItemId})");
// return false;
// }
// switch (itemData.TypeSmall)
// {
// case EItemSmallType.CAP:
// if (_charEntity.ClothInfo.ClothHeadwearItemGuid != itemGuid)
// {
// Log.getLogger().error($"Not EquipCloth Item({itemGuid})");
// return false;
// }
// _charEntity.ClothInfo.ClothHeadwearItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothHeadwear = 0;
// break;
// case EItemSmallType.BACKPACK:
// case EItemSmallType.BAG:
// if (_charEntity.ClothInfo.ClothBagItemGuid != itemGuid)
// {
// Log.getLogger().error($"Not EquipCloth Item({itemGuid})");
// return false;
// }
// _charEntity.ClothInfo.ClothBagItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothBag = 0;
// break;
// case EItemSmallType.SHOES:
// if (_charEntity.ClothInfo.ClothShoesItemGuid != itemGuid)
// {
// Log.getLogger().error($"Not EquipCloth Item({itemGuid})");
// return false;
// }
// _charEntity.ClothInfo.ClothShoesItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothShoes = 0;
// break;
// case EItemSmallType.OUTER:
// if (_charEntity.ClothInfo.ClothOuterItemGuid != itemGuid)
// {
// Log.getLogger().error($"Not EquipCloth Item({itemGuid})");
// return false;
// }
// _charEntity.ClothInfo.ClothOuterItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothOuter = 0;
// break;
// case EItemSmallType.SHIRT:
// if (_charEntity.ClothInfo.ClothTopsItemGuid != itemGuid)
// {
// Log.getLogger().error($"Not EquipCloth Item({itemGuid})");
// return false;
// }
// _charEntity.ClothInfo.ClothTopsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothTops = 0;
// break;
// case EItemSmallType.PANTS:
// if (_charEntity.ClothInfo.ClothBottomsItemGuid != itemGuid)
// {
// Log.getLogger().error($"Not EquipCloth Item({itemGuid})");
// return false;
// }
// _charEntity.ClothInfo.ClothBottomsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothBottoms = 0;
// break;
// default:
// Log.getLogger().error($"Need Case Item TypeSmall({itemData.TypeSmall})");
// return false;
// }
// return true;
// }
// public bool ClothInfoSave(ClothInfo clothInfo, [MaybeNullWhen(false)] out ClothInfo changedClothInfo, out ServerErrorCode errorCode)
// {
// ClothInfo backUp = _charEntity.ClothInfo.Clone();
// changedClothInfo = backUp;
// if (string.IsNullOrEmpty(clothInfo.ClothAvatarItemGuid))
// {
// _charEntity.ClothInfo.ClothAvatarItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothAvatar = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothAvatarItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothAvatarItemGuid({clothInfo.ClothAvatarItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothHeadwearItemGuid))
// {
// _charEntity.ClothInfo.ClothHeadwearItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothHeadwear = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothHeadwearItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothHeadwearItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothMaskItemGuid))
// {
// _charEntity.ClothInfo.ClothMaskItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothMask = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothMaskItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothMaskItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothEarringsItemGuid))
// {
// _charEntity.ClothInfo.ClothEarringsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothEarrings = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothEarringsItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothEarringsItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothNecklessItemGuid))
// {
// _charEntity.ClothInfo.ClothNecklessItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothNeckless = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothNecklessItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothNecklessItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothTopsItemGuid))
// {
// _charEntity.ClothInfo.ClothTopsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothTops = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothTopsItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothTopsItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothBottomsItemGuid))
// {
// _charEntity.ClothInfo.ClothBottomsItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothBottoms = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothBottomsItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothBottomsItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothSocksItemGuid))
// {
// _charEntity.ClothInfo.ClothSocksItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothSocks = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothSocksItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothSocksItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothGlovesItemGuid))
// {
// _charEntity.ClothInfo.ClothGlovesItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothGloves = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothGlovesItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothGlovesItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothShoesItemGuid))
// {
// _charEntity.ClothInfo.ClothShoesItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothShoes = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothShoesItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothShoesItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothOuterItemGuid))
// {
// _charEntity.ClothInfo.ClothOuterItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothOuter = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothOuterItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothOuterItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// if (string.IsNullOrEmpty(clothInfo.ClothBagItemGuid))
// {
// _charEntity.ClothInfo.ClothBagItemGuid = string.Empty;
// _charEntity.ClothInfo.ClothBag = 0;
// }
// else
// {
// if (!EquipCloth(clothInfo.ClothBagItemGuid))
// {
// Log.getLogger().error($"EquipCloth Fail ClothHeadwearItemGuid({clothInfo.ClothBagItemGuid})");
// _charEntity.ClothInfo = backUp;
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// }
// changedClothInfo = _charEntity.ClothInfo;
// errorCode = ServerErrorCode.Success;
// return true;
// }
// public async Task<bool> LoadDB()
// {
// if (!await _inventory.LoadDB(Guid))
// {
// Log.getLogger().error($"{accountId} Inventory LoadDB Fail !!!");
// return false;
// }
// if (!await LoadDBToolSlot())
// {
// Log.getLogger().error($"{accountId} ToolSlot LoadDB Fail !!!");
// return false;
// }
// if (!await LoadDBTattooSlot())
// {
// Log.getLogger().error($"{accountId} TattooSlot LoadDB Fail !!!");
// return false;
// }
// if (!await LoadMinimapMarker())
// {
// Log.getLogger().error($"{accountId} MinimapMarker LoadDB Fail !!!");
// return false;
// }
// if (!await LoadCharProfileDB())
// {
// Log.getLogger().error($"{accountId} CharProfile LoadDB Fail !!!");
// return false;
// }
// if (!await LoadInstanceLastRoom())
// {
// Log.getLogger().error($"{accountId} InstanceLastRoom LoadDB Fail !!!");
// return false;
// }
// if (!await ownedQuestList.LoadDB(this, Guid))
// {
// Log.getLogger().error($"{accountId} ownedQuestList LoadDB Fail !!!");
// return false;
// }
// if (!await ownedQuestMail.LoadDB(Guid))
// {
// Log.getLogger().error($"{accountId} ownedQuestMail LoadDB Fail !!!");
// return false;
// }
// if (!await m_escape_position_time_info.LoadDB(Guid))
// {
// Log.getLogger().error($"{accountId} m_escape_position_time_info LoadDB Fail !!!");
// return false;
// }
// return true;
// }
// public async Task CheatAddItem(int itemId, int count)
// {
// ClientToGame clientToGame = new();
// clientToGame.Response = new();
// clientToGame.Response.AddItemRes = new();
// List<DBDocumentInfo> dBDocumentInfos = new();
// _inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity);
// List<ILogInvoker> invokers = new List<ILogInvoker>();
// System.Guid tranGuid = System.Guid.NewGuid();
// if (!_inventory.AddItem(itemId, count, newInventoryEntity, out var addedItems, out var errorCode, out var itemlogDatas))
// {
// Log.getLogger().error($"{accountId} AddItem Fail");
// clientToGame.Response.ErrorCode = errorCode;
// Send(clientToGame);
// return;
// }
// dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update));
// foreach (var item in addedItems)
// {
// dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update));
// }
// if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false)
// {
// Log.getLogger().error($"DB UpdateInventory Failed.");
// clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed;
// Send(clientToGame);
// return;
// }
// _inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate());
// _inventory.UpdateItemDBToMemory(addedItems);
// clientToGame.Response.AddItemRes.Index = Inventory.GetInventoryTapNumber(itemId) + 1;
// foreach (var addedItem in addedItems)
// {
// clientToGame.Response.AddItemRes.Item.Add(addedItem.ConvetToItem());
// }
// Send(clientToGame);
// foreach (var itemInfoLog in itemlogDatas)
// {
// invokers.Add(new ItemLog(itemInfoLog));
// }
// var log_action = new LogActionEx(LogActionType.CheatCommandItem);
// BusinessLogger.collectLogs(log_action, this, invokers);
// }
// public async Task<ServerErrorCode> BuyItem(int itemId, int count)
// {
// ClientToGame clientToGame = new();
// clientToGame.Response = new();
// clientToGame.Response.BuyItemRes = new();
// List<DBDocumentInfo> dBDocumentInfos = new();
// _inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity);
// if (TableData.Instance._ItemTable.TryGetValue(itemId, out var itemData) == false)
// {
// Log.getLogger().error($"Not Found Table. itemID : {itemId}");
// return ServerErrorCode.NotFoundItemTableId;
// }
// Dictionary<ECurrencyType, long> currencyInfos = new();
// if (currencyInfos.TryGetValue(itemData.BuyType, out var price) == false)
// {
// currencyInfos.TryAdd(itemData.BuyType, itemData.BuyPrice * count);
// }
// else
// {
// currencyInfos[itemData.BuyType] += itemData.BuyPrice * count;
// }
// List<ILogInvoker> invokers = new List<ILogInvoker>();
// var errorCode = CurrenciesSubtract(currencyInfos, ref invokers, out var currencyDocument);
// if (errorCode != ServerErrorCode.Success)
// {
// return errorCode;
// }
// dBDocumentInfos.Add(new DBDocumentInfo(currencyDocument, EDBExecuteType.Update));
// if (!_inventory.AddItem(itemId, count, newInventoryEntity, out var addedItems, out errorCode, out var itemlogDatas))
// {
// Log.getLogger().error($"{accountId} AddItem Fail");
// return errorCode;
// }
// dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update));
// foreach (var item in addedItems)
// {
// dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update));
// }
// if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false)
// {
// Log.getLogger().error($"DB UpdateInventory Failed.");
// return ServerErrorCode.DbUpdateFailed;
// }
// _inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate());
// _inventory.UpdateItemDBToMemory(addedItems);
// _charEntity.ReadFrom(currencyDocument);
// foreach (var addedItem in addedItems)
// {
// clientToGame.Response.BuyItemRes.Item.Add(addedItem.ConvetToItem());
// }
// clientToGame.Response.BuyItemRes.CurrencyInfo = _charEntity.CharInfo;
// Send(clientToGame);
// foreach (var itemInfoLog in itemlogDatas)
// {
// invokers.Add(new ItemLog(itemInfoLog));
// }
// var log_action = new LogActionEx(LogActionType.ItemBuyFromMannequin);
// BusinessLogger.collectLogs(log_action, this, invokers);
// return ServerErrorCode.Success;
// }
// public async Task CheatDelItem(int itemId, int count)
// {
// ClientToGame clientToGame = new();
// clientToGame.Response = new();
// clientToGame.Response.RemoveItemsRes = new();
// List<DBDocumentInfo> dBDocumentInfos = new();
// _inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity);
// List<ILogInvoker> invokers = new List<ILogInvoker>();
// if (!_inventory.DeleteItem(itemId, count, newInventoryEntity, out var deletedItems, out var errorCode, out var itemlogData))
// {
// Log.getLogger().error($"{accountId} DeleteItem Fail");
// clientToGame.Response.ErrorCode = errorCode;
// Send(clientToGame);
// return;
// }
// dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update));
// foreach (var item in deletedItems)
// {
// dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update));
// }
// if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false)
// {
// Log.getLogger().error($"DB UpdateInventory Failed.");
// clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed;
// Send(clientToGame);
// return;
// }
// _inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate());
// _inventory.UpdateItemDBToMemory(deletedItems);
// invokers.Add(new ItemLog(itemlogData));
// clientToGame.Response.RemoveItemsRes.Index = Inventory.GetInventoryTapNumber(itemId) + 1;
// foreach (var deletedItem in deletedItems)
// {
// clientToGame.Response.RemoveItemsRes.Item.Add(deletedItem.ConvetToItem());
// }
// Send(clientToGame);
// var log_action = new LogActionEx(LogActionType.CheatCommandItem);
// BusinessLogger.collectLogs(log_action, this, invokers);
// }
// public void SetLastGameServerPosition(string lastGameServerName, int lastGameServerWorldId, Pos lastGameServerPos)
// {
// LastPositionInfo.LastGameServer = lastGameServerName;
// LastPositionInfo.LastGameServerWorldId = lastGameServerWorldId;
// LastPositionInfo.LastGameServerPos = lastGameServerPos.Clone();
// }
// public void AddLastInstancePosition(int instanceId, string instanceRoomId, Pos instanceRoomPos)
// {
// var info = new InstancePositionInfo
// {
// InstanceId = instanceId,
// InstanceRoomId = instanceRoomId,
// InstanceRoomPos = instanceRoomPos.Clone()
// };
// LastPositionInfo.LastInstanceInfos.Add(info);
// }
// public void SetEnterInstancePosition(int instanceId, string instanceRoomId, Pos instanceRoomPos)
// {
// LastPositionInfo.EnterInstanceInfo.InstanceId = instanceId;
// LastPositionInfo.EnterInstanceInfo.InstanceRoomId = instanceRoomId;
// LastPositionInfo.EnterInstanceInfo.InstanceRoomPos = instanceRoomPos.Clone();
// }
// public async Task<bool> ChangeState(int state)
// {
// if (eState == (EPlayerState)state)
// {
// return false;
// }
// if (await GameServerApp.Instance.LoginStorage.ChangeState(accountId, state) == false)
// {
// return false;
// }
// eState = (EPlayerState)state;
// return true;
// }
// public EPlayerState getState()
// {
// return eState;
// }
// public async Task<bool> LoadDBToolSlot()
// {
// var toolSlotDocument = await GameServerApp.Instance.MainDB.GetToolSlot(Guid);
// if (toolSlotDocument == null)
// {
// Log.getLogger().error("document is null");
// return false;
// }
// if (!_toolSlotEntity.ReadFrom(toolSlotDocument))
// {
// Log.getLogger().error("ToolSlot read error");
// return false;
// }
// return true;
// }
// public bool RegisterToolSlot(int slot, string itemGuid, [MaybeNullWhen(false)] out Document changedDocument)
// {
// changedDocument = default;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TOOL_SLOT)
// {
// Log.getLogger().error($"Out of Range ToolSlot({slot})");
// return false;
// }
// _toolSlotEntity.Attr.slotInfos[slot] = itemGuid;
// changedDocument = _toolSlotEntity.DocumentForUpdate();
// return true;
// }
// public bool DeregisterToolSlot(int slot, [MaybeNullWhen(false)] out Document changedDocument)
// {
// changedDocument = default;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TOOL_SLOT)
// {
// Log.getLogger().error($"Out of Range ToolSlot({slot})");
// return false;
// }
// _toolSlotEntity.Attr.slotInfos[slot] = string.Empty;
// changedDocument = _toolSlotEntity.DocumentForUpdate();
// return true;
// }
// public ServerErrorCode GetToolItem(int slot, [MaybeNullWhen(false)] out int activateItemId)
// {
// activateItemId = 0;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TOOL_SLOT)
// {
// Log.getLogger().error($"Out of Range ToolSlot({slot})");
// return ServerErrorCode.ToolSlotOutOfRange;
// }
// var itemGuid = _toolSlotEntity.Attr.slotInfos.ElementAtOrDefault(slot);
// if (string.IsNullOrEmpty(itemGuid))
// {
// Log.getLogger().error($"Empty ItemGuid ToolSlot({slot})");
// return ServerErrorCode.EmptyToolSlot;
// }
// if (!_inventory.GetItem(itemGuid, out var item))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// return ServerErrorCode.NotFoundItem;
// }
// activateItemId = item.Attr.ItemId;
// return ServerErrorCode.Success;
// }
// public bool ActivateToolItem(int slot, [MaybeNullWhen(false)] out ItemEntity activateItem, out ServerErrorCode errorCode)
// {
// activateItem = default;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TOOL_SLOT)
// {
// Log.getLogger().error($"Out of Range ToolSlot({slot})");
// errorCode = ServerErrorCode.ToolSlotOutOfRange;
// return false;
// }
// var itemGuid = _toolSlotEntity.Attr.slotInfos.ElementAtOrDefault(slot);
// if (string.IsNullOrEmpty(itemGuid))
// {
// Log.getLogger().error($"Empty ItemGuid ToolSlot({slot})");
// errorCode = ServerErrorCode.EmptyToolSlot;
// return false;
// }
// if (!_inventory.GetItem(itemGuid, out var item))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// errorCode = ServerErrorCode.NotFoundItem;
// return false;
// }
// _charEntity.EquipInfo.ToolItemGuid = item.Attr.ItemGuid;
// _charEntity.EquipInfo.ToolItemId = item.Attr.ItemId;
// _charEntity.EquipInfo.ToolItemStep = 0;
// activateItem = item;
// errorCode = ServerErrorCode.Success;
// return true;
// }
// public void DeactivateToolItem()
// {
// _charEntity.EquipInfo.ToolItemGuid = string.Empty;
// _charEntity.EquipInfo.ToolItemId = 0;
// _charEntity.EquipInfo.ToolItemStep = 0;
// }
// public void ApplyAttribute(List<AttributeInfo> changeAttributeList)
// {
// foreach(var changeAttribute in changeAttributeList)
// {
// Attributes[changeAttribute.Attributeid - 1] += changeAttribute.Value;
// }
// }
// public void ApplyAttribute(int attributeId, int value)
// {
// Attributes[attributeId - 1] += value;
// }
// public bool ApplyItemAttribute(ItemEntity item, bool decrease)
// {
// if (!TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData))
// {
// Log.getLogger().error($"Not Exist itemId({item.Attr.ItemId})");
// return false;
// }
// if (!TableData.Instance._ItemLevelEnchantDataTable.TryGetValue(item.Attr.Level, out var enchantData))
// {
// Log.getLogger().error($"Not Exist EnchantDataTable Level({item.Attr.Level})");
// return false;
// }
// if (enchantData.enchantDataList.TryGetValue(itemData.Rarity, out var enchantInfo) == false)
// {
// Log.getLogger().error($"Not Exist Rarity({itemData.Rarity})");
// return false;
// }
// for (int attributeSlot = 0; attributeSlot < item.Attr.AttributeIds.Count; ++attributeSlot)
// {
// int attributeId = item.Attr.AttributeIds[attributeSlot];
// if (Attributes.Length < attributeId - 1)
// {
// Log.getLogger().error($"attrivuteData ID : ({attributeId})");
// continue;
// }
// if(enchantInfo.AttributeValues.Count <= attributeSlot)
// {
// Log.getLogger().error($"MetaTable is changed. itemid : {item.Attr.ItemId}");
// return false;
// }
// int applyAttribute = enchantInfo.AttributeValues[attributeSlot];
// if (decrease == true)
// {
// ApplyAttribute(attributeId, applyAttribute * -1);
// }
// else
// {
// ApplyAttribute(attributeId, applyAttribute);
// }
// }
// return true;
// }
// public async Task<bool> LoadDBTattooSlot()
// {
// var tattooSlotDocument = await GameServerApp.Instance.MainDB.GetTattooSlot(Guid);
// if (tattooSlotDocument == null)
// {
// Log.getLogger().error("document is null");
// return false;
// }
// if (!_tattooSlotEntity.ReadFrom(tattooSlotDocument))
// {
// Log.getLogger().error("TattooSlot read error");
// return false;
// }
// int count = TableData.Instance._AttributeDefinitionDataTable.Count;
// Attributes = new int[count];
// Dictionary<int, int> itemSetIds = new();
// foreach (var slotInfo in _tattooSlotEntity.Attr.slotInfos) //item attribute
// {
// if (slotInfo.ItemGuid == string.Empty)
// {
// continue;
// }
// if (_inventory.GetItem(slotInfo.ItemGuid, out var item) == false)
// {
// continue;
// }
// if (!TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData))
// {
// Log.getLogger().error($"Not Exist itemId({item.Attr.ItemId})");
// return false;
// }
// if (ApplyItemAttribute(item, false) == false)
// {
// Log.getLogger().error($"Failed Apply Item Attribute itemId({item.Attr.ItemId})");
// return false;
// }
// if (itemData.ItemSetID == 0)
// {
// continue;
// }
// if (itemSetIds.TryGetValue(itemData.ItemSetID, out var value) == false)
// {
// itemSetIds.Add(itemData.ItemSetID, 1);
// }
// else
// {
// itemSetIds[itemData.ItemSetID] = value + 1;
// }
// }
// foreach (var itemSet in itemSetIds) //item set effect
// {
// if (!TableData.Instance._ItemSetDataTable.TryGetValue(itemSet.Key, out var itemSetData))
// {
// Log.getLogger().error($"Not Exist Key({itemSet.Key})");
// return false;
// }
// foreach (var itemSetInfo in itemSetData.itemSetInfoList)
// {
// if (itemSet.Value >= itemSetInfo.RequirementCount)
// {
// if (!TableData.Instance._AttributeDefinitionDataTable.TryGetValue(itemSetInfo.AttributeName, out var attrivuteData))
// {
// Log.getLogger().error($"Not Exist AttributeName({itemSetInfo.AttributeName})");
// return false;
// }
// if (Attributes.Length < attrivuteData.ID - 1)
// {
// Log.getLogger().error($"attrivuteData ID : ({itemSetInfo.AttributeName})");
// continue;
// }
// Attributes[attrivuteData.ID - 1] += itemSetInfo.AttributeValue;
// }
// }
// }
// return true;
// }
// public void UpdateTattooSlotDBToMemory(Document changedDocument)
// {
// _tattooSlotEntity.ReadFrom(changedDocument);
// }
// public void UpdateTattooAttribute(int slot, string newItemGuid)
// {
// if (_tattooSlotEntity.Attr.slotInfos[slot].ItemGuid != string.Empty)
// {
// if (_inventory.GetItem(_tattooSlotEntity.Attr.slotInfos[slot].ItemGuid, out var oldItem) == false)
// {
// Log.getLogger().error($"Not Exist Item({_tattooSlotEntity.Attr.slotInfos[slot]})");
// return;
// }
// if (ApplyItemAttribute(oldItem, true) == false)
// {
// Log.getLogger().error($"Not Exist Item({oldItem.PK_Guid})");
// return;
// }
// }
// if (newItemGuid != string.Empty)
// {
// if (_inventory.GetItem(newItemGuid, out var newItem) == false)
// {
// Log.getLogger().error($"Not Exist Item({newItemGuid})");
// return;
// }
// if (ApplyItemAttribute(newItem, false) == false)
// {
// Log.getLogger().error($"Not Exist Item({newItemGuid})");
// return;
// }
// }
// }
// public bool RegisterTattooSlot(int slot, string itemGuid, [MaybeNullWhen(false)] out Document changedDocument)
// {
// changedDocument = default;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TATTOO_SLOT)
// {
// Log.getLogger().error($"Out of Range TattooSlot({slot})");
// return false;
// }
// if (!_inventory.HasItem(itemGuid))
// {
// Log.getLogger().error($"Not Exist Item({itemGuid})");
// return false;
// }
// if (_tattooSlotEntity.Attr.slotInfos[slot].ItemGuid != string.Empty)
// {
// if (!_inventory.HasItem(_tattooSlotEntity.Attr.slotInfos[slot].ItemGuid))
// {
// Log.getLogger().error($"Not Exist Item({_tattooSlotEntity.Attr.slotInfos[slot]})");
// return false;
// }
// }
// TattooSlotEntity newTattooSlotEntity = new(_tattooSlotEntity.DocumentForUpdate());
// newTattooSlotEntity.Attr.slotInfos[slot].ItemGuid = itemGuid;
// changedDocument = newTattooSlotEntity.DocumentForUpdate();
// return true;
// }
// public void AllDeregisterTattooSlot(out Document changedDocument)
// {
// TattooSlotEntity newTattooSlotEntity = new(_tattooSlotEntity.DocumentForUpdate());
// foreach(var slotInfo in newTattooSlotEntity.Attr.slotInfos)
// {
// slotInfo.ItemGuid = string.Empty;
// }
// changedDocument = newTattooSlotEntity.DocumentForUpdate();
// }
// public bool DeregisterTattooSlot(int slot, [MaybeNullWhen(false)] out Document changedDocument)
// {
// changedDocument = default;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TATTOO_SLOT)
// {
// Log.getLogger().error($"Out of Range TattooSlot({slot})");
// return false;
// }
// if (!_inventory.HasItem(_tattooSlotEntity.Attr.slotInfos[slot].ItemGuid))
// {
// Log.getLogger().error($"Not Exist Item({_tattooSlotEntity.Attr.slotInfos[slot]})");
// return false;
// }
// TattooSlotEntity newTattooSlotEntity = new(_tattooSlotEntity.DocumentForUpdate());
// newTattooSlotEntity.Attr.slotInfos[slot].ItemGuid = string.Empty;
// changedDocument = newTattooSlotEntity.DocumentForUpdate();
// return true;
// }
// public bool DeregisterTattooSlot(string itemGuid, out int slot, [MaybeNullWhen(false)] out Document changedDocument)
// {
// slot = -1;
// for (int i = 0; i < Constant.MAX_TATTOO_SLOT; i++)
// {
// if (_tattooSlotEntity.Attr.slotInfos[i].ItemGuid == itemGuid)
// {
// slot = i;
// break;
// }
// }
// return DeregisterTattooSlot(slot, out changedDocument);
// }
// public int GetTattooSlot(string itemGuid)
// {
// for (int i = 0; i < Constant.MAX_TATTOO_SLOT; i++)
// {
// if (_tattooSlotEntity.Attr.slotInfos[i].ItemGuid == itemGuid)
// {
// return i;
// }
// }
// return -1;
// }
// public string GetTattooGuidFromSlot(int slot)
// {
// if(slot >= ServerCommon.Constant.MAX_TATTOO_SLOT)
// {
// return string.Empty;
// }
// return _tattooSlotEntity.Attr.slotInfos[slot].ItemGuid;
// }
// public List<TattooSlotInfo> MakeTattooInfoForPacket()
// {
// List<TattooSlotInfo> tattooInfos = new();
// foreach (var slotInfo in _tattooSlotEntity.Attr.slotInfos)
// {
// var tattoo = new TattooSlotInfo();
// tattoo.ItemInfo = new();
// tattoo.IsVisible = slotInfo.IsVisible == true ? 1 : 0;
// if (slotInfo.ItemGuid == null || slotInfo.ItemGuid == string.Empty)
// {
// tattooInfos.Add(tattoo);
// continue;
// }
// if (_inventory.GetItem(slotInfo.ItemGuid, out var item) == false)
// {
// tattooInfos.Add(tattoo);
// continue;
// }
// tattoo.ItemInfo.ItemId = item.Attr.ItemId;
// tattoo.ItemInfo.Level = item.Attr.Level;
// tattoo.ItemInfo.Attributeids.AddRange(item.Attr.AttributeIds);
// tattooInfos.Add(tattoo);
// }
// return tattooInfos;
// }
// public List<string> MakeBlockInfoForPacket()
// {
// List<string> blockInfos = new();
// foreach (var blockInfo in ownedBlockList.GetBlockList())
// {
// blockInfos.Add(blockInfo.Guid);
// }
// return blockInfos;
// }
// private List<MyTattooSlotInfo> MakeMyTattooInfoForPacket()
// {
// List<MyTattooSlotInfo> tattooInfos = new();
// foreach (var slotInfo in _tattooSlotEntity.Attr.slotInfos)
// {
// var tattoo = new MyTattooSlotInfo();
// tattoo.IsVisible = slotInfo.IsVisible == true ? 1 : 0;
// if (slotInfo.ItemGuid == null || slotInfo.ItemGuid == string.Empty)
// {
// tattooInfos.Add(tattoo);
// continue;
// }
// tattoo.ItemGuid = slotInfo.ItemGuid;
// tattooInfos.Add(tattoo);
// }
// return tattooInfos;
// }
// public bool isRegisterTattoo(string itemGuid)
// {
// foreach (var slotInfo in _tattooSlotEntity.Attr.slotInfos)
// {
// if(itemGuid == slotInfo.ItemGuid)
// {
// return true;
// }
// }
// return false;
// }
// public async Task<ServerErrorCode> saveVisibleTattooSlot(int slot, bool visible)
// {
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_TATTOO_SLOT)
// {
// Log.getLogger().error($"Out of Range TattooSlot({slot})");
// return ServerErrorCode.InvalidSlotIndex;
// }
// TattooSlotEntity newTattooSlotEntity = new(_tattooSlotEntity.DocumentForUpdate());
// newTattooSlotEntity.Attr.slotInfos[slot].IsVisible = visible;
// if(await GameServerApp.Instance.MainDB.UpdateTattooSlot(newTattooSlotEntity) == false)
// {
// Log.getLogger().error($"UpdateTattooSlot Failed.");
// return ServerErrorCode.DbUpdateFailed;
// }
// _tattooSlotEntity.ReadFrom(newTattooSlotEntity.DocumentForUpdate());
// return ServerErrorCode.Success;
// }
// public ServerErrorCode AddCurrency(ECurrencyType currencyType, long value, ref CharEntity newCharEntity, ref List<ILogInvoker> invokers, out CurrencyMaxNoti? ntf)
// {
// ntf = null;
// if (value < 0)
// {
// Log.getLogger().info($"Currency Must have Positive Value accountId : {accountId}, value : {value}");
// return ServerErrorCode.CurrencyInvalidValue;
// }
// long origin_value = CurrencyManager.Instance.getCurrencyValueByType(newCharEntity, currencyType);
// if (origin_value == long.MinValue) return ServerErrorCode.InvalidArgument;
// long saved_value = origin_value + value;
// long delta_value = value;
// if (!TableData.Instance._CurrencyDataTable.TryGetValue(currencyType, out var tableData))
// {
// Log.getLogger().warn($"Currency Not FoundData accountId : {accountId}, currencyType : {currencyType}");
// return ServerErrorCode.CurrencyNotFoundData;
// }
// if (saved_value >= tableData.MaxCount)
// {
// saved_value = tableData.MaxCount;
// delta_value = tableData.MaxCount - origin_value;
// ntf = new();
// ntf.CurrencyType = currencyType.ToString();
// }
// var currency_delta_update = new CurrencyDeltaUpdate(currencyType, AmountDeltaType.Acquire, delta_value, saved_value);
// invokers.Add(currency_delta_update);
// CurrencyManager.Instance.UpdateCurrencyValueByType(newCharEntity, currencyType, saved_value);
// return ServerErrorCode.Success;
// }
// public ServerErrorCode CurrencySubtract(ECurrencyType currencyType, long value, ref List<ILogInvoker> invokers, out Document document)
// {
// CharEntity newCharEntity = new CharEntity(_charEntity.DocumentForUpdate());
// document = new();
// ServerErrorCode erroCode = SubtractCurrency(currencyType, value, newCharEntity, ref invokers);
// if (erroCode != ServerErrorCode.Success) return erroCode;
// document = newCharEntity.DocumentForUpdate();
// return ServerErrorCode.Success;
// }
// public ServerErrorCode CurrenciesSubtract(Dictionary<ECurrencyType, long> currencyInfos, ref List<ILogInvoker> invokers, out Document document)
// {
// CharEntity newCharEntity = new CharEntity(_charEntity.DocumentForUpdate());
// document = new();
// foreach (var currencyInfo in currencyInfos)
// {
// var type = currencyInfo.Key;
// var value = currencyInfo.Value;
// ServerErrorCode erroCode = SubtractCurrency(type, value, newCharEntity, ref invokers);
// if (erroCode != ServerErrorCode.Success) return erroCode;
// }
// document = newCharEntity.DocumentForUpdate();
// return ServerErrorCode.Success;
// }
// ServerErrorCode SubtractCurrency(ECurrencyType type, long value, CharEntity newCharEntity, ref List<ILogInvoker> invokers)
// {
// if (value < 0)
// {
// Log.getLogger().info($"Currency Must have Positive Value accountId : {accountId}, value : {value}");
// return ServerErrorCode.CurrencyInvalidValue;
// }
// long originValue = CurrencyManager.Instance.getCurrencyValueByType(newCharEntity, type);
// if (originValue == long.MinValue) return ServerErrorCode.InvalidArgument;
// long savedValue = originValue - value;
// if (savedValue < 0)
// {
// Log.getLogger().error($"Currency Not enough accountId : {accountId}, currencyType : {type.ToString()}, originValue : {originValue}, Substractvalue : {value}");
// return ServerErrorCode.CurrencyNotEnough;
// }
// var currency_delta_update = new CurrencyDeltaUpdate(type, AmountDeltaType.Consume, value, savedValue);
// invokers.Add(currency_delta_update);
// CurrencyManager.Instance.UpdateCurrencyValueByType(newCharEntity, type, savedValue);
// return ServerErrorCode.Success;
// }
// public ServerErrorCode ModifyCurrencies(Dictionary<ECurrencyType, long> currencyInfos, ref List<ILogInvoker> invokers, out Document document)
// {
// CharEntity newCharEntity = new CharEntity(_charEntity.DocumentForUpdate());
// document = new();
// HashSet<ECurrencyType> notiType = new();
// System.Guid guid = System.Guid.NewGuid();
// foreach (var currencyInfo in currencyInfos)
// {
// var type = currencyInfo.Key;
// var value = currencyInfo.Value;
// long originValue = CurrencyManager.Instance.getCurrencyValueByType(newCharEntity, type);
// if (originValue == long.MinValue) return ServerErrorCode.InvalidArgument;
// long savedValue = originValue + value;
// long deltaValue = value;
// //마이너스일경우 예외처리
// if (savedValue < 0)
// {
// Log.getLogger().warn($"Currency Not enough accountId : {accountId}, currencyType : {type.ToString()}, originValue : {originValue}, Substractvalue : {value}");
// return ServerErrorCode.CurrencyNotEnough;
// }
// //맥스치 보정 처리
// if (!TableData.Instance._CurrencyDataTable.TryGetValue(type, out var tableData))
// {
// Log.getLogger().error($"Currency Not FoundData accountId : {accountId}, currencyType : {type}");
// return ServerErrorCode.CurrencyNotFoundData;
// }
// if (savedValue >= tableData.MaxCount)
// {
// savedValue = tableData.MaxCount;
// deltaValue = tableData.MaxCount - originValue;
// Log.getLogger().info($"Currency MaxNoti accountId : {accountId}, currencyType : {type}, originValue : {originValue}, Addvalue : {value}");
// notiType.Add(type);
// }
// if (value > 0)
// {
// var currency_delta_update = new CurrencyDeltaUpdate(type, AmountDeltaType.Acquire, deltaValue, savedValue);
// invokers.Add(currency_delta_update);
// }
// else if (value < 0)
// {
// var currency_delta_update = new CurrencyDeltaUpdate(type, AmountDeltaType.Consume, deltaValue, savedValue);
// invokers.Add(currency_delta_update);
// }
// CurrencyManager.Instance.UpdateCurrencyValueByType(newCharEntity, type, savedValue);
// }
// document = newCharEntity.DocumentForUpdate();
// //MaxNoti
// foreach (var type in notiType)
// {
// SendCurrencyMaxNoti(type.ToString(), HostId);
// }
// return ServerErrorCode.Success;
// }
// private void SendCurrencyMaxNoti(string currencyType, HostID hostId)
// {
// CurrencyManager.Instance.SendCurrencyMaxNoti(currencyType, hostId);
// }
// public async Task<ServerErrorCode> UserReport(string targetNickName, string reason, string title, string detail)
// {
// var nicknameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(targetNickName);
// if(nicknameEntity == null)
// {
// return ServerErrorCode.NotFoundNickName;
// }
// Timestamp time = Timestamp.FromDateTime(DateTime.UtcNow);
// string Pk = $"{DateTime.UtcNow.Year.ToString()}{DateTime.UtcNow.Month.ToString()}";
// string Sk = $"{time}#{_charEntity.CharInfo.DisplayName}";
// UserReportAttr attr = new UserReportAttr();
// attr.ReporterGuid = Guid;
// attr.ReporterNickName = _charEntity.CharInfo.DisplayName;
// attr.TargetGuid = Guid;
// attr.TargetNickName = targetNickName;
// attr.Reason = reason;
// attr.Title = title;
// attr.Detail = detail;
// attr.State = 1;
// attr.CreateTime = time;
// if(await GameServerApp.Instance.MainDB.InsertUserReport(Pk, Sk, attr) == false)
// {
// return ServerErrorCode.DbError;
// }
// return ServerErrorCode.Success;
// }
// public async Task<bool> LoadMinimapMarker()
// {
// var minimapMarkerDocument = await GameServerApp.Instance.MainDB.GetMinimapMarker(Guid);
// if (minimapMarkerDocument == null)
// {
// Log.getLogger().error("document is null");
// return false;
// }
// if (!_minimapMarkerEntity.ReadFrom(minimapMarkerDocument))
// {
// Log.getLogger().error("MinimapMarker read error");
// return false;
// }
// return true;
// }
// public void RollBackMinimapMarker(Document oldDocument)
// {
// if (!_minimapMarkerEntity.ReadFrom(oldDocument))
// {
// Log.getLogger().error("MinimapMarker read error");
// }
// }
// public bool RegisterMinimapMarker(CharPos markerPos, [MaybeNullWhen(false)] out Document changedDocument, out Document oldDocument)
// {
// oldDocument = _minimapMarkerEntity.DocumentForUpdate();
// _minimapMarkerEntity.Attr.markerInfos[markerPos.MapId] = markerPos.Pos;
// changedDocument = _minimapMarkerEntity.DocumentForUpdate();
// return true;
// }
// public bool DeregisterMinimapMarker(int mapId, [MaybeNullWhen(false)] out Document changedDocument, out Document oldDocument)
// {
// changedDocument = default;
// oldDocument = _minimapMarkerEntity.DocumentForUpdate();
// _minimapMarkerEntity.Attr.markerInfos.Remove(mapId, out _);
// if (_minimapMarkerEntity.Attr.markerInfos.ContainsKey(mapId))
// {
// return false;
// }
// changedDocument = _minimapMarkerEntity.DocumentForUpdate();
// return true;
// }
// public void SendMinimapMarker()
// {
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Indun)
// return;
// ClientToGame clientToGame = new();
// clientToGame.Message = new();
// clientToGame.Message.MinimapMarkerNoti = new();
// foreach(var markerInfo in _minimapMarkerEntity.Attr.markerInfos)
// {
// CharPos markPos = new()
// {
// MapId = markerInfo.Key,
// Pos = markerInfo.Value,
// };
// clientToGame.Message.MinimapMarkerNoti.MarkerPos.Add(markPos);
// }
// Send(clientToGame);
// }
// public async Task<bool> LoadCharProfileDB()
// {
// var document = await GameServerApp.Instance.MainDB.GetDocument(EEntityType.CharProfile, Guid, "", new CharProfileAttr());
// if (document is null)
// {
// Log.getLogger().debug("charProfile == null");
// return false;
// }
// if (charProfileEntity.ReadFrom(document) == false)
// {
// Log.getLogger().error("charProfileEntity ReadFrom Failed.");
// return false;
// }
// return true;
// }
// public async Task<bool> SaveCharProfile(string SNSLink, string message)
// {
// var copyEntity = GetCharProfileEntity();
// copyEntity.Attr.SNSLick = SNSLink;
// copyEntity.Attr.Message = message;
// if (await GameServerApp.Instance.MainDB.UpdateCharProfile(copyEntity) == false)
// {
// Log.getLogger().error("UpdateCharProfile is failed.");
// return false;
// }
// charProfileEntity.ReadFrom(copyEntity.DocumentForUpdate());
// return true;
// }
// public CharProfileEntity GetCharProfileEntity()
// {
// return new(charProfileEntity.DocumentForUpdate());
// }
// public int getAttribute(int attributeId)
// {
// return Attributes[attributeId - 1];
// }
// public List<AttributeInfo> getAttributeList()
// {
// List<AttributeInfo> attributeInfos = new List<AttributeInfo>();
// for(int i = 0; i < Attributes.Length; ++i)
// {
// attributeInfos.Add(new AttributeInfo() { Attributeid = i + 1, Value = Attributes[i] });
// }
// return attributeInfos;
// }
// public async Task<ServerErrorCode> changeNickName(string nickName)
// {
// // 첫번째 글자가 숫자인지 체크 한다.
// if (Regex.IsMatch(nickName[0].ToString(), "[0-9]") == true)
// {
// return ServerErrorCode.UserNicknameNotAllowedNumberAtFirstChars;
// }
// // 특수문자가 포함되어 있는지 체크 한다.
// if(true == nickName.isContainSpecialChars(out _))
// {
// return ServerErrorCode.UserNicknameNotAllowWithSpecialChars;
// }
// // 한글 문자가 포함되어 있는지, 허용되는 글자수 인지 체크 한다.
// if (true == nickName.isContainKoreanChars(out var korean_collection))
// {
// // 한글 초성체가 있는지 체크 한다.
// if(true == nickName.isContainInitialismKoreanChars(out _))
// {
// return ServerErrorCode.UserNicknameNotAllowWithInitialismKorean;
// }
// if (false == korean_collection.isContainCharsWithCount( MetaHelper.GameConfigMeta.UserNicknameMinLengthWithKorean
// , MetaHelper.GameConfigMeta.UserNicknameMaxLengthWithKorean ))
// {
// return ServerErrorCode.UserNicknameAllowedMin2ToMax8WithKorean;
// }
// }
// // 영문 문자가 포함되어 있는지, 허용되는 글자수 인지 체크 한다.
// else if (true == nickName.isContainEnglishChars(out var english_colletion))
// {
// if (false == english_colletion.isContainCharsWithCount( MetaHelper.GameConfigMeta.UserNicknameMinLengthWithEnglish
// , MetaHelper.GameConfigMeta.UserNicknameMaxLengthWithEnglish ))
// {
// return ServerErrorCode.UserNicknameAllowedMin4ToMax16WithEnglish;
// }
// }
// else
// {
// // 허용되지 않는 언어 입니다 !!!
// return ServerErrorCode.UserNicknameNotAllowChars;
// }
// // 금지어 여부를 체크 한다.
// if (ServerUtil.isBanNickname(nickName) == true)
// {
// Log.getLogger().info($"User Nickname is Ban !!! : nickname:{nickName}");
// return ServerErrorCode.BanNickName;
// }
// NickNameEntity? entity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(nickName);
// if (entity != null)
// {
// Log.getLogger().error($"Duplicated NickName : {nickName}");
// return ServerErrorCode.DuplicatedNickName;
// }
// _charEntity.CharInfo.DisplayName = nickName;
// await GameServerApp.Instance.MainDB.DeleteNickName(_nickNameEntity);
// await GameServerApp.Instance.MainDB.InsertNickName(nickName, Guid, accountId);
// await GameServerApp.Instance.MainDB.SaveChar(_charEntity);
// ClientToGame noti = new();
// noti.Message = new();
// noti.Message.ChangeNickNameNoti = new();
// noti.Message.ChangeNickNameNoti.Guid = Guid;
// noti.Message.ChangeNickNameNoti.NickName = nickName;
// map?.Broadcast(this, noti, true);
// return ServerErrorCode.Success;
// }
// public async Task<bool> LoadInstanceLastRoom()
// {
// var instanceLastRoomDocument = await GameServerApp.Instance.MainDB.GetInstanceLastRoom(Guid);
// if (instanceLastRoomDocument == null)
// {
// Log.getLogger().error("document is null");
// return false;
// }
// if (!instanceLastRoomEntity.ReadFrom(instanceLastRoomDocument))
// {
// Log.getLogger().error("MinimapMarker read error");
// return false;
// }
// return true;
// }
// public InstanceLastRoomEntity GetInstanceLastRoomEntity()
// {
// return new(instanceLastRoomEntity.DocumentForUpdate());
// }
// public bool getLocationInfo([MaybeNullWhen(false)] out UserLocationInfo info)
// {
// info = default;
// if (map == null)
// {
// Log.getLogger().error($"{accountId} map is null");
// return false;
// }
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel)
// {
// if (map.MapFileType != MapFileType.World)
// {
// Log.getLogger().error($"{accountId} Server:{GameServerApp.Instance.Config.GameServerType.ToString()} and Map:{map.MapFileName} type:{map.MapFileType.ToString()} miss match");
// return false;
// }
// }
// else
// {
// if (map.MapFileType != MapFileType.Instance)
// {
// Log.getLogger().error($"{accountId} Server:{GameServerApp.Instance.Config.GameServerType.ToString()} and Map:{map.MapFileName} type:{map.MapFileType.ToString()} miss match");
// return false;
// }
// }
// info = new();
// info.IsChannel = GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel ? 1 : 0;
// info.Id = map.MapMId;
// info.ChannelNumber = GameServer.Instance.myServerInfo.channel;
// info.Language = (int)ServerUtil.getLanguageByChannel(info.ChannelNumber);
// return true;
// }
// public bool getCurrentStateInfo(ClientSession session, [MaybeNullWhen(false)] out StageLogInfo stageLogInfo)
// {
// stageLogInfo = default;
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel)
// {
// stageLogInfo = StageBusinessLogHelper.toStageLogInfo(0, ContentsType.None, string.Empty, ClientSessionManager.Instance.Count, GameServerApp.Instance.Config.DefaultMaxUser);
// }
// else
// {
// return InstanceRoomManager.Instance.getStageInfo(session.InstanceRoomId, out stageLogInfo);
// }
// return true;
// }
// }
//}