public async Task SellCardAsync([Summary("Card rarity to sell")] string rarity, [Summary("Card name to sell")][Remainder] string cardName) { DatabaseUserEntry userData = Db.GetUserEntry(0, Context.Message.Author.Id); GachaCard exits = userData.Cards.FirstOrDefault(card => string.Equals(card.Name, cardName, StringComparison.OrdinalIgnoreCase) && string.Equals(card.Rarity.ToString(), rarity, StringComparison.OrdinalIgnoreCase)); if (exits != null) { uint refundCoin = GetPriceForCard(exits.Rarity); await ReplyAsync($"> Sold **{exits.Name} [{exits.Rarity.ToString()}]** for **{refundCoin}** coins {Emotes.DiscordCoin}"); if (exits.Amount > 1) { exits.Amount--; } else { if (userData.FavoriteCard == exits) { userData.FavoriteCard = null; } userData.Cards.Remove(exits); } userData.Coins += refundCoin; Db.WriteData(); return; } await ReplyAsync("> Couldn't find the specified card with given name"); }
/// <summary> /// 아이템 카드 생성 /// </summary> public void CreateCard(DATA_ITEM_SUB_TYPE_NEW._enItemStatusSubType kPayType, enCardGrade CardGrade, Texture CardTexture, CItem item, DATA_ITEM_NEW ItemTableData, DelegateOnceEventDone cardOpenEvt) { _CardGrade = CardGrade; _CardTexture = CardTexture; _CItem = item; _ItemTableData = ItemTableData; OnCardOpenEvent = cardOpenEvt; if (_CardGrade == enCardGrade.Normal) { _GachaCardUI = UIResourceMgr.CreatePrefab <GachaCard>(BUNDLELIST.PREFABS_UI_CASHSHOP, transform, "GachaCardNormal3D"); } else if (_CardGrade == enCardGrade.Royal) { _GachaCardUI = UIResourceMgr.CreatePrefab <GachaCard>(BUNDLELIST.PREFABS_UI_CASHSHOP, transform, "GachaCardRoyal3D"); } if (_GachaCardUI != null) { #if GMTOOLSHOP _GachaCardUI.Init(kPayType, _CardGrade, item, ItemTableData); _GachaCardUI.gameObject.layer = 0; _GachaCardUI.transform.localPosition = new Vector3(0.0f, 10000.0f, 0.01f); _GachaCardUI.transform.localScale = new Vector3(0.0017f, 0.0017f, 0.0017f); _GachaCardUI.transform.Rotate(new Vector3(0.0f, 180.0f, 0.0f)); _GachaCardUI.gameObject.SetActive(true); #else _GachaCardUI.Init(kPayType, _CardGrade, item, ItemTableData); _GachaCardUI.gameObject.layer = 0; _GachaCardUI.transform.localPosition = new Vector3(0.0f, 10000.0f, 0.01f); _GachaCardUI.transform.localScale = new Vector3(0.0017f, 0.0017f, 0.0017f); _GachaCardUI.transform.Rotate(new Vector3(0.0f, 180.0f, 0.0f)); _GachaCardUI.gameObject.SetActive(true); #endif } SkinnedMeshRenderer skinnedMeshRenderer = _Card.GetComponent <SkinnedMeshRenderer>(); if (skinnedMeshRenderer != null) { if (CardTexture is Texture) { skinnedMeshRenderer.material.mainTexture = (Texture)CardTexture; } //else if (CardTexture is Material) //{ // skinnedMeshRenderer.material.mainTexture = ((Material)CardTexture).mainTexture; //} } }
public async Task FavoriteCardAsync([Summary("Card name to favorite")][Remainder] string cardName) { DatabaseUserEntry userData = Db.GetUserEntry(0, Context.Message.Author.Id); GachaCard exits = userData.Cards.FirstOrDefault(card => string.Equals(card.Name, cardName, StringComparison.OrdinalIgnoreCase)); if (exits != null) { userData.FavoriteCard = exits; await ReplyAsync($"> Set **{exits.Name}** as favorite card"); Db.WriteData(); return; } await ReplyAsync("> Couldn't find the specified card with given name"); }
/// <summary> /// 크리쳐 카드 생성. /// </summary> public void CreateCard(DATA_ITEM_SUB_TYPE_NEW._enItemStatusSubType kPayType, enCardGrade type, Texture CardTexture, CCreatureDetail CreatureDetail, DATA_CREATURE_NEWVER CreatureTableData, DelegateOnceEventDone cardOpenEvt, DelegateOnceEventDoneWithInt event3D) { _CardGrade = type; _CardTexture = CardTexture; _CreatureID = CreatureTableData.m_iCreatureTID; OnCardOpenEvent = cardOpenEvt; onOpen3DEvent = event3D; if (type == enCardGrade.Normal) { _GachaCardUI = UIResourceMgr.CreatePrefab <GachaCard>(BUNDLELIST.PREFABS_UI_CASHSHOP, transform, "GachaCardNormal3D"); } else if (type == enCardGrade.Royal) { _GachaCardUI = UIResourceMgr.CreatePrefab <GachaCard>(BUNDLELIST.PREFABS_UI_CASHSHOP, transform, "GachaCardRoyal3D"); } if (_GachaCardUI != null) { _GachaCardUI.Init(CreatureDetail); _GachaCardUI.gameObject.layer = 0; _GachaCardUI.transform.localPosition = new Vector3(0.0f, 10000.0f, 0.01f); _GachaCardUI.transform.localScale = new Vector3(0.0017f, 0.0017f, 0.0017f); _GachaCardUI.transform.Rotate(new Vector3(0.0f, 180.0f, 0.0f)); _GachaCardUI.gameObject.SetActive(true); } SkinnedMeshRenderer skinnedMeshRenderer = _Card.GetComponent <SkinnedMeshRenderer>(); if (skinnedMeshRenderer != null) { if (CardTexture is Texture) { skinnedMeshRenderer.material.mainTexture = (Texture)CardTexture; } //else if (CardTexture is Material) //{ // skinnedMeshRenderer.material.mainTexture = ((Material)CardTexture).mainTexture; //} } }
public async Task GetGacha([Summary("Card pack index")][Remainder] int cardPack = 1) { if (!Config.Configuration.Packs.TryGetValue(cardPack, out string content)) { await ReplyAsync("> Invalid Card Pack"); return; } DatabaseUserEntry userData = Db.GetUserEntry(0, Context.Message.Author.Id); if (userData.Coins < Config.Configuration.GachaPrice) { await ReplyAsync($"> Insufficient Coins {Emotes.DiscordCoin}"); return; } AnimeCharacterDatabaseApi.AnimeResult anime = await AnimeCharacterDatabaseApi.Client.SearchAnimeAsync(content); AnimeCharacterDatabaseApi.CharacterResult result = await AnimeCharacterDatabaseApi.Client.GetCharactersAsync(anime.Id); userData.Coins -= Config.Configuration.GachaPrice; userData.GachaRolls++; m_random = new Random(DateTime.Now.Millisecond); float rarityLevel = (float)m_random.NextDouble(); GachaCard newCard = new GachaCard { Name = result.Name, Id = result.Id, Amount = 1 }; newCard.Rarity = newCard.Rarity.ToPercent(rarityLevel); GachaCard existingCard = userData.Cards.SingleOrDefault(card => card.Id == result.Id && card.Rarity == newCard.Rarity); if (existingCard != null) { existingCard.Amount++; } else { userData.Cards.Add(newCard); } Db.WriteData(); Embed embed = new EmbedBuilder() .WithColor(GetColorForCard(newCard.Rarity)) .WithAuthor(author => { author .WithName($"Opened {anime.Name} Card Pack! 🎉") .WithUrl($"https://www.animecharactersdatabase.com/characters.php?id={result.Id}"); }) .WithThumbnailUrl(anime.Image) .AddField($"Details", $"► Rarity: **{newCard.Rarity}**\n" + $"► Name: **{result.Name}**\n" + $"► Gender: **{result.Gender}**\n" + $"► From: **{anime.Name}**\n" + $"{result.Name} has been added to you cards list!") .WithImageUrl(result.ImageUrl) .WithFooter(footer => { footer .WithText($"Paid {Config.Configuration.GachaPrice} coins for a roll") .WithIconUrl(Context.User.GetAvatarUrl()); }) .Build(); await ReplyAsync(embed : embed); }