Ejemplo n.º 1
0
        protected override long GetExperienceWon(EndingArguments <MonsterEntity> arguments, AbstractFighter fighter)
        {
            var monsterFight = arguments.Fight as MonsterFight;

            switch (fighter.Type)
            {
            case EntityTypeEnum.TYPE_CHARACTER:
                return(Util.CalculPVMExperience(
                           arguments.Losers,
                           arguments.Droppers,
                           fighter.Level,
                           fighter.Statistics.GetTotal(EffectEnum.AddWisdom),
                           arguments.Fight.ChallengeXpBonus,
                           monsterFight?.MonsterGroup.AgeBonus ?? 0));

            case EntityTypeEnum.TYPE_TAX_COLLECTOR:
                return(Util.CalculPVMExperienceTaxCollector(
                           arguments.Losers,
                           arguments.Droppers,
                           fighter.Level,
                           fighter.Statistics.GetTotal(EffectEnum.AddWisdom),
                           arguments.Fight.ChallengeXpBonus,
                           monsterFight?.MonsterGroup.AgeBonus ?? 0));
            }
            return(0);
        }
Ejemplo n.º 2
0
 protected override long GetTargetKamas(EndingArguments <MonsterEntity> arguments, MonsterEntity fighter)
 {
     return((long)Math.Round(
                Util.Next(fighter.Grade.Template.MinKamas, fighter.Grade.Template.MaxKamas)
                * WorldConfig.RATE_KAMAS
                * arguments.Fight.ChallengeLootBonus));
 }
Ejemplo n.º 3
0
 protected override IEnumerable <ItemDAO> GetTargetItems(EndingArguments <MonsterEntity> arguments, MonsterEntity fighter)
 {
     return(DropManager.Instance.GetDrops
            (
                arguments.DroppersTotalPP,
                fighter,
                WorldConfig.RATE_DROP * arguments.Fight.ChallengeLootBonus
            ));
 }
Ejemplo n.º 4
0
 protected override long GetKamasWon(EndingArguments <MonsterEntity> arguments, AbstractFighter fighter)
 {
     return(Util.CalculPVMKamas(arguments.KamasLoot, fighter.Prospection, arguments.DroppersTotalPP));
 }
Ejemplo n.º 5
0
        public override void Execute(AbstractFight fight)
        {
            long kamasLoot = GetAdditionalKamas(fight);
            var  itemLoot  = new List <ItemDAO>(GetAdditionalLoot(fight));

            var droppers = fight
                           .WinnerTeam
                           .Fighters
                           .Where(fighter => fighter.CanDrop)
                           .Concat(GetAdditionalDroppers(fight))
                           .ToList();

            var losers = fight
                         .LoserTeam
                         .Fighters
                         .OfType <T>()
                         .Where(fighter => fighter.Invocator == null)
                         .ToList();

            var droppersTotalPP = droppers.Sum(fighter => fighter.Prospection);

            var arguments = new EndingArguments <T>(fight, droppers, losers, droppersTotalPP, itemLoot, kamasLoot);

            foreach (var loser in losers)
            {
                kamasLoot += GetTargetKamas(arguments, loser);
                itemLoot.AddRange(GetTargetItems(arguments, loser));
            }

            var distributedDrop = DropManager.Instance.Distribute(droppers, droppersTotalPP, itemLoot);

            foreach (var fighter in droppers)
            {
                fighter.CachedBuffer = true;
                var itemWon  = distributedDrop[fighter];
                var kamasWon = GetKamasWon(arguments, fighter);
                var xpWon    = GetExperienceWon(arguments, fighter);
                switch (fighter.Type)
                {
                case EntityTypeEnum.TYPE_CHARACTER:
                    var character = (CharacterEntity)fighter;
                    foreach (var item in itemWon)
                    {
                        character.Inventory.AddItem(item);
                    }
                    character.Inventory.AddKamas(kamasWon);
                    character.AddExperience(xpWon);
                    break;

                case EntityTypeEnum.TYPE_MONSTER_FIGHTER:
                    var monsterFight = fight as MonsterFight;

                    // case of monster winning
                    if (monsterFight != null && fight.WinnerTeam == fight.Team0)
                    {
                        foreach (var item in itemWon)
                        {
                            monsterFight.MonsterGroup.Inventory.AddItem(item);
                        }
                        monsterFight.MonsterGroup.Inventory.AddKamas(kamasWon);
                    }
                    else
                    {
                        foreach (var item in itemWon)
                        {
                            var invocator = fighter.Invocator;
                            while (fighter.Invocator != null)
                            {
                                invocator = fighter.Invocator;
                            }
                            invocator?.Inventory?.AddItem(item);
                            invocator?.Inventory?.AddKamas(kamasWon);
                        }
                    }
                    break;

                case EntityTypeEnum.TYPE_TAX_COLLECTOR:
                    var taxCollector = (TaxCollectorEntity)fighter;
                    taxCollector.Storage.AddKamas(kamasWon);
                    taxCollector.ExperienceGathered += xpWon;
                    foreach (var item in itemLoot)
                    {
                        taxCollector.Storage.AddItem(item);
                    }
                    break;
                }
                fight.Result.AddResult(fighter,
                                       FightEndTypeEnum.END_WINNER,
                                       false,
                                       kamasWon,
                                       xpWon,
                                       0,
                                       0,
                                       0,
                                       0,
                                       itemWon
                                       .GroupBy(item => item.TemplateId)
                                       .Select(g => new { TemplateId = g.Key, Count = g.Count() })
                                       .ToDictionary(g => g.TemplateId, g => g.Count));
                fighter.CachedBuffer = false;
            }
        }
Ejemplo n.º 6
0
 protected abstract long GetKamasWon(EndingArguments <T> arguments, AbstractFighter fighter);
Ejemplo n.º 7
0
 protected abstract long GetExperienceWon(EndingArguments <T> arguments, AbstractFighter fighter);
Ejemplo n.º 8
0
 protected abstract IEnumerable <ItemDAO> GetTargetItems(EndingArguments <T> arguments, T fighter);
Ejemplo n.º 9
0
 protected abstract long GetTargetKamas(EndingArguments <T> arguments, T fighter);