220 lines
7.4 KiB
C#
220 lines
7.4 KiB
C#
//using Amazon.DynamoDBv2.DocumentModel;
|
|
//using Nettention.Proud;
|
|
//using ServerCommon;
|
|
//using ServerCommon.BusinessLogDomain;
|
|
//using ServerCore; using ServerBase;
|
|
//using System.Diagnostics.CodeAnalysis;
|
|
|
|
//namespace GameServer
|
|
//{
|
|
// public class MyHome
|
|
// {
|
|
// MyHomeListEntity _myHomeList = new();
|
|
// MyHomeEntity _myHome = new();
|
|
|
|
// Document _myhomelist_backup_document;
|
|
// Document _myhome_backup_document;
|
|
|
|
// public MyHome () { }
|
|
|
|
// public int GetMyHomeId() { return _myHome.Attr.MyHomeId; }
|
|
|
|
// public async Task<bool> LoadDB(string accountGuid)
|
|
// {
|
|
// var myHomeListDocument = await GameServerApp.Instance.MainDB.GetMyHomeList(accountGuid);
|
|
// if (myHomeListDocument == null)
|
|
// {
|
|
// Log.getLogger().error("myHomeListDocument is null");
|
|
// return false;
|
|
// }
|
|
|
|
// if (!_myHomeList.ReadFrom(myHomeListDocument))
|
|
// {
|
|
// Log.getLogger().error("myHomeList read error");
|
|
// return false;
|
|
// }
|
|
|
|
// if (_myHomeList.Attr.myHomeIds.Count == 0)
|
|
// {
|
|
// await BasicMyHomeListSetting();
|
|
// }
|
|
|
|
// var myHomeDocument = await GameServerApp.Instance.MainDB.GetMyHomeData(accountGuid);
|
|
// if (myHomeDocument == null)
|
|
// {
|
|
// Log.getLogger().error("myHomeDocument is null");
|
|
// return false;
|
|
// }
|
|
|
|
// if (!_myHome.ReadFrom(myHomeDocument))
|
|
// {
|
|
// Log.getLogger().error("myHome read error");
|
|
// return false;
|
|
// }
|
|
|
|
// if (_myHome.Attr.MyHomeId == 0)
|
|
// {
|
|
// await BasicMyHomeSetting();
|
|
// }
|
|
|
|
// return true;
|
|
// }
|
|
|
|
// async Task BasicMyHomeListSetting()
|
|
// {
|
|
// int defaultMyhomeId = ServerCommon.Constant.DEFAULT_MYHOME_ID;
|
|
|
|
// if (TableData.Instance._GameConfigDataTable.TryGetValue("DefaultInstanceMyHomeId", out var stringValue))
|
|
// {
|
|
// if (ServerUtil.MakeStringToInt(stringValue, out var intValue))
|
|
// {
|
|
// defaultMyhomeId = intValue;
|
|
// }
|
|
// }
|
|
|
|
// AddMyHome(defaultMyhomeId);
|
|
|
|
// await GameServerApp.Instance.MainDB.UpdateDocument(_myHomeList.DocumentForUpdate());
|
|
// }
|
|
|
|
// async Task BasicMyHomeSetting()
|
|
// {
|
|
// int defaultMyhomeId = ServerCommon.Constant.DEFAULT_MYHOME_ID;
|
|
|
|
// if (TableData.Instance._GameConfigDataTable.TryGetValue("DefaultInstanceMyHomeId", out var stringValue))
|
|
// {
|
|
// if (ServerUtil.MakeStringToInt(stringValue, out var intValue))
|
|
// {
|
|
// defaultMyhomeId = intValue;
|
|
// }
|
|
// }
|
|
|
|
// _myHome.Attr.MyHomeId = defaultMyhomeId;
|
|
|
|
// await GameServerApp.Instance.MainDB.UpdateDocument(_myHome.DocumentForUpdate());
|
|
// }
|
|
|
|
// public void SendInfo(HostID hostId, string accountId)
|
|
// {
|
|
// ClientToGame clientToGame = new ClientToGame();
|
|
// clientToGame.Message = new ClientToGameMessage();
|
|
// clientToGame.Message.MyHomeInfoNoti = new ClientToGameMessage.Types.MyHomeInfoNoti();
|
|
|
|
// foreach(var myHomeId in _myHomeList.Attr.myHomeIds)
|
|
// {
|
|
// clientToGame.Message.MyHomeInfoNoti.Ownedlist.Add(myHomeId);
|
|
// }
|
|
|
|
// clientToGame.Message.MyHomeInfoNoti.Info = new();
|
|
// clientToGame.Message.MyHomeInfoNoti.Info.Id = _myHome.Attr.MyHomeId;
|
|
// clientToGame.Message.MyHomeInfoNoti.Info.FixedMyHomeRoomId = $"myhome:{accountId}";
|
|
|
|
// foreach (var prop in _myHome.Attr.PropInfo)
|
|
// {
|
|
// PropInfo propInfo = new PropInfo();
|
|
// propInfo.AnchorGuid = prop.Key;
|
|
// propInfo.ItemGuid = prop.Value.GuidByType;
|
|
|
|
// clientToGame.Message.MyHomeInfoNoti.Info.PropLIst.Add(propInfo);
|
|
// }
|
|
|
|
// GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
|
|
// }
|
|
|
|
// public bool AddMyHome(int myHomeId)
|
|
// {
|
|
// if (!TableData.Instance._MyHomeTable.TryGetValue(myHomeId, out _))
|
|
// {
|
|
// Log.getLogger().error($"myHomeId : {myHomeId} is not tabledata");
|
|
// return false;
|
|
// }
|
|
|
|
// _myHomeList.Attr.myHomeIds.Add(myHomeId);
|
|
|
|
// return true;
|
|
// }
|
|
|
|
// public ServerErrorCode AddMyHome(int myHomeId, out Document? changeDocument, out MyHomeLogInfo myHomeLogInfo)
|
|
// {
|
|
// changeDocument = default;
|
|
// myHomeLogInfo = default;
|
|
|
|
// if (!TableData.Instance._MyHomeTable.TryGetValue(myHomeId, out _))
|
|
// {
|
|
// Log.getLogger().error($"myHomeId : {myHomeId} is not tabledata");
|
|
// return ServerErrorCode.NotFoundTable;
|
|
// }
|
|
|
|
// if(_myHomeList.Attr.myHomeIds.Contains(myHomeId) == true)
|
|
// {
|
|
// Log.getLogger().info($"Already Register MyHome. myHomeId : {myHomeId}");
|
|
// return ServerErrorCode.AlreadyRegistered;
|
|
// }
|
|
|
|
// MyHomeListEntity changeEntity = new MyHomeListEntity(_myHomeList.DocumentForUpdate());
|
|
// changeEntity.Attr.myHomeIds.Add(myHomeId);
|
|
// changeDocument = changeEntity.DocumentForUpdate();
|
|
|
|
// myHomeLogInfo = MyHomeBusinessLogHelper.toMyHomeLogInfo(myHomeId, changeDocument);
|
|
|
|
// return ServerErrorCode.Success;
|
|
// }
|
|
|
|
// public void UpdateMyHomeToMemory(Document changeDocument)
|
|
// {
|
|
// _myHomeList.ReadFrom(changeDocument);
|
|
// }
|
|
|
|
// public bool ExchangeMyHome(int newMyHomeId, [MaybeNullWhen(false)] out Document changedDocument) // TODO: 마이홈ID로?? 마이홈아이템ID로??
|
|
// {
|
|
// changedDocument = default;
|
|
|
|
// if (!_myHomeList.Attr.myHomeIds.Contains(newMyHomeId))
|
|
// return false;
|
|
|
|
// BackUpMyHome();
|
|
|
|
// _myHome.Attr.MyHomeId = newMyHomeId;
|
|
// _myHome.Attr.PropInfo.Clear();
|
|
|
|
// changedDocument = _myHome.DocumentForUpdate();
|
|
// return true;
|
|
// }
|
|
|
|
// public bool ExchangeMyHomeProp(string anchorGuid, string itemGuid, int itemId, [MaybeNullWhen(false)] out Document changedDocument)
|
|
// {
|
|
// changedDocument = default;
|
|
|
|
// if (!TableData.Instance._MyHomeTable.TryGetValue(_myHome.Attr.MyHomeId, out var myHomeData))
|
|
// return false;
|
|
|
|
// if (!MapDataTable.Instance.IsExistAnchor(myHomeData.RoomFile, anchorGuid))
|
|
// return false;
|
|
|
|
// BackUpMyHome();
|
|
|
|
// AnchorProp prop = new();
|
|
|
|
// prop.TableId = itemId;
|
|
// prop.GuidByType = itemGuid;
|
|
|
|
// _myHome.Attr.PropInfo[anchorGuid] = prop;
|
|
|
|
// changedDocument = _myHome.DocumentForUpdate();
|
|
// return true;
|
|
// }
|
|
|
|
// public void BackUpMyHome()
|
|
// {
|
|
// _myhomelist_backup_document = _myHomeList.DocumentForUpdate();
|
|
// _myhome_backup_document = _myHome.DocumentForUpdate();
|
|
// }
|
|
|
|
// public void RollBackMyHome()
|
|
// {
|
|
// _myHomeList.ReadFrom(_myhomelist_backup_document);
|
|
// _myHome.ReadFrom(_myhome_backup_document);
|
|
// }
|
|
// }
|
|
//}
|