コード例 #1
0
        public override List <WarGearCombination> Evaluate(List <WarGearCombination> configs, string entry)
        {
            int    indexSep = entry.IndexOf(":");
            String right    = entry.Substring(indexSep + 1);


            List <WarGearCombination> oldconfigs = new List <WarGearCombination>();


            if (indexSep >= 0)
            {
                //On retire la partie de gauche
                String left = entry.Substring(0, indexSep);

                List <WarGearCombination> confGauche = new GlobalNode().Evaluate(configs, left);
                foreach (WarGearCombination cg in confGauche)
                {
                    foreach (WarGearCombination old in configs)
                    {
                        WarGearCombination copy = old.Copy();
                        foreach (Weapon arme in cg.Weapons)
                        {
                            copy.Weapons.RemoveAll(a => a.Id == arme.Id);
                        }
                        if (copy.Weapons.Count + cg.Weapons.Count == old.Weapons.Count)
                        {
                            oldconfigs.Add(copy);
                        }
                    }
                }
            }
            else
            {
                //recopie sans modif
                foreach (WarGearCombination old in configs)
                {
                    WarGearCombination copy = old.Copy();
                    oldconfigs.Add(copy);
                }
            }

            List <WarGearCombination> conf = new List <WarGearCombination>();

            //On ajoute la partie droite
            List <WarGearCombination> confDroite = new GlobalNode().Evaluate(configs, right);

            foreach (WarGearCombination old in oldconfigs)
            {
                foreach (WarGearCombination droite in confDroite)
                {
                    WarGearCombination copy = old.Copy();
                    foreach (Weapon arme in droite.Weapons)
                    {
                        copy.Weapons.Add(arme);
                    }
                    conf.Add(copy);
                }
            }
            return(conf);
        }
コード例 #2
0
        public override List <WarGearCombination> Evaluate(List <WarGearCombination> configs, string entry)
        {
            int    indexSep = entry.IndexOf("|");
            String left     = entry.Substring(0, indexSep);
            String right    = entry.Substring(indexSep + 1);

            List <WarGearCombination> newconf = new List <WarGearCombination>();

            //On ajoute la partie droite
            List <WarGearCombination> confGauche;

            if (left.Length > 0)
            {
                confGauche = new GlobalNode().Evaluate(configs, left);
            }
            else
            {
                confGauche = new List <WarGearCombination>();
                foreach (WarGearCombination config in configs)
                {
                    confGauche.Add(config.Copy());
                }
            }
            List <WarGearCombination> confDroite = new GlobalNode().Evaluate(configs, right);


            newconf.AddRange(confGauche);
            newconf.AddRange(confDroite);

            return(newconf);
        }
コード例 #3
0
        public override List <WarGearCombination> Evaluate(List <WarGearCombination> configs, string entry)
        {
            int indexParentheseFermente = 1;
            int nbOuvrante = 1;

            for (; indexParentheseFermente < entry.Length; indexParentheseFermente++)
            {
                if (entry[indexParentheseFermente] == '(')
                {
                    nbOuvrante++;
                }

                else if (entry[indexParentheseFermente] == ')')
                {
                    nbOuvrante--;
                }
                if (nbOuvrante == 0)
                {
                    break;
                }
            }

            string between        = entry.Substring(1, indexParentheseFermente - 1);
            string betweenAvecPar = entry.Substring(0, indexParentheseFermente + 1);


            //calcul la partie entre parenthèse
            List <WarGearCombination> confDroite = new GlobalNode().Evaluate(new List <WarGearCombination>(), between);

            List <WarGearCombination> newconf = new List <WarGearCombination>();

            foreach (WarGearCombination conf in confDroite)
            {
                string precalcul = entry.Replace(betweenAvecPar, "");
                if (precalcul.Length > 0)
                {
                    List <WarGearCombination> lc = new List <WarGearCombination>();
                    lc.Add(conf.Copy());
                    newconf.AddRange(new GlobalNode().Evaluate(lc, precalcul));
                }
                else
                {
                    newconf.Add(conf);
                }
            }

            return(newconf);
        }
コード例 #4
0
        public override List <WarGearCombination> Evaluate(List <WarGearCombination> configs, string entry)
        {
            String right = entry.Substring(1);

            //On garde l'ancien sans modif
            List <WarGearCombination> newconf = new List <WarGearCombination>();

            newconf.Add(new WarGearCombination());

            //On ajoute la partie droite
            List <WarGearCombination> confDroite = new GlobalNode().Evaluate(configs, right);

            newconf.AddRange(confDroite);

            return(newconf);
        }