public void DBSelectDeck() { var heroIdList = TCGGameSrv.ResourceDataLoader.Data_Card_List.Where(x => x.cardType == Resource.CardType.hero).Select(x => x.ID).ToList(); var heroTokens = new List <LBD.TokenInfo>(); foreach (var meta in heroIdList) { var token = nonFungibles.Find(x => x.meta == meta.ToString()); if (null != token) { heroTokens.Add(token); } } if (heroTokens.Count > 0) { var tokenIds = heroTokens.Select(x => x.GetTokenId()).ToArray(); var repoUser = TCGGameSrv.IocContainer.Resolve <Repository.IUser>(); if (null == tblDecks) { tblDecks = new List <Table.TblDeck>(); } foreach (var tokenid in tokenIds) { var tblDeck = repoUser.GetDeck(tokenid); if (null == tblDeck) { tblDeck = new Table.TblDeck() { tokenid = tokenid, deckname = "NoName", regDate = DateTime.Now }; tblDeck.seq = repoUser.InsertDeck(tblDeck); tblDecks.Add(tblDeck); } else { tblDecks.Add(tblDeck); } } if (null != tblDecks) { ComposableTokenRequest = tblDecks.Count; foreach (var tblDeck in tblDecks) { LBD.LBDApiManager.Instance.AddLBDCmd(new LBD.Msg.LBDMsg_GetComposableToken() { uid = UID, guid = Id.ToString(), type = TcpMsg.GetComposableType.GetTokenChildren, tokenType = LBD.LBDApiManager.TokenIdToTokenType(tblDeck.tokenid), tokenIdx = LBD.LBDApiManager.TokenIdToTokenIndex(tblDeck.tokenid), limit = 0, orderBy = string.Empty, page = 0, value = string.Empty }); } } else { if (stateType == UserStateType.InitGetDeck) { UserData(); } } } else { if (stateType == UserStateType.InitGetDeck) { UserData(); } } }
public void RegisterDeck(string tokenId, string deckName) { var tokenInfo = nonFungibles.Find(x => x.GetTokenId() == tokenId); var ackData = new TcpMsg.AckRegisterDeck(); if (null == tokenInfo) { ackData.errCode = TcpMsg.Error.NotFoundTokenInfo; } else { var resourceCardData = TCGGameSrv.ResourceDataLoader.Data_Card_Dictionary_ID[Convert.ToInt32(tokenInfo.meta)]; if (null == resourceCardData) { ackData.errCode = TcpMsg.Error.ResourcdNotFound; } else { if (resourceCardData.cardType != Resource.CardType.hero) { ackData.errCode = TcpMsg.Error.NotHeroCard; } else { if (null == deckInfos) { deckInfos = new List <TcpMsg.DeckInfo>(); } var deck = deckInfos.Find(x => x.GetDeckUid() == tokenId); if (null != deck) { ackData.errCode = TcpMsg.Error.Deck_Already_Exists; } else { var repoUser = TCGGameSrv.IocContainer.Resolve <Repository.IUser>(); var tblDeck = new Table.TblDeck() { tokenid = tokenId, deckname = deckName, regDate = DateTime.Now }; tblDeck.seq = repoUser.InsertDeck(tblDeck); tblDecks.Add(tblDeck); deck = new TcpMsg.DeckInfo() { name = deckName, heroCard = TokenInfoToCardInfo(tokenInfo), unitList = new List <TcpMsg.CardInfo>() }; deckInfos.Add(deck); ackData.deckInfo = deck; } } } } if (ackData.errCode != TcpMsg.Error.None) { logger.Warn($"UID={UID} Error Code={ackData.errCode.ToString()}"); } Send(new Packet(ackData)); }