Esempio n. 1
0
        public bool update(Dictionary <string, string> inputs, out string error)
        {
            error = "";
            foreach (string token in inputs.Keys)
            {
                if (validUpdateCardKeys.Contains(token.ToLowerInvariant()))
                {
                    switch (token.ToLowerInvariant())
                    {
                    case "title":
                        customTitle = inputs[token];
                        break;

                    case "lore":
                        customLore = inputs[token];
                        break;

                    case "img":
                        img = inputs[token];
                        break;

                    case "acronym":
                        customAcronym = inputs[token];
                        break;

                    default:
                        error = error + System.Environment.NewLine + "Unrecognized Key: " + token + " Value: " + inputs[token];
                        break;
                    }
                }
                else
                {
                    var condition = CardCondition.stringToCardCondition(token.ToLowerInvariant());
                    if (condition != CardConditionOptions.INVALID)
                    {
                        if (int.TryParse(inputs[token], out int value))
                        {
                            conditions.Add(new CardCondition(condition, value));
                        }
                        else
                        {
                            error = "Card condition (" + condition + ") had no valid value assigned.";
                            return(false);
                        }
                    }
                    else
                    {
                        error = error + System.Environment.NewLine + "Unrecognized Key: " + token + " Value: " + inputs[token];
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
 public override string ToString()
 {
     return(value + " " + CardCondition.cardConditionString(cardCondition));
 }
Esempio n. 3
0
        public bool updateNewCard(Dictionary <string, string> inputs, out string error)
        {
            error = "";
            foreach (string token in inputs.Keys)
            {
                if (validNewCardKeys.Contains(token.ToLowerInvariant()))
                {
                    switch (token.ToLowerInvariant())
                    {
                    case "title":
                        title = inputs[token];
                        break;

                    case "description":
                        description = inputs[token];
                        break;

                    case "lore":
                        customLore = inputs[token];
                        break;

                    case "success":
                        success = inputs[token];
                        break;

                    case "failure":
                        failure = inputs[token];
                        break;

                    case "legality":
                        cardLegality = Card.stringToCardLegality(inputs[token]);
                        if (cardLegality == CardLegality.INVALID)
                        {
                            error = "Card Legality input valid. Received: " + inputs[token];
                            return(false);
                        }
                        break;

                    case "type":
                        cardType = Card.stringToCardType(inputs[token]);
                        if (cardType == CardType.INVALID)
                        {
                            error = "Card Type input valid. Received: " + inputs[token];
                            return(false);
                        }
                        break;

                    case "acronym":
                        acronym = inputs[token];
                        break;
                    }
                }
                else
                {
                    var condition = CardCondition.stringToCardCondition(token.ToLowerInvariant());
                    if (condition != CardConditionOptions.INVALID)
                    {
                        if (int.TryParse(inputs[token], out int value))
                        {
                            conditions.Add(new CardCondition(condition, value));
                        }
                        else
                        {
                            error = "Card condition (" + condition + ") had no valid value assigned.";
                            return(false);
                        }
                    }
                    else
                    {
                        error = error + System.Environment.NewLine + "Unrecognized Key: " + token + " Value: " + inputs[token];
                    }
                }
            }
            return(true);
        }