示例#1
0
        internal Duelist ToEntity()
        {
            var hand = Hand.Select(c => c.ToValueObject()).ToList();
            var deck = Deck.Restore(DeckCards.Select(c => c.ToValueObject()).ToList());

            return(Duelist.Restore(Id, Health, Mana, ManaSlots, deck, hand));
        }
 // Start is called before the first frame update
 void Start()
 {
     game = GameObject.Find("GameControl").GetComponent <GameControl>();
     spin = GameObject.Find("Spin").GetComponent <SpiningManager>();
     dice = GameObject.Find("Dice").GetComponent <Dice>();
     deck = GameObject.Find("DeckCards").GetComponent <DeckCards>();
 }
示例#3
0
 public void IsRunTestInvalid()
 {
     {
         // consecutive, different suit
         DeckCards invalidRun = new DeckCards();
         invalidRun.AddCard(new Card(Card.CardValue.Two, Card.CardSuit.Heart));
         invalidRun.AddCard(new Card(Card.CardValue.Three, Card.CardSuit.Club));
         invalidRun.AddCard(new Card(Card.CardValue.Five, Card.CardSuit.Heart));
         invalidRun.AddCard(new Card(Card.CardValue.Four, Card.CardSuit.Heart));
         Assert.IsFalse(DeckValidation.IsRun(invalidRun));
     }
     {
         // not consecutive
         DeckCards invalidRun = new DeckCards();
         invalidRun.AddCard(new Card(Card.CardValue.Two, Card.CardSuit.Heart));
         invalidRun.AddCard(new Card(Card.CardValue.Four, Card.CardSuit.Heart));
         invalidRun.AddCard(new Card(Card.CardValue.Jack, Card.CardSuit.Heart));
         invalidRun.AddCard(new Card(Card.CardValue.Eight, Card.CardSuit.Heart));
         Assert.IsFalse(DeckValidation.IsRun(invalidRun));
     }
     {
         // short run
         DeckCards invalidRun = new DeckCards();
         invalidRun.AddCard(new Card(Card.CardValue.King, Card.CardSuit.Spade));
         invalidRun.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Spade));
         invalidRun.AddCard(new Card(Card.CardValue.Two, Card.CardSuit.Spade));
         Assert.IsFalse(DeckValidation.IsRun(invalidRun));
     }
 }
示例#4
0
        public async Task Post(int deckID, int multiverseID)
        {
            var deckCard = new DeckCards();

            //get card from service
            var card = await _mtgService.GetCardByID(multiverseID);

            //map to dto
            var model = _mapper.Map <CardDto>(card);

            deckCard.CardID = card.id;
            deckCard.DeckID = deckID;

            //insert card into db if it doesnt exist
            var dbCard = _context.Card.Where(x => x.id == card.id).SingleOrDefault();

            if (dbCard == null)
            {
                _context.Card.Add(model);
                _context.SaveChanges();
            }
            ;

            //insert into deckcard
            _context.DeckCards.Add(deckCard);
            _context.SaveChanges();
        }
示例#5
0
    void Start()
    {
        deck = GetComponentInChildren <DeckCards>();
        print("Screen width = " + Screen.width.ToString());
        hand  = GetComponentsInChildren <CardCollection>()[0];
        board = GetComponentsInChildren <CardCollection>()[1];

        print("PAAAAAAAAAREZZA" + hand.transform.parent.gameObject.tag);
        print("asjkdfasd 319" + board.transform.parent.gameObject.tag);


        hand.transform.position = new Vector3(-1.0f * Screen.width / 200, transform.position.y, 0);
        print("Card collectio" + GetComponentInChildren <CardCollection>().transform.position.ToString());
        hand.w = 1.0f * Screen.width / 100;
        hand.ForceStart();
        for (int i = 0; i < number_of_starting_cards; i++)
        {
            hand.AddCard(deck.NextCard());
        }

        board.transform.position = new Vector3(hand.transform.position.x, hand.transform.position.y + board_hand_buf, 0);
        board.w = hand.w;
        board.ForceStart();

        var game = GameObject.FindGameObjectWithTag("game").GetComponent <Game>();

        transform.parent.GetComponentInChildren <EndTurn>().Activate(game.player_turn);
        transform.parent.GetComponentInChildren <EndTurn>().Deactivate((game.player_turn + 1) % 2);
    }
示例#6
0
        /// <summary>
        /// Copy data from the provided argument into this object.
        /// </summary>
        /// <param name="controller"></param>
        public void Stamp(Controller controller)
        {
            SetasideZone.Stamp(controller.SetasideZone);
            BoardZone.Stamp(controller.BoardZone);
            DeckZone.Stamp(controller.DeckZone);
            HandZone.Stamp(controller.HandZone);
            GraveyardZone.Stamp(controller.GraveyardZone);
            SecretZone.Stamp(controller.SecretZone);

            DeckCards.AddRange(controller.DeckCards);
            BaseClass = controller.BaseClass;
            base.Stamp(controller);

            //Hero = FromCard(this, controller.Hero.Card, null, null, controller.Hero.Id) as Hero;
            //Hero.Stamp(controller.Hero);
            Hero = (Hero)controller.Hero.Clone(this);

            //Hero.Power = FromCard(this, controller.Hero.Power.Card, null, null, controller.Hero.Power.Id) as HeroPower;
            //Hero.Power.Stamp(controller.Hero.Power);
            Hero.Power = (HeroPower)controller.Hero.Power.Clone(this);

            if (controller.Hero.Weapon != null)
            {
                //Hero.Weapon =
                //	FromCard(this, controller.Hero.Weapon.Card, null, null, controller.Hero.Weapon.Id) as Weapon;
                //Hero.Weapon.Stamp(controller.Hero.Weapon);
                Hero.Weapon = (Weapon)controller.Hero.Weapon.Clone(this);
            }

            if (controller.Choice != null)
            {
                Choice = new Choice(this);
                Choice.Stamp(controller.Choice);
            }
        }
示例#7
0
        public async Task AddToDeckAsync(CardViewModel cardVM)
        {
            var deckCard = new DeckCards();

            //get card from service
            var card = await _mtgService.GetCardByID(Convert.ToInt32(cardVM.multiverseid));

            //map to dto
            var model = _mapper.Map <CardDto>(card);

            deckCard.CardID = card.id;
            deckCard.DeckID = cardVM.DeckID;

            //insert card into db if it doesnt exist
            var dbCard = _context.Card.Where(x => x.id == card.id).SingleOrDefault();

            if (dbCard == null)
            {
                _context.Card.Add(model);
                _context.SaveChanges();
            }
            ;

            //insert into deckcard
            _context.DeckCards.Add(deckCard);
            _context.SaveChanges();
        }
示例#8
0
        public async Task Post(int deckID, string cardID)
        {
            var deckCard = new DeckCards();

            deckCard.CardID = cardID;
            deckCard.DeckID = deckID;

            // cant make this block async as the _context.deckcards.add rely on a card in the database
            //insert card into db if it doesnt exist
            var dbCard = _context.Card.Where(x => x.id == cardID).SingleOrDefault();

            if (dbCard == null)
            {
                var card = await _mtgService.GetCardByID(cardID);

                var model = _mapper.Map <CardDto>(card);

                _context.Card.Add(model);
                _context.SaveChanges();
            }
            ;

            //insert into deckcard
            _context.DeckCards.Add(deckCard);
            _context.SaveChanges();
        }
        public async Task <IActionResult> NewGAme()
        {
            var deck1 = await cd.GetDeck(1);

            DeckCards cards = await cd.GetCards(deck1.Deck_Id, 5);

            DeckCards cards2 = await cd.GetCards(deck1.Deck_Id, 5);

            player1 = new Player1 {
                CardList = cards.Cards
            };
            player2 = new Player2 {
                CardList = cards2.Cards
            };
            match = new Match {
                Player1 = player1, Player2 = player2, Carddeck = deck1
            };

            DupeCheck(match.Player1.CardList, match.Player1.Pile);
            DupeCheck(match.Player2.CardList, match.Player2.Pile);
            HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
            HttpContext.Session.SetString("deck1", JsonConvert.SerializeObject(deck1));

            return(View(match));
        }
示例#10
0
 public void IsRunTestValid()
 {
     {
         // 2 - 4
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Two, Card.CardSuit.Heart));
         validRun.AddCard(new Card(Card.CardValue.Three, Card.CardSuit.Heart));
         validRun.AddCard(new Card(Card.CardValue.Five, Card.CardSuit.Heart));
         validRun.AddCard(new Card(Card.CardValue.Four, Card.CardSuit.Heart));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
     {
         // unsorted desk 2-4
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Five, Card.CardSuit.Heart));
         validRun.AddCard(new Card(Card.CardValue.Two, Card.CardSuit.Heart));
         validRun.AddCard(new Card(Card.CardValue.Four, Card.CardSuit.Heart));
         validRun.AddCard(new Card(Card.CardValue.Three, Card.CardSuit.Heart));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
     {
         // 4 - 7
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Four, Card.CardSuit.Diamond));
         validRun.AddCard(new Card(Card.CardValue.Five, Card.CardSuit.Diamond));
         validRun.AddCard(new Card(Card.CardValue.Six, Card.CardSuit.Diamond));
         validRun.AddCard(new Card(Card.CardValue.Seven, Card.CardSuit.Diamond));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
     {
         // Ace as a high card
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Jack, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Queen, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.King, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Spade));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
     {
         // 10 - K
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Ten, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Jack, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Queen, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.King, Card.CardSuit.Spade));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
     {
         // more than 4 cards
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Eight, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Nine, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Ten, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Jack, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Queen, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.King, Card.CardSuit.Spade));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
 }
示例#11
0
 public void DeckCardsMultipleDecksJocker()
 {
     for (int index = 1; index < 10; index++)
     {
         var testDeck = new DeckCards(index, true);
         Assert.AreEqual(testDeck.Count, 54 * index, "Deck count should be {0}", 54 * index);
     }
 }
示例#12
0
        public GameGeneratorPage()
        {
            InitializeComponent();

            var deck     = new Deck(0, false);
            var cardList = deck.GetCards(52, Owner.Uninitialized);

            //
            //  this puts the cards into the list in the right order for the columns.
            for (var i = 0; i < 13; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    var cardCtrl = new CardCtrl(cardList[i + j * 13], true)
                    {
                        Tag      = DeckCards.Count,
                        Location = Location.Deck,
                        CanDrag  = true
                    };
                    cardCtrl.DragStarting   += Card_DragStarting;
                    cardCtrl.PointerPressed += CardCtrl_PointerPressed;
                    DeckCards.Add(cardCtrl);
                    _sortedCards.Add(cardCtrl);
                }
            }

            CurrentCount = 20;

            _lvDeck.Tag     = new DropTargetTag(Location.Deck, DeckCards);
            _lvComputer.Tag = new DropTargetTag(Location.Computer, ComputerCards)
            {
                Owner = Owner.Computer
            };
            _lvCountedCards.Tag = new DropTargetTag(Location.Counted, CountedCards);
            _lvCrib.Tag         = new DropTargetTag(Location.Crib, CribCards);
            _lvPlayer.Tag       = new DropTargetTag(Location.Player, PlayerCards)
            {
                Owner = Owner.Player
            };
            _lvSharedCard.Tag = new DropTargetTag(Location.Shared, SharedCard)
            {
                Owner = Owner.Shared
            };

            GameStates.AddRange(_validStates);
            _cmbDealer.ItemsSource   = Enum.GetValues(typeof(PlayerType)).Cast <PlayerType>();
            _cmbOwner.ItemsSource    = Enum.GetValues(typeof(Owner)).Cast <Owner>();
            _cmbLocation.ItemsSource = Enum.GetValues(typeof(Location)).Cast <Location>();

            _droppedCards.Add(ComputerCards);
            _droppedCards.Add(PlayerCards);
            _droppedCards.Add(CountedCards);
            _droppedCards.Add(CribCards);
            _droppedCards.Add(SharedCard);
        }
示例#13
0
    public override void NewStartingHand()
    {
        //Вернуть карты из руки в колоду
        ReservCards.ForEach(x => { DeckCards.Add(x.Combat.CardData); x.DestroyUI(); });
        ReservCards.Clear();

        ShuffleCards(DeckCards); //Перетасовать
        AddCardsReserve(startPositionReservCard);

        ReservCards.StartingHandLocation();
    }
示例#14
0
 private void AddTestAnswers()
 {
     DeckCards = DeckCards.AddAltAnswers();
     DeckCards.Shuffle();
     if (DeckCards == null)
     {
         return;
     }
     isReady = true;
     enabled = true;
 }
        public async Task <IActionResult> CardPick2()
        {
            match = JsonConvert.DeserializeObject <Match>(HttpContext.Session.GetString("match"));
            deck1 = JsonConvert.DeserializeObject <DeckCards>(HttpContext.Session.GetString("deck1"));
            if (match.Player1.CardList.Count() > 0 && match.Player2.CardList.Count() > 0)
            {
                bool goAgain = true;
                while (goAgain)
                {
                    var random = new Random();
                    if (match.Player1.CardList.Count() > 0 && match.Player2.CardList.Count() > 0)
                    {
                        int  index       = random.Next(match.Player2.CardList.Count - 1);
                        Card cardAtIndex = match.Player2.CardList[index];
                        if (match.Player1.CardList.Any(x => x.Value == cardAtIndex.Value))
                        {
                            Card matched = match.Player1.CardList.Find(x => x.Value == cardAtIndex.Value);
                            match.Player2.Pile.Add(cardAtIndex);
                            match.Player2.Pile.Add(matched);
                            match.Player2.CardList.Remove(cardAtIndex);
                            match.Player1.CardList.Remove(matched);
                            match.Message = "Go again";
                            goAgain       = true;
                        }
                        else
                        {
                            DeckCards card = await cd.GetCards(deck1.Deck_Id, 1);

                            match.Player2.CardList.Add(card.Cards[0]);
                            DupeCheck(match.Player2.CardList, match.Player2.Pile);
                            match.Message = "Go fish";
                            HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
                            HttpContext.Session.SetString("deck1", JsonConvert.SerializeObject(deck1));

                            goAgain = false;

                            return(RedirectToAction("NewCardPick", match));
                        }
                    }
                    else
                    {
                        HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
                        return(RedirectToAction("GameOver", match));
                    }
                }
            }
            else
            {
                HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
                return(RedirectToAction("GameOver", match));
            }
            return(RedirectToAction("NewCardPick", match));
        }
示例#16
0
 public void DeckCardsSingleDeckInvalid()
 {
     try
     {
         var NonEmptyDeck = new DeckCards(0);
         Assert.Fail("Exception not thown");
     }
     catch (InvalidOperationException)
     {
         Assert.IsTrue(true);
     }
 }
示例#17
0
        public void ValidateEqualDecks()
        {
            var deck1 = new DeckCards(1);
            var deck2 = new DeckCards(1);

            for (int index = 0; index < 52; index++)
            {
                var card1 = deck1.GetNext();
                var card2 = deck2.GetNext();
                Assert.IsTrue(card1 == card2, "decks are not equal");
            }
        }
示例#18
0
 public void IsRunAceLowCard()
 {
     {
         // Ace as a low card
         DeckCards validRun = new DeckCards();
         validRun.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Two, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Three, Card.CardSuit.Spade));
         validRun.AddCard(new Card(Card.CardValue.Four, Card.CardSuit.Spade));
         Assert.IsTrue(DeckValidation.IsRun(validRun));
     }
 }
 public IActionResult NewCardPick()
 {
     match = JsonConvert.DeserializeObject <Match>(HttpContext.Session.GetString("match"));
     deck1 = JsonConvert.DeserializeObject <DeckCards>(HttpContext.Session.GetString("deck1"));
     if (match.Player1.CardList.Count() > 0 && match.Player2.CardList.Count() > 0)
     {
         return(View(match));
     }
     else
     {
         HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
         return(RedirectToAction("GameOver", match));
     }
 }
示例#20
0
        public void SortTest()
        {
            var deck = new DeckCards();
            var c1   = new Card(Card.CardValue.Ten, Card.CardSuit.Heart);
            var c2   = new Card(Card.CardValue.Five, Card.CardSuit.Heart);

            deck.AddCard(c1);
            deck.AddCard(c2);
            deck.Sort();

            // ensure that the values are sorted
            Assert.AreEqual(deck.GetNext(), c2);
            Assert.AreEqual(deck.GetNext(), c1);
        }
示例#21
0
        private CardOverview GetCardOverview(DeckCards deckCards)
        {
            var card = deckCards.Card;

            try
            {
                var manaSymbols = _manaCostConverter.Convert(card.ManaCost);
                return(new CardOverview(card.Id, card.Name, manaSymbols, card.ImageUrl, deckCards.Quantity));
            }
            catch (ManaSymbolFactoryException ex)
            {
                _logger.LogWarning(ex, "Something went wrong while converting the mana string {manaCost} for card {card}", card.ManaCost, card.Id);
                return(new CardOverview(card.Id, card.Name, Enumerable.Empty <ManaSymbol>(), card.ImageUrl, deckCards.Quantity));
            }
        }
示例#22
0
        private void HandleNullDeckCardStoreModification(Deck deck, Card card, DeckCardStoreAction action)
        {
            if (action == DeckCardStoreAction.RemoveCard)
            {
                _logger.LogWarning("The card {cardId} could not be removed as it did not exist within deck {deckId}.", card.Id, deck.Id);
                return;
            }

            _logger.LogInformation("Attempting to add card {cardId} to deck {deckId} with a quantity of 1.", card.Id, deck.Id);
            var deckCards = new DeckCards {
                Deck = deck, Card = card, Quantity = 1
            };

            deck.DeckCards.Add(deckCards);
        }
示例#23
0
        public void AddToDeck(WorkspaceCard workspaceCard)
        {
            if (!DeckCards.Any(dc => dc.WorkspaceCardId == workspaceCard.Id))
            {
                var nextId = Id <DeckCard> .GetNextId(DeckCards);

                var deckCard = new DeckCard(nextId, workspaceCard.Id, 1);
                DeckCards.Add(deckCard);
            }
            else
            {
                var deckCard = DeckCards.Find(dc => dc.WorkspaceCardId == workspaceCard.Id);
                //deckCard.Quantity++;
            }
        }
示例#24
0
    public void SwapCard(Card handCard, Card deckCard)
    {
        var handIndex = HandCards.IndexOf(handCard);

        HandCards.Remove(handCard);
        HandCards.Insert(handIndex, deckCard);

        var deckIndex = DeckCards.IndexOf(deckCard);

        DeckCards.Remove(deckCard);
        DeckCards.Insert(deckIndex, handCard);

        IsSwapped[handIndex] = !IsSwapped[handIndex];

        RefreshCards();
    }
示例#25
0
 public void IsThirdTestValid()
 {
     {
         DeckCards validThird = new DeckCards();
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Heart));
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Diamond));
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Club));
         Assert.IsTrue(DeckValidation.IsThird(validThird));
     }
     {
         DeckCards validThird = new DeckCards();
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Heart));
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Diamond));
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Club));
         validThird.AddCard(new Card(Card.CardValue.Ace, Card.CardSuit.Spade));
         Assert.IsTrue(DeckValidation.IsThird(validThird));
     }
 }
示例#26
0
        public void ValidateNonEqualDecks()
        {
            var deck1 = new DeckCards(1);
            var deck2 = new DeckCards(1);

            deck2.Shuffle();

            for (int index = 0; index < 52; index++)
            {
                var card1 = deck1.GetNext();
                var card2 = deck2.GetNext();

                if (card1 != card2)
                {
                    Assert.IsTrue(true);
                    return;
                }
            }
            Assert.IsTrue(false, "Decks are the same");
        }
        public async Task <IActionResult> BJNewGame()
        {
            var deck1 = await cd.GetDeck(1);

            DeckCards cards = await cd.GetCards(deck1.Deck_Id, 2);

            DeckCards cards2 = await cd.GetCards(deck1.Deck_Id, 2);

            player1 = new Player1 {
                CardList = cards.Cards
            };
            player2 = new Player2 {
                CardList = cards2.Cards
            };
            match = new Match {
                Player1 = player1, Player2 = player2, Carddeck = deck1
            };
            HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
            HttpContext.Session.SetString("deck1", JsonConvert.SerializeObject(deck1));
            return(RedirectToAction("FirstMove", match));
        }
        /// <summary>
        /// Shuffles the cards in the main deck.
        /// </summary>
        /// <param name="withDiscard">Defaults to false; determines if the discard pile should be placed back into the deck before shuffling.</param>
        public void ShuffleCards(bool withDiscard = false)
        {
            if (withDiscard)
            {
                ReplaceDiscardPile(eReplaceType.Top);
            }
            List <T> deckList = DeckCards.ToList <T>();

            T[]    deckArray = new T[DeckCards.Length];
            Random rng       = new Random();

            int size = deckArray.Length;

            for (int i = 0; i < size; i++)
            {
                int index = rng.Next(0, deckList.Count());
                T   card  = deckList.ElementAt(index);
                deckArray[i] = card;
                deckList.Remove(card);
            }
        }
        public async Task <IActionResult> CardPick(string value)
        {
            match = JsonConvert.DeserializeObject <Match>(HttpContext.Session.GetString("match"));
            deck1 = JsonConvert.DeserializeObject <DeckCards>(HttpContext.Session.GetString("deck1"));
            if (match.Player1.CardList.Count() > 0 && match.Player2.CardList.Count() > 0)
            {
                Card cardToMatch = match.Player1.CardList.Find(x => x.Value == value);
                if (match.Player2.CardList.Any(x => x.Value == value))
                {
                    Card matched = match.Player2.CardList.Find(x => x.Value == value);
                    match.Player1.Pile.Add(cardToMatch);
                    match.Player1.Pile.Add(matched);
                    match.Player1.CardList.Remove(cardToMatch);
                    match.Player2.CardList.Remove(matched);
                    match.Message = "Go again";

                    HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
                    HttpContext.Session.SetString("deck1", JsonConvert.SerializeObject(deck1));

                    return(RedirectToAction("NewCardPick", match));
                }
                else
                {
                    DeckCards card = await cd.GetCards(deck1.Deck_Id, 1);

                    match.Player1.CardList.Add(card.Cards[0]);

                    DupeCheck(match.Player1.CardList, match.Player1.Pile);
                    match.Message = "Go fish";
                    HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
                    HttpContext.Session.SetString("deck1", JsonConvert.SerializeObject(deck1));
                    return(RedirectToAction("CardPick2", match));
                }
            }
            else
            {
                HttpContext.Session.SetString("match", JsonConvert.SerializeObject(match));
                return(RedirectToAction("GameOver", match));
            }
        }
示例#30
0
        /// <param name="printLogs">Делегат вывода данных в окно логов</param>
        /// <param name="printCardsInTextBox">Делегат вывода в указанный RichTextBox список карт</param>
        /// <param name="obj">Доступные RichTextBox окна</param>
        public Sever(
            Action <string> printLogs,
            Action <RichTextBox, List <PlayingCard> > printCardsInTextBox,
            List <RichTextBox> obj
            )
        {
            // методы взаимодействия с формой
            PrintLogs           = printLogs;
            PrintCardsInTextBox = printCardsInTextBox;
            AllBoxes            = obj;
            PrintLogs("Сервер инициализирован");

            Mode = GameMode.AiVsAi;
            PrintLogs($"Текущий режим: {Mode}");

            // работа с колодой
            DeckBox = new DeckCards(); // сама колода
            PrintCardsInTextBox(AllBoxes[0], new List <PlayingCard> {
                DeckBox.ViewTrump()
            });                                                                                // показать козырь

            // выдача карт на руки
            for (var i = 0; i < 6; i++)
            {
                HandPlayer1Box.Add(DeckBox.TakeCard());
                HandPlayer2Box.Add(DeckBox.TakeCard());
            }
            ViewState();
            PrintLogs("Карты розданы");

            // определение активного игрока
            InitActivePlayer();
            PrintLogs("Сейчас ходит игрок " + ActivePlayer);

            // создание сервера
            Player1 = new Lori(DeckBox.ViewTrump(), "Lori One");
            Player2 = new Lori(DeckBox.ViewTrump(), "Lori Two");
        }