Exemplo n.º 1
0
        void reset()
        {
            configOk    = false;
            RawCardData = "";

            FilePath     = "";
            Name         = "";
            Cost         = null;
            Types        = new AttributGroup <CardTypes>();
            Abilities    = new List <Ability>();
            Triggers     = new List <Trigger>();
            SpellEffects = new List <EffectGroup> ();
            Konstrains   = new List <string>();
            R            = new List <string>();
            DeckNeeds    = new List <string>();
            TextField    = new List <string>();
            Comments     = new List <string>();

            Oracle = "";

            Power     = 0;
            Toughness = 0;

            S                = "";
            AlternateMode    = "";
            Colors           = null;
            Loyalty          = "";
            HandLifeModifier = "";
            DeckHints        = "";

            picturePath = "";
            nbrImg      = 1;
            Alternate   = false;
        }
Exemplo n.º 2
0
 public Trigger(MagicEventType _type,
                AttributGroup <Target> _targets = null,
                Ability _exec = null)
 {
     Type        = _type;
     ValidTarget = _targets;
     Exec        = _exec;
 }
Exemplo n.º 3
0
        public static AttributGroup <ManaTypes> ParseMultipleColors(string strColors)
        {
            AttributGroup <ManaTypes> result = new AttributGroup <ManaTypes> (AttributeType.Composite);

            string[] tmp = strColors.Split(',');
            foreach (string s in tmp)
            {
                result += (ManaTypes)Enum.Parse(typeof(ManaTypes), s);
            }
            return(result);
        }
Exemplo n.º 4
0
 public static AttributGroup <T> operator +(AttributGroup <T> ma, T a)
 {
     if (!(ma?.Count > 0))
     {
         return(a == null ? null : new AttributGroup <T> (a));
     }
     if (ma.attributeType == AttributeType.Composite)
     {
         AttributGroup <T> tmp = ma.Clone;
         tmp.Add(a);
         return(tmp);
     }
     else if (a == null)
     {
         return(ma.Clone);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 5
0
        public static AttributGroup <T> operator |(AttributGroup <T> ma, T a)
        {
//			if (ma == null)
//				return a == null ? null : new MultiformAttribut<T> (a);
            if (ma.attributeType == AttributeType.Choice)
            {
                AttributGroup <T> tmp = ma.Clone;
                tmp.Add(a);
                return(tmp);
            }
            else if (a == null)
            {
                return(ma.Clone);
            }
            else
            {
                return(null);
            }

//				new MultiformAttribut<MultiformAttribut<T>>(AttributeType.Choice,
//				ma.Clone, new MultiformAttribut<T> (a));
        }
Exemplo n.º 6
0
//		static List<string> list = new List<String> ();

        public static AttributGroup <Target> ParseTargets(string str)
        {
            AttributGroup <Target> result = new AttributGroup <Target>(AttributeType.Choice);

            string[] tmp = str.Trim().Split(new char[] { ',' });
            foreach (string t in tmp)
            {
                if (string.IsNullOrWhiteSpace(t))
                {
                    continue;
                }

                string[] cardTypes = t.Trim().Split(new char[] { '.', '+' });

                switch (cardTypes[0].Trim())
                {
                case "Opponent":
                    result |= TargetType.Opponent;
                    break;

                case "Player":
                    result |= TargetType.Player;
                    break;

                case "CHARGE":
                    result |= TargetType.Charge;
                    break;

                default:
                    CardTarget ctar = new CardTarget();

                    foreach (string ct in cardTypes)
                    {
                        switch (ct)
                        {
                        case "Card":
                            break;

                        case "Permanent":
                            ctar.TypeOfTarget = TargetType.Permanent;
                            break;

                        case "YouCtrl":
                            ctar.Controler = ControlerType.You;
                            break;

                        case "YouDontCtrl":
                            ctar.Controler = ControlerType.Opponent;
                            break;

                        case "OppCtrl":
                            ctar.Controler = ControlerType.Opponent;
                            break;

                        case "Other":
                            ctar.CanBeTargetted = false;
                            break;

                        case "TypeYouCtrl":
                            ctar.TypeOfTarget = TargetType.Permanent;
                            ctar.Controler    = ControlerType.You;
                            break;

                        case "attacking":
                            ctar.CombatState = CombatImplication.Attacking;
                            break;

                        case "blocking":
                            ctar.CombatState = CombatImplication.Blocking;
                            break;

                        case "CARDNAME":
                        case "Self":
                            ctar.TypeOfTarget = TargetType.Self;
                            break;

                        case "EnchantedBy":
                            ctar.TypeOfTarget = TargetType.EnchantedBy;
                            break;

                        case "equipped":
                            ctar.HavingAttachedCards += CardTypes.Equipment;
                            break;

                        case "kicked":
                            ctar.TypeOfTarget = TargetType.Kicked;
                            break;

                        case "Attached":
                            ctar.TypeOfTarget = TargetType.Attached;
                            break;

                        case "EquippedBy":
                            ctar.TypeOfTarget = TargetType.EquipedBy;
                            break;

                        case "White":
                            ctar.ValidCardColors += ManaTypes.White;
                            break;

                        default:
                            #region ability inclusion/exclusion
                            if (ct.StartsWith("without"))
                            {
                                ctar.WithoutAbilities += Ability.ParseKeyword(ct.Substring(7));
                                break;
                            }
                            if (ct.StartsWith("with"))
                            {
                                ctar.HavingAbilities += Ability.ParseKeyword(ct.Substring(4));
                                break;
                            }
                            #endregion
                            #region numeric contrain
                            NumericConstrain nc     = null;
                            string           strTmp = "";
                            if (ct.ToLower().StartsWith("power"))
                            {
                                ctar.PowerConstrain = new NumericConstrain();
                                nc     = ctar.PowerConstrain;
                                strTmp = ct.Substring(5);
                            }
                            else if (ct.ToLower().StartsWith("toughness"))
                            {
                                ctar.ToughnessConstrain = new NumericConstrain();
                                nc     = ctar.ToughnessConstrain;
                                strTmp = ct.Substring(9);
                            }

                            if (nc != null)
                            {
                                string strRelation = strTmp.Substring(0, 2);
                                switch (strRelation)
                                {
                                case "EQ":
                                    nc.Relation = NumericRelations.Equal;
                                    break;

                                case "LT":
                                    nc.Relation = NumericRelations.Less;
                                    break;

                                case "LE":
                                    nc.Relation = NumericRelations.LessOrEqual;
                                    break;

                                case "GT":
                                    nc.Relation = NumericRelations.Greater;
                                    break;

                                case "GE":
                                    nc.Relation = NumericRelations.GreaterOrEqual;
                                    break;

                                case "NE":
                                    nc.Relation = NumericRelations.NotEqual;
                                    break;

                                default:
                                    break;
                                }
                                strTmp = strTmp.Substring(2);

                                if (strTmp != "X" && !string.IsNullOrWhiteSpace(strTmp))
                                {
                                    nc.Value = int.Parse(strTmp);
                                }

                                break;
                            }
                            #endregion
                            #region card types constrains
                            CardTypes cts;
                            if (Enum.TryParse <CardTypes>(ct, true, out cts))
                            {
                                ctar.ValidCardTypes += (CardTypes)Enum.Parse(typeof(CardTypes), ct, true);
                            }
                            else
                            {
                                Debug.WriteLine("Unknow card type: " + ct);
                            }
                            #endregion
                            break;
                        }
                    }
                    result |= ctar;
                    break;
                }
            }

            return(result);
        }