Exemplo n.º 1
0
 void FunctionDefinition()
 {
     funcBuilder = FunctionBuilder.Start();
     FunctionName();
     ParameterDeclarationList();
     funcBuilder.WithParameters(parameterDeclarationListBuilder.Build());
     Expect(10);
     ExpressionList();
     Expect(6);
 }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            #region Start
            Console.ForegroundColor = ConsoleColor.White;       // The text will be White.
            ListBuilder.Build();                                // On load we need to call the ListBuilder to build all our List
            WelcomeScreen welcome = new WelcomeScreen();        // Create a new welcome screen
            welcome.Welcome();                                  // Call that screen.


            Console.WriteLine("Type 'Help' to see a list of commands");
            Console.WriteLine("");

            //Run timer every 5 minutes (300,000 millisec's) for autosave feature
            System.Timers.Timer autoSave = new System.Timers.Timer();
            autoSave.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            autoSave.Interval = 300000;
            autoSave.Enabled  = true;
            #endregion

            CurrentLocationClass.DisplayCurrentLocation();
            Console.WriteLine("");

            #region While loop
            // Infinite loop, until the user types "exit"
            while (true)
            {
                // Display a prompt, so the user knows to type something
                Console.Write(Player._player.CurrentHitPoints + "/" + Player._player.MaxHitPoints + " Hp" + " >");

                // Wait for the user to type something, and press the <Enter> key
                string userInput = Console.ReadLine();

                // If they typed a blank line, loop back and wait for input again
                if (string.IsNullOrWhiteSpace(userInput))
                {
                    continue;
                }

                // Convert to lower-case, to make comparisons easier
                string cleanedInput = userInput.ToLower();

                // Save the current game data, and break out of the "while(true)" loop
                if (cleanedInput == "exit")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Saving character, will close when finished!");
                    SaveData.SaveGameData(Player._player);
                    break;
                }

                // If the user typed something, try to determine what to do
                ParseInput(cleanedInput);
            }
        }
Exemplo n.º 3
0
        public void ShouldBeAbleToBuildAList()
        {
            IDeclaration <MyClass> declaration = Substitute.For <IDeclaration <MyClass> >();

            var builder = new ListBuilder <MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings());

            reflectionUtil.RequiresConstructorArgs(typeof(MyClass)).Returns(false);
            reflectionUtil.CreateInstanceOf <MyClass>().Returns(myClass);
            declaration.Construct();
            declaration.AddToMaster(Arg.Any <MyClass[]>());
            propertyNamer.SetValuesOfAllIn(Arg.Any <IList <MyClass> >());
            declaration.CallFunctions(Arg.Any <IList <MyClass> >());

            builder.Build();
        }
Exemplo n.º 4
0
        public void BuildTest()
        {
            // ウィンドウ幅いっぱい - 1 までは列を揃えて出力すること。
            // それを超えると空白1文字区切りで出力すること。
            var builder = new ListBuilder();

            builder.Add("abcdefg", -32000, -32000, 1, 1);
            builder.Add("あ", 1, -1, 1, 1);
            builder.Add("abcdefあ", -1, -32000, 1, 9999);

            var results = builder.Build(29).ToArray();

            Assert.AreEqual("abcdefg -32000 -32000 1    1", results[0]);
            Assert.AreEqual("あ           1     -1 1    1", results[1]);
            Assert.AreEqual("abcdefあ     -1 -32000 1 9999", results[2]);
        }
Exemplo n.º 5
0
        public void ShouldBeAbleToBuildAList()
        {
            IDeclaration <MyClass> declaration = MockRepository.GenerateMock <IDeclaration <MyClass> >();

            var builder = new ListBuilder <MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings());

            using (mocks.Record())
            {
                reflectionUtil.Stub(x => x.RequiresConstructorArgs(typeof(MyClass))).Return(false).Repeat.Any();
                reflectionUtil.Expect(x => x.CreateInstanceOf <MyClass>()).Return(myClass).Repeat.Any();
                declaration.Expect(x => x.Construct());
                declaration.Expect(x => x.AddToMaster(Arg <MyClass[]> .Is.TypeOf));
                propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg <IList <MyClass> > .Is.TypeOf));
                declaration.Expect(x => x.CallFunctions(Arg <IList <MyClass> > .Is.TypeOf)).IgnoreArguments();
            }

            using (mocks.Playback())
                builder.Build();
        }
Exemplo n.º 6
0
        private Player _player;                 // Create a player from the PLayer class

        /**
         * There are several things that need to happen when the interface is initialized.
         * First we need to populate all our list by calling a ListBuilder class method. Then
         * we need to build a new player and populate the labels with the player's stats
         */
        public JoshorInterface()
        {
            InitializeComponent();

            ListBuilder.Build();                                                                        // On load we need to call the ListBuilder to build all out List
            _player = new Player("Killakia", "Warrior", "Human", 100, 10, 10, World.Weapons[2], false); // Creating a player object

            /**
             * Displaying the players stats int the stat group
             */
            lblDisplayPlayerName.Text  = _player.playerName;
            lblDisplayPlayerRace.Text  = _player.playerRace;
            lblDisplayPlayerClass.Text = _player.playerClass;
            lblDisplayLvl.Text         = _player.lvl.ToString();
            lblDisplayGold.Text        = _player.gold.ToString();
            lblDisplayExp.Text         = _player.xp.ToString();
            lblDisplayAC.Text          = _player.ac.ToString();
            lblDisplayHP.Text          = _player.CurrentHitPoints.ToString();
            cboWeapons.Text            = _player.equipt.name.ToString();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var customType = typeof(User);

            IList customList = ListBuilder.Build(customType);

            customList.Add(new User
            {
                Id    = 1,
                Name  = "Ilya",
                Login = "******"
            });
            customList.Add(new User
            {
                Id    = 2,
                Name  = "Siarhei",
                Login = "******"
            });

            PrintList(customList);

            Console.ReadKey();
        }
Exemplo n.º 8
0
        public void ShouldBeAbleToBuildAList()
        {
            IDeclaration<MyClass> declaration = MockRepository.GenerateMock<IDeclaration<MyClass>>();

            var builder = new ListBuilder<MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings());

            using (mocks.Record())
            {
                reflectionUtil.Stub(x => x.RequiresConstructorArgs(typeof (MyClass))).Return(false).Repeat.Any();
                reflectionUtil.Expect(x => x.CreateInstanceOf<MyClass>()).Return(myClass).Repeat.Any();
                declaration.Expect(x => x.Construct());
                declaration.Expect(x => x.AddToMaster(Arg<MyClass[]>.Is.TypeOf));
                propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg<IList<MyClass>>.Is.TypeOf));
                declaration.Expect(x => x.CallFunctions(Arg<IList<MyClass>>.Is.TypeOf)).IgnoreArguments();
            }

            using (mocks.Playback())
                builder.Build();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            System.Random rand = new System.Random(Guid.NewGuid().GetHashCode());

            ListBuilder.Build();
            string restart = "";

            StandardMessages.IntroMessage();
            Tuple <bool, Player> loginPlayer;
            Player player;

            do
            {
                loginPlayer = Login.LoginMenu();
            }while (loginPlayer.Item1 == false);

            while (restart != "exit")
            {
                player = Login.getPlayer(loginPlayer.Item2.Name, loginPlayer.Item2.Password);

                string option = "";

                DateTime time = DateTime.Now;

                DateTime answer    = InitializeStorm(time, rand);
                DateTime scheduled = time.AddSeconds(5);

                while (player.IsAlive == true && option != "exit")
                {
                    //Code to display stats in another console window
                    //using (var displayProcess = new Process())
                    //{
                    //    displayProcess.StartInfo.FileName = (@"..\..\..\DisplayStats\bin\Debug\DisplayStats.exe");

                    //    displayProcess.Start();
                    //    displayProcess.Refresh();
                    //}

                    StandardMessages.Menu();
                    option = Console.ReadLine().ToLower();

                    if (time > answer)
                    {
                        MoveRandomly(rand);
                        answer = InitializeStorm(time, rand);
                    }

                    if (time > scheduled)
                    {
                        MoveScheduled(rand);
                        scheduled = time.AddSeconds(10);
                    }

                    time = DateTime.Now;

                    player = menu(option, player, time, answer, scheduled, rand);
                }

                if (player.IsAlive == false)
                {
                    Console.WriteLine("You have died. Would you like to start again from last save point or exit?\nTo restart type restart. To exit type exit.");
                    restart = Console.ReadLine();
                }
                else
                {
                    restart = option;
                }
            }
        }