Exemplo n.º 1
0
        public static void CounterAttack(Player demon, Player attacker)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var dbDemon = playerRepo.Players.FirstOrDefault(f => f.Id == demon.Id);

            if (dbDemon.Mobility != PvPStatics.MobilityFull)
            {
                decimal xpGain     = 30 + 5 * dbDemon.Level;
                decimal pointsGain = dbDemon.Level * 2;
                PlayerProcedures.GivePlayerPvPScore_NoLoser(attacker, pointsGain);
                var playerLog = "You absorb dark magic from your vanquished opponent, earning " + pointsGain + " points and " + xpGain + " XP.  Unfortunately the demon's new form fades into mist, denying you any other trophies of your conquest.";
                PlayerLogProcedures.AddPlayerLog(attacker.Id, playerLog, true);
                PlayerProcedures.GiveXP(attacker, xpGain);

                var item = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer {
                    PlayerId = dbDemon.Id
                });
                ItemProcedures.DeleteItem(item.Id);

                DomainRegistry.Repository.Execute(new DeletePlayer {
                    PlayerId = demon.Id
                });

                StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__DungeonDemonsDefeated, 1);
            }
            else if (dbDemon != null && dbDemon.Mobility == PvPStatics.MobilityFull && attacker.Mobility == PvPStatics.MobilityFull)
            {
                var(complete, _) = AttackProcedures.Attack(dbDemon, attacker, PvPStatics.Dungeon_VanquishSpellSourceId);

                if (!complete)
                {
                    (complete, _) = AttackProcedures.Attack(dbDemon, attacker, PvPStatics.Dungeon_VanquishSpellSourceId);
                }

                var dbDemonBuffs = ItemProcedures.GetPlayerBuffs(dbDemon);
                if (dbDemon.Mana < PvPStatics.AttackManaCost * 6)
                {
                    DomainRegistry.Repository.Execute(new Meditate {
                        PlayerId = dbDemon.Id, Buffs = dbDemonBuffs, NoValidate = true
                    });
                }

                if (complete)
                {
                    AIProcedures.EquipDefeatedPlayer(dbDemon, attacker);
                }
            }
        }
Exemplo n.º 2
0
        public static void CounterAttack(Player victim, Player boss)
        {
            var definition = bossData.SingleOrDefault(d => d.Value.BotId == boss.BotId);
            var world      = DomainRegistry.Repository.FindSingle(new GetWorld());

            var counterAttackTimes = GetCounterAttackTimes(boss.Health, boss.MaxHealth, world.TurnNumber);
            var complete           = false;

            for (var i = 0; i < counterAttackTimes && !complete; i++)
            {
                (complete, _) = AttackProcedures.Attack(boss, victim, ChooseSpell(boss, world.TurnNumber, definition.Value.Spells));
            }

            if (complete)
            {
                AIProcedures.EquipDefeatedPlayer(boss, victim);
            }
        }
Exemplo n.º 3
0
        public static void Run(int turnNumber, MinibossData data)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var miniboss =
                playerRepo.Players.FirstOrDefault(p => p.BotId == data.BotId && p.Mobility == PvPStatics.MobilityFull);

            // spawn a new boss if last is null
            if (miniboss == null && rand.NextDouble() < ChanceToRespawn)
            {
                var spawnLocation = LocationsStatics.GetRandomLocation_InRegion(data.Region);

                var cmd = new CreatePlayer
                {
                    FirstName    = data.Title,
                    LastName     = NameService.GetRandomLastName(),
                    Location     = spawnLocation,
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = data.FormSourceId,
                    Money        = 2000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = GetLevel(turnNumber),
                    BotId        = data.BotId
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var minibossEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                minibossEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(minibossEF));
                playerRepo.SavePlayer(minibossEF);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = data.RuneIdToGive, PlayerId = minibossEF.Id
                    });
                }
            }

            if (miniboss != null && miniboss.Mobility == PvPStatics.MobilityFull)
            {
                // move to a randomn location in this region
                var nextLocation       = LocationsStatics.GetRandomLocation_InRegion(data.Region);
                var actualNextLocation = AIProcedures.MoveTo(miniboss, nextLocation, 11);
                miniboss.dbLocationName = actualNextLocation;
                miniboss.Mana           = miniboss.MaxMana;
                playerRepo.SavePlayer(miniboss);
                var playersHere = GetEligibleTargetsAtLocation(actualNextLocation);
                foreach (var target in playersHere)
                {
                    var(complete, _) = AttackProcedures.Attack(miniboss, target, ChooseSpell(miniboss, turnNumber, data.Spells));

                    if (complete)
                    {
                        AIProcedures.EquipDefeatedPlayer(miniboss, target);
                    }
                }
            }
        }