/// <summary> /// Resets the image cache(s) /// </summary> public void ClearImageCache() { ImageCache.ClearImageCaches(); ActiveDeck?.ResetDeckCache(); FireLayoutRenderUpdatedEvent(); Logger.AddLogLine("Cleared Image Cache"); }
public static void hitForCurrentPlayer() { // track the player that took an action Player player = null; // draw a random card from active deck Card drawnCard = ActiveDeck.drawCard(); updateActiveDeckCount(); // get current player if (PlayerTurnIndex == Players.Count) { // no more players to iterate. // its the dealer's turn // give dealer the drawn card player = TableDealer; } else { // give card to player // retrieve the player player = Players[PlayerTurnIndex]; } // give card to player player.receiveCard(drawnCard); }
public static void startNextGame() { // take cards from dealer and players and add to discard pile TableDealer.reset(); Players.ForEach(player => player.reset()); // if active deck has less than shuttle trigger value, // reset discard deck and active deck if (ActiveDeck.getCount() < Settings.ActiveDeckReshuffleTarget) { ActiveDeck = new ActiveDeck(); ActiveDeck.createDeck(); updateActiveDeckCount(); DiscardDeck = new DiscardDeck(); updateDiscardDeckCount(); } // reset game status GameStatus = GameStatusEnum.InProgress; PlayerTurnIndex = 0; // retoggle visibility handlers DealerHandVisibility = Visibility.Hidden; NextGameControlsVisibility = Visibility.Hidden; ActiveGameControlsVisibility = Visibility.Visible; // deal initial hand dealInititalHand(); }
public void RandomCardDraw_ReturnsVoid() { // Arrange const int CARDS_DRAWN = 3; List <List <Card> > drawSeq = new List <List <Card> >(); // Act for (int i = 0; i < 2; i++) { drawSeq.Add(new List <Card>()); ActiveDeck activeDeck = new ActiveDeck(); activeDeck.createDeck(); // creates a fresh deck of 52 cards of the same sequence // draw 3 cards for (int j = 0; j < CARDS_DRAWN; j++) { drawSeq[i].Add(activeDeck.drawCard()); } } // determine sequencing bool equalSequence = true; for (int cardSequence = 0; cardSequence < CARDS_DRAWN; cardSequence++) { if (drawSeq[0][cardSequence].getId() != drawSeq[1][cardSequence].getId()) { equalSequence = false; break; } } // Assert Assert.IsFalse(equalSequence); }
// methods // ---------- // create initial game state // ---------- public static void createGameState(GameTypeEnum gameType) { GameType = gameType; GameStatus = GameStatusEnum.InProgress; // initialize decks ActiveDeck = new ActiveDeck(); ActiveDeckCount = "0"; DiscardDeck = new DiscardDeck(); DiscardDeckCount = "0"; // initialise actors TableDealer = createDealer(); DealerHandVisibility = Visibility.Hidden; NextGameControlsVisibility = Visibility.Hidden; ActiveGameControlsVisibility = Visibility.Visible; // initialise players list Players = new List <Player>(); PlayerTurnIndex = 0; // clear all event delegates clearEventDelegates(); }
public void InitializesActiveDeck_ReturnsVoid() { // Arrange ActiveDeck activeDeck = new ActiveDeck(); // Act // Assert Assert.AreEqual(0, activeDeck.getCount()); }
public void Create52CardDeck_ReturnsVoid() { // Arrange ActiveDeck activeDeck = new ActiveDeck(); // Act activeDeck.createDeck(); // Assert Assert.AreEqual(52, activeDeck.getCount()); }
public void CreateMultipleDeck_ReturnsVoid() { // Arrange const int NumberOfDecks = 3; ActiveDeck activeDeck = new ActiveDeck(); // Act activeDeck.createDeck(NumberOfDecks); // Assert Assert.AreEqual(52 * NumberOfDecks, activeDeck.getCount()); }
// Game play methods // ---------- public static void startNewGame() { // get dealer and players to subscribe to game state events TableDealer.subscribeToGameStateEvents(); Players.ForEach(player => player.subscribeToGameStateEvents()); // create active deck ActiveDeck.createDeck(Settings.NumberOfDecks); updateActiveDeckCount(); // deal initial hand dealInititalHand(); }
private static void dealInititalHand() { // give out 2 cards to dealer for (int i = 0; i < Settings.initialCardDrawCount; i++) { Card card = ActiveDeck.drawCard(); updateActiveDeckCount(); TableDealer.receiveCard(card); } // give out 2 cards to each player Players.ForEach(player => { for (int i = 0; i < Settings.initialCardDrawCount; i++) { Card card = ActiveDeck.drawCard(); updateActiveDeckCount(); player.receiveCard(card); } }); }
public void UpdateDecks(bool reselectActiveDeck = true, IEnumerable <Deck> forceUpdate = null) { var selectedDeck = SelectedDecks.FirstOrDefault(); var decks = DeckList.Instance.Decks.Where( d => (string.IsNullOrEmpty(DeckNameFilter) || d.Name.ToLowerInvariant().Contains(DeckNameFilter.ToLowerInvariant())) && DeckMatchesSelectedDeckType(d) && DeckMatchesSelectedTags(d) && (SelectedClasses.Any( c => ((c.ToString() == "All" || d.Class == c.ToString()) && !d.Archived) || (c.ToString() == "Archived" && d.Archived)))).ToList(); if (forceUpdate == null) { forceUpdate = new List <Deck>(); } foreach (var deck in _displayedDecks.Where(dpi => !decks.Contains(dpi.Deck) || forceUpdate.Contains(dpi.Deck)).ToList()) { _displayedDecks.Remove(deck); } foreach (var deck in decks.Where(d => !_displayedDecks.Select(x => x.Deck).Contains(d))) { _displayedDecks.Add(GetDeckPickerItemFromCache(deck)); } Sort(); if (selectedDeck != null && reselectActiveDeck && decks.Contains(selectedDeck)) { SelectDeck(selectedDeck); } if (ActiveDeck != null) { ActiveDeck.StatsUpdated(); } }
public ActiveDeck getStaticDecklist() { ActiveDeck deckActivo = null; try { WebRequest request = WebRequest.Create(ConfigurationManager.AppSettings["api_runaterra"] + "/static-decklist"); WebResponse response = request.GetResponse(); using (Stream dataStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); deckActivo = JsonConvert.DeserializeObject <ActiveDeck>(responseFromServer); } response.Close(); } catch (WebException e) { Console.WriteLine("Error: " + e.Message); } return(deckActivo); }
public async void IniciarBusqueda(Label label_status) { ActiveDeck deckActivo = null; //Pregunto todo el rato si el jugador a entrado en partida do { deckActivo = getStaticDecklist(); await Task.Delay(1000); //label_status.Text = "Buscando partida"; Console.WriteLine("Buscando partida"); } while (deckActivo.DeckCode == null); Console.WriteLine("Partida encontrada"); //label_status.Text = "Partida encontrada"; //Se que esta en partida y pregunto todo el rato a ver si a acabado GameResult resultado = null; ActiveDeck deckEnPartida = null; //Pregunto todo el rato si el jugador a acabado la partida do { deckEnPartida = getStaticDecklist(); await Task.Delay(1000); Console.WriteLine("En partida"); //label_status.Text = "En partida"; } while (deckEnPartida.DeckCode != null); resultado = getGameResult(); Console.WriteLine("Partida Acabada"); // //label_status.Text = "Partida acabada"; jsonServices.InsertarAJSON(deckActivo, resultado); IniciarBusqueda(label_status); }
// Decks // ---------- private static void updateActiveDeckCount() { ActiveDeckCount = ActiveDeck.getCount().ToString(); }