コード例 #1
0
    public void Initialize(int NumberOfCards)
    {
        _Manager = GameObject.Find("_Manager");
        System.Random rnd = new System.Random();
        _Manager.GetComponent <Manager>().cardSound(rnd.Next(1, 4));
        if ((PlayerID == 1) || (NumberOfCards != 0))
        {
            CardSprite = _Manager.GetComponent <Manager>().setSprite(Value, Shape.ToString());
        }
        else
        {
            CardSprite = _Manager.GetComponent <Manager>().DefaultCard();
        }

        posX = (NumberOfCards * 50);

        int val = (Value + 2);

        if ((val <= 10) || (val == 11 && val + _Manager.GetComponent <Manager>().TotalPoints(PlayerID) <= 21))
        {
            Value = val;
        }
        else if (val > 11)
        {
            Value = 10;
        }
        else if (val == 11)
        {
            Value = 1;
        }
    }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ResetSelectionOfSuits();
            newDemandedSuit = (CardSuits)(sender as WrapPanelSelectableItem).Tag;
            (sender as WrapPanelSelectableItem).ItemSelected = Visibility.Visible;
            var logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Info($"New demanded suit: {newDemandedSuit.ToString()}.");
        }
コード例 #3
0
        //clicking proper game suit - selection of card suit
        private void SuitButton_Click(object sender, RoutedEventArgs e)
        {
            thisSuit = (CardSuits)(sender as WrapPanelSelectableItem).Tag;
            thisRank = CardRanks.None;
            var logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Info($"New choosen Card suit: {thisSuit.ToString()}.");
            ResetSelectionOfSuits();
            (sender as WrapPanelSelectableItem).ItemSelected = Visibility.Visible;
            RemoveAllChildrenFromRankScrllView();
            PopulateRankWrapPanel();
        }
コード例 #4
0
 private static string GenerateResourceName(CardSuits suit, CardRanks rank)
 {
     if (rank == CardRanks.Joker)
     {
         return($"{rank.ToString()}_of_none");
     }
     else if (rank != CardRanks.Joker && rank != CardRanks.None)
     {
         return($"{rank.ToString()}_of_{suit.ToString()}");
     }
     else
     {
         return("");
     }
 }
コード例 #5
0
        private BitmapImage GetImageSourceFromPropertiesObject(CardSuits suit, CardRanks rank)
        {
            BitmapImage output = null;

            try
            {
                string name = GenerateResourceName(suit, rank);
                output = new BitmapImage(new Uri($"pack://application:,,,/CardGraphicsLibraryHandler;component/Resources/{name}.png"));
            }
            catch (Exception ex)
            {
                var logger = NLog.LogManager.GetCurrentClassLogger();
                logger.Error($"Error while reading specific card image ({suit.ToString()}, {rank.ToString()}) from resources: {ex.Message}.");
            }

            return(output);
        }
コード例 #6
0
        //control demanding options
        public bool CheckDemandPossibilities(CardRanks newDemRank, CardSuits newDemSuit, int playerNumber,
                                             ref CardRanks demandedRank, ref CardSuits demandedSuit, ref GameStatus status,
                                             ref Dictionary <int, SinglePlayerData> PlayersCurrentData)
        {
            var    logger        = NLog.LogManager.GetCurrentClassLogger();
            string demandingType = "";

            if (Engine.ExtendedLogging)
            {
                logger.Info($"+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                logger.Info($"+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                logger.Info($"Demand possibilities checker current gme state: {status.ToString()}.");
                logger.Info($"+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                logger.Info($"+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            }

            //can't demand rank and suit at the same time
            if (newDemRank != CardRanks.None && newDemSuit != CardSuits.None)
            {
                string text = "Rank and Suit can not be demanded both at the same time";
                logger.Error(text);
                throw new ArgumentException(text);
            }

            //set demanding after placing the card on the table
            if (newDemRank == CardRanks.None && newDemSuit == CardSuits.None)
            {
                demandingType = "none";
                demandedRank  = CardRanks.None;
                demandedSuit  = CardSuits.None;
                //status
                if (status != GameStatus.Battle && status != GameStatus.Stops &&
                    status != GameStatus.StopsAndBattle)
                {
                    status = GameStatus.Standard;
                }
                ResetDemandingOptionsForAllPlayers(ref PlayersCurrentData, false);
            }
            else if (newDemRank != CardRanks.None && newDemSuit == CardSuits.None)
            {
                demandingType = "rank";
                SetRankDemandOption(playerNumber, newDemRank, ref demandedRank, ref demandedSuit, ref PlayersCurrentData);
                //status
                status = GameStatus.RankDemanding;
            }
            else if (newDemRank == CardRanks.None && newDemSuit != CardSuits.None)
            {
                demandingType = "suit";
                SetSuitDemandOption(playerNumber, newDemSuit, ref demandedRank, ref demandedSuit, ref PlayersCurrentData);
                //status
                status = GameStatus.SuitDemanding;
            }

            if (Engine.ExtendedLogging)
            {
                logger.Info($"Demand possibilities checking done. Demanded rank: {demandedRank.ToString()}, demanded suit: {demandedSuit.ToString()}, type: {demandingType}.");
            }

            return(true);
        }
コード例 #7
0
 //method that returns string representation of the card
 public override string ToString()
 {
     return(rank.ToString() + " of " + suit.ToString() + " from deck " + deckNumber.ToString());
 }
コード例 #8
0
        public static BitmapImage GetSuitImageSource(CardSuits suit)
        {
            BitmapImage output = null;

            try
            {
                output = new BitmapImage(new Uri($"pack://application:,,,/CardGraphicsLibraryHandler;component/Resources/{suit.ToString()}suit.png"));
            }
            catch (Exception ex)
            {
                var logger = NLog.LogManager.GetCurrentClassLogger();
                logger.Error($"Error while reading suit image from resources: {ex.Message}.");
            }

            return(output);
        }