Esempio n. 1
0
        public Card(CardSuits suit, CardNames name)
        {
            this.suit = suit;
            this.name = name;

            value = (int)name;
        }
Esempio n. 2
0
        public Card(CardSuits suit, CardNames name)
        {
            this.suit = suit;
            this.name = name;

            value = (int)name;
        }
Esempio n. 3
0
 public bool CheckForSpecificCardInPlay(CardNames cardName)
 {
     if (GetCardsInPlay().Any(c => c.CardNameEnum == cardName))
     {
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
 public CardData(CardNames name, Owner owner, int rank, int value, int index, Suit suit)
 {
     _cardName = name;
     _value    = value;
     _index    = index;
     _suit     = suit;
     _rank     = rank;
     _owner    = owner;
 }
Esempio n. 5
0
        public void DoSearch()
        {
            foreach (var card in Cards)
            {
                card.IsDisplayed = true;
            }

            foreach (var card in Cards)
            {
                var isNameMatch          = string.IsNullOrEmpty(CardNameSearch) ? true : card.Info.Name.ToLower().Contains(CardNameSearch.ToLower());
                var isPatchMatch         = string.IsNullOrEmpty(PatchSearch) ? true : card.Info.Patch.Contains(PatchSearch);
                var isNpcMatch           = string.IsNullOrEmpty(NPCNameSearch) ? true : card.Info.NPCs.FirstOrDefault(n => n.ToLower().Contains(NPCNameSearch.ToLower())) != null;
                var isMinDifficultyMatch = string.IsNullOrEmpty(MinDifficultySearch) ? true : card.Difficulty >= int.Parse(MinDifficultySearch);
                var isMaxDifficultyMatch = string.IsNullOrEmpty(MaxDifficultySearch) ? true : card.Difficulty <= int.Parse(MaxDifficultySearch);
                var isCollectionMatch    = string.IsNullOrEmpty(CollectedSearch) || CollectedSearch == "No Preference" ? true : (CollectedSearch == "Collected" && card.IsCollected) || (CollectedSearch == "Uncollected" && !card.IsCollected);

                card.IsDisplayed = isNameMatch && isPatchMatch && isNpcMatch && isMinDifficultyMatch && isMaxDifficultyMatch && isCollectionMatch;
            }

            // store fields for resetting later
            var cardName = CardNameSearch;
            var patch    = PatchSearch;
            var npcName  = NPCNameSearch;

            CardNames.Clear();
            Patches.Clear();
            NPCNames.Clear();

            var displayedCards = Cards.Where(c => c.IsDisplayed);

            foreach (var displayedCard in displayedCards)
            {
                if (!CardNames.Contains(displayedCard.Info.Name))
                {
                    CardNames.Add(displayedCard.Info.Name);
                }

                if (!Patches.Contains(displayedCard.Info.Patch))
                {
                    Patches.Add(displayedCard.Info.Patch);
                }

                foreach (var npc in displayedCard.Info.NPCs)
                {
                    if (!NPCNames.Contains(npc))
                    {
                        NPCNames.Add(npc);
                    }
                }
            }

            // set fields back after the search
            CardNameSearch = cardName;
            PatchSearch    = patch;
            NPCNameSearch  = npcName;
        }
Esempio n. 6
0
 public void InitCard(Dealer parent, int value, Suits suit, CardNames name)
 {
     Parent           = parent;
     Value            = value;
     Suit             = suit;
     Name             = name;
     FrontImage       = Resources.Load(Name.ToString(), typeof(Sprite)) as Sprite;
     MySpriteRenderer = gameObject.GetComponent <SpriteRenderer> ();
     MyGameLogic      = GameObject.Find("GameLogic").GetComponent <GameLogic> ();
 }
Esempio n. 7
0
 public Card()
 {
     cardName        = (CardNames)Random.Range(0, 6);
     cardDescription = (Description)Random.Range(0, 2);
     title           = cardName.ToString();
     description     = cardDescription.ToString();
     hp     = GetValue();
     attack = GetValue();
     mana   = GetValue();
 }
Esempio n. 8
0
        public Card(CardTypes type, CardNames name)
        {
            Type     = type;
            CardName = name;

            InitializeComponent();

            Bitmap cardImage = (Bitmap)Properties.Resources.ResourceManager.GetObject($"_{(int) name}_{(int) type}");

            pbImage.Image = cardImage;
        }
Esempio n. 9
0
 public Card(CardNames name, Suits suit, bool madness, ScoreConditions scoreCondition, int scoreValue, List <Suits> suitsToScore, string fullImagePath)
 {
     CardNameEnum    = name;
     CardNameDisplay = GetDisplayName();
     Suit            = suit;
     HasMadness      = madness;
     ScoreCondition  = scoreCondition;
     ScoreValue      = scoreValue;
     SuitsToScore    = suitsToScore;
     DoubleScore     = false;
     Art             = fullImagePath;
 }
Esempio n. 10
0
        internal CardView Card(CardNames cardName)
        {
            foreach (CardView card in _vectorCards.Cards)
            {
                if (card.Data.Name == cardName)
                {
                    return(card);
                }
            }

            throw new Exception("card not found");
        }
Esempio n. 11
0
        public Card BuyCard(CardNames name)
        {
            var reserveDeck = this._reserveDecks.First(x => x.CardInfo.CardName == name);

            if (reserveDeck.CardsLeft <= 0)
            {
                throw new InvalidOperationException($"Not able to get card {name.ToString()} from deck. Deck is empty.");
            }

            reserveDeck.CardsLeft--;
            return(reserveDeck.CardInfo);
        }
Esempio n. 12
0
        private static string GetCardIdByName(string name)
        {
            string id;

            if (CardNames.TryGetValue(name, out id))
            {
                return(id);
            }
            else
            {
                Console.WriteLine("No Card with such name found, you probably misspelled it.");
                return(null); // throw err
            }
        }
Esempio n. 13
0
        public void FaceCardTest()
        {
            for (int indexSuit = 0; indexSuit < 4; indexSuit++)
            {
                for (int indexName = 9; indexName < 12; indexName++)
                {
                    CardNames exampleName = (CardNames)indexName;
                    CardSuits exampleSuit = (CardSuits)indexSuit;
                    var       card        = new UsualCard(exampleName, exampleSuit);

                    Assert.IsTrue(card.CardSuit == exampleSuit && card.CardName == exampleName && card.CardNumber == 10);
                }
            }
        }
Esempio n. 14
0
    public static string[] GetMoveStrings(CardNames moveName)
    {
        switch (moveName)
        {
        case CardNames.JabHigh:
            return(JabHigh());

        case CardNames.SwingHigh:
            return(SwingHigh());

        case CardNames.PunchMid:
            return(PunchMid());

        case CardNames.KickMid:
            return(KickMid());

        case CardNames.KickLow:
            return(KickLow());

        case CardNames.BlockHigh:
            return(BlockHigh());

        case CardNames.BlockMid:
            return(BlockMid());

        case CardNames.CheckLow:
            return(CheckLow());

        case CardNames.WeaveHigh:
            return(WeaveHigh());

        case CardNames.DodgeMid:
            return(DodgeMid());

        case CardNames.CounterHigh:
            return(CounterHigh());

        case CardNames.CounterMid:
            return(CounterMid());

        default:
            Debug.LogError("Invalid MoveName tag" + moveName);
            return(new string[0]);
        }
    }
Esempio n. 15
0
    private Card CreateNewCard(CardNames name)
    {
        string _stringName = name.ToString();
        Suits  _suit;
        int    _value;

        switch (_stringName [0])
        {
        case 'c':
            _suit = Suits.Clubs;
            break;

        case 'd':
            _suit = Suits.Diamonds;
            break;

        case 'h':
            _suit = Suits.Hearts;
            break;

        case 's':
            _suit = Suits.Spades;
            break;

        default:
            _suit = Suits.None;
            break;
        }
        _value = int.Parse(_stringName.Substring(1));

        GameObject _cardGameObject = Instantiate(CardPrefab, transform.position, Quaternion.identity) as GameObject;

        _cardGameObject.transform.SetParent(transform);

        Card _card = _cardGameObject.GetComponent <Card>();

        _card.InitCard(this, _value, _suit, name);
        return(_card);
    }
Esempio n. 16
0
 public Card GetCardInfo(CardNames name)
 {
     return(this._cards.FirstOrDefault(x => x.CardName == name));
 }
Esempio n. 17
0
        public void LoadCardFromJToken(JToken cardJToken, string defaultSetCode)
        {
            if (cardJToken == null)
            {
                UnityEngine.Debug.LogWarning("LoadCardFromJToken::NullCardJToken");
                return;
            }

            string cardId = cardJToken.Value <string>(CardIdIdentifier) ?? string.Empty;

            if (string.IsNullOrEmpty(cardId))
            {
                UnityEngine.Debug.LogWarning("LoadCardFromJToken::InvalidCardId:" + cardJToken.ToString());
                return;
            }

            string cardName = cardJToken.Value <string>(CardNameIdentifier) ?? string.Empty;
            Dictionary <string, PropertyDefValuePair> cardProperties = new Dictionary <string, PropertyDefValuePair>();

            foreach (PropertyDef property in CardProperties)
            {
                PropertyDefValuePair newPropertyEntry = new PropertyDefValuePair()
                {
                    Def = property
                };
                try
                {
                    string  listValue = string.Empty;
                    JObject jObject   = null;
                    switch (property.Type)
                    {
                    case PropertyType.ObjectEnumList:
                        listValue = string.Empty;
                        foreach (JToken jToken in cardJToken[property.Name])
                        {
                            if (!string.IsNullOrEmpty(listValue))
                            {
                                listValue += EnumDef.Delimiter;
                            }
                            jObject    = jToken as JObject;
                            listValue += jObject?.Value <string>("id") ?? string.Empty;
                        }
                        newPropertyEntry.Value = listValue;
                        break;

                    case PropertyType.ObjectList:
                        listValue = string.Empty;
                        foreach (JToken jToken in cardJToken[property.Name])
                        {
                            if (!string.IsNullOrEmpty(listValue))
                            {
                                listValue += EnumDef.Delimiter;
                            }
                            jObject    = jToken as JObject;
                            listValue += jObject?.ToString() ?? string.Empty;
                        }
                        newPropertyEntry.Value = listValue;
                        break;

                    case PropertyType.ObjectEnum:
                        jObject = cardJToken[property.Name] as JObject;
                        newPropertyEntry.Value = jObject.Value <string>("id") ?? string.Empty;
                        break;

                    case PropertyType.Object:
                        jObject = cardJToken[property.Name] as JObject;
                        newPropertyEntry.Value = jObject?.ToString() ?? string.Empty;
                        break;

                    case PropertyType.StringEnumList:
                    case PropertyType.StringList:
                        listValue = string.Empty;
                        foreach (JToken jToken in cardJToken[property.Name])
                        {
                            if (!string.IsNullOrEmpty(listValue))
                            {
                                listValue += EnumDef.Delimiter;
                            }
                            listValue += jToken.Value <string>() ?? string.Empty;
                        }
                        newPropertyEntry.Value = listValue;
                        break;

                    case PropertyType.EscapedString:
                        newPropertyEntry.Value = (cardJToken.Value <string>(property.Name) ?? string.Empty).Replace("\\", "");
                        break;

                    case PropertyType.StringEnum:
                    case PropertyType.Number:
                    case PropertyType.Integer:
                    case PropertyType.Boolean:
                    case PropertyType.String:
                    default:
                        newPropertyEntry.Value = cardJToken.Value <string>(property.Name) ?? string.Empty;
                        break;
                    }
                }
                catch
                {
                    newPropertyEntry.Value = string.Empty;
                }
                cardProperties[property.Name] = newPropertyEntry;
            }

            HashSet <string> setCodes = new HashSet <string>();

            if (SetsInCardObject)
            {
                JToken        setContainer = cardJToken[CardSetIdentifier];
                List <JToken> setJTokens   = (setContainer as JArray)?.ToList() ?? new List <JToken>();
                if (setJTokens.Count == 0)
                {
                    setJTokens.Add(setContainer);
                }
                foreach (JToken jToken in setJTokens)
                {
                    JObject setObject = jToken as JObject;
                    string  setCode   = setObject?.Value <string>(SetCodeIdentifier);
                    if (setCode == null)
                    {
                        UnityEngine.Debug.LogWarning("LoadCardFromJToken::InvalidSetObject:" + setContainer.ToString());
                    }
                    else
                    {
                        setCodes.Add(setCode);
                    }
                }
            }
            else
            {
                setCodes.Add(cardJToken.Value <string>(CardSetIdentifier) ?? defaultSetCode);
            }

            foreach (string cardSet in setCodes)
            {
                bool isReprint = CardNames.Contains(cardName);
                if (!isReprint)
                {
                    CardNames.Add(cardName);
                }
                Card newCard = new Card(this, setCodes.Count > 1 ? (cardId + "_" + cardSet) : cardId, cardName, cardSet, cardProperties, isReprint);
                LoadedCards[newCard.Id] = newCard;
                if (!Sets.ContainsKey(cardSet))
                {
                    LoadedSets[cardSet] = new Set(cardSet);
                }
            }
        }
Esempio n. 18
0
        public Dictionary <string, string> Read()
        {
            var textCollection = new Dictionary <string, string>();

            using (var context = new CardAttributesContext())
            {
                if (!context.Database.Exists())
                {
                    var languageEng = new Languages()
                    {
                        Language = Enum.GetName(typeof(LanguageEnum), 1)
                    };
                    var languageRu = new Languages()
                    {
                        Language = Enum.GetName(typeof(LanguageEnum), 2)
                    };
                    var keywordNames = new KeyWords()
                    {
                        KeyWord = Enum.GetName(typeof(KeyWordEnum), 1)
                    };
                    var keywordSuits = new KeyWords()
                    {
                        KeyWord = Enum.GetName(typeof(KeyWordEnum), 2)
                    };
                    var cardNamesEng = new CardNames()
                    {
                        Name         = "Six,Seven,Eight,Nine,Ten,Jack,Lady,King,Ace",
                        Languages    = languageEng,
                        NamesKeyWord = keywordNames
                    };
                    var cardNamesRu = new CardNames()
                    {
                        Name         = "Шестерка,Семерка,Восьмерка,Девятка,Десять,Валет,Дама,Король,Туз",
                        Languages    = languageRu,
                        NamesKeyWord = keywordNames
                    };
                    var SuitsEng = new CardSuits()
                    {
                        Suit         = "Diamonds,Spades,Clubs,Hearts",
                        Languages    = languageEng,
                        SuitsKeyWord = keywordSuits
                    };
                    var SuitsRu = new CardSuits()
                    {
                        Suit         = "Буби,Пики,Крести,Червы",
                        Languages    = languageRu,
                        SuitsKeyWord = keywordSuits
                    };

                    context.Languages.Add(languageEng);
                    context.Languages.Add(languageRu);
                    context.KeyWords.Add(keywordNames);
                    context.KeyWords.Add(keywordSuits);
                    context.CardNames.Add(cardNamesEng);
                    context.CardNames.Add(cardNamesRu);
                    context.CardSuits.Add(SuitsEng);
                    context.CardSuits.Add(SuitsRu);

                    context.SaveChanges();
                }

                context.Database.Log = Console.WriteLine;
                var cardNames = context.CardNames
                                .Include(n => n.NamesKeyWord)
                                .First(n => n.Languages.LanguagesId == _languageType);

                CardSuits cardSuits = context.CardSuits
                                      .Include(n => n.SuitsKeyWord)
                                      .First(n => n.Languages.LanguagesId == _languageType);

                textCollection.Add(cardNames.NamesKeyWord.KeyWord, cardNames.Name);
                textCollection.Add(cardSuits.SuitsKeyWord.KeyWord, cardSuits.Suit);
            }
            return(textCollection);
        }
Esempio n. 19
0
 public Card(CardNames name)
 {
     CardName = name;
 }
Esempio n. 20
0
 public static int CompareCardNamesByValue(CardNames x, CardNames y)
 {
     return((int)x - (int)y);
 }
Esempio n. 21
0
 public Card(Suit suit, CardNames name, int value)
 {
     Suit  = suit;
     Name  = name;
     Value = value;
 }
Esempio n. 22
0
        public void LoadCardFromJToken(JToken cardJToken, string defaultSetCode)
        {
            if (cardJToken == null)
            {
                UnityEngine.Debug.LogError("LoadCardFromJToken::NullCardJToken");
                return;
            }

            Dictionary <string, PropertyDefValuePair> metaProperties = new Dictionary <string, PropertyDefValuePair>();
            PropertyDef idDef = new PropertyDef(CardIdIdentifier, PropertyType.String);

            PopulateCardProperty(metaProperties, cardJToken, idDef, idDef.Name);
            string cardId = string.Empty;

            if (metaProperties.TryGetValue(CardIdIdentifier, out PropertyDefValuePair cardIdEntry))
            {
                cardId = cardIdEntry.Value;
                if (string.IsNullOrEmpty(cardId))
                {
                    UnityEngine.Debug.LogWarning("LoadCardFromJToken::MissingCardId");
                    return;
                }
                if (!string.IsNullOrEmpty(CardIdStop))
                {
                    cardId = cardId.Split(CardIdStop[0])[0];
                }
            }
            else
            {
                UnityEngine.Debug.LogWarning("LoadCardFromJToken::ParseIdError");
                return;
            }

            PropertyDef nameDef = new PropertyDef(CardNameIdentifier, PropertyType.String);

            PopulateCardProperty(metaProperties, cardJToken, nameDef, nameDef.Name);
            string cardName = string.Empty;

            if (metaProperties.TryGetValue(CardNameIdentifier, out PropertyDefValuePair cardNameEntry))
            {
                cardName = cardNameEntry.Value ?? string.Empty;
            }
            else
            {
                UnityEngine.Debug.LogWarning("LoadCardFromJToken::ParseNameError");
            }

            Dictionary <string, PropertyDefValuePair> cardProperties = new Dictionary <string, PropertyDefValuePair>();

            PopulateCardProperties(cardProperties, cardJToken, CardProperties);

            Dictionary <string, string> cardSets = new Dictionary <string, string>();

            PopulateCardSets(cardSets, cardJToken, defaultSetCode);

            string cardImageWebUrl = string.Empty;

            if (!string.IsNullOrEmpty(CardImageProperty))
            {
                PropertyDef imageDef = new PropertyDef(CardImageProperty, PropertyType.String);
                PopulateCardProperty(metaProperties, cardJToken, imageDef, imageDef.Name);
                if (metaProperties.TryGetValue(CardImageProperty, out PropertyDefValuePair cardImageEntry))
                {
                    cardImageWebUrl = cardImageEntry.Value ?? string.Empty;
                }
            }

            if (string.IsNullOrEmpty(CardImageProperty) || !string.IsNullOrEmpty(cardImageWebUrl) || !string.IsNullOrEmpty(CardImageUrl))
            {
                foreach (var set in cardSets)
                {
                    bool isReprint = CardNameIsUnique && CardNames.Contains(cardName);
                    if (!isReprint)
                    {
                        CardNames.Add(cardName);
                    }
                    string cardDuplicateId = cardSets.Count > 1 && isReprint
                        ? (cardId + PropertyDef.ObjectDelimiter + set.Key) : cardId;
                    Card newCard = new Card(this, cardDuplicateId, cardName, set.Key, cardProperties, isReprint);
                    newCard.ImageWebUrl     = cardImageWebUrl;
                    LoadedCards[newCard.Id] = newCard;
                    if (!Sets.ContainsKey(set.Key))
                    {
                        LoadedSets[set.Key] = new Set(set.Key, set.Value);
                    }
                }
            }
            else
            {
                UnityEngine.Debug.Log("LoadCardFromJToken::MissingCardImageWebUrl"); // TODO: HANDLE DIFFERENTLY?
            }
        }
Esempio n. 23
0
        public Card(CardNames name)
        {
            Name = name.ToString();

            Value = Math.Min((int)name, 10);
        }
Esempio n. 24
0
 public UsualCard(CardNames name, CardSuits suit)
 {
     CardName   = name;
     CardSuit   = suit;
     CardNumber = GetCardNumber();
 }
Esempio n. 25
0
 public Card GetCardByEnumName(CardNames cardName)
 {
     return(this.CardsInCollection.FirstOrDefault(c => c.CardNameEnum == cardName));
 }
Esempio n. 26
0
 public CardView GetCardByName(CardNames card)
 {
     return(GetCardByIndex((int)card));
 }
Esempio n. 27
0
 private void AddDeckToReserve(CardNames name, int count)
 {
     this._reserveDecks.Add(new ReserveDeck {
         CardInfo = this._cardConfig.GetCardInfo(name), CardsLeft = count
     });
 }
Esempio n. 28
0
 public Card(Suit suit, CardNames name, int value)
 {
     Suit = suit;
     Name = name;
     Value = value;
 }
Esempio n. 29
0
 public bool HasReserveCard(CardNames cardName)
 {
     return(this._reserveDecks.SingleOrDefault(x => x.CardInfo.CardName == cardName && x.CardsLeft > 0) != null);
 }
Esempio n. 30
0
        /// <summary>
        /// Generates Card
        /// </summary>
        /// <param name="type">Type for card</param>
        /// <param name="name">Name for card</param>
        /// <returns>New card</returns>
        public Card CreateCard(CardTypes type, CardNames name)
        {
            Card card = new Card(type, name);

            return(card);
        }
Esempio n. 31
0
 public VectorCard(Canvas canvas, int index, CardNames name)
 {
     _canvas   = canvas;
     _index    = index;
     _cardName = name;
 }