public Treasure GenerateFor(Creature creature, int level)
        {
            var creatureName = GetCreatureNameForTreasure(creature.Name, creature.Description);
            var coinMultiplier = adjustmentSelector.Select<double>(TableNameConstants.TreasureAdjustments, creatureName, TreasureConstants.Coin);
            var goodsMultiplier = adjustmentSelector.Select<double>(TableNameConstants.TreasureAdjustments, creatureName, TreasureConstants.Goods);
            var itemsMultiplier = adjustmentSelector.Select<double>(TableNameConstants.TreasureAdjustments, creatureName, TreasureConstants.Items);

            var treasure = new Treasure();
            treasure.Coin = coinGenerator.GenerateAtLevel(level);

            var rawQuantity = coinMultiplier * treasure.Coin.Quantity;
            treasure.Coin.Quantity = Convert.ToInt32(rawQuantity);

            while (booleanPercentileSelector.SelectFrom(goodsMultiplier--))
            {
                var goods = goodsGenerator.GenerateAtLevel(level);
                treasure.Goods = treasure.Goods.Union(goods);
            }

            while (booleanPercentileSelector.SelectFrom(itemsMultiplier--))
            {
                var items = itemsGenerator.GenerateAtLevel(level);
                treasure.Items = treasure.Items.Union(items);
            }

            var setTreasure = GetSetTreasure(creatureName, creature.Quantity);
            treasure.Items = treasure.Items.Union(setTreasure);

            return treasure;
        }
 public Coin(Treasure.CoinNames name, string description, Treasure.Material typeOfMaterial, int quantityOfMaterial)
 {
     _name = name;
     _description = description;
     _typeOfMaterial = typeOfMaterial;
     _quantitiyOfMaterial = quantityOfMaterial;
 }
Пример #3
0
 // TODO Sprint 3 Mod 05b - modify the ConsoleView constructor to accept the treasure object
 /// <summary>
 /// constructor to create the console view, send all major data objects
 /// </summary>
 /// <param name="myPlayer">active player object</param>
 /// <param name="hall">current hall object</param>
 /// <param name="hall">current guest list object</param>
 public ConsoleView(Player myPlayer, Hall hall, GuestList guests, StaffList staff, Treasure treasure)
 {
     _myPlayer = myPlayer;
     _hall = hall;
     _guestList = guests;
     _staffList = staff;
     _treasure = treasure;
     InitializeConsoleWindow();
 }
Пример #4
0
 public Treasure(DataRow data, Treasure parent = null)
 {
     Parent = parent;
     Name = data["treasureClass"].ToString();
     NoDrop = 100 - (float) data["noDrop"];
     PickType = (PickTypes) data["pickType"];
     SpawnCondition = (Bitmask01) data["spawnCondition"];
     Difficulty = (int) data["gameModeRestriction1"];
     for (var i = 0; i < 8; i++)
         Drops.Add(GetDropClass(data, i + 1));
 }
Пример #5
0
  public bool startTurn()
  {
    iteration++;
    int count = 0;
    count = Client.getPirateCount(connection);
    pirates = new Pirate[count];
    for(int i = 0; i < count; i++)
    {
      pirates[i] = new Pirate(Client.getPirate(connection, i));
    }
    count = Client.getPlayerCount(connection);
    players = new Player[count];
    for(int i = 0; i < count; i++)
    {
      players[i] = new Player(Client.getPlayer(connection, i));
    }
    count = Client.getPortCount(connection);
    ports = new Port[count];
    for(int i = 0; i < count; i++)
    {
      ports[i] = new Port(Client.getPort(connection, i));
    }
    count = Client.getShipCount(connection);
    ships = new Ship[count];
    for(int i = 0; i < count; i++)
    {
      ships[i] = new Ship(Client.getShip(connection, i));
    }
    count = Client.getTileCount(connection);
    tiles = new Tile[count];
    for(int i = 0; i < count; i++)
    {
      tiles[i] = new Tile(Client.getTile(connection, i));
    }
    count = Client.getTreasureCount(connection);
    treasures = new Treasure[count];
    for(int i = 0; i < count; i++)
    {
      treasures[i] = new Treasure(Client.getTreasure(connection, i));
    }

    if(!initialized)
    {
      initialized = true;
      init();
    }
    return run();
  }
Пример #6
0
 public void AddTreasure(Treasure myTreasure)
 {
     //Ran by anything with the Treasure componenet, this will sort them and add them to the appropriate scripts
     switch (myTreasure._treasureType){
     case TreasureType.blue:
         blueTreasure.Add (myTreasure);
     break;
     case TreasureType.red:
         redTreasure.Add (myTreasure);
     break;
     case TreasureType.green:
         greenTreasure.Add (myTreasure);
     break;
     case TreasureType.yellow:
         yellowTreasure.Add (myTreasure);
     break;
     }
 }
        public void GenerateHiddenContainedTreasure()
        {
            selectedContents.Contents.Miscellaneous = new[] { ContentsTypeConstants.Treasure };

            var generatedTreasure = new Treasure();
            mockTreasureGenerator.Setup(g => g.GenerateAtLevel(9266)).Returns(generatedTreasure);

            mockPercentileSelector.Setup(s => s.SelectFrom(TableNameConstants.TreasureContainers)).Returns("container");
            mockPercentileSelector.Setup(s => s.SelectFrom(TableNameConstants.TreasureConcealment)).Returns("peek-a-boo");

            var contents = contentsGenerator.Generate(9266);
            Assert.That(contents.IsEmpty, Is.False);
            Assert.That(contents.Miscellaneous.Single(), Is.EqualTo(ContentsTypeConstants.Treasure));

            var treasure = contents.Treasures.Single();
            Assert.That(treasure.Treasure, Is.EqualTo(generatedTreasure));
            Assert.That(treasure.Container, Is.EqualTo("container"));
            Assert.That(treasure.Concealment, Is.EqualTo("peek-a-boo"));
        }
        public void NPCIsHalfLevel(int npcLevel, int effectiveLevel)
        {
            characterClass.Level = npcLevel;
            characterClass.Name = "class name";
            npcs.Add(characterClass.Name);

            var npcTreasure = new Treasure();
            mockTreasureGenerator.Setup(g => g.GenerateAtLevel(effectiveLevel)).Returns(npcTreasure);

            var equipment = equipmentGenerator.GenerateWith(feats, characterClass, race);
            Assert.That(equipment.Treasure, Is.EqualTo(npcTreasure));
        }
        public void Setup()
        {
            mockTypeAndAmountPercentileSelector = new Mock<ITypeAndAmountPercentileSelector>();
            mockRollSelector = new Mock<IRollSelector>();
            mockPercentileSelector = new Mock<IPercentileSelector>();
            mockCollectionSelector = new Mock<ICollectionSelector>();
            mockDice = new Mock<Dice>();
            mockEncounterCharacterGenerator = new Mock<IEncounterCharacterGenerator>();
            mockEncounterTreasureGenerator = new Mock<IEncounterTreasureGenerator>();
            mockFilterVerifier = new Mock<IFilterVerifier>();
            mockCreatureCollectionSelector = new Mock<IEncounterCollectionSelector>();

            encounterGenerator = new EncounterGenerator(mockTypeAndAmountPercentileSelector.Object, mockRollSelector.Object, mockPercentileSelector.Object, mockCollectionSelector.Object,
                mockDice.Object, mockEncounterCharacterGenerator.Object, mockEncounterTreasureGenerator.Object, mockFilterVerifier.Object, mockCreatureCollectionSelector.Object);

            encounterLevelAndModifier = new Dictionary<string, string>();
            encounterTypeAndAmount = new Dictionary<string, string>();
            requiresSubtype = new List<string>();

            level = 9266;
            environment = "environment";
            temperature = "temperature";
            timeOfDay = "time of day";
            encounterLevelAndModifier["90210"] = "9876";
            encounterTypeAndAmount["creature"] = "creature amount";
            treasure = new Treasure();
            treasure.Coin.Quantity = 8765;

            var tableName = string.Format(TableNameConstants.LevelXEncounterLevel, level);
            mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(tableName)).Returns(encounterLevelAndModifier);

            mockCreatureCollectionSelector.Setup(s => s.SelectFrom(90210, environment, temperature, timeOfDay)).Returns(encounterTypeAndAmount);
            mockCreatureCollectionSelector.Setup(s => s.SelectAllFrom(level, environment, temperature, timeOfDay)).Returns(new[] { encounterTypeAndAmount });

            mockRollSelector.Setup(s => s.SelectFrom("creature amount", 9876)).Returns("effective roll");
            mockDice.Setup(d => d.Roll(It.IsAny<string>())).Returns((string s) => ParseRoll(s));
            mockDice.Setup(d => d.Roll("effective roll")).Returns(42);

            mockCollectionSelector.Setup(s => s.SelectFrom(TableNameConstants.CreatureGroups, GroupConstants.RequiresSubtype)).Returns(requiresSubtype);
            mockCollectionSelector.Setup(s => s.SelectRandomFrom(It.IsAny<IEnumerable<string>>())).Returns((IEnumerable<string> c) => c.Last());

            mockFilterVerifier.Setup(v => v.FiltersAreValid(environment, level, temperature, timeOfDay)).Returns(true);
            mockFilterVerifier.Setup(v => v.EncounterIsValid(It.IsAny<Dictionary<string, string>>(), It.IsAny<int>())).Returns(true);

            mockEncounterTreasureGenerator.Setup(g => g.GenerateFor(It.Is<Creature>(c => c.Name == "creature"), level)).Returns(treasure);
            mockEncounterTreasureGenerator.Setup(g => g.GenerateFor(It.Is<Creature>(c => c.Name != "creature"), level)).Returns(() => new Treasure());
        }
Пример #10
0
        private bool Simplify(Treasure treasure)
        {
            Treasure last = null;
            var doSimplify = false;

            foreach (var drop in treasure.Drops)
            {
                if (drop.Type == 0) continue;
                if (!(drop.Content is Treasure)) break;
                if (last != null)
                {
                    if (drop.Content.Equals(last))
                    {
                        doSimplify = true;
                        continue;
                    }
                    if (doSimplify)
                    {
                        treasure.Drops.Remove(drop);
                        treasure.Parent.Drops.Add(drop);
                        return false;
                    }
                }

                last = (Treasure) drop.Content;
            }

            if (doSimplify)
            {
                Drop lastDrop = null;
                foreach (var drop in treasure.Drops)
                {
                    var t = drop.Content as Treasure;
                    if (t == null) break;

                    if (lastDrop != null)
                        if (!(drop.Equals(lastDrop)))
                        {
                            lastDrop = drop;
                            continue;
                        }

                    lastDrop = drop;
                    switch (t.Difficulty)
                    {
                        case 0:
                            treasure.NormalChance = t.NoDrop;
                            break;
                        case 1:
                            treasure.NightmareChance = t.NoDrop;
                            break;
                        case 2:
                            treasure.HellChance = t.NoDrop;
                            break;
                    }

                    treasure.Drops = ((Treasure) drop.Content).Drops;
                }
            }
            return true;
        }
Пример #11
0
 public DungeonTreasure()
 {
     Container = string.Empty;
     Treasure = new Treasure();
     Concealment = string.Empty;
 }
Пример #12
0
        public void GetTreasureForAllCreatures()
        {
            encounterTypeAndAmount["other creature"] = "other creature amount";

            mockRollSelector.Setup(s => s.SelectFrom("other creature amount", 9876)).Returns("other effective roll");
            mockDice.Setup(d => d.Roll("other effective roll")).Returns(600);

            var otherTreasure = new Treasure();
            otherTreasure.Coin.Quantity = 1337;
            mockEncounterTreasureGenerator.Setup(g => g.GenerateFor(It.Is<Creature>(c => c.Name == "other creature"), level)).Returns(otherTreasure);

            var encounter = encounterGenerator.Generate(environment, level, temperature, timeOfDay);
            Assert.That(encounter, Is.Not.Null);
            Assert.That(encounter.Treasures, Contains.Item(treasure));
            Assert.That(encounter.Treasures, Contains.Item(otherTreasure));
            Assert.That(encounter.Treasures.Count, Is.EqualTo(2));
        }
Пример #13
0
        public void PlayerCharacterIsFullLevel(int level, int effectiveLevel)
        {
            characterClass.Level = level;
            characterClass.Name = "class name";
            npcs.Add("npc class");

            var playerTreasure = new Treasure();
            mockTreasureGenerator.Setup(g => g.GenerateAtLevel(effectiveLevel)).Returns(playerTreasure);

            var equipment = equipmentGenerator.GenerateWith(feats, characterClass, race);
            Assert.That(equipment.Treasure, Is.EqualTo(playerTreasure));
        }
        // TODO Sprint 3 Mod 02b - add a method to initialze the game treasure types
        /// <summary>
        /// intitialize the type of treasures in the game
        /// </summary>
        public void InitializeTreasures()
        {
            _treasures = new Treasure();

            // TODO Sprint 3 Mod 06 - initialize the coin types
            Coin goldCoin = new Coin(
                "Small Gold Coin",
                "Gold coin with the Kings's face on one side and the Castle Wilhelm on the other side.",
                Treasure.Material.Gold,
                1);

            Coin silverCoin = new Coin(
                "Samll Silver Coin",
                "Silver coin with the Queen's face on one side and the River Thomes on the other side.",
                Treasure.Material.Silver,
                1);

            Coin bronzeCoin = new Coin(
                "Small Bronze Coin",
                "Bronze coin with the Prince's face on one side and Mount Fidoria on the other side.",
                Treasure.Material.Bronze,
                1);

            _treasures.CoinTypes.Add(goldCoin);
            _treasures.CoinTypes.Add(silverCoin);
            _treasures.CoinTypes.Add(bronzeCoin);
        }
Пример #15
0
 public Equipment()
 {
     Treasure = new Treasure();
 }
Пример #16
0
        public void Setup()
        {
            mockPercentileSelector = new Mock<IPercentileSelector>();
            mockEncounterGenerator = new Mock<IEncounterGenerator>();
            mockTreasureGenerator = new Mock<ITreasureGenerator>();
            poolGenerator = new DomainPoolGenerator(mockPercentileSelector.Object, mockEncounterGenerator.Object, mockTreasureGenerator.Object);

            selectedPool = string.Empty;
            encounter = new Encounter();
            treasure = new Treasure();

            mockPercentileSelector.Setup(s => s.SelectFrom(TableNameConstants.Pools)).Returns(() => selectedPool);
            mockEncounterGenerator.Setup(g => g.Generate(EnvironmentConstants.Dungeon, 9266, "temperature", EnvironmentConstants.TimesOfDay.Night)).Returns(encounter);
            mockTreasureGenerator.Setup(g => g.GenerateAtLevel(9266)).Returns(treasure);
        }
Пример #17
0
        public void Setup()
        {
            mockWeaponGenerator = new Mock<IWeaponGenerator>();
            mockCollectionsSelector = new Mock<ICollectionsSelector>();
            mockArmorGenerator = new Mock<IArmorGenerator>();
            mockTreasureGenerator = new Mock<ITreasureGenerator>();
            generator = new ConfigurableIterationGenerator(3);
            equipmentGenerator = new EquipmentGenerator(mockCollectionsSelector.Object, mockWeaponGenerator.Object,
                mockTreasureGenerator.Object, mockArmorGenerator.Object, generator);
            feats = new List<Feat>();
            characterClass = new CharacterClass();
            meleeWeapon = new Item();
            rangedWeapon = new Item();
            baseRangedWeaponTypes = new List<string>();
            armor = new Item();
            treasure = new Treasure();
            race = new Race();
            shieldProficiencyFeats = new List<string>();
            weaponProficiencyFeats = new List<string>();
            npcs = new List<string>();

            characterClass.Level = 9266;
            meleeWeapon.Name = "melee weapon";
            meleeWeapon.ItemType = ItemTypeConstants.Weapon;
            meleeWeapon.Attributes = new[] { AttributeConstants.Melee };
            rangedWeapon.Name = "ranged weapon";
            rangedWeapon.ItemType = ItemTypeConstants.Weapon;
            rangedWeapon.Attributes = new[] { "not melee" };
            armor.Name = "armor";
            armor.ItemType = ItemTypeConstants.Armor;
            baseRangedWeaponTypes.Add("base ranged weapon");
            treasureItem = new Item { Name = "treasure item" };
            treasure.Items = new[] { treasureItem };

            mockWeaponGenerator.Setup(g => g.GenerateFrom(feats, characterClass, race)).Returns(meleeWeapon);
            mockWeaponGenerator.Setup(g => g.GenerateRangedFrom(feats, characterClass, race)).Returns(rangedWeapon);
            mockWeaponGenerator.Setup(g => g.GenerateMeleeFrom(feats, characterClass, race)).Returns(meleeWeapon);
            mockArmorGenerator.Setup(g => g.GenerateArmorFrom(feats, characterClass, race)).Returns(armor);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ItemGroups, It.IsAny<string>())).Returns((String table, String name) => new[] { name });
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ItemGroups, rangedWeapon.Name)).Returns(baseRangedWeaponTypes);
            mockTreasureGenerator.Setup(g => g.GenerateAtLevel(9266)).Returns(treasure);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, AttributeConstants.Shield + GroupConstants.Proficiency))
                .Returns(shieldProficiencyFeats);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, ItemTypeConstants.Weapon + GroupConstants.Proficiency))
                .Returns(weaponProficiencyFeats);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ClassNameGroups, GroupConstants.NPCs))
                .Returns(npcs);
        }
Пример #18
0
 void InitTreasure()
 {
     InitGame();
     treasures=new Treasure[row,col];
     List<int> randomN=new List<int>();
     for(int i=0;i<row*col;i++){
         randomN.Add(i);
         treasures[i/col,i%col]=new Treasure();
         unFindTreasure.Add(i);
     }
     for(int i=0;i<maxNOfTreasure;i++){
         int seed=UnityEngine.Random.Range(0,randomN.Count-1);
         treasures[randomN[seed]/col,randomN[seed]%col].isTreasure=1;
         randomN.Remove(randomN[seed]);
     }
     for(int i=0;i<row;i++){
         for(int j=0;j<col;j++){
             int num=0;
             treasures[i,j].surround=getSurroundTreasure(i,j);
             for(int k=0;k<treasures[i,j].surround.Count;k++){
                 int x=treasures[i,j].surround[k].x;
                 int y=treasures[i,j].surround[k].y;
                 num+=treasures[x,y].isTreasure;
             }
             if(treasures[i,j].isTreasure==0){
                 treasures[i,j].num=num;
                 treasures[i,j].numRemain=num;
             }
         }
     }
 }
Пример #19
0
        private void GiveTreasure(int playerId, Treasure treasure)
        {
            // Treasure may have coins
            if (treasure.Coins > 0)
            {
                eventManager.QueueEvent(EventType.GiveCoins, new GiveCoinsEventArgs(playerId, treasure.Coins));
            }

            // Treasure may have equipment
            if (treasure.Equipment != null)
            {
                eventManager.QueueEvent(EventType.GiveEquipment, new GiveEquipmentEventArgs(playerId, treasure.Equipment.Id, true));
            }

            if (treasure.IsTreasureCache)
            {
                // If treasure is a cache
                GiveTreasure(playerId, gameState.getTreasures(1, treasure.Rarity).First());
            }
            else
            {
                return; // We are done here!
            }
        }