Example #1
0
        public Character GetRandomCharacter(int ScaleLevelMin, int ScaleLevelMax)
        {
            var myCharacterViewModel = CharactersViewModel.Instance;

            var rnd = HelperEngine.RollDice(1, myCharacterViewModel.Dataset.Count);

            var myData = new Character(myCharacterViewModel.Dataset[rnd - 1]);

            // Help identify which Character it is...
            myData.Name += " " + (1 + CharacterList.Count).ToString();

            var rndScale = HelperEngine.RollDice(ScaleLevelMin, ScaleLevelMax);

            myData.ScaleLevel(rndScale);

            // Add Items...
            myData.Head        = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.Head, AttributeEnum.Unknown);
            myData.Necklass    = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.Necklass, AttributeEnum.Unknown);
            myData.PrimaryHand = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.PrimaryHand, AttributeEnum.Unknown);
            myData.OffHand     = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.OffHand, AttributeEnum.Unknown);
            myData.RightFinger = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.RightFinger, AttributeEnum.Unknown);
            myData.LeftFinger  = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.LeftFinger, AttributeEnum.Unknown);
            myData.Feet        = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.Feet, AttributeEnum.Unknown);

            return(myData);
        }
Example #2
0
        public HitStatusEnum RollToHitTarget(int AttackScore, int DefenseScore)
        {
            var d20 = HelperEngine.RollDice(1, 20);

            // Turn On UnitTestingSetRoll
            if (GameGlobals.ForceRollsToNotRandom)
            {
                // Don't let it be 0, if it was not initialized...
                if (GameGlobals.ForceToHitValue < 1)
                {
                    GameGlobals.ForceToHitValue = 1;
                }

                d20 = GameGlobals.ForceToHitValue;
            }

            if (d20 == 1)
            {
                // Force Miss
                BattleMessages.HitStatus = HitStatusEnum.CriticalMiss;
                return(BattleMessages.HitStatus);
            }

            if (d20 == 20)
            {
                // Force Hit
                BattleMessages.HitStatus = HitStatusEnum.CriticalHit;
                return(BattleMessages.HitStatus);
            }

            var ToHitScore = d20 + AttackScore;

            if (ToHitScore < DefenseScore)
            {
                BattleMessages.AttackStatus = " misses ";
                // Miss
                BattleMessages.HitStatus    = HitStatusEnum.Miss;
                BattleMessages.DamageAmount = 0;
            }
            else
            {
                // Hit
                BattleMessages.HitStatus = HitStatusEnum.Hit;
            }

            return(BattleMessages.HitStatus);
        }
Example #3
0
        // Will drop between 1 and 4 items from the item set...
        public List <Item> GetRandomMonsterItemDrops(int round)
        {
            var myList = new List <Item>();

            if (!GameGlobals.AllowMonsterDropItems)
            {
                return(myList);
            }

            var myItemsViewModel = ItemsViewModel.Instance;

            if (myItemsViewModel.Dataset.Count > 0)
            {
                // Random is enabled so build up a list of items dropped...
                var ItemCount = HelperEngine.RollDice(1, 4);
                for (var i = 0; i < ItemCount; i++)
                {
                    var rnd      = HelperEngine.RollDice(1, myItemsViewModel.Dataset.Count);
                    var itemBase = myItemsViewModel.Dataset[rnd - 1];
                    var item     = new Item(itemBase);
                    item.ScaleLevel(round);

                    // Make sure the item is added to the global list...
                    var myItem = ItemsViewModel.Instance.CheckIfItemExists(item);
                    if (myItem == null)
                    {
                        // Item does not exist, so add it to the datstore
                        ItemsViewModel.Instance.AddItem_Sync(item);
                    }
                    else
                    {
                        // Swap them becaues it already exists, no need to create a new one...
                        item = myItem;
                    }

                    // Add the item to the local list...
                    myList.Add(item);
                }
            }

            return(myList);
        }
Example #4
0
        // Add Monsters
        // Scale them to meet Character Strength...
        public void AddMonstersToRound()
        {
            // Check to see if the monster list is full, if so, no need to add more...
            if (MonsterList.Count() >= GameGlobals.MaxNumberPartyPlayers)
            {
                return;
            }

            // Make Sure Monster List exists and is loaded...
            var myMonsterViewModel = MonstersViewModel.Instance;

            if (myMonsterViewModel.Dataset.Count() > 0)
            {
                // Scale monsters to be within the range of the Characters

                var ScaleLevelMax     = 1;
                var ScaleLevelMin     = 1;
                var ScaleLevelAverage = 1;

                if (CharacterList.Any())
                {
                    ScaleLevelMax     = GetMaxCharacterLevel();
                    ScaleLevelMin     = GetMinCharacterLevel();
                    ScaleLevelAverage = GetAverageCharacterLevel();
                }

                // Get 6 monsters

                //IF BOSS BATTLE THIS CHANGES

                if (GameGlobals.BossBattles)
                {
                    //roll D100
                    //determine if BB are enabled
                    Random random     = new Random();
                    int    checkValue = random.Next(0, 100);
                    //determine if BB is enabled
                    if (checkValue < GameGlobals.BossBattleChance * 100)
                    {
                        //enable BB and the battle is a boss
                        //this is General Woundwort

                        var monster = new Monster(myMonsterViewModel.Dataset[0]);
                        monster.Name += " " + (1 + MonsterList.Count()).ToString();
                        // Scale the monster to be between the average level of the characters+1
                        //but bc its a boss make it stronger
                        var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage + 4);
                        monster.ScaleLevel(rndScale);
                        MonsterList.Add(monster);
                    }
                    else
                    {
                        do
                        {
                            var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);
                            {
                                var monster = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                                // Help identify which monster it is...
                                monster.Name += " " + (1 + MonsterList.Count()).ToString();

                                // Scale the monster to be between the average level of the characters+1
                                var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage + 1);
                                monster.ScaleLevel(rndScale);
                                MonsterList.Add(monster);
                            }
                        } while (MonsterList.Count() < GameGlobals.MaxNumberPartyPlayers);
                    }
                }
                else
                {
                    do
                    {
                        var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);
                        {
                            var monster = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                            // Help identify which monster it is...
                            monster.Name += " " + (1 + MonsterList.Count()).ToString();

                            // Scale the monster to be between the average level of the characters+1
                            var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage);
                            monster.ScaleLevel(rndScale);
                            MonsterList.Add(monster);
                        }
                    } while (MonsterList.Count() < GameGlobals.MaxNumberPartyPlayers);
                }


                //// No monsters in DB, so add 6 new ones...
                //for (var i = 0; i < GameGlobals.MaxNumberPartyPlayers; i++)
                //{
                //    var item = new Monster();
                //    // Help identify which monster it is...
                //    item.Name += " " + MonsterList.Count() + 1;
                //    MonsterList.Add(item);
                //}
            }
        }
Example #5
0
        // This function takes a Character and returns a string
        // about whether the character drops item
        public string DetermineCriticalMissProblem(Character attacker)
        {
            if (attacker == null)
            {
                return(" Invalid Character ");
            }

            var  myReturn = " Nothing Bad Happened ";
            Item droppedItem;

            // It may be a critical miss, roll again and find out...
            var rnd = HelperEngine.RollDice(1, 10);

            /*
             *  1. Primary Hand Item breaks, and is lost forever
             *  2-4, Character Drops the Primary Hand Item back into the item pool
             *  5-6, Character drops a random equipped item back into the item pool
             *  7-10, Nothing bad happens, luck was with the attacker
             */

            switch (rnd)
            {
            case 1:
                myReturn = " Luckly, nothing to drop from " + ItemLocationEnum.PrimaryHand;
                var myItem = ItemsViewModel.Instance.GetItem(attacker.PrimaryHand);
                if (myItem != null)
                {
                    myReturn = " Item " + myItem.Name + " from " + ItemLocationEnum.PrimaryHand + " Broke, and lost forever";
                }

                attacker.PrimaryHand = null;
                break;

            case 2:
            case 3:
            case 4:
                // Put on the new item, which drops the one back to the pool
                myReturn    = " Luckly, nothing to drop from " + ItemLocationEnum.PrimaryHand;
                droppedItem = attacker.AddItem(ItemLocationEnum.PrimaryHand, null);
                if (droppedItem != null)
                {
                    // Add the dropped item to the pool
                    ItemPool.Add(droppedItem);
                    myReturn = " Dropped " + droppedItem.Name + " from " + ItemLocationEnum.PrimaryHand;
                }
                break;

            case 5:
            case 6:
                var LocationRnd    = HelperEngine.RollDice(1, ItemLocationList.GetListCharacter.Count);
                var myLocationEnum = ItemLocationList.GetLocationByPosition(LocationRnd);
                myReturn = " Luckly, nothing to drop from " + myLocationEnum;

                // Put on the new item, which drops the one back to the pool
                droppedItem = attacker.AddItem(myLocationEnum, null);
                if (droppedItem != null)
                {
                    // Add the dropped item to the pool
                    ItemPool.Add(droppedItem);
                    myReturn = " Dropped " + droppedItem.Name + " from " + myLocationEnum;
                }
                break;
            }

            return(myReturn);
        }