Example #1
0
        public Inventory(User owner)
        {
            //Tools.Print("{0}'s Inventory was constructed\n", owner);

            //store the owner of the instance
            this.owner = owner;

            //list of all the things in the users inventory
            this.items = new Dictionary<char, Item>();
        }
Example #2
0
        public Pet(User newMaster, string newName, char newGender = 'm')
        {
            this.master = newMaster;
            this.name = newName;
            this.gender = newGender;

            //assign components
            this.mood = new PetMoodComponent(this);
            this.food = new PetFoodComponent(this);
            this.battle = new PetBattleComponent(this);

            //Tools.Print("A new {1} lion was created, named {0}, belonging to {2}\n",
              //  this.name, this.getGender(), this.master.name);
            //constructor method
        }
Example #3
0
 public FeedAction(User master)
     : base(master)
 {
     //nothing happens
 }
Example #4
0
 public BattleAction(User master)
     : base(master)
 {
 }
Example #5
0
 public Action(User master)
 {
     this.master = master;
 }
Example #6
0
 public StatAction(User master)
     : base(master)
 {
     this.master = master;
 }
Example #7
0
        static void Main(string[] args)
        {
            //debugging stuff

            ////checking how c# passes vars
            //int orig = 100;
            //int first = orig;
            //orig++;
            //Tools.Print("Orig {0} and first {1}\n", new object[]{orig, first});

            //seeing if you can convert chars to ints and back
            //char val = 'A'; // c=99 so a=97? B=66 so A=65?
            //val++;
            //int newVal = (int)val;
            //char newest = (char)newVal;
            //Tools.Print(newVal.ToString()) ;

            //testing if `c` and `C` are the same, they aren't
            //string val;
            //if ('c' == 'c') {val = "t"; }
            //else {  val = "f"; }
            //Tools.Print(val);

            /*char qwe = 'a';
            qwe++;
            Console.WriteLine(qwe);*/

            //end debugging

            //Intro to the app
            Console.Title = Meta.name_ver;

            Console.BackgroundColor = defaultBG;
            Console.ForegroundColor = defaultFG;

            //Print intro line
            string welcomeString = "Welcome to the PET GAME version: {0}\n\n";
            string welcomeArg = Meta.ver;
            Tools.Print(ConsoleColor.Black, ConsoleColor.White, welcomeString, welcomeArg);

            //Creates User with a default name
            User user = new User();
            user.inventory.AddItem(new FoodFruit());
            user.inventory.AddItem(new FoodApple());
            //user.inventory.AddItem(new FoodApple());
            //user.inventory.AddItem(new FoodMeat());

            //Gets the name of the pet.
            //string name = Tools.Prompt("What is the name of your new male Pet?");
            string name = "YourFirstPet";
            Pet yourPet = new Pet(user, name);

            //Intro message
            Tools.Print(newFG: ConsoleColor.DarkBlue,
                        newBG: ConsoleColor.Cyan,
                        text: "\nThis is the main loop for the game. \n" +
                            "It is here that you'll feed or fight your" +
                            "\npet in order to train the shit out of it" +
                            "\n\n\n\t\tBEGIN!\n");

            //main loop
            while (true)
            {
                //give the user a choice of actions.
                string choices = "\t[f]eed, [b]attle, [t]hrow, [s]tats or [q]uit.";
                KeyValuePair<string, string> action = getUserAction(choices);

                //feed the pet
                if (action.Value == "feed")
                {
                    //this is  a real shitty way of doing this. There
                    // shouldn't be a class all on its own... :(
                    FeedAction feeding = new FeedAction(user);

                    user.inventory.ShowInventory();

                    string choice = Tools.Prompt("Choose a key from your items to feed");
                    char charChoice = (char)choice[0];

                    feeding.FeedPet(yourPet, user.inventory.items[charChoice] as FoodType);
                    //feeding.FeedPet(yourPet, new FoodMeat());
                }
                //check stats of the current pet
                else if (action.Value == "stats")
                {
                    StatAction stats = new StatAction(user);
                    stats.CheckPetStats(yourPet);
                }

                else if (action.Value == "throw")
                {
                    Tools.Print(newBG:ConsoleColor.DarkRed, text:"You throw your pet against the wall\n");

                    yourPet.battle.TakeDamage(10);
                }

                else if (action.Value == "battle")
                {
                    Creature enemy = new Creature();

                    BattleAction battle = new BattleAction(user);
                    battle.BattlePet(yourPet, enemy);
                }

                //quit the main loop
                else if (action.Value == "quit")
                {
                    break;
                }

                //Tools.Print(newFG: ConsoleColor.Yellow, text:"This was the action chosen: {0}\n", vals:action);

            }

            //Wait for Key on exit
            Tools.Print(ConsoleColor.DarkRed,
                    ConsoleColor.DarkYellow,
                    "Press any key to exit {0}",
                    Meta.name_ver);
            Console.ReadKey();
        }
Example #8
0
 /// <summary>
 /// Constructor, assigns a User to owner
 /// </summary>
 /// <param name="owner">the user who owns this pet</param>
 public PetStatusComponent(User owner)
 {
     this.owner = owner;
 }