Ejemplo n.º 1
0
        /// <summary>
        /// Set up all the data for the player.
        /// </summary>
        internal void InitPlayer(Game game)
        {
            if (game == null) throw new ArgumentNullException("game");

            _game = game;
            int i;

            /* Initial attributes. */
            for (i = 0; i < (int) Attributes.MaxAttribute; i++)
                SetAttribute((Attributes) i, Misc.Dice("6d3"));

            /* Initial hitpoints. */
            _hits = _maxHits = (GetAttribute(Attributes.Toughness) +
                                                                      (GetAttribute(Attributes.Strength) >> 1) +
                                                                      Misc.Dice("1d6"));

            /* Initial magical power. */
            _power = _maxPower = (GetAttribute(Attributes.Mana) +
                                                                        (GetAttribute(Attributes.Intelligence) >> 2) +
                                                                        Misc.Dice("1d6"));

            /* Initial experience. */
            _experience = 0;
            for (i = 0; i < MaxSkills; i++)
                _tskillExp[i] = 0;

            /* The number of training units initially used. */
            for (i = (int) TrainingSkills.T_MANA + 1; i < MaxSkills; i++)
                _tskillTraining[i] = Config.Tunits/(MaxSkills - (int) TrainingSkills.T_MANA - 1);

            /* Searching skill. */
            _searching = (byte) (GetAttribute(Attributes.Intelligence) +
                                                    (GetAttribute(Attributes.Mana)/5));

            /* Combat bonusses. */
            toHit = _toDamage = 0;

            /* Default name. */
            _name = "brak";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main function.
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            try
            {

            /* Print startup message. */
            Console.WriteLine("\nQuickHack Version 0.1");
            Console.WriteLine("(C) Copyright 1996, 1997 by Thomas Biskup.\n");
            if (args.Length > 1)
                return;

            Terminal.StandardPrintString("Setting up the game...");

            /* Initialize everything. */
            Terminal.StandardPrintString(".");
            Terminal.InitRand();
            Terminal.StandardPrintString(".");
            var player = new Player();
            var dungeon = new Dungeon();
            var monsters = new Monsters();
            var game = new Game(dungeon, monsters);
            monsters.InitMonsters(dungeon);
            Terminal.StandardPrintString(".");
            dungeon.InitDungeon(monsters, player);
            Terminal.StandardPrintString(".");
            player.InitPlayer(game);
            Terminal.StandardPrintString(".");
            InitScreen();

            /* Play the game. */
            game.Play();

            /* Clean up. */
            Terminal.CleanUpIO();

            /* Be done. */
            return;
            }
            catch (Exception ex)
            {
                try
                {
                    Terminal.CleanUpIO();
                }
                catch
                {
                }

                Console.WriteLine(ex);
                Console.ReadLine();
            }
        }