Esempio n. 1
0
        public EvilEmperor()
        {
            Name               = "Palpetine";
            Email              = "*****@*****.**";
            LightSaberColor    = "Kneeon";
            CurrentDamageLevel = DamageLevel.Healthy;
            Deceased           = false;
            DarkSide           = false;

            FightLog             = new AttackRecorder();
            FightLog.FightEvents = new List <string>()
            {
                Name + " Zoom Zoom!",
            };

            LastWords = "i .... i done goofed";
        }
        public Obi_Wan()
        {
            Name               = "Obi-From-Chernobyl";
            Email              = "*****@*****.**";
            LightSaberColor    = "Skincolored";
            CurrentDamageLevel = DamageLevel.Healthy;
            Deceased           = false;
            DarkSide           = false;

            FightLog             = new AttackRecorder();
            FightLog.FightEvents = new List <string>()
            {
                Name + " pulls out his phone to google some fighting-tips.",
            };

            LastWords = "ggwp";
        }
        public Darth()
        {
            Name                 = "Darth Vader";
            Email                = "*****@*****.**";
            LightSaberColor      = "Red";
            CurrentDamageLevel   = DamageLevel.Healthy;
            DarkSide             = true;
            Deceased             = false;
            FightLog             = new AttackRecorder();
            FightLog.FightEvents = new List <string>()
            {
                Name + " loosens his tie, or rather, what he *thinks* is his tie. And no, you don't want to know any more.",
                Name + " unstraps his lightsaber. It's red!",
                Name + " quotes Caesar: 'Jacta Alea Est', dude! Come get some, Luke..",
                Name + " expels a horribly dry laugh from his asthmatic lungs and sneers at Luke."
            };

            LastWords = "Aaaaargh, I thought that little bugger was on top of the generator!";
        }
        public Luke()
        {
            Name                 = "Luke Skywalker";
            Email                = "*****@*****.**";
            LightSaberColor      = "Blue";
            CurrentDamageLevel   = DamageLevel.Healthy;
            DarkSide             = false;
            Deceased             = false;
            FightLog             = new AttackRecorder();
            FightLog.FightEvents = new List <string>()
            {
                Name + " loosens his tie and straps on Leia's bra for verisimilitude.",
                Name + " unstraps his lightsaber. It's blue!",
                Name + " looks at his Dad and quotes Groucho Marx: 'I have a mind to join a club and beat you over the head with it.'",
                Name + " privately thinks of joining a different club altogether. Preferably one in a galaxy far, far away.."
            };

            LastWords = "Aaaaargh, I never thought to take out life insurance! How pathetic of me in this cruel, cruel world.";
        }
        public ViewResult RecruitForm(ThePlayer newWarrior)
        {
            // check user input
            if (ModelState.IsValid)
            {
                // Set up a game log of Fight Events
                AttackRecorder gameLog = new AttackRecorder();

                gameLog.FightEvents = new List <string>()
                {
                    "..the game log was the only book in town that the Evil Emperor wanted to read."
                };

                // Set up a Jedi Warrior object - using the data entered in the form
                ThePlayer myWarrior = new ThePlayer();
                myWarrior.Name  = newWarrior.Name;
                myWarrior.Email = newWarrior.Email;

                ThePlayer.playerMail = myWarrior.Email;

                myWarrior.LightSaberColor    = newWarrior.LightSaberColor;
                myWarrior.CurrentDamageLevel = JediKnight.DamageLevel.Healthy;
                myWarrior.DarkSide           = newWarrior.DarkSide;
                myWarrior.Deceased           = false;
                myWarrior.FightLog           = new AttackRecorder();

                // Init the personal fight log
                myWarrior.FightLog.FightEvents = new List <string>()
                {
                    myWarrior.Name + " loosens his tie",
                    myWarrior.Name + " unstraps his lightsaber and admires it's wonderfully " + myWarrior.LightSaberColor + " sheen.",
                    myWarrior.Name + " quotes Caesar: 'Jacta Alea Est', dude!",
                    myWarrior.Name + " shuffles his feet and looks a bit shyly at the other guys.. quite imposing figures, actually.."
                };
                // start up first knight in game log
                gameLog.FightEvents.AddRange(myWarrior.FightLog.FightEvents);

                // Set up some more Jedi objects
                Darth DarthV = new Darth();
                // start up second knight in game log
                gameLog.FightEvents.AddRange(DarthV.FightLog.FightEvents);

                Luke LukeS = new Luke();
                // start up third knight in game log
                gameLog.FightEvents.AddRange(LukeS.FightLog.FightEvents);

                Obi_Wan obiWan = new Obi_Wan();
                // start up fourth knejt' in game log

                EvilEmperor evilEmperor = new EvilEmperor();
                // let the 'pror get in on the log

                List <JediKnight> myJedis = new List <JediKnight>();
                myJedis.Add(myWarrior);
                myJedis.Add(DarthV);
                myJedis.Add(LukeS);



                // Now, let's run a battle scenario umpteen times over, based on the logic in the model for each Knight.
                // That ought to be enough to kill one of our protagonists outright a few times over..
                for (int i = 1; i < 18; i++)
                {
                    // Pick a random Jedi Knight to kick into action courtesy of our Helper class
                    int        randomInt = RandomGenerator.Rand.Next(0, myJedis.Count);
                    JediKnight warrior   = myJedis[randomInt];
                    // Empty the individual fight log before next batch recording of events
                    warrior.FightLog.FightEvents.Clear();
                    warrior.FightLog.FightEvents.Add("The Evil Emperor randomly points a bony finger at " + warrior.Name + " and says: 'do some nasty work for me - now!'");

                    //boost the darkside!
                    evilEmperor.DarkSideBoost(myJedis);

                    //saveLuke
                    if (LukeS.CurrentDamageLevel < JediKnight.DamageLevel.Challenged)
                    {
                        obiWan.SaveLuke(LukeS);
                    }

                    //saveLuke(again) and add obiWan to the battle
                    if (LukeS.CurrentDamageLevel <= JediKnight.DamageLevel.Critical && myJedis.Contains(obiWan) == false)
                    {
                        myJedis.Add(obiWan);
                        warrior.FightLog.FightEvents.Add(obiWan.Name + " has joined the battle ck. ");
                        obiWan.SecondWind(LukeS);
                    }

                    //saveDarth and add Palpetine to the battle
                    if (DarthV.CurrentDamageLevel <= JediKnight.DamageLevel.Critical && myJedis.Contains(evilEmperor) == false)
                    {
                        myJedis.Add(evilEmperor);
                        warrior.FightLog.FightEvents.Add(evilEmperor.Name + " has joined the battle mk. ");
                        evilEmperor.SecondWind(DarthV);
                    }

                    // Attack opponents, but only if they are on the opposing side, and only if you aren't dead yourself..yet.
                    switch (warrior.Name)
                    {
                    case "Darth Vader":
                        if (!warrior.Deceased)
                        {
                            warrior.AttackEnemy(warrior, LukeS);
                            if (myWarrior.DarkSide == false)
                            {
                                warrior.AttackEnemy(warrior, myWarrior);
                            }
                        }
                        else     // this happens if the Emperor points a bony finger at a dead Jedi Knight
                        {
                            //increment number of deaths
                            warrior.numOfDeaths++;

                            warrior.FightLog.FightEvents.Add(warrior.Name + " unfortunately feels a bit out of it right now, and is rather actively knockin' on the Force's Door.");
                            // Darth is a mean ole bean, so we'll re-life him with a lousy medicare allowance of 'Hurting'
                            warrior.Deceased           = false;
                            warrior.CurrentDamageLevel = JediKnight.DamageLevel.Hurting;
                            warrior.FightLog.FightEvents.Add("Wow, that door-mojo worked... " + warrior.Name + " is in a rather hurt condition, but still bouncing back for some mean ole revenge!");
                        }
                        // add player fight events to game log
                        gameLog.FightEvents.AddRange(warrior.FightLog.FightEvents);
                        break;

                    case "Luke Skywalker":
                        if (!warrior.Deceased)
                        {
                            warrior.AttackEnemy(warrior, DarthV);
                            if (myWarrior.DarkSide == true)
                            {
                                warrior.AttackEnemy(warrior, myWarrior);
                            }
                        }
                        else
                        {
                            //increment number of deaths
                            warrior.numOfDeaths++;

                            warrior.FightLog.FightEvents.Add(warrior.Name + " unfortunately feels a bit out of it right now, and is feebly knockin' on the Force's Door, in a Lukey way.");
                            // give Luke an advantage when killed, by rescusiating him and by setting his health to max
                            warrior.Deceased           = false;
                            warrior.CurrentDamageLevel = JediKnight.DamageLevel.Healthy;
                            warrior.FightLog.FightEvents.Add(warrior.Name + " apparently has mucho clout with the Force's Door and is now bouncing back for some swashbuckling revenge!");
                        }
                        // add player fight events to game log
                        gameLog.FightEvents.AddRange(warrior.FightLog.FightEvents);
                        break;

                    // default case will be our guy on the dance floor wanting a serious piece of the action
                    default:
                        if (!warrior.Deceased)
                        {
                            if (warrior.DarkSide == false)
                            {
                                warrior.AttackEnemy(warrior, DarthV);
                            }
                            if (warrior.DarkSide == true)
                            {
                                warrior.AttackEnemy(warrior, LukeS);
                            }
                        }
                        else
                        {
                            warrior.FightLog.FightEvents.Add(warrior.Name + " unfortunately feels a bit out of it right now, and is knockin' on the Force's Door.");
                            warrior.Deceased           = false;
                            warrior.CurrentDamageLevel = JediKnight.DamageLevel.Challenged;
                            warrior.FightLog.FightEvents.Add(warrior.Name + " apparently has some clout with the Force's Door and is now bent on some challenged-level revenge!");
                        }
                        // add player fight events to game log
                        gameLog.FightEvents.AddRange(warrior.FightLog.FightEvents);
                        break;
                    }
                }

                // Conclude fight at this point - check who's still vital, and do the victory roll
                foreach (JediKnight warrior in myJedis)
                {
                    if (!warrior.Deceased)
                    {
                        gameLog.FightEvents.Add("Ho ho ho! " + warrior.Name + "'s still around, with a rude health of: " + warrior.CurrentDamageLevel);
                    }
                    else
                    {
                        gameLog.FightEvents.Add("Awww, " + warrior.Name + " is sleeping with the fishes!");
                    }
                }

                //output number of deaths
                gameLog.FightEvents.Add("\n## Death Statistics ##");
                foreach (JediKnight warrior in myJedis)
                {
                    gameLog.FightEvents.Add(warrior.Name + " has died " + warrior.numOfDeaths + " time(s).");
                }

                // Set up viewbag list of event strings
                ViewBag.FightDescription = new List <string> {
                    "A long time ago in a galaxy far, far away...."
                };


                // put the game log contents into the ViewBag
                foreach (string FightEvent in gameLog.FightEvents)
                {
                    ViewBag.FightDescription.Add(FightEvent);

                    //errorlog
                    //if (FightEvent.Contains("points"))
                    //{
                    //    ErrorLogger.SaveMsg(FightEvent);
                    //}
                }

                //MailMethod
                foreach (string FightEvent in gameLog.FightEvents)
                {
                    EmailSender.MailThis.Add(FightEvent);
                }

                return(View("Jedi_Vs_Sith", myWarrior));
            }
            else
            {
                // validation error - redisplay form with error messages
                return(View());
            }
        }