Ejemplo n.º 1
0
        //evaluates a damageformula string of the form "str + 2 * mag / eDef"
        public double Evaluate(String form, Unit att, Unit def)
        {
            statHolder = new Dictionary<String, int>();
            statHolder.Add("str", (int)(att.str * att.buffList[0]));
            statHolder.Add("mag", (int) (att.mag * att.buffList[1]));
            statHolder.Add("def", (int) (att.def * att.buffList[2]));
            statHolder.Add("fth", (int)(att.fth * att.buffList[3]));
            statHolder.Add("ski", (int)(att.ski * att.buffList[4]));
            statHolder.Add("eva", (int)(att.eva * att.buffList[5]));
            statHolder.Add("luck", (int)(att.luck * att.buffList[6]));
            statHolder.Add("spd", (int)(att.spd * att.buffList[7]));

            statHolder.Add("eStr", (int)(def.str * def.buffList[0]));
            statHolder.Add("eMag", (int)(def.mag * def.buffList[1]));
            statHolder.Add("eDef", (int)(def.def * def.buffList[2]));
            statHolder.Add("eFth", (int)(def.fth * def.buffList[3]));
            statHolder.Add("eSki", (int)(def.ski * def.buffList[4]));
            statHolder.Add("eEva", (int)(def.eva * def.buffList[5]));
            statHolder.Add("eLuck", (int)(def.luck * def.buffList[6]));
            statHolder.Add("eSpd", (int)(def.spd * def.buffList[7]));

            double total;
            try
            {
                total = (double)statHolder[form.Substring(0, form.IndexOf(" "))];
            }
            catch
            {
                total = Convert.ToDouble(form.Substring(0, form.IndexOf(" ")));
            }
            double placeHolder;
            form = form.Substring(form.IndexOf(" ")+1) + " ";

            while (!(form.Equals("")))
            {

                try
                {
                    placeHolder = (double) statHolder[form.Substring(2, form.Substring(2).IndexOf(" "))];
                }
                catch
                {

                    placeHolder =  Convert.ToDouble(form.Substring(2, form.Substring(2).IndexOf(" ")));

                }
                if (form.Substring(0, 1).Equals("+")) total += placeHolder ;
                if (form.Substring(0, 1).Equals("-")) total -= placeHolder;
                if (form.Substring(0, 1).Equals("*")) total *= placeHolder;
                if (form.Substring(0, 1).Equals("/")) total /= placeHolder;

                form = form.Substring(form.Substring(2).IndexOf(" ") + 3);

            }

            return total;
        }
Ejemplo n.º 2
0
 public double Evaluate(String form, Unit supp)
 {
     Char dummy = new Char();
     return Evaluate(form, supp, dummy);
 }
Ejemplo n.º 3
0
 //sets the distance of the current unit with an enemy unit
 protected void setDistance(Unit un, int newDist)
 {
     if ((curUnit.affil == 1) || (curUnit.affil == -1 && un.affil != 1))
     {
         DistGrid[curUnit.number][un.number] = newDist;
     }
     else
     {
         DistGrid[un.number][curUnit.number] = newDist;
     }
 }
Ejemplo n.º 4
0
 protected void Retreat(Unit un)
 {
     if (getDistance(un) != 5) setDistance(un, getDistance(un) + 1);
 }
Ejemplo n.º 5
0
 //for some reason I decided to only make this for the current unit...Might be better to make it for any two
 protected int getDistance(Unit un)
 {
     if ((curUnit.affil == 1)||(curUnit.affil == -1 && un.affil != 1))
     {
         return DistGrid[curUnit.number][un.number];
     }
     else
     {
         return DistGrid[un.number][curUnit.number];
     }
 }
Ejemplo n.º 6
0
 protected void Advance(Unit un)
 {
     if (getDistance(un) != 1) setDistance(un, getDistance(un) - 1);
 }
Ejemplo n.º 7
0
        public void TurnStart()
        {
            phase = Phase.TurnStart;
            curUnit = AllUnits[0];
            //for now, skip monster units
            eneList.Clear();
            if (curUnit.affil == 1)
            {
                eneList.AddRange(P2Chars);
                eneList.AddRange(Mons);

            }
            else if (curUnit.affil == 2)
            {
                eneList.AddRange(P1Chars);
                eneList.AddRange(Mons);
            }
            else
            {
                eneList.AddRange(P1Chars);
                eneList.AddRange(P2Chars);
            }
        }