public void SharedGenerationFunction(ICharacter newChar, int level, IRaceTemplate race = null)
        {
            var rTemplate   = race ?? _model.RaceFactory.GetRandomTemplate();
            var randomStats = Stats.GetRandomBaseStats();

            newChar.Race  = rTemplate.Name;
            newChar.Lore  = rTemplate.Description;
            newChar.Stats = randomStats;
            ApplyRaceTemplate(rTemplate, randomStats);
            newChar.LvlUp(_model.Party.Experience);
            var spells = new List <ISpell> {
                _spellFactory.GetSpell("Attack"), _spellFactory.GetSpell("Defend")
            };
            var spellCount = RHelper.Roll(2, 5);

            for (var i = 0; i < spellCount; ++i)
            {
                ISpell spell;

                do
                {
                    spell = _spellFactory.GetRandomSpell();
                } while (spells.Contains(spell));

                spells.Add(spell);
            }
            newChar.Spells = spells;
        }
Example #2
0
        private void FindSuitableSpot(out int row, out int col, Func <int, int, bool> predicate)
        {
            var heatZone = _map.HeatZone;

            do
            {
                row = RHelper.Roll(heatZone.Top, heatZone.Bottom);
                col = RHelper.Roll(heatZone.Left, heatZone.Right);
            } while (predicate(row, col));
        }
        public void GeneratePack(int x, int y)
        {
            var pack = new MobPack(_model.Map)
            {
                Position = new Point(x, y)
            };
            var enemyCount = _model.Party.FrontRow.Count - RHelper.Roll(0, 1);

            if (enemyCount == 0)
            {
                ++enemyCount;
            }

            var xpReward = 0;

            // 25% Chance to get a group of enemies with the same race
            var raceGroup = RHelper.RollPercentage(25) ? _model.RaceFactory.GetRandomTemplate() : null;

            for (var i = 0; i < enemyCount; ++i)
            {
                var strengthRoll = RHelper.Roll(0, 99);
                var strength     = strengthRoll < 60
                    ? MobPackStrength.Equal
                    : strengthRoll < 90
                        ? MobPackStrength.Stronger
                        : strengthRoll < 98
                            ? MobPackStrength.Challenging
                            : MobPackStrength.Elite;

                xpReward += GenerateEnemy(pack, raceGroup, strength);
            }

            pack.XPReward = xpReward;

            switch (pack.Strength)
            {
            case MobPackStrength.Equal:
                pack.SightRadius = 25;
                break;

            case MobPackStrength.Stronger:
                pack.SightRadius = 20;
                break;

            case MobPackStrength.Challenging:
                pack.SightRadius = 10;
                break;

            case MobPackStrength.Elite:
                pack.SightRadius = 5;
                break;
            }

            _packs.Add(pack);
        }
Example #4
0
        public ISpell GetRandomSpell()
        {
            ISpell spell;

            do
            {
                spell = _spells[RHelper.Roll(_spells.Count - 1)];
            } while (spell.Name == "Attack" || spell.Name == "Defend" || spell.Name == "Switch");

            return(spell);
        }
Example #5
0
 public Digger(int row, int col, int digGoal, IRMap map)
 {
     _row               = row;
     _col               = col;
     _digGoal           = digGoal;
     _map               = map;
     _digged            = 0;
     _darkDigger        = RHelper.RollPercentage(25);
     _doubleCombatBonus = RHelper.RollPercentage(10);
     _combatBonus       = (ulong)RHelper.Roll(0, 23);
 }
Example #6
0
 public void GenerateMap(int level)
 {
     _mobPackManager.ClearPacks();
     _featureTarget = level * 2 + RHelper.Roll(5, 15);
     PrepareMap();
     GenerateFeatures();
     PlaceWarp();
     EnsureEnemies();
     PlacePortal();
     _map.RecalculateHeatZone();
     _map.CreateFoVMap();
 }
Example #7
0
        public static IStats GetRandomBaseStats()
        {
            var stats = new Stats();
            var hp    = stats[Stat.HP];

            hp[StatType.Base]   = RHelper.Roll(75, 200);
            hp[StatType.Growth] = RHelper.Roll(5, 25);

            stats[BaseStat.MP][StatType.Base] = 200d;

            for (var stat = Stat.AD; stat <= Stat.CHA; ++stat)
            {
                var s = stats[stat];
                s[StatType.Base]   = RHelper.Roll(20, 80);
                s[StatType.Growth] = RHelper.Roll(1, 20);
            }

            stats.EVAType = RHelper.RollPercentage(10) ? EVAType.Block : EVAType.Dodge;

            if (stats.EVAType == EVAType.Dodge)
            {
                stats[BaseStat.EVA][StatType.Base]   = 2d;
                stats[BaseStat.EVA][StatType.Growth] = RHelper.Roll(1, 8);
            }
            else
            {
                stats[BaseStat.EVA][StatType.Base]   = RHelper.Roll(20, 80);
                stats[BaseStat.EVA][StatType.Growth] = RHelper.Roll(0, 1);
            }

            var spd = stats[BaseStat.SPD];

            spd[StatType.Base]       = 100d;
            spd[StatType.Growth]     = RHelper.Roll(5, 10);
            spd[StatType.Multiplier] = 0.0255d;

            for (var stat = Stat.FIR; stat <= Stat.LGT; ++stat)
            {
                stats[stat][StatType.Base] = RHelper.Roll(50, 200);
            }

            for (var stat = Stat.PSN; stat <= Stat.SIL; ++stat)
            {
                stats[stat][StatType.Base] = RHelper.Roll(0, 30);
            }

            stats.XPMultiplier = RHelper.Roll(80, 120) / 100d;

            return(stats);
        }
Example #8
0
        protected override void OnTurnTriggered(ICharacter character)
        {
            var silChance = GetVar(character, "sil_Chance");
            var silResi   = character.Stats.GetTotalStat(DebuffResistance.SIL) * 3;

            if (RHelper.Roll(0, 99) > (silChance - silResi))
            {
                RemoveFrom(character);
            }
            else
            {
                SetVar(character, "sil_Chance", silChance / 3);
            }
        }
Example #9
0
        public override void GenerateImpl(int row, int col, Direction dir)
        {
            var topRow  = row;
            var leftCol = col;

            GetTopLeftCorner(ref topRow, ref leftCol, dir);

            var maxRow = topRow + Height;
            var maxCol = leftCol + Width;

            for (var r = topRow; r < maxRow; ++r)
            {
                for (var c = leftCol; c < maxCol; ++c)
                {
                    if (r == topRow || c == leftCol || r == maxRow - 1 || c == maxCol - 1)
                    {
                        Map[r, c] = RCell.Wall | RCell.Important;
                    }
                    else
                    {
                        Map[r, c] = RCell.Floor;
                    }
                }
            }

            var treasureCount = (int)Math.Sqrt(Width * Height);

            for (var i = 0; i < treasureCount; ++i)
            {
                int chestRow;
                int chestCol;
                do
                {
                    chestRow = RHelper.Roll(topRow + 1, maxRow - 2);
                    chestCol = RHelper.Roll(leftCol + 1, maxCol - 2);
                } while (Map[chestRow, chestCol].Is(RCell.Chest));

                Map[chestRow, chestCol] |= RCell.Chest | _rarities.Get() | _sizes.Get();
            }

            if (dir != Direction.Center)
            {
                Map[row, col] = RCell.Door | RCell.Locked | RCell.Closed;
            }
        }
Example #10
0
        public bool Generate(int row, int col, Direction direction)
        {
            Width  = RHelper.Roll(MinWidth, MaxWidth);
            Height = RHelper.Roll(MinHeight, MaxHeight);

            if (!CheckAvailableSpace(row, col, direction))
            {
                return(false);
            }

            GenerateImpl(row, col, direction);

            if (!_spawningEnabled || !RHelper.RollPercentage(_spawnChance))
            {
                return(true);
            }

            var topRow  = row;
            var leftCol = col;

            GetTopLeftCorner(ref topRow, ref leftCol, direction);

            var maxRow = topRow + Height;
            var maxCol = leftCol + Width;

            int spawnRow;
            int spawnCol;

            do
            {
                spawnRow = RHelper.Roll(topRow, maxRow);
                spawnCol = RHelper.Roll(leftCol, maxCol);
            } while (!Map[spawnRow, spawnCol].Is(RCell.Walkable));

            _packManager.GeneratePack(spawnCol, spawnRow);

            return(true);
        }
Example #11
0
        private static ICharacter GetTarget(IList <ICharacter> characters)
        {
            /********************************
            * 60% to attack main tank      *
            * 30% to attack secondary tank *
            * 5% each to attack back row   *
            ********************************/

            ICharacter target = null;
            var        size   = characters.Count;

            do
            {
                var targetRoll = RHelper.Roll(99);
                target = characters[targetRoll < 60 || size == 1
                    ? 0
                    : targetRoll < 90 || size == 2
                        ? 1
                        : targetRoll < 95 || size == 3
                            ? 2
                            : 3];
            } while (target.IsDead);
            return(target);
        }
Example #12
0
 public IRaceTemplate GetRandomTemplate()
 {
     return(Templates[RHelper.Roll(Templates.Count - 1)]);
 }
Example #13
0
        public ITargetInfo SelectSpell(ICharacter character, IBattleModel battleModel, bool isEnemy)
        {
            // TODO Check if Boss has Rotation
            var targetInfo        = new TargetInfo();
            var lowHP             = character.CurrentHP / character.Stats.GetTotalStat(BaseStat.HP) <= .3d;
            var lowMP             = character.CurrentMP <= 75d;
            var silenced          = character.IsSilenced;
            var defendAvailable   = silenced || lowHP || lowMP;
            var spellSelectCount  = 0;
            var initialSpellIndex = defendAvailable ? 1 : 2;
            var spellList         = character.Spells;

            do
            {
                if (spellList.Count == 1)
                {
                    targetInfo.Spell = spellList[0];
                    break;
                }

                ++spellSelectCount;
                if (spellSelectCount == 10)
                {
                    initialSpellIndex = 0;
                }

                targetInfo.Spell =
                    spellList[RHelper.Roll(silenced ? 0 : initialSpellIndex, silenced ? 1 : spellList.Count - 1)];
            } while (targetInfo.Spell.MPCost >= character.CurrentMP + 1f);

            targetInfo.Target = null;
            var targetType = targetInfo.Spell.TargetType;

            if (targetType == TargetType.Allies || targetType == TargetType.Enemies)
            {
                return(targetInfo);
            }

            if (targetType == TargetType.Myself)
            {
                targetInfo.Target = character;
                return(targetInfo);
            }

            var enemies  = battleModel.Enemies;
            var frontRow = battleModel.FrontRow;

            if (targetInfo.Spell.IsSupportSpell)
            {
                var rollMax = isEnemy ? enemies.Count - 1 : frontRow.Count - 1;
                do
                {
                    targetInfo.Target = isEnemy ? enemies[RHelper.Roll(rollMax)] : frontRow[RHelper.Roll(rollMax)];
                } while (targetInfo.Target.IsDead);

                return(targetInfo);
            }

            targetInfo.Target = isEnemy ? GetTarget(frontRow) : GetTarget(enemies);
            return(targetInfo);
        }
 private string GetRandomName()
 {
     return(_names[RHelper.Roll(_names.Count)]);
 }