public void actionDarthVader(JediKnight inst, string action = "")
 {
     switch (action)
     {
         case "encouragement":
             this.fightLog.FightEvents = new List<string>()
             {
                 Encouragement
             };
             break;
         case "chew":
             this.fightLog.FightEvents = new List<string>()
             {
                 Chew
             };
             break;
         default:
             break;
     }
 }
Esempio n. 2
0
 public void SaveLuke(JediKnight inst)
 {
     //Reset the damage level
     inst.currentDamageLevel = JediKnight.DamageLevel.Healthy;
 }
Esempio n. 3
0
        // attack another jedi knight with the help of magic random numbers
        public void AttackEnemy(JediKnight jediKnight, JediKnight opponent)
        {
            try
            {
                // set up an attack using a standard lightsaber action, registering opponent's resulting damage level, and slandering him
                if (opponent.currentDamageLevel == DamageLevel.Wasted)
                {
                    // He's already finito.. see if we can make him join the game again!
                    jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " takes a poke trying to off " + opponent.Name + " who is already at the Rigor Mortis stage. Tsk, tsk.. a bit necro-phixated, are we?");
                    // Rescusiate..
                    jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " gets all squishy-feely at seeing " + opponent.Name + " so horribly pale, and takes him - ok, drags him.. along to the Jawa sandcrawler for recycling.");
                    opponent.currentDamageLevel = DamageLevel.Critical;
                    opponent.Deceased = false;
                    jediKnight.fightLog.FightEvents.Add(opponent.Name + " didn't bring in much of a recycle fee for " + jediKnight.Name + " - but the Jawas were real nice. Our hero was kicked out in the desert again alive, minus only a few insignificant internal body parts and sporting a damage level of: "
                            + opponent.currentDamageLevel);
                }
                else
                {
                    RandomGenerator ranGen = new Helpers.RandomGenerator();
                    int randomInt = ranGen.RandomInteger(10);
                    // record which lightsaber maneouver was randomly chosen
                    currentLightSaberAction = (LightSaberAction)randomInt;
                    jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " attacks " + opponent.Name
                                             + " by deftly applying the Light Saber Academy approved maneouver "
                                             + currentLightSaberAction);

                    // Make a stab using the current DamageLevel cast to an int. Record which new damage level resulted from the attack.
                    System.Threading.Thread.Sleep(500); // skip a heartbeat here, so we get a new random seed number
                    randomInt = ranGen.RandomInteger((int)(opponent.currentDamageLevel));
                    // Series of if statements, to determine which damage level is closest to the generated number
                    if (randomInt >= 50)
                        opponent.currentDamageLevel = DamageLevel.Healthy;
                    else if (randomInt < 50 && randomInt > 25)
                        opponent.currentDamageLevel = DamageLevel.Challenged;
                    else if (randomInt <= 25 && randomInt > 10)
                        opponent.currentDamageLevel = DamageLevel.Critical;
                    else // less than or equal to 10, we's long gone dude
                    {
                        opponent.currentDamageLevel = DamageLevel.Wasted;
                        opponent.Deceased = true;
                    }

                    jediKnight.fightLog.FightEvents.Add(opponent.Name + " now has a damage level of: " + opponent.currentDamageLevel + " based on a randomInt of " + randomInt);

                    // Pick a random slander expression for posterity, except if he is dead as a result of that last attack of yours.
                    if (opponent.currentDamageLevel > DamageLevel.Wasted)
                    {
                        randomInt = ranGen.RandomInteger(enemySlanders.Length, 0);
                        string slander = enemySlanders[randomInt];
                        jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " says: " + slander);
                    }
                    else if (opponent.currentDamageLevel == DamageLevel.Wasted)
                    {
                        jediKnight.fightLog.FightEvents.Add(opponent.Name + " hoarsely whispers: " + opponent.LastWords);
                        jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " says: Rest in pieces, " + opponent.Name + ".");
                        jediKnight.fightLog.FightEvents.Add(opponent.Name + " has bought the big farm in the sky.");
                    }
                }
            }
            catch (Exception e)
            {
                // TODO: log the exception
                string msg = e.Message;
            }
        }
        public JediKnight PickJediKnight(List<JediKnight> JediKnights, int randomInt)
        {
            //Log actions
            Logging logTxt = new Helpers.Logging();

            if (this.lastPickedJedi != JediKnights[randomInt])
            {
                this.lastPickedJedi = JediKnights[randomInt];
                logTxt.Main("There's a new Jedi Knight for you");
                return this.lastPickedJedi;
            }
            else
            {
               // logTxt.Main("So sad, random number generator is not working properly");
                return null;
            }
        }
Esempio n. 5
0
        // attack another jedi knight with the help of magic random numbers       
        public void AttackEnemy(JediKnight jediKnight, JediKnight opponent)
        {
            try
            {

                //MailMessage mail = new MailMessage();
                //mail.To.Add("*****@*****.**");
                //mail.From = new MailAddress("*****@*****.**");
                //mail.Subject = "Email using Gmail form our game";

                //string Body = "Hi, this mail is to test sending mail" +
                //            "using Gmail in ASP.NET";
                //mail.Body = Body;

                //mail.IsBodyHtml = true;
                //SmtpClient smtp = new SmtpClient("smtp.gmail.com", 465);
                //smtp.EnableSsl = true;
                //smtp.Credentials = new System.Net.NetworkCredential("email", "pass");
                //smtp.Send(mail);

                // set up an attack using a standard lightsaber action, registering opponent's resulting damage level, and slandering him                
                if (opponent.currentDamageLevel == DamageLevel.Wasted)
                {   
                    // He's already finito.. see if we can make him join the game again!
                    jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " takes a poke trying to off " + opponent.Name + " who is already at the Rigor Mortis stage. Tsk, tsk.. a bit necro-phixated, are we?");
                    // Rescusiate..
                    jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " gets all squishy-feely at seeing " + opponent.Name + " so horribly pale, and takes him - ok, drags him.. along to the Jawa sandcrawler for recycling.");
                    opponent.currentDamageLevel = DamageLevel.Critical;
                    opponent.Deceased = false;
                    jediKnight.fightLog.FightEvents.Add(opponent.Name + " didn't bring in much of a recycle fee for " + jediKnight.Name + " - but the Jawas were real nice. Our hero was kicked out in the desert again alive, minus only a few insignificant internal body parts and sporting a damage level of: "
                            + opponent.currentDamageLevel);
                }
                else
                {
                    //Get the instance of the log class
                    Logging logTxt = new Helpers.Logging();

                    RandomGenerator ranGen = new Helpers.RandomGenerator();
                    int randomInt = ranGen.RandomInteger(10);
                    // record which lightsaber maneouver was randomly chosen
                    currentLightSaberAction = (LightSaberAction)randomInt;
                    jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " attacks " + opponent.Name
                                             + " by deftly applying the Light Saber Academy approved maneouver "
                                             + currentLightSaberAction);

                    if (currentLightSaberAction == LightSaberAction.Pierce_Enemy_Chest)
                    {
                        jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " scored a hole-in " + opponent.Name
                                             + " by Piercing the Enemy Chest");

                        opponent.currentDamageLevel = DamageLevel.Wasted;

                        //Log action in the log file
                        logTxt.Main(jediKnight.Name + " killed " + opponent.Name + " by Piercing his chest");
                    }

                    // Make a stab using the current DamageLevel cast to an int. Record which new damage level resulted from the attack.
                    System.Threading.Thread.Sleep(1000); // skip a heartbeat here, so we get a new random seed number
                    randomInt = ranGen.RandomInteger((int)(opponent.currentDamageLevel));

                    logTxt.Main("Jedi Knight random health level is: " + randomInt);

                    // Series of if statements, to determine which damage level is closest to the generated number
                    if (randomInt >= 50)
                        opponent.currentDamageLevel = DamageLevel.Healthy;
                    else if (randomInt < 50 && randomInt > 25)
                        opponent.currentDamageLevel = DamageLevel.Challenged;
                    else if (randomInt <= 25 && randomInt > 10)
                        opponent.currentDamageLevel = DamageLevel.Critical;
                    else // less than or equal to 10, we's long gone dude
                    {
                        opponent.currentDamageLevel = DamageLevel.Wasted;
                        opponent.Deceased = true;
                        jediKnight.numOfDeaths++;
                    }

                    jediKnight.fightLog.FightEvents.Add(opponent.Name + " now has a damage level of: " + opponent.currentDamageLevel + " based on a randomInt of " + randomInt);

                    // Pick a random slander expression for posterity, except if he is dead as a result of that last attack of yours.
                    if (opponent.currentDamageLevel > DamageLevel.Wasted)
                    {
                        randomInt = ranGen.RandomInteger(enemySlanders.Length - 1);
                        string slander = enemySlanders[randomInt];
                        jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " says: " + slander);
                        
                    }
                    else if (opponent.currentDamageLevel == DamageLevel.Wasted)
                    {
                        if (opponent.Name == "Luke Skywalker")
                        {
                            Obi_Wan ObiWan = new Obi_Wan();
                            jediKnight.fightLog.FightEvents.Add(ObiWan.Encouragement);
                            jediKnight.fightLog.FightEvents.Add(ObiWan.Dismay);
                            ObiWan.SaveLuke(opponent);
                            logTxt.Main("Obi-Wan helps Luke Skywalker regain his health");
                            jediKnight.fightLog.FightEvents.Add(opponent.Name + " now has a damage level of: " + opponent.currentDamageLevel);
                        }
                        else
                        {
                            jediKnight.fightLog.FightEvents.Add(opponent.Name + " hoarsely whispers: " + opponent.LastWords);
                            jediKnight.fightLog.FightEvents.Add(jediKnight.Name + " says: Rest in pieces, " + opponent.Name + ".");
                            jediKnight.fightLog.FightEvents.Add(opponent.Name + " has bought the big farm in the sky.");
                        }
                        opponent.numOfDeaths++;
                        logTxt.Main(opponent.Name + " has died " + opponent.numOfDeaths + " times");
                        logTxt.Main(jediKnight.Name + " has died " + jediKnight.numOfDeaths + " times");
                    }

                }
            }
            catch (Exception e)
            {
                // TODO: log the exception
                string msg = e.Message;
            }
        }