Exemplo n.º 1
0
        public static string MonsterAttacksPlayer(TRPG_core _gameState, Buff _buffs, Monster _monster, int _seed)
        {
            Random RNG       = new Random(_seed);
            Buff   finalBuff = _buffs;

            finalBuff.Clamp();
            Buff monsterBuffs = _monster.Buffs;

            monsterBuffs.Clamp();

            string result = "";

            result += "The " + _monster.GetFullName() + " attacks you.\n";

            //Check to see if the monster actually hit
            if (RNG.Next(100) <= (_monster.Accuracy + monsterBuffs.Dexterity))
            {
                int dmgDone = (_monster.Damage + monsterBuffs.Strength) - (RNG.Next(Math.Max(1, _buffs.Intelligence)) + RNG.Next(Math.Max(1, _buffs.Wisdom)));
                if (dmgDone < 0)
                {
                    dmgDone = 0;
                }
                _gameState.player.Health -= dmgDone;

                result += "The " + _monster.Name + " hits you and deals " + dmgDone + " damage.\n";
                result += "Your health is now " + _gameState.player.Health + ".\n";
            }
            else
            {
                result += "Fortunately, it misses and does no damage.\n";
            }

            return(result);
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            TRPG_core core = new TRPG_core();

            Console.WriteLine("What is your name?\n");
            core.player.Name = Console.ReadLine();

            Random RNG = new Random();
            Buff newStats = new Buff(10, 10, 10, 10, 10, 10);

            bool statsPicked = false;
            while (!statsPicked)
            {
                Console.Clear();
                newStats = new Buff(10, 10, 10, 10, 10, 10);
                newStats.Scramble(RNG.Next(), 5 + RNG.Next(10));
                newStats.Clamp();
                Console.WriteLine("Are these stats acceptable? (y/n)");
                Console.WriteLine(newStats.ToString());
                string response = Console.ReadLine();
                if (response.ToLower() == "y")
                {
                    statsPicked = true;
                }
            }

            core.Update("");
            while (true)
            {
                core.Update(Console.ReadLine());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Carries out a player's attack with a specified weapon against a specified monster
        /// </summary>
        /// <param name="_gameState">Main TRPG_core instance containing entire game state</param>
        /// <param name="_weapon">Weapon object to be used in the attack</param>
        /// <param name="_buffs">Sum of all buffs currently effecting the player</param>
        /// <param name="_monster">Monster object to be attacked</param>
        /// <returns>Returns a string describing the event</returns>
        public static string PlayerAttacksMonster(TRPG_core _gameState, Weapon _weapon, Buff _buffs, Monster _monster, int _seed)
        {
            Random RNG       = new Random(_seed);
            Buff   finalBuff = _buffs + _weapon.Buffs;

            finalBuff.Clamp();
            string result = "";

            result += "You attack the " + _monster.Name + " with your " + _weapon.Name + ".\n";

            //Check to see if the player actually hit
            if (RNG.Next(100) <= (_weapon.Accuracy + finalBuff.Dexterity))
            {
                int dmgDone = (_weapon.Damage + finalBuff.Strength) - (RNG.Next(Math.Max(1, _monster.Defense + _monster.Buffs.Intelligence)) + RNG.Next(Math.Max(1, _monster.Defense + _monster.Buffs.Wisdom)));
                if (dmgDone < 0)
                {
                    dmgDone = 0;
                }
                _monster.Health -= dmgDone;

                if (dmgDone > (_weapon.Damage / 2))//If it is a good hit
                {
                    result += "You hit the " + _monster.Name + " and deal " + dmgDone + " damage.\n";
                }
                else
                {
                    result += "You hit the " + _monster.Name + ", but only deal " + dmgDone + " damage.\n";
                }

                result += "The " + _monster.Name + "'s health is now " + _monster.Health + ". ";
            }
            else
            {
                result += "Unfortunately, you miss and do no damage. ";
                if (finalBuff.Intelligence < finalBuff.Strength && RNG.Next(100) < 25)
                {
                    result += "Worse yet, you lose your footing and hit yourself instead.\n";
                    int dmgDone = RNG.Next(Math.Max(1, _weapon.Damage / 2));
                    _gameState.player.Health -= dmgDone;
                    result += "You lose " + dmgDone + " health! ";
                }
            }

            if (_monster.Health <= 0)
            {
                result += "The " + _monster.Name + " is killed! ";
                for (int i = 0; i < _gameState.dungeon.CurrentRoom.Contents.Count; i++)
                {
                    if (_gameState.dungeon.CurrentRoom.Contents[i] is Monster)
                    {
                        if (_gameState.dungeon.CurrentRoom.Contents[i] == _monster)
                        {
                            _gameState.dungeon.CurrentRoom.Contents.RemoveAt(i);
                        }
                    }
                }
            }

            return(result + "\n");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Combine all buffs on Items in the Inventory and combine with supplied base Buff.
        /// Mostly for use with calculating actual stats on Players.
        /// </summary>
        /// <param name="a">Base Buffs</param>
        /// <param name="b">Inventory to tally up</param>
        /// <returns></returns>
        public static Buff operator +(Buff a, Inventory b)
        {
            Buff result = a;

            foreach (Item item in b)
            {
                if (!(item is Monster) && !(item is Weapon))
                {
                    result += item.Buffs;
                }
            }

            result.Clamp();

            return(result);
        }
Exemplo n.º 5
0
        public override string ToString()
        {
            string result = "";

            if (this is Weapon)
            {
                result += GetFullName() + " is a weapon that does ";
                result += Damage + " base damage, with a base accuracy of ";
                result += Accuracy + ". It weighs ";
                result += (int)Weight + "lbs. and is worth ";
                result += (int)Value + " gold. ";
                if (Buffs.Magnitude > 0)
                {
                    result += "\nThis " + Name + " has the following enchantments:\n";
                    result += Buffs.ToString();
                }
            }
            else if (this is Player)
            {
                if (Name != "")
                {
                    result += "Your name is " + Name + ".\n";
                }

                result += "You are an adventurer ";
                if (Experience > 0)
                {
                    result += "with " + Experience + " experience, ";
                }
                result += "traveling through a mysterious dungeon seeking treasure and glory.\n";
                result += "Your health is " + Health + " and you are currently carrying " + Contents.Weight + "lbs. of loot.\n\n";
                result += "Your base stats are as follows:\n";
                result += Buffs + "\n\n";

                if (Contents.Count > 0)
                {
                    result += "After factoring in the effects of your inventory, your actual stats are as follows:\n";
                    Buff finalBuff = Buffs + Contents;
                    finalBuff.Clamp();
                    result += finalBuff + "\n\n";

                    result += "Here's a rundown of your inventory:\n";
                    result += "===================================\n\n";

                    foreach (Item item in Contents)
                    {
                        result += item.ToString();
                        result += "\n-----------------------------------\n\n";
                    }
                }
            }
            else if (this is Monster)
            {
                result += Name + " is a monster that does ";
                result += Damage + " base damage, with a base accuracy of ";
                result += Accuracy + ". Its health is ";
                result += Health + ".";
                if (Buffs.Magnitude > 0)
                {
                    result += "\nThis " + Name + " has the following stats:\n";
                    result += Buffs.ToString();
                }
            }
            else
            {
                result += "The " + Name + " weighs ";
                result += Weight + "lbs. and is worth ";
                result += Value + " gold. ";
                if (Buffs.Magnitude > 0)
                {
                    result += "\nThis " + Name + " confers the following buffs:\n";
                    result += Buffs.ToString();
                }
            }

            if (Lore != "")
            {
                result += "\n\n" + Lore;
            }

            return(result);
        }