Exemple #1
0
        /// Create places and their interconnections by taking place names, exit
        /// data and descriptions from a text file.
        /// Return a map of place names to places.  File format for each place:
        ///   First line:  place name (one word)
        ///   Second line: pairs of exit direction and neighbor place name
        ///   Remaining paragraph: place description, blank line terminated
        public static Dictionary <string, Place> CreatePlaces(string fileName)
        {
            var reader = Fio.OpenReader(fileName);
            // Map to return
            var places = new Dictionary <string, Place> ();

            // temporary Map to delay recording exits until all places exist
            var exitStrings = new Dictionary <string, string> ();

            while (!reader.EndOfStream)
            {
                var name      = reader.ReadLine();
                var exitPairs = reader.ReadLine();
                // You could also substitute your lab's ReadParagraph for the two
                //   lines below if you want to format each paragraph line yourself.
                var description = TextUtil.LineWrap(reader);
                reader.ReadLine(); // assume empty line after description
                places [name]      = new Place(description);
                exitStrings [name] = exitPairs;
            }
            reader.Close();
            // need places before you can map exits
            // go back and use exitPairs to map exits:
            foreach (var name in places.Keys)
            {
                var place = places [name];
                var parts = TextUtil.SplitWhite(exitStrings[name]);
                for (var i = 0; i < parts.Length; i += 2)
                {
                    place.SetExit(parts [i], places [parts [i + 1]]);
                }
            }
            return(places);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            //Initializes basic global variables by either just defining or
            //Reading in the info from files

            GlobalVar.NumbWins = 0;

            var reader = Fio.OpenReader("Text Documents/Move_List.txt");

            GlobalVar.MoveDir = Reader.GetDictionary(reader);
            reader.Close();

            var pokeReader = Fio.OpenReader("Text Documents/Pokemon_List.txt");
            var pokeDir    = Reader.GetDictionary(pokeReader);

            pokeReader.Close();

            //2 seperate lists are needed so that if both players have the same pokemon it would be a copy and not
            //the EXACT same pokemon
            GlobalVar.PokeList  = Reader.MakePokemonList(pokeDir);
            GlobalVar.PokeList2 = Reader.MakePokemonList(pokeDir);


            Console.ForegroundColor = ConsoleColor.Black;

            //Once variables are defined then the game begins!
            var game = new Game();

            game.Play();
            Console.ResetColor();
        }