private void _addToDecklistNonPendulumOrLinkMonsters(Archetype archetype, Decklist decklist) { var nonPendulumOrLinkMonstersTypes = new string[] { "Effect Monster", "Flip Effect Monster", "Flip Tuner Effect Monster", "Gemini Monster", "Normal Monster", "Normal Tuner Monster", "Ritual Effect Monster", "Ritual Monster", "Spirit Monster", "Toon Monster", "Tuner Monster", "Union Effect Monster", "Union Tuner Effect Monster", "Fusion Monster", "Synchro Monster", "Synchro Tuner Monster", "XYZ Monster" }; foreach (string type in nonPendulumOrLinkMonstersTypes) { if (type.ToLower().Contains("synchro") || type.ToLower().Contains("xyz") || type.ToLower().Contains("fusion")) { decklist.ExtraDeck.Add( _getMonsterCard(archetype, type) ); } else { decklist.MainDeck.Add( _getMonsterCard(archetype, type) ); } } }
public void Convert_FilterDatesAreNull_WeGetValidDecklistWithNumberOfGamesAndWinsDTOWithSummarizedStatisticsFromAllDays( int numberOfGames, int numberOfWins) { var decklists = new List <Decklist>(); var decklist1 = new Decklist(new List <Card>(), new List <Card>(), new List <Card>()); decklist1.Name = "Blue-Eyes_2018-12-12"; decklist1.WhenDecklistWasFirstPlayed = DateTime.Parse("2018-12-12"); decklist1.DecklistStatistics.Add(_generateDecklistStatistics( 1, DateTime.Parse("2018-12-12"), numberOfGames, numberOfWins)); decklist1.DecklistStatistics.Add(_generateDecklistStatistics( 1, DateTime.Parse("2018-12-13"), numberOfGames, numberOfWins)); decklists.Add(decklist1); _initConverter(); var dtos = _converter.Convert(decklists, null, null); Assert.Multiple(() => { Assert.AreEqual(numberOfGames * 2, dtos.ToList()[0].NumberOfGames); Assert.AreEqual(numberOfWins * 2, dtos.ToList()[0].NumberOfWins); }); }
/// <inheritdoc /> public DecklistWithStatisticsDTO Convert(Decklist decklist) { var decklistDto = new DecklistWithStatisticsDTO() { DecklistId = decklist.Id, WhenDeckWasFirstPlayed = decklist.WhenDecklistWasFirstPlayed, Name = decklist.Name, Archetype = decklist.Archetype.Name, }; var decklistStatisticsDtos = new List <DeckStatisticsDTO>(); foreach (var statistics in decklist.DecklistStatistics) { decklistStatisticsDtos.Add( new DeckStatisticsDTO() { DateWhenDeckWasUsed = statistics.DateWhenDeckWasUsed, NumberOfTimesWhenDeckWasUsed = statistics.NumberOfTimesWhenDeckWasUsed, NumberOfTimesWhenDeckWon = statistics.NumberOfTimesWhenDeckWon } ); } decklistDto.Statistics = decklistStatisticsDtos; decklistDto.MainDeck = _decksDtosFactory.CreateMainDeckDto(decklist); decklistDto.ExtraDeck = _decksDtosFactory.CreateExtraDeckDto(decklist); decklistDto.SideDeck = _decksDtosFactory.CreateDeckDto(decklist); return(decklistDto); }
public async Task GetArchetypeOfDecklist_DeckHasDefaultArchetype_DeckGetsDefaultArchetype() { using (var dbInMemory = new YgoProAnalyticsDatabase(_getOptionsForSqlInMemoryTesting <YgoProAnalyticsDatabase>())) { dbInMemory.Database.EnsureCreated(); var archetype = new Archetype(Archetype.Default, true); nekrozOfBrionac = _NekrozofBrionac(archetype); nekrozMirror = _NekrozMirror(archetype); herald = _Herald(archetype); bookstone = _ImpcantationBookStone(archetype); dbInMemory.Cards.AddRange(nekrozOfBrionac, nekrozMirror, herald, bookstone); await dbInMemory.SaveChangesAsync(); var decklist = new Decklist(new List <Card> { nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, bookstone, bookstone, bookstone }, new List <Card> { herald, herald }, new List <Card>()); _analyzer = new ArchetypeAndDecklistAnalyzer(dbInMemory); _analyzer.GetArchetypeOfTheDecklistWithStatistics(decklist, DateTime.Now); Assert.AreEqual(Archetype.Default, decklist.Archetype.Name); } }
public SetPrizes(Decklist decklist, List <Card> cards) { InitializeComponent(); _decklist = decklist; _cards = cards; SetCardImages(); }
private int _getNumberOfGamesInRange(Decklist decklist, DateTime?statisticsFrom, DateTime?statisticsTo) { if (statisticsFrom != null && statisticsTo == null) { return(decklist .DecklistStatistics .Where(x => x.DateWhenDeckWasUsed >= statisticsFrom) .Sum(x => x.NumberOfTimesWhenDeckWasUsed)); } else if (statisticsFrom == null && statisticsTo != null) { return(decklist .DecklistStatistics .Where(x => x.DateWhenDeckWasUsed <= statisticsTo) .Sum(x => x.NumberOfTimesWhenDeckWasUsed)); } else if (statisticsFrom != null && statisticsTo != null) { return(decklist .DecklistStatistics .Where(x => x.DateWhenDeckWasUsed >= statisticsFrom && x.DateWhenDeckWasUsed <= statisticsTo) .Sum(x => x.NumberOfTimesWhenDeckWasUsed)); } else { return(decklist .DecklistStatistics .Sum(x => x.NumberOfTimesWhenDeckWasUsed)); } }
void Awake() { card_displays = new Dictionary <int, DeckCardDisplay>(); to_display = new Decklist(); child_height = card_display_prefab.GetComponent <RectTransform>().rect.height; }
public void Convert_WeWantSumOfAllStatisticsFromCountingToSecondDay_WeGetValidDecklistWithNumberOfGamesAndWinsDTO( int numberOfGames, int numberOfWins) { var decklists = new List <Decklist>(); var decklist1 = new Decklist(new List <Card>(), new List <Card>(), new List <Card>()); decklist1.Name = "Blue-Eyes_2018-12-12"; decklist1.WhenDecklistWasFirstPlayed = DateTime.Parse("2018-12-12"); decklist1.DecklistStatistics.Add(_generateDecklistStatistics( 1, DateTime.Parse("2018-12-12"), numberOfGames, numberOfWins)); decklist1.DecklistStatistics.Add(_generateDecklistStatistics( 2, DateTime.Parse("2018-12-13"), numberOfGames, numberOfWins)); decklist1.DecklistStatistics.Add(_generateDecklistStatistics( 3, DateTime.Parse("2018-12-14"), numberOfGames, numberOfWins)); decklists.Add(decklist1); _initConverter(); var dtos = _converter.Convert(decklists, null, DateTime.Parse("2018-12-13")); Assert.Multiple(() => { Assert.AreEqual(numberOfGames * 2, dtos.ToList()[0].NumberOfGames); Assert.AreEqual(numberOfWins * 2, dtos.ToList()[0].NumberOfWins); }); }
/// <summary>Removes the duplicate decklists from list of decklists.</summary> /// <param name="decklist">The decklist.</param> /// <param name="listOfDecks">The list of decks.</param> /// <returns>Amount of duplicates removed.</returns> public NumberOfDuplicatesWithListOfDecklists RemoveDuplicateDecklistsFromListOfDecklists( Decklist decklist, IEnumerable <Decklist> listOfDecks) { int duplicateCount = 0; List <Decklist> listWithoutDuplicates = new List <Decklist>(); foreach (var deck in listOfDecks) { if (CheckIfDecklistsAreDuplicate(decklist, deck)) { if (duplicateCount == 0) { listWithoutDuplicates.Add(decklist); } duplicateCount++; } else { listWithoutDuplicates.Add(deck); } } return(new NumberOfDuplicatesWithListOfDecklists(duplicateCount, listWithoutDuplicates, decklist)); }
void Start() { Decklist decklist0 = player[0].GetComponentInChildren <Decklist>(); Decklist decklist1 = player[1].GetComponentInChildren <Decklist>(); HandManager handmanager0 = player[0].GetComponentInChildren <HandManager>(); HandManager handmanager1 = player[1].GetComponentInChildren <HandManager>(); PlayerStats stats0 = player[0].GetComponentInChildren <PlayerStats>(); PlayerStats stats1 = player[1].GetComponentInChildren <PlayerStats>(); decklist0.Addcard("ShieldUp", "ShieldUp", "HeroicStrike", "Whirlwind", "MortalStrike", "Execute", "Execute"); decklist1.Addcard("SinisterStrike", "FoK", "FoK", "FoK", "FoK", "FoK"); decklist0.Shuffledeck(); decklist1.Shuffledeck(); //禁用多余的玩家 for (int i = playercount; i > 1; i--) { player[i - 1].SetActive(false); } Debug.Log(GameObject.FindGameObjectWithTag("Turn")); GameObject.FindGameObjectWithTag("Turn").GetComponent <TurnManager>().BeginTurn(); }
/// <inheritdoc /> public bool CanDeckBeUsedOnGivenBanlist(Decklist decklist, Banlist banlist) { var countedCards = _countCards(decklist); bool isForbiddenCardInDecklist = _deckContainsNotAllowedCards( banlist.ForbiddenCards, countedCards, (card, countedCard) => { return(true); }); bool isMoreThanOneCopyOfLimitedCardInDeck = _deckContainsNotAllowedCards( banlist.LimitedCards, countedCards, (card, countedCard) => { return(countedCard.NumberOfCopies > 1); }); bool isMoreThanTwoCopiesOfSemiLimitedCardInDeck = _deckContainsNotAllowedCards( banlist.SemiLimitedCards, countedCards, (card, countedCard) => { return(countedCard.NumberOfCopies > 2); }); return(!isForbiddenCardInDecklist && !isMoreThanOneCopyOfLimitedCardInDeck && !isMoreThanTwoCopiesOfSemiLimitedCardInDeck); }
public async Task GetArchetypeOfDecklist_DeckHas1MainArchetype_DeckGets1Archetype() { using (var dbInMemory = new YgoProAnalyticsDatabase(_getOptionsForSqlInMemoryTesting <YgoProAnalyticsDatabase>())) { dbInMemory.Database.EnsureCreated(); var archetypeNekroz = new Archetype("Nekroz", true); var archetypeHerald = new Archetype("Herald", true); nekrozOfBrionac = _NekrozofBrionac(archetypeNekroz); nekrozMirror = _NekrozMirror(archetypeNekroz); herald = _Herald(archetypeHerald); dbInMemory.Cards.AddRange(nekrozOfBrionac, nekrozMirror, herald); await dbInMemory.SaveChangesAsync(); var decklist = new Decklist(new List <Card> { nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozOfBrionac, nekrozMirror }, new List <Card> { herald, herald }, new List <Card> { herald }); _analyzer = new ArchetypeAndDecklistAnalyzer(dbInMemory); _analyzer.GetArchetypeOfTheDecklistWithStatistics(decklist, DateTime.Now); Assert.AreEqual("Nekroz", decklist.Archetype.Name); } }
public NumberOfDuplicatesWithListOfDecklists( int duplicateCount, List <Decklist> newListOfDecklists, Decklist decklistThatWasChecked) { DuplicateCount = duplicateCount; NewListOfDecklists = newListOfDecklists ?? throw new ArgumentNullException(nameof(newListOfDecklists)); DecklistThatWasChecked = decklistThatWasChecked ?? throw new ArgumentNullException(nameof(decklistThatWasChecked)); }
private IEnumerable <CardWithInfoAboutNumberOfCopiesInDeck> _countCards(Decklist decklist) { var cardsWithInfoAboutNumberOfCopiesInDeck = new List <CardWithInfoAboutNumberOfCopiesInDeck>(); _countCardsFromDeck(cardsWithInfoAboutNumberOfCopiesInDeck, decklist.MainDeck); _countCardsFromDeck(cardsWithInfoAboutNumberOfCopiesInDeck, decklist.ExtraDeck); _countCardsFromDeck(cardsWithInfoAboutNumberOfCopiesInDeck, decklist.SideDeck); return(cardsWithInfoAboutNumberOfCopiesInDeck); }
private void _addPlayableBanlistsToDecklist(Decklist decklist, IEnumerable <Banlist> banlists) { foreach (var banlist in banlists) { if (!decklist.PlayableOnBanlists.Contains(banlist) && _banlistService.CanDeckBeUsedOnGivenBanlist(decklist, banlist)) { decklist.PlayableOnBanlists.Add(banlist); } } }
private void _addToDecklistSpellAndTrapMonster(Archetype archetype, Decklist decklist) { decklist.MainDeck.Add( _helper.GetCard(archetype, "Spell Card") ); decklist.MainDeck.Add( _helper.GetCard(archetype, "Trap Card") ); }
private void CalculateResults() { int[] comboCount = new int[_combos.Count]; for (int i = 0; i < _reshuffleAmount; i++) { List <int> randomHand = Decklist.rand(_deckMain).GetRange(0, handSize); bool firstFound = true; for (int j = 0; j < _combosIds.Count; j++) { bool resultFound = false; List <int> combo = _combosIds[j]; if (ListComparer.ContainsAllItems(randomHand, combo)) { resultFound = true; comboCount[j]++; if (firstFound) { _globalCombosCount++; firstFound = false; } } List <Card> randomHandCard = new List <Card>(); foreach (var c in randomHand) { randomHandCard.Add(CardsManager.GetCard(c)); } logs.Add($"Hand number {i.ToString()} Combo number: {j.ToString()} Found combo: {resultFound} Combo: {string.Join(", ", _combos[j])} Hand: {string.Join(", ", randomHandCard)}"); } } for (int j = 0; j < _combosIds.Count; j++) { logs.Add($"\nResult for Combo{j.ToString()} is: {comboCount[j].ToString()}\n"); } for (int i = 0; i < _combos.Count; i++) { DisplayResults(_combos[i], comboCount[i]); } decimal percentage = GetPercentage(_globalCombosCount, _reshuffleAmount); amountLabel.Text = $"{_globalCombosCount.ToString()} out of {_reshuffleAmount} hands = {percentage.ToString()}%"; LastComboLogFileName = $"ComboLogs_{_deckName}_{DateTime.Now.ToString("yyyyMMddTHHmmss")}.txt"; try { if (!Directory.Exists(_logsFolder)) { Directory.CreateDirectory(_logsFolder); } File.WriteAllLines(Path.Combine(_logsFolder, LastComboLogFileName), logs); } catch { MessageBox.Show("The app experienced issues exporting logs into the folder.", "Error saving logs to the logs folder", MessageBoxButtons.OK, MessageBoxIcon.Error); } logs.Clear(); }
void LoadDecklist(Player player, Decklist decklist) { foreach (int card_id in decklist.GetIds()) { Card card_prefab = card_database.GetCard(card_id); if (card_prefab != null) { Card card = Instantiate(card_prefab); player.deck.AddCard(card); } } }
/// <inheritdoc /> public ExtraDeckDTO CreateExtraDeckDto(Decklist decklist) { var extraDeckDto = new ExtraDeckDTO(); foreach (var card in decklist.ExtraDeck) { var lowerCardType = card.Type.ToLower(); handleMonsterFor(extraDeckDto, card, lowerCardType); } return(extraDeckDto); }
private static Decklist _genereateDecklistWithAllRequiredData( List <Card> mainDeck, List <Card> extraDeck, List <Card> sideDeck) { var decklist = new Decklist(mainDeck, extraDeck, sideDeck); decklist.Name = "TestName"; decklist.Archetype = new Archetype(Archetype.Default, true); decklist.WhenDecklistWasFirstPlayed = DateTime.Parse("1998-12-12"); return(decklist); }
public Decklist GetValidDecklistWithStatistics(Archetype archetype) { var decklist = new Decklist(new List <Card>(), new List <Card>(), new List <Card>()) { Name = "Valid decklist", Archetype = archetype, WhenDecklistWasFirstPlayed = new DateTime(1997, 4, 29) }; decklist.DecklistStatistics.Add(GetValidStatisticsForValidDeck()); return(decklist); }
private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { int index = this.listBox1.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { Decklist decklist = (Decklist)listBox1.Items[index]; DeckWindow deckWindow = new DeckWindow(decklist); this.Hide(); deckWindow.ShowDialog(); deckWindow.Dispose(); this.Show(); } }
public ResultsWindow(List <List <Card> > combos, Decklist deck, decimal reshuffleAmount, bool goFirst) { InitializeComponent(); _combos = combos; _reshuffleAmount = reshuffleAmount; SetHandSize(goFirst); numericUpDown1.Value = _reshuffleAmount; foreach (var combo in _combos) { List <int> comboIds = combo.Select(x => x.Id).ToList(); _combosIds.Add(comboIds); } _deckMain = deck.Main.ToList(); _deckName = deck.Name; CalculateResults(); }
public void CanDeckBeUsedOnGivenBanlist_DeckCanBeUsed_ReturnsTrue() { var mainDeck = _generateSimplifiedDeckOfCards(40); var extraDeck = _generateSimplifiedDeckOfCards(15); var sideDeck = _generateSimplifiedDeckOfCards(15); Decklist decklist = _genereateDecklistWithAllRequiredData(mainDeck, extraDeck, sideDeck); var banlist = new Banlist("2018.05 TCG", 1); _db.Decklists.Add(decklist); _db.Banlists.Add(banlist); _db.SaveChanges(); var canBeUsed = _banlistService.CanDeckBeUsedOnGivenBanlist(decklist, banlist); Assert.IsTrue(canBeUsed); }
/// <<inheritdoc /> public Archetype GetArchetypeOfTheDecklistWithStatistics(Decklist decklist, DateTime whenDecklistWasUsed) { if (decklist.Archetype == null) { decklist.Archetype = _getTheMostUsedArchetypeInDecklist(decklist); } var statistics = decklist.Archetype.Statistics.FirstOrDefault(x => x.DateWhenArchetypeWasUsed == whenDecklistWasUsed); if (statistics == null) { statistics = new ArchetypeStatistics(decklist.Archetype, whenDecklistWasUsed); decklist.Archetype.Statistics.Add(statistics); } return(decklist.Archetype); }
void Start() { Decklist decklist0 = player[0].GetComponentInChildren <Decklist>(); HandManager handmanager0 = player[0].GetComponentInChildren <HandManager>(); Stats stats0 = player[0].GetComponentInChildren <Stats>(); decklist0.Addcard("ShieldUp"); decklist0.Addcard("ShieldUp"); decklist0.Addcard("ShieldUp"); decklist0.Addcard("ShieldUp"); decklist0.Addcard("Execute"); decklist0.Addcard("Execute"); // decklist0.Draw(stats0.carddraw); player[0].SetActive(false); }
private void _analyzeNewDeck(List <Decklist> allDecksFromThePack, bool decksWon, List <Decklist> decklistsWithoutDuplicates, Decklist decklist) { var numberOfDuplicatesWithListOfDecklists = _archetypeAndDecklistAnalyzer. RemoveDuplicateDecklistsFromListOfDecklists( decklist, allDecksFromThePack.OrderBy(x => x.WhenDecklistWasFirstPlayed)); decklistsWithoutDuplicates.Add(numberOfDuplicatesWithListOfDecklists.DecklistThatWasChecked); var statistics = decklist.DecklistStatistics .FirstOrDefault(x => x.DateWhenDeckWasUsed == decklist.WhenDecklistWasFirstPlayed); if (statistics == null) { statistics = DecklistStatistics.Create(decklist, decklist.WhenDecklistWasFirstPlayed); decklist.DecklistStatistics.Add(statistics); } statistics. IncrementNumberOfTimesWhenDeckWasUsedByAmount(numberOfDuplicatesWithListOfDecklists.DuplicateCount); if (decksWon) { statistics. IncrementNumberOfTimesWhenDeckWonByAmount(numberOfDuplicatesWithListOfDecklists.DuplicateCount); } var archetype = _archetypeAndDecklistAnalyzer.GetArchetypeOfTheDecklistWithStatistics( decklist, decklist.WhenDecklistWasFirstPlayed); var archetypeStatisticsFromDay = archetype.Statistics .First(x => x.DateWhenArchetypeWasUsed == decklist.WhenDecklistWasFirstPlayed); archetypeStatisticsFromDay.IncrementNumberOfDecksWhereWasUsedByAmount( numberOfDuplicatesWithListOfDecklists.DuplicateCount); if (decksWon) { archetypeStatisticsFromDay.IncrementNumberOfTimesWhenArchetypeWonByAmount( numberOfDuplicatesWithListOfDecklists.DuplicateCount); } _addPlayableBanlistsToDecklist(decklist, _banlists); }
private Decklist _getValidDecklist() { var decklist = new Decklist(new List <Card>(), new List <Card>(), new List <Card>()) { Name = _validDecklistName, Archetype = new Archetype(_validArchatypeName, false), WhenDecklistWasFirstPlayed = _date }; decklist .GetType() .GetProperty(nameof(Decklist.Id)) .SetValue(decklist, _validDecklistId); decklist.DecklistStatistics.Add( _getValidStatisticsForValidDeck() ); return(decklist); }
public void CanDeckBeUsedOnGivenBanlist_ThereIsMoreThanOneLimitedCardInDecklist_ReturnsFalse() { var mainDeck = _generateSimplifiedDeckOfCards(40); var extraDeck = _generateSimplifiedDeckOfCards(15); var sideDeck = _generateSimplifiedDeckOfCards(14); Decklist decklist = _genereateDecklistWithAllRequiredData(mainDeck, extraDeck, sideDeck); var banlist = new Banlist("2018.05 TCG", 1); banlist.LimitedCards.Add(mainDeck[4]); _db.Decklists.Add(decklist); _db.Banlists.Add(banlist); _db.SaveChanges(); decklist.SideDeck.Add(_db.Cards.Find(mainDeck[4].Id)); _db.SaveChanges(); var canBeUsed = _banlistService.CanDeckBeUsedOnGivenBanlist(decklist, banlist); Assert.IsFalse(canBeUsed); }
/// <inheritdoc /> public DeckDTO CreateDeckDto(Decklist decklist) { var deck = new DeckDTO(); foreach (var card in decklist.SideDeck) { var lowerCardType = card.Type.ToLower(); if (lowerCardType.Contains("monster")) { handleMonsterFor(deck, card, lowerCardType); } else { handleTraps(deck, card, lowerCardType); handleSpells(deck, card, lowerCardType); } } return(deck); }