示例#1
0
        //discard a card, change state
        public void DiscardCard(Player player, Card c)
        {
            //check state
            if (!CanDiscard(player))
            {
                _currentError = ErrorMessage.NotPlayerTurn;
                throw new ArgumentException("It is not this player's turn", "player");
            }
            //check if player has the card
            PlayerHasCard(player, c);

            //check if the card was just drawn
            if (c.Equals(_cardJustDrawn))
            {
                _currentError = ErrorMessage.CannotDiscard;
                throw new ArgumentException("Cannot discard a card that was just drawn", "player");
            }
            RemovePlayerCard(player, c);
            Discard.Add(c);

            State newState = (player == Player.One) ? State.Player2Draw : State.Player1Draw;

            AfterActStuff(new DiscardMove(player, c), newState);

            _currentError = ErrorMessage.NoError;
        }
示例#2
0
        public void Discard_ShouldBeInitialised()
        {
            var dealer = new Dealer();

            _discard = new Discard();
            _discard.Add(dealer.DealCard());
        }
示例#3
0
    public Card PlayFromHand(Card cardToPlay, CardGame gameToPlayIn, Discard receivingDiscard)
    {
        cardsInHand.Remove(cardToPlay);
        receivingDiscard.Add(cardToPlay);
        gameToPlayIn.Play(cardToPlay);

        return(cardToPlay);
    }
示例#4
0
 public Player(string PlayName)
 {
     _name = PlayName;
     PlayerHand = new Hand();
     PlayerDiscard = new Discard();
     PlayerField = new Field();
     PlayersDeck = new PlayerDeck();
 }
示例#5
0
 public void DiscardCard(Card discardCard)
 {
     Discard.AddCard(discardCard);
     if (HasSpecialPassive(SpecialPassiveEffects.SoulSacrifice))
     {
         Hero.HealUnit(-discardCard.TotalResource);
     }
 }
示例#6
0
        //pop a card from a Pile
        Card PopFromPile(PileName p)
        {
            if (p == PileName.Stock)
            {
                return(Stock.Pop());
            }

            return(Discard.Pop());
        }
示例#7
0
 private void Awake()
 {
     players   = new PlayerScript[MAX_PLAYERS];
     deck      = deckObj.GetComponent <Deck>();
     discard   = discardObj.GetComponent <Discard>();
     decking   = true;
     beginning = false;
     quitGame.SetActive(false);
 }
示例#8
0
    public Card Discard(Card cardToDiscard, Discard receivingDiscard)
    {
        cardsInHand.Remove(cardToDiscard);

        receivingDiscard.Add(cardToDiscard);


        return(cardToDiscard);
    }
示例#9
0
 // Start is called before the first frame update
 void Start()
 {
     this.deck        = new Deck();
     this.discard     = new Discard();
     this.hand        = new Hand();
     this.cardFactory = new CardFactory();
     this.player      = GameObject.Find("Player").GetComponent <Player>();
     CardInitialize();
 }
示例#10
0
文件: Game.cs 项目: djericj/Uno
 private void SetFaceCard(Card card)
 {
     FaceCard = card;
     if (card.IsWildCard || card.IsWildDrawFourCard)
     {
         card.Color = GetRandomColor();
     }
     Log("INFO", $"FaceCard is {FaceCard.DisplayCard()}");
     Discard.Enqueue(card);
 }
示例#11
0
    public void PutIn(Discard discard)
    {
        Deselect();
        InitMove(discard.Position, discard.Rotation, 0.8f);
        status = CardStatus.DiscardPile;
        NewHolder(discard);
        cardCollider.enabled = false;

        currentHand = null;
    }
示例#12
0
        public Discard GetMappedDiscard(Discard discard, User user)
        {
            DateTime date        = DateTime.Now;
            Material material    = GetMaterial(discard.MaterialId);
            Place    place       = GetPlace(discard.PlaceId);
            int      weekOfMonth = getWeekOfMonth(date.Day);

            return(new Discard(discard.MaterialId, discard.UserId, discard.PlaceId,
                               discard.Quantity, DateTime.Now, material.Description, place.Name, weekOfMonth));
        }
示例#13
0
    public Player()
    {
        var hand = new Hand();
        var deck = new Deck();

        hand.Deck = deck;
        deck.Hand = hand;
        Hand      = hand;
        Deck      = deck;
    }
示例#14
0
        public void CreateDiscardList(Shelf shelf, Book book)
        {
            using var libraryContext = new LibraryContext();
            var discard = new Discard();

            discard.ShelfID = shelf.ShelfID;
            discard.BookID  = book.BookID;
            libraryContext.Discards.Add(discard);
            libraryContext.SaveChanges();
        }
示例#15
0
    IEnumerator DiscardHand(Discard discardPile)
    {
        yield return(new WaitForSeconds(0.2f));

        Card[] cardArray = cards.ToArray();

        for (int i = 0; i < cardArray.Length; i++)
        {
            cardArray[i].PutIn(discardPile);
        }
    }
        public void validateDiscard(Discard discard)
        {
            Discard discardFound = discardsDbContext.Discards.FirstOrDefault(x =>
                                                                             x.UserId == discard.UserId && x.Date.DayOfYear == discard.Date.DayOfYear &&
                                                                             x.Date.Year == discard.Date.Year);

            if (discardFound != null)
            {
                throw new Exception("Você já depositou hoje");//personalizada
            }
        }
示例#17
0
        public void DiscardHand()
        {
            foreach (Card c in PlayerHand.Cards)
            {
                PlayerHand.Cards.Remove(c);
                Discard.Add(c);
                PlayerHand.Actions   = new List <Action>();
                PlayerHand.Resources = new Dictionary <Res, int>();

                Draw();
            }
        }
示例#18
0
    // Use this for initialization
    void Start()
    {
        control = GameObject.FindGameObjectWithTag("GameController").GetComponent <Controller>();
        deck    = GameObject.FindGameObjectWithTag("Deck").GetComponent <Deck>();
        discard = GameObject.FindGameObjectWithTag("Discard").GetComponent <Discard>();

        hand = new HandCard[HAND_MAX];
        HandCard[] hcScripts = GetComponentsInChildren <HandCard>();
        foreach (HandCard hc in hcScripts)
        {
            int ind = -1;
            switch (hc.transform.name)
            {
            case "Hand Card 1":
                ind = 0;
                break;

            case "Hand Card 2":
                ind = 1;
                break;

            case "Hand Card 3":
                ind = 2;
                break;

            case "Hand Card 4":
                ind = 3;
                break;

            case "Extra Card 1":
                ind = 4;
                break;

            case "Extra Card 2":
                ind = 5;
                break;
            }
            hand[ind] = hc;
        }

        for (int i = 0; i < HAND_MAX; i++)
        {
            hand[i].setOwner(this);

            //test block - delete after testing
            hand[i].setCard(new Card(1, Card.Suit.SPADES));
        }

        activeCard  = null;
        chosenCards = 0;
        mode        = Modes.SPAWN;
        Debug.Log("begin");
    }
示例#19
0
    public void DiscardSpecificCard(Card card)
    {
        int  cardIndex     = cards.IndexOf(card);
        Card cardToDiscard = cards[cardIndex];

        cards.RemoveAt(cardIndex);

        Discard discard = FindObjectOfType <Discard>();

        discard.AddCardToDiscard(card);
        SetCardsInDeckTextField();
    }
    public void DiscardPileSelected(Discard discard)
    {
        bool turnOK = (turnPhase == TurnPhase.Player1 ||
                       turnPhase == TurnPhase.Player2);

        bool expectingOK = (expecting == Expecting.DiscardPile ||
                            expecting == Expecting.CardSlotOrDiscardPile);

        if (phase == Phase.NormalTurns &&
            turnOK &&
            expectingOK &&
            selectedCard != null)
        {
            selectedCard.PutIn(discard);
            selectedCard.ShowAllRatings(turnPhase);
            selectedCard = null;

            if (!playedCard && !playerDiscard)
            {
                playerDiscard = true;
                expecting     = Expecting.Card;

                UI.Instance.UpdateInstructions("Play 1 card OR discard another cards to play 1 from the discard pile.");
            }

            else if (playedCard && !playerDiscard)
            {
                playerDiscard = true;
                InitNextTurn();
            }

            else if (!playedCard && playerDiscard)
            {
                if (turnPhase == TurnPhase.Player1)
                {
                    player1Hand.NotYourTurn();
                    discardPile.DealCards(player1DiscardHand);
                    UI.Instance.UpdateInstructions("Play one card from the discard pile.");
                }

                else if (turnPhase == TurnPhase.Player2)
                {
                    player2Hand.NotYourTurn();
                    discardPile.DealCards(player2DiscardHand);
                    UI.Instance.UpdateInstructions("Play one card from the discard pile.");
                }

                doubleDiscard = true;
                expecting     = Expecting.Card;
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        finishedDrawingStartOfTurnCards = false;
        playerHandDebuff = 0;
        battleData       = FindObjectOfType <BattleData>();
        deck             = FindObjectOfType <Deck>();
        discard          = FindObjectOfType <Discard>();
        character        = battleData.GetCharacter();

        initialHandSize = character.GetStartingHandSize();

        ConfigHand();
    }
示例#22
0
    // Use this for initialization
    void Start()
    {
        gm          = this;
        GameDeck    = GameObject.Find("Deck").GetComponent <Deck>();
        DiscardPile = GameObject.Find("Discard").GetComponent <Discard>();
        Log         = GameObject.Find("GameLog").GetComponent <GameLog>();
        Players     = new GameObject[PlayerCount];
        Players[0]  = GameObject.Find("PlayerObject");
        Players[0].GetComponent <Controller>().Order = 0;
        Players[0].GetComponent <Controller>().Name  = pname;
        PlayerIndex = 0;
        for (int i = 1; i < PlayerCount; i++)
        {
            Players[i] = Instantiate(COM);
            Players[i].transform.SetParent(gameObject.transform);
            Players[i].GetComponent <Controller>().Order = i;
            Players[i].GetComponent <Controller>().Name  = "COM " + i;
            if (ShowAllHands)
            {
                Players[i].transform.localRotation = Quaternion.Euler(180, 0, 0);
                Players[i].transform.FindChild("Name").localRotation = Quaternion.Euler(Vector3.zero);
            }
        }
        foreach (Card c in GameDeck.Cards)
        {
            c.InstantiateObject();
        }
        for (int i = 0; i < 7; i++) // distribute cards
        {
            foreach (GameObject player in Players)
            {
                Controller pc = player.GetComponent <Controller>();
                if (pc.Hand == null)
                {
                    pc.Hand = new List <Card>();
                }
                Card c = GameDeck.Draw();
                player.GetComponent <Controller>().AddCard(c);
            }
        }

        Turn = (int)System.Math.Floor(Random.Range(0, 3.9f));
        Log.LogTurn(Players[Turn].GetComponent <Controller>());
        Clockwise = false;
        DiscardPile.DiscardCard(GameDeck.Draw());
        if (ColorInPlay == Card.Colors.Wild)
        {
            ColorInPlay = Players[Turn].GetComponent <Controller>().ChooseColor();
        }
        CurrentState = States.Wait;
    }
        public void Result()
        {
            var discardPile = new Discard();

            discardPile.Add(new Card(Suit.Clubs, Value.Eight));
            discardPile.Add(new Card(Suit.Diamonds, Value.Seven));
            discardPile.Add(new Card(Suit.Diamonds, Value.Ace));

            discardPile.Accept(_discardPileVisitor);

            Assert.AreEqual(3, _discardPileVisitor.Result().Count);
            Assert.AreEqual(Value.Ace, _discardPileVisitor.Result().Peek().Value);
            Assert.AreEqual(Suit.Diamonds, _discardPileVisitor.Result().Peek().Suit);
        }
    private bool DiscardPileClicked(Transform objectHit)
    {
        Discard discard = objectHit.GetComponentInParent <Discard>();

        if (discard != null)
        {
            clickedDiscardPile = discard;
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#25
0
        public virtual void StartHand()
        {
            _deck         = new Deck(this.rules);
            _table        = new Table();
            _discard      = new Discard();
            _firstDiscard = true;

            ServerPlayer p;
            PhazeRule    pr;
            int          prnum;
            bool         dealt;

            //this does [X] things:
            //tell the player what phaze they're on
            //create a new hand for them (and notify them)
            //create a scoreboard for them
            foreach (object o in _players)
            {
                p     = (ServerPlayer)o;
                dealt = false;
                if (p == (ServerPlayer)_players[_handNumber])
                {
                    dealt = true;
                }
                prnum = p.CurrentPhaze;
                pr    = this.rules.PhazeRules.Phaze(prnum);
                //notify the client what phaze they're on

                p.Send(new CurrentPhazeMessage(prnum));

                p.NewHand(pr);
                p.Send(new NewHandMessage());
                p.Scoreboard.AddSession(new Session(dealt, prnum));
            }
            deal();

            //reset turn
            _turn = 0;

            //update all statuses!
            updateClientsStatuses();
            updateClientsScoreboards();

            //tell the user whose turn it is!
            p              = (ServerPlayer)_players[_handNumber];
            p.MyTurn       = true;
            p.PickedUpCard = false;             //double check!
            startTurn(p);
        }
示例#26
0
文件: Game.cs 项目: djericj/Uno
        private void ReloadFromDiscard()
        {
            Object obj = new Object();

            lock (obj)
            {
                Card[] discardCards = new Card[Discard.Count()];
                Discard.CopyTo(discardCards, 0);
                foreach (var card in discardCards)
                {
                    GameDeck.Enqueue(card);
                }
                Discard.Clear();
            }
        }
示例#27
0
        public void ResetState()
        {
            ActionsAvailable = 0;

            AllCards.Clear();
            Deck.Clear();
            Discard.Clear();
            Hand.Clear();
            Characters.Clear();
            Lessons.Clear();
            Creatures.Clear();
            Location.Clear();
            Match.Clear();
            Items.Clear();
            Adventure.Clear();
        }
示例#28
0
 public IActionResult Create([FromBody] Discard discard)//indica que o usuário vem pelo body da requisição
 {
     try
     {
         if (discard == null)
         {
             return(BadRequest());
         }
         discardBLL.Add(discard);
         return(Accepted());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#29
0
 public void DiscardCard() //...............Discard Action cards......................
 {
     int count = 1;
     Console.WriteLine("Choose a card to Discard");
     
     foreach (Action card in ActionHand)
     {
         Console.Write("{0}). {1}, ", count, card.Name.ToString());
         count += 1;
     }
     Int32.TryParse(Console.ReadLine(), out int query2);
     //Instead of backing out, which is difficult, it assumes the first card will be dropped
     if (query2 < 1 || query2 > ActionHand.Count) query2 = 1;
     Discard.Add(ActionHand[query2-1]);
     ActionHand.RemoveAt(query2 - 1);
 }
示例#30
0
        //draw a card from stock or discard
        //player
        //pile
        public void DrawCard(Player player, PileName pn)
        {
            if (!CanDraw(player))
            {
                _currentError = ErrorMessage.NotPlayerTurn;
                throw new ArgumentException("It is not this player's turn", "player");
            }

            if (IsPileEmpty(pn))
            {
                throw new ArgumentException("The pile is empty", "pn");
            }

            Card c = PopFromPile(pn);

            AddToPlayerCards(player, c);
            //if drawn from discard pile, remeber the card
            if (pn == PileName.Discard)
            {
                _cardJustDrawn = c;
            }
            else
            {
                _cardJustDrawn = null;
            }

            if (pn == PileName.Stock && IsPileEmpty(PileName.Stock))
            {
                var topOnDiscard = Discard.Pop();
                while (Discard.Count > 0)
                {
                    Stock.Add(Discard.Pop());
                    Stock.Shuffle(null);
                }

                Discard.Add(topOnDiscard);
            }


            _currentError = ErrorMessage.NoError;

            var newState = (player == Player.One) ?State.Player1MeldLayDiscard : State.Player2MeldLayDiscard;

            AfterActStuff(new DrawMove(player, pn), newState);
        }
示例#31
0
        public void AddToDiscardListWorksMulitpleTimes()
        {
            Discard discard = new Discard();

            Card y1 = new Card("Y");
            Card y2 = new Card("Y");
            Card y3 = new Card("Y");
            Card y4 = new Card("Y");

            discard.AddToDiscard(y2);
            discard.AddToDiscard(y2);
            discard.AddToDiscard(y2);
            discard.AddToDiscard(y1);

            int result = discard.CardsInDiscard.Count;

            Assert.AreEqual(4, result);
        }