Example #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;
        }
Example #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());
            }
        }
Example #3
0
 public Item(string _name, string _id)
 {
     Name = _name;
     Adjectives = new List<string>();
     Buffs = Buff.Randomized(_name.GetHashCode(), 10);
     ID = _id;
 }
Example #4
0
 public Room()
 {
     Contents = new Inventory();
     Buffs = new Buff();
     Description = "A blank, empty room.";
     ExtraDescript = "There's seriously nothing here. It's just a square room with ";
     ExtraDescript += "white walls. Where is that light even coming from? How do you ";
     ExtraDescript += "get out!?";
 }
Example #5
0
 public Item(string _name, string _id, int _value, int _weight)
 {
     Name = _name;
     Value = _value;
     Weight = _weight;
     Adjectives = new List<string>();
     Buffs = Buff.Randomized(_name.GetHashCode(), 10);
     ID = _id;
 }
Example #6
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";
        }
Example #7
0
        public static Buff operator +(Buff a, Buff b)
        {
            Buff result = new Buff();

            result.Strength = a.Strength + b.Strength;
            result.Dexterity = a.Dexterity + b.Dexterity;
            result.Constitution = a.Constitution + b.Constitution;
            result.Intelligence = a.Intelligence + b.Intelligence;
            result.Wisdom = a.Wisdom + b.Wisdom;
            result.Charisma = a.Charisma + b.Charisma;

            return result;
        }
Example #8
0
        public void GenerateRandom(int _seed, List<Item> _itemsMaster, List<Weapon> _weaponsMaster, List<Monster> _monstersMaster)
        {
            Random RNG = new Random(_seed);
            Buffs = Buff.Randomized(RNG.Next(), 10);
            Description = "You enter a randomly generated room. ";
            ExtraDescript = "This room was generated at random, so there's not much of a description. Sorry.";

            int rt = RNG.Next(5);

            if (rt == 0)
            {
                Description = "This room is poorly lit. ";
                ExtraDescript = "The only source of light in the room is a faint glow off some green fungus, ";
                ExtraDescript += "but from what you can see it is roughly square, with a dirt floor and rough ";
                ExtraDescript += "stone brick walls. The room stinks of mildew and decay. ";
            }
            else if (rt == 1)
            {
                Description = "You are in a large, round room. ";
                ExtraDescript = "This room is large and circular. It is brightly lit by an ornate, gold chandelier in the center, ";
                ExtraDescript += "and you can see file gold and lapis lazuli inlays in the marble floor. ";
                ExtraDescript += "The walls are ornamented with masterful bas relief sculptures of wars long past. ";
            }
            else if (rt == 2)
            {
                Description = "You are now standing in water. ";
                ExtraDescript = "This room is small and irregular in shape, and you are standing in ankle-deep water. ";
                ExtraDescript += "The water is murky with scum floating on top, but you feel silt beneath your feet ";
                ExtraDescript += "with no indication of a solid floor. ";
            }
            else if (rt == 3)
            {
                Description = "This room is warm and has a sandy floor. ";
                ExtraDescript = "This room is long and rectangular, with smooth stone brick walls and a floor covered in ";
                ExtraDescript += "pale yellow sand. It is very warm in here, and you sweat a little as you look around. ";
            }
            else if (rt == 4)
            {
                Description = "You are in a dim, hot room. ";
                ExtraDescript = "This is less of a room than a cave. The walls are craggy reddish stone covered in ";
                ExtraDescript += "scrapes, as if gouged by claws. It is very, very hot in here, and from cracks ";
                ExtraDescript += "in the floor you can hear screams rising from the dark. What is this awful place? ";
            }

            int n = RNG.Next(5);
            for (int i = 0; i < n; i++)
            {
                Contents.Add(_itemsMaster[(int)RNG.Next(_itemsMaster.Count)].Copy());
            }

            n = RNG.Next(3);
            for (int i = 0; i < n; i++)
            {
                Contents.Add(_weaponsMaster[(int)RNG.Next(_weaponsMaster.Count)].Copy());
            }

            n = RNG.Next(5);
            for (int i = 0; i < n; i++)
            {
                Contents.Add(_monstersMaster[(int)RNG.Next(_monstersMaster.Count)].Copy());
            }
            Description += "There ";
            if (n == 0)
            {
                Description += "are no monsters ";
            }
            else if (n == 1)
            {
                Description += "is one monster ";
            }
            else if (n == 2)
            {
                Description += "are two monsters ";
            }
            else
            {
                Description += "are several monsters ";
            }
            Description += "in here.\n";
        }
Example #9
0
 public Weapon()
 {
     Weight = 5;
     Value = 10;
     Damage = 10;
     Accuracy = 75;
     Adjectives = new List<string>();
     Buffs = new Buff();
 }
Example #10
0
 public Player()
 {
     Health = 100;
     Adjectives = null;
     Buffs = new Buff(10, 10, 10, 10, 10, 10);
     Contents = new Inventory();
 }
Example #11
0
 public Monster()
 {
     Health = 25;
     Damage = 10;
     Defense = 10;
     Accuracy = 75;
     Adjectives = new List<string>();
     Buffs = new Buff();
 }
Example #12
0
        private float weight = 0; //Weight of item for inventory tracking

        #endregion Fields

        #region Constructors

        public Item()
        {
            Adjectives = new List<string>();
            Buffs = new Buff();
        }
Example #13
0
        public static Buff Randomized(int _seed, int _scalar)
        {
            Buff result = new Buff();
            Random RNG = new Random(_seed);
            int t = 5 * (_scalar / 10);

            if (RNG.Next(100) <= t) { result.Strength += RNG.Next(_scalar); }
            if (RNG.Next(100) <= t) { result.Strength -= RNG.Next(_scalar); }

            if (RNG.Next(100) <= t) { result.Dexterity += RNG.Next(_scalar); }
            if (RNG.Next(100) <= t) { result.Dexterity -= RNG.Next(_scalar); }

            if (RNG.Next(100) <= t) { result.Constitution += RNG.Next(_scalar); }
            if (RNG.Next(100) <= t) { result.Constitution -= RNG.Next(_scalar); }

            if (RNG.Next(100) <= t) { result.Intelligence += RNG.Next(_scalar); }
            if (RNG.Next(100) <= t) { result.Intelligence -= RNG.Next(_scalar); }

            if (RNG.Next(100) <= t) { result.Wisdom += RNG.Next(_scalar); }
            if (RNG.Next(100) <= t) { result.Wisdom -= RNG.Next(_scalar); }

            if (RNG.Next(100) <= t) { result.Charisma += RNG.Next(_scalar); }
            if (RNG.Next(100) <= t) { result.Charisma -= RNG.Next(_scalar); }

            return result;
        }