Example #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            SpecialCondition specialCondition = db.SpecialCondition.Find(id);

            db.SpecialCondition.Remove(specialCondition);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "idSpecialCondition,SpecialCondition1")] SpecialCondition specialCondition)
 {
     if (ModelState.IsValid)
     {
         db.Entry(specialCondition).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(specialCondition));
 }
    /// <summary>
    /// Sets a special condition.
    /// </summary>
    /// <param name="condition">Condition.</param>
    public void SetSpecialCondition(SpecialCondition condition)
    {
        switch (condition)
        {
        case SpecialCondition.isAlsoGoal:
            isAlsoGoal = true;
            break;

        default:
            break;
        }
    }
Example #4
0
        public ActionResult Create([Bind(Include = "idSpecialCondition,SpecialCondition1")] SpecialCondition specialCondition)
        {
            if (ModelState.IsValid)
            {
                specialCondition.idSpecialCondition = Guid.NewGuid();
                db.SpecialCondition.Add(specialCondition);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(specialCondition));
        }
        public ProductionRule(string line)
        {
            string[] ruleAndConditions = line.Trim().Split('&');

            //Parse the production rule
            string[] ruleParts = ruleAndConditions[0].Trim().Split(' ');

            Probability = Convert.ToDouble(ruleParts[0]);
            LHS         = new Symbol()
            {
                Type = SymbolType.Nonterminal, Text = ruleParts[1].Trim()
            };

            List <Symbol> rhs = new List <Symbol>();

            for (int i = 3; i < ruleParts.Length; i++)
            {
                Symbol newSymbol;

                ruleParts[i] = ruleParts[i].Trim();

                if (ruleParts[i].StartsWith(@"'"))
                {
                    newSymbol = new Symbol()
                    {
                        Type = SymbolType.Terminal, Text = ruleParts[i].Replace('\'', ' ').Trim()
                    }
                }
                ;
                else
                {
                    newSymbol = new Symbol()
                    {
                        Type = SymbolType.Nonterminal, Text = ruleParts[i]
                    }
                };

                rhs.Add(newSymbol);
            }

            RHS = rhs.ToArray();

            //Parse the special conditions
            if (ruleAndConditions.Length > 1)
            {
                Conditions = SpecialCondition.ParseConditions(ruleAndConditions[1]);
            }
            else
            {
                Conditions = new SpecialCondition[0];
            }
        }
Example #6
0
        // GET: SpecialConditions/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SpecialCondition specialCondition = db.SpecialCondition.Find(id);

            if (specialCondition == null)
            {
                return(HttpNotFound());
            }
            return(View(specialCondition));
        }
Example #7
0
        /// <summary>
        /// Tries to find a special condition in the effect description
        /// </summary>
        /// <param name="line"></param>
        private void ParseSpecialEffect(string line)
        {
            SpecialCondition specialCondition = SpecialCondition.None;

            line = NormalizeLine(line, InvalidWords, RegexReplacementMatches);

            if (_regexAffectedStat.IsMatch(line))
            {
                if (Enum.TryParse(_regexAffectedStat.Match(line).Value, out specialCondition))
                {
                    Condition = specialCondition;
                }
                else
                {
                    throw new UnmatchedFoodEffectException(line, "SpecialEffect");
                }
            }
        }
Example #8
0
 public AppliedSpecialCondition(SpecialCondition specialCondition, int turnsRemaining)
 {
     SpecialCondition = specialCondition;
     TurnsRemaining = turnsRemaining;
 }
 public SetSpecialConditionOutgoingPacket(SpecialCondition specialCondition)
 {
     this.SpecialCondition = specialCondition;
 }