You are viewing our Forum Archives. To view or take place in current topics click here.
Creating a Text based Adventure, need help debugging.
Posted:

Creating a Text based Adventure, need help debugging.Posted:

-Rossi
  • Junior Member
Status: Offline
Joined: Jun 21, 201212Year Member
Posts: 64
Reputation Power: 2
Status: Offline
Joined: Jun 21, 201212Year Member
Posts: 64
Reputation Power: 2
Hey, I'm creating a Hunger Games text based adventure game, and need help squashing a bug or two...
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HungerGamesADVENTURE1
{
    public struct Player
    {
        public string Name;
        public int District;
        public int Attack;
        public int Defence;
        public int Health;
        public int Level;
        public Player(int district, string name, int attack, int defence, int health, int level)
        {
            Name = name;
            District = district;
            Attack = attack;
            Defence = defence;
            Health = health;
            Level = level;
        }
    }

    public struct Monster
    {
         
     
        public string MobName;
        public int Attack;
        public int Defence;
        public int Health;
        public int Level;
        public Monster(string name, int attack, int defence, int health, int level)
        {
            MobName = name;
            Attack = attack;
            Defence = defence;
            Health = health;
            Level = level;
        }
    }

    class Program
    {   
        public Monster wolf = new Monster("Wolf", 20, 10, 35, 5);
        public Monster trackerj = new Monster("Tracker Jacker", 10, 5, 15, 0);
        public Monster tiger = new Monster("Tiger", 35, 20, 50, 10);
        public Monster cat = new Monster("Angered Cat", 15, 5, 20, 0);
        public Monster ape = new Monster("Defensive Capuchin", 5, 20, 30, 5);
        public Monster human = new Monster("Crazy old guy", 30, 20, 50, 10);
        static void Main(string[] args)
        {
           

            Header();
       
            Console.WriteLine("Hello, what would you like to name your character?");
            string playerName = Console.ReadLine();


            Console.WriteLine("Okay, {0}, what district are you from?", playerName);
            string input = Console.ReadLine();
            int playerDistrict;
            while (true)
            {
                if (int.TryParse(input, out playerDistrict))
                {
                   
                    while (true)
                    {
                        playerDistrict = int.Parse(input);
                        if (playerDistrict > 13)
                        {
                            Console.WriteLine("There are only 13 districts in Panem!");
                           
                        }
                        else if (playerDistrict < 1)
                        {
                            Console.WriteLine("Your district cannot be '0' or a negative number!");
                        }
                        else
                        {
                            break;
                        }
                       
                    }
               
                break;
                }
                else
                {
                    Console.WriteLine("Your district must be a number");
                    Console.ReadLine();

                }
 
           

                   Player p = new Player(int.Parse(input), playerName, 20, 15, 40, 0);
                Console.WriteLine("Well, {0} from {1}, it seems we are ready to go!", p.Name, p.District);
                Console.WriteLine("Would you like to play the 'Adventure' or 'MonsterBattles'?");
                input = Console.ReadLine();
                if (input == "Adventure")
                {
                    Console.WriteLine("We will be shortly heading on an adventure with you, {0}", p.Name);
                }
                else if (input == "MonsterBattles")
                {
                    Console.WriteLine("Let's go fight some monsters, {0}!", p.Name);
                    monsterBattle(p);
                }

                Console.ReadLine();
            }
        }

        static void monsterBattle(Player p)
        {

             Console.Clear();
             Header2();
             Console.WriteLine("Welcome to the battle arena. Here you will fight random monsters. Good luck, {0}!", p.Name);
             Console.WriteLine("When you are ready, press any key and you will enter the arena.");
             Console.ReadKey();
             Console.WriteLine(" ");
             Console.WriteLine(ConsoleColor.DarkRed + " {0} enters the arena...", p.Name);
             if (p.Level > 2)
             {
                 Random r = new Random();
                 int rnd = r.Next(10);
                 if (rnd > 5)
                 {
                   //  battle();
                 }
             }
               
        }

        static void battle(Monster args)
        {
           
        }

     

        static void helpMenu()
        {

        }

        static void Header()
        {
            Console.WriteLine("=========================================================");
            Console.WriteLine("= Welcome to the Hunger Games Adventures - A text based =");
            Console.WriteLine("= ======== adventure game created by RossCoombs ======= =");
            Console.WriteLine("= === If you need help at any time during the game, === =");
            Console.WriteLine("= ===================  type 'help' ==================== =");
            Console.WriteLine("=========================================================");
            Console.WriteLine(" ");
            Console.WriteLine(" ");
            Console.WriteLine(" ");
        }

        static void Header2()
        {
            Console.WriteLine("================================================================");
            Console.WriteLine("= You are playing 'The Hunger Games Adventures' - A text based =");
            Console.WriteLine("= =========== adventure game created by RossCoombs =========== =");
            Console.WriteLine("=  If you need help at any time during the game, type 'help'!  =");
            Console.WriteLine("================================================================");
            Console.WriteLine(" ");
            Console.WriteLine(" ");
            Console.WriteLine(" ");
        }
    }
}


The issue is that after you reply what district you're from, it breaks completely. I'm also in need of a way of specifying a monster to battle with. It's going to be based on the users level, and then it's going to randomize between the possible outcomes. I just can't seem to give the battle function the player AND monsters.

If you can help, thank you very much!
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.