//using System.Diagnostics.CodeAnalysis; //using ServerCommon; //using ServerCore; using ServerBase; //using Nettention.Proud; //using Amazon.DynamoDBv2.DocumentModel; //using ServerCommon.BusinessLogDomain; //namespace GameServer //{ // public class OwnedSocialAction // { // SocialActionCollectionEntity socialActionCollection = new(); // SocialActionSlotEntity socialActionSlot = new(); // /// // /// 재생 중인 소셜액션 아이디 // /// // public int PlayingSocialActionId { get; private set; } = 0; // /// // /// 소셜액션 재생 시작시간(UTC) // /// // public DateTime SocialActionStartTime { get; private set; } // public OwnedSocialAction() { } // public async Task LoadDB(string accountGuid) // { // var collectDocument = await GameServerApp.Instance.MainDB.GetSocialActionCollection(accountGuid); // if (collectDocument == null) // { // Log.getLogger().error("collectDocument is null"); // return false; // } // if (!socialActionCollection.ReadFrom(collectDocument)) // { // Log.getLogger().error("socialActionCollection read error"); // return false; // } // if (socialActionCollection.Attr.collectionInfos.Count == 0) // { // await BasicSocialActionCollectionsSetting(accountGuid); // } // var slotDocument = await GameServerApp.Instance.MainDB.GetSocialActionSlot(accountGuid); // if(slotDocument == null) // { // Log.getLogger().error("slotDocument is null"); // return false; // } // if (!socialActionSlot.ReadFrom(slotDocument)) // { // Log.getLogger().error("socialActionSlot read error"); // return false; // } // if (socialActionSlot.Attr.slotInfos.Count == 0) // { // await BasicSocialActionSlotSetting(accountGuid); // } // return true; // } // /// // /// 기본 소셜액션 컬렉션 세팅 // /// // /// // /// // async Task BasicSocialActionCollectionsSetting(string accountGuid) // { // foreach (var data in TableData.Instance._SocialActionTable.Values) // { // if (!data.IsDefault) // continue; // AddSocialAction(data.SocialActionId); // } // await GameServerApp.Instance.MainDB.UpdateDocument(socialActionCollection.DocumentForUpdate()); // } // /// // /// 치트용 모든 SocialAction 추가 // /// // /// // public async Task AllSocialActionCollectionsSetting() // { // foreach (var data in TableData.Instance._SocialActionTable.Values) // { // if (socialActionCollection.Attr.collectionInfos.Contains(data.SocialActionId)) // continue; // AddSocialAction(data.SocialActionId); // } // await GameServerApp.Instance.MainDB.UpdateDocument(socialActionCollection.DocumentForUpdate()); // } // /// // /// 기본 소셜액션 슬롯 세팅 // /// // /// // /// // async Task BasicSocialActionSlotSetting(string accountGuid) // { // foreach (var data in TableData.Instance._SocialActionTable.Values) // { // if(!data.IsDefault) // continue; // if (data.SlotNum < 1 || data.SlotNum > Constant.MAX_EMOTION_SLOT) // continue; // int slot = data.SlotNum - 1; // socialActionSlot.Attr.slotInfos[slot] = data.SocialActionId; // } // await GameServerApp.Instance.MainDB.UpdateDocument(socialActionSlot.DocumentForUpdate()); // } // public void SendInfo(HostID hostId) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Message = new ClientToGameMessage(); // clientToGame.Message.OwnedSocialActionNoti = new ClientToGameMessage.Types.OwnedSocialActionNoti(); // foreach (var id in socialActionCollection.Attr.collectionInfos) // { // clientToGame.Message.OwnedSocialActionNoti.OwnedList.Add(id); // } // foreach (var slotInfo in socialActionSlot.Attr.slotInfos) // { // SlotInfo slot = new SlotInfo(); // slot.Slot = slotInfo.Key; // slot.Id = slotInfo.Value; // clientToGame.Message.OwnedSocialActionNoti.EquipList.Add(slot); // } // GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame); // } // public bool ExchangeSocialActionSlot(int slot, int id, [MaybeNullWhen(false)] out Document changedDocument) // { // changedDocument = default; // if (slot < 0 || slot >= ServerCommon.Constant.MAX_SOCIAL_ACTION_SLOT) // { // Log.getLogger().error($"Slot : {slot} is out range"); // return false; // } // if (id != 0) // { // if (!socialActionCollection.Attr.collectionInfos.TryGetValue(id, out _)) // { // Log.getLogger().error($"SocialActionId : {id} - Not owned"); // return false; // } // foreach (var slotInfo in socialActionSlot.Attr.slotInfos) // { // if (slotInfo.Value == id) // { // Log.getLogger().error($"SocialActionId : {id} is duplicated"); // return false; // } // } // } // socialActionSlot.Attr.slotInfos[slot] = id; // changedDocument = socialActionSlot.DocumentForUpdate(); // return true; // } // /// // /// 소셜액션이 슬롯에 존재하는지 확인 // /// // /// 사용할 소셜액션 아이디 // /// 슬롯에 존재, 슬롯에 없음 // public bool IsSocialActionOnSlot(int socialActionId) // { // foreach (var slotInfo in socialActionSlot.Attr.slotInfos) // { // if (slotInfo.Value == socialActionId) // return true; // } // return false; // } // public void SetPlaySocialAction(int socialActionId, DateTime startTime = default) // { // PlayingSocialActionId = socialActionId; // SocialActionStartTime = DateTime.UtcNow; // if (startTime != default) // SocialActionStartTime = startTime; // } // public void RemovePlaySocialAction() // { // PlayingSocialActionId = 0; // SocialActionStartTime = default; // } // /// // /// 새로운 소셜액션 컬렉션에 추가 // /// // /// 소셜액션 컬렉션에 추가할 소셜액션 아이디 // /// 추가 성공, 추가 실패 // public bool AddSocialAction(int socialActionId) // { // if (!TableData.Instance._SocialActionTable.TryGetValue(socialActionId, out _)) // { // Log.getLogger().error($"socialActionId : {socialActionId} is not tabledata"); // return false; // } // socialActionCollection.Attr.collectionInfos.Add(socialActionId); // return true; // } // public ServerErrorCode AddSocialAction(int socialActionId, out Document? changeDocument, out SocialActionLogInfo? socialActionLogInfo) // { // changeDocument = default; // socialActionLogInfo = default; // if (!TableData.Instance._SocialActionTable.TryGetValue(socialActionId, out _)) // { // Log.getLogger().error($"socialActionId : {socialActionId} is not tabledata"); // return ServerErrorCode.NotFoundTable; // } // if (socialActionCollection.Attr.collectionInfos.Contains(socialActionId) == true) // { // Log.getLogger().info($"Already Register SocialAction. socialActionId : {socialActionId}"); // return ServerErrorCode.AlreadyRegistered; // } // SocialActionCollectionEntity changeEntity = new SocialActionCollectionEntity(socialActionCollection.DocumentForUpdate()); // changeEntity.Attr.collectionInfos.Add(socialActionId); // changeDocument = changeEntity.DocumentForUpdate(); // socialActionLogInfo = SocialActionBusinessLogHelper.toSocialActionLogInfo(socialActionId, changeDocument); // return ServerErrorCode.Success; // } // public void UpdateSocialActionToMemory(Document changeDocument) // { // socialActionCollection.ReadFrom(changeDocument); // } // } //}