示例#1
0
        public void SetUp()
        {
            this.logger = new ActionLog();
            GlobalConstants.ActionLog = this.logger;

            this.target = new CombatEngine(Mock.Of <IRollable>(
                                               roller => roller.RollSuccesses(
                                                   It.IsAny <int>(),
                                                   It.IsIn <int>(7)) == 1 &&
                                               roller.RollSuccesses(
                                                   It.IsAny <int>(),
                                                   It.IsNotIn(7)) == 2));
            this.statisticHandler    = new EntityStatisticHandler();
            this.skillHandler        = new EntitySkillHandler();
            this.derivedValueHandler = new DerivedValueHandler(this.statisticHandler, this.skillHandler);
            this.abilityHandler      = new AbilityHandler();

            this.materialHandler = new MaterialHandler();

            this.objectIconHandler = new ObjectIconHandler(new RNG());

            this.itemHandler = new LiveItemHandler(new RNG());

            GlobalConstants.GameManager = Mock.Of <IGameManager>(
                manager => manager.ItemHandler == this.itemHandler &&
                manager.ObjectIconHandler == this.objectIconHandler);

            this.needHandler = new NeedHandler();
        }
示例#2
0
 public DungeonItemPlacer(
     ILiveItemHandler itemHandler,
     RNG roller,
     IItemFactory itemFactory)
 {
     this.Roller      = roller;
     this.ItemHandler = itemHandler;
     this.ItemFactory = itemFactory;
 }
示例#3
0
        public QuestProvider(
            IEntityRelationshipHandler entityRelationshipHandler,
            ILiveItemHandler itemHandler,
            IItemFactory itemFactory,
            RNG roller)
        {
            this.BagOfGoldHelper           = new BagOfGoldHelper(itemHandler, itemFactory);
            this.Roller                    = roller;
            this.EntityRelationshipHandler = entityRelationshipHandler;

            this.Actions = GlobalConstants.ScriptingEngine.FetchAndInitialiseChildren <IQuestAction>().ToList();
        }
示例#4
0
        public void SetUp()
        {
            ActionLog actionLog = new ActionLog();

            GlobalConstants.ActionLog = actionLog;
            this.scriptingEngine      = new ScriptingEngine();

            this.ItemHandler = new LiveItemHandler(new RNG());
            IGameManager gameManager = Mock.Of <IGameManager>(
                manager => manager.ItemHandler == this.ItemHandler);

            GlobalConstants.GameManager = gameManager;

            this.target = new QuestTracker(this.ItemHandler);
        }
示例#5
0
 public ItemFactory(
     GUIDManager guidManager,
     IItemDatabase itemDatabase,
     ILiveItemHandler itemHandler,
     IObjectIconHandler objectIconHandler,
     IDerivedValueHandler derivedValueHandler,
     GameObjectPool <JoyObjectNode> itemPool,
     RNG roller = null)
 {
     this.GuidManager         = guidManager;
     this.ItemDatabase        = itemDatabase;
     this.ItemHandler         = itemHandler;
     this.ObjectIcons         = objectIconHandler;
     this.DerivedValueHandler = derivedValueHandler;
     this.ItemPool            = itemPool;
     this.Roller = roller is null ? new RNG() : roller;
 }
示例#6
0
        public IItemInstance GetBagOfGold(int count)
        {
            if (GlobalConstants.GameManager is null == false && ItemHandler is null)
            {
                ItemHandler = GlobalConstants.GameManager.ItemHandler;
                ItemFactory = GlobalConstants.GameManager.ItemFactory;
            }

            IItemInstance        bag   = ItemFactory.CreateRandomItemOfType(new[] { "container" }, true);
            List <IItemInstance> coins = new List <IItemInstance>();
            int gold   = count / 100;
            int silver = (count - (gold * 100)) / 10;
            int copper = (count - (gold * 100) - (silver * 10));

            if (gold > 0)
            {
                IItemInstance goldCoin = ItemFactory.CreateSpecificType("gold coin", new[] { "currency" }, true);
                for (int i = 0; i < gold; i++)
                {
                    coins.Add(goldCoin.Copy(goldCoin));
                }
            }

            if (silver > 0)
            {
                IItemInstance silverCoin = ItemFactory.CreateSpecificType("silver coin", new[] { "currency" }, true);
                for (int i = 0; i < silver; i++)
                {
                    coins.Add(silverCoin.Copy(silverCoin));
                }
            }

            if (copper > 0)
            {
                IItemInstance copperCoin = ItemFactory.CreateSpecificType("copper coin", new[] { "currency" }, true);
                for (int i = 0; i < copper; i++)
                {
                    coins.Add(copperCoin.Copy(copperCoin));
                }
            }

            bag.AddContents(coins);

            return(bag);
        }
示例#7
0
        public void SetUp()
        {
            ActionLog actionLog = new ActionLog();

            GlobalConstants.ActionLog = actionLog;
            this.scriptingEngine      = new ScriptingEngine();

            IItemInstance item = Mock.Of <IItemInstance>();

            this.overworld = Mock.Of <IWorldInstance>(
                w => w.Name == "overworld" &&
                w.GetWorlds(It.IsAny <IWorldInstance>()) == new List <IWorldInstance>
            {
                Mock.Of <IWorldInstance>(
                    instance => instance.Guid == Guid.NewGuid())
            } &&
                w.GetRandomSentientWorldWide() == Mock.Of <IEntity>(
                    entity => entity.Guid == Guid.NewGuid() &&
                    entity.MyWorld == this.world &&
                    entity.Contents == new List <IItemInstance> {
                item
            }));

            this.world = Mock.Of <IWorldInstance>(
                w => w.GetOverworld() == this.overworld &&
                w.Name == "TEST" &&
                w.Guid == Guid.NewGuid());

            this.left = Mock.Of <IEntity>(
                entity => entity.Guid == Guid.NewGuid() &&
                entity.PlayerControlled == true &&
                entity.MyWorld == this.world &&
                entity.HasDataKey(It.IsAny <string>()) == false);

            this.right = Mock.Of <IEntity>(
                entity => entity.Guid == Guid.NewGuid() &&
                entity.MyWorld == this.world &&
                entity.Contents == new List <IItemInstance> {
                item
            });

            IRelationship friendship = Mock.Of <IRelationship>(
                relationship => relationship.GetRelationshipValue(It.IsAny <Guid>(), It.IsAny <Guid>()) == 0);

            IEntityRelationshipHandler relationshipHandler = Mock.Of <IEntityRelationshipHandler>(
                handler => handler.Get(It.IsAny <IJoyObject[]>(), It.IsAny <string[]>(), It.IsAny <bool>())
                == new[] { friendship });
            ILiveItemHandler itemHandler = Mock.Of <ILiveItemHandler>(
                handler => handler.GetQuestRewards(It.IsAny <Guid>()) == new List <IItemInstance> {
                item
            });
            IItemFactory itemFactory = Mock.Of <IItemFactory>(
                factory => factory.CreateRandomItemOfType(
                    It.IsAny <string[]>(),
                    It.IsAny <bool>()) == item &&
                factory.CreateSpecificType(
                    It.IsAny <string>(),
                    It.IsAny <string[]>(),
                    It.IsAny <bool>()) == item &&
                factory.CreateRandomWeightedItem(
                    It.IsAny <bool>(),
                    It.IsAny <bool>()) == item);

            this.gameManager = Mock.Of <IGameManager>(
                manager => manager.ItemFactory == itemFactory &&
                manager.Player == this.left &&
                manager.ItemHandler == itemHandler &&
                manager.GUIDManager == new GUIDManager());

            GlobalConstants.GameManager = this.gameManager;

            this.target = new QuestProvider(
                relationshipHandler,
                itemHandler,
                itemFactory,
                new RNG());
            this.questTracker = new QuestTracker();
        }
示例#8
0
 public QuestTracker(ILiveItemHandler itemHandler = null)
 {
     this.ItemHandler = itemHandler ?? GlobalConstants.GameManager.ItemHandler;
     this.Initialise();
 }
示例#9
0
 public BagOfGoldHelper(ILiveItemHandler itemHandler, IItemFactory itemFactory)
 {
     ItemFactory = itemFactory;
     ItemHandler = itemHandler;
 }