示例#1
0
        public void AssignLootDisableViaConfig()
        {
            var sortedPairs = new List <KeyValuePair <uint, int> >
            {
                new KeyValuePair <uint, int>(50000, 124),
                new KeyValuePair <uint, int>(50020, 100),
                new KeyValuePair <uint, int>(12332, 78),
                new KeyValuePair <uint, int>(42223, 77),
                new KeyValuePair <uint, int>(73738, 50),
                new KeyValuePair <uint, int>(12202, 12),
                new KeyValuePair <uint, int>(12902, 4),
                new KeyValuePair <uint, int>(12123, 0),
                new KeyValuePair <uint, int>(33222, 220)
            };
            var rewardAssigner = new RewardAssigner(StaticRandom.Instance, _logger);
            var numberOfAwards = 4;

            var x                    = new LootBagTypeDefinition().BuildLootBagTypeDefinitions(numberOfAwards);
            var bonusList            = new List <RVRPlayerBagBonus>();
            var randomRolls          = new Dictionary <uint, int>();
            var pairingContributions = new Dictionary <uint, int> {
                { 50000, 100 }
            };
            var assignedLoot = rewardAssigner.AssignLootToPlayers(numberOfAwards, x, sortedPairs, bonusList, randomRolls, pairingContributions, new WorldConfigs {
                AllowBagBonusContribution = "Y", AllowPairingContribution = "N", AllowRandomContribution = "Y", DebugLootRolls = "N"
            });


            Assert.IsTrue(numberOfAwards == assignedLoot.Count);
            Assert.IsTrue(assignedLoot[0].Assignee == 33222);
            Assert.IsTrue(assignedLoot[1].Assignee == 50000);
            Assert.IsTrue(assignedLoot[2].Assignee == 50020);
            Assert.IsTrue(assignedLoot[3].Assignee == 12332);
        }
示例#2
0
        public void AssignLootWithBonusesGoldBagBonus()
        {
            var sortedPairs = new List <KeyValuePair <uint, int> >
            {
                new KeyValuePair <uint, int>(50000, 124),
                new KeyValuePair <uint, int>(50020, 100),
                new KeyValuePair <uint, int>(12332, 78),
                new KeyValuePair <uint, int>(42223, 77),
                new KeyValuePair <uint, int>(73738, 50),
                new KeyValuePair <uint, int>(12202, 12),
                new KeyValuePair <uint, int>(12902, 4),
                new KeyValuePair <uint, int>(12123, 0),
                new KeyValuePair <uint, int>(33222, 220)
            };

            // +100 gold bag bonus should mean 50020 wins gold. And nothing else!
            var bonusList = new List <RVRPlayerBagBonus>
            {
                new RVRPlayerBagBonus
                {
                    CharacterId = 50020,
                    GoldBag     = 200,
                    BlueBag     = 1,
                    PurpleBag   = 0,
                    GreenBag    = 0
                }
            };

            var rewardAssigner = new RewardAssigner(StaticRandom.Instance, _logger);
            var numberOfAwards = 4;

            var x           = new LootBagTypeDefinition().BuildLootBagTypeDefinitions(numberOfAwards);
            var randomRolls = new Dictionary <uint, int>();

            var pairingContributions = new Dictionary <uint, int>();
            var assignedLoot         = rewardAssigner.AssignLootToPlayers(numberOfAwards, x, sortedPairs, bonusList, randomRolls, pairingContributions, new WorldConfigs {
                AllowBagBonusContribution = "Y", AllowPairingContribution = "Y", AllowRandomContribution = "Y", DebugLootRolls = "N"
            });

            Assert.IsTrue(numberOfAwards == assignedLoot.Count);
            Assert.IsTrue(assignedLoot[0].Assignee == 50020);
            Assert.IsTrue(assignedLoot[1].Assignee == 33222);
            Assert.IsTrue(assignedLoot[2].Assignee == 50000);
            Assert.IsTrue(assignedLoot[3].Assignee == 12332);
        }
示例#3
0
        public static bool AddZoneLockBags(Player plr, ref List <string> values)
        {
            var destructionLootChest = LootChest.Create(plr.Region, plr.WorldPosition, (ushort)plr.ZoneId);

            var orderLootChest = LootChest.Create(plr.Region, plr.WorldPosition, (ushort)plr.ZoneId);

            plr = GetTargetOrMe(plr) as Player;
            if (plr == null)
            {
                return(true);
            }
            int numberBags     = GetInt(ref values);
            var _rewardManager = new RVRRewardManager();

            var rewardAssigner = new RewardAssigner(StaticRandom.Instance, null);

            var bagDefinitions = rewardAssigner.DetermineBagTypes(numberBags);

            // Assign eligible players to the bag definitions.
            foreach (var lootBagTypeDefinition in bagDefinitions)
            {
                var listPlayerContributions = new List <PlayerContribution>();
                var pc = new PlayerContribution();
                pc.ContributionId = 4;
                pc.Timestamp      = TCPManager.GetTimeStamp();
                listPlayerContributions.Add(pc);

                var cd = new ConcurrentDictionary <uint, List <PlayerContribution> >();
                cd.TryAdd(plr.CharacterId, listPlayerContributions);
                var cm = new ContributionManager(cd, BountyService._ContributionDefinitions);

                var eligPlayer = new List <KeyValuePair <uint, int> >();
                eligPlayer.Add(new KeyValuePair <uint, int>(plr.CharacterId, 10));
                var bonuses              = new List <RVRPlayerBagBonus>();
                var randomRolls          = new Dictionary <uint, int>();
                var pairingContributions = new Dictionary <uint, int>();
                var rewardAssignments    = rewardAssigner.AssignLootToPlayers(numberBags, new List <LootBagTypeDefinition> {
                    lootBagTypeDefinition
                }, eligPlayer, bonuses, randomRolls, pairingContributions, new WorldConfigs {
                    AllowBagBonusContribution = "Y", AllowPairingContribution = "Y", AllowRandomContribution = "Y"
                });

                var bagContentSelector = new BagContentSelector(RVRZoneRewardService.RVRRewardKeepItems, StaticRandom.Instance);

                foreach (var reward in rewardAssignments)
                {
                    if (reward.Assignee != 0)
                    {
                        var playerItemList   = (from item in plr.ItmInterface.Items where item != null select item.Info.Entry).ToList();
                        var playerRenown     = plr.CurrentRenown.Level;
                        var playerClass      = plr.Info.CareerLine;
                        var playerRenownBand = PlayerUtil.CalculateRenownBand(playerRenown);

                        var lootDefinition = bagContentSelector.SelectBagContentForPlayer(_logger, reward, playerRenownBand, playerClass, playerItemList.ToList(), true);
                        if (lootDefinition.IsValid())
                        {
                            plr.SendClientMessage("Lootdefinition is valid");
                            // Only distribute if loot is valid
                            var generatedLootBag = new LootBagBuilder().BuildChestLootBag(lootDefinition, plr);

                            if (plr.Realm == Realms.REALMS_REALM_DESTRUCTION)
                            {
                                destructionLootChest.Add(plr.CharacterId, generatedLootBag);
                            }
                            if (plr.Realm == Realms.REALMS_REALM_ORDER)
                            {
                                orderLootChest.Add(plr.CharacterId, generatedLootBag);
                            }
                        }
                        else
                        {
                            plr.SendClientMessage("Lootdefinition is NOT valid");
                        }
                    }
                }
            }
            return(true);
        }