Exemplo n.º 1
0
        public void EquippedArmorIncreasesYourDefenseAndYourFlatFootedDefenseButNotTouchDefense()
        {
            var bag       = new ComponentContainer();
            var inventory = new Inventory();

            bag.Add(inventory);
            bag.Add(new AbilityScores());
            bag.Add(new SizeStats());
            var def = new DefenseStats();

            def.Initialize(bag);
            var startAC    = def.ArmorClass.TotalValue;
            var startFlat  = def.FlatFootedArmorClass.TotalValue;
            var startTouch = def.TouchArmorClass.TotalValue;

            var armor = new Armor();

            armor.ArmorClass = 10;

            inventory.AddGear(armor);
            inventory.EquipItem(armor);
            Assert.Equal(startAC + 10, def.ArmorClass.TotalValue);
            Assert.Equal(startFlat + 10, def.FlatFootedArmorClass.TotalValue);
            Assert.Equal(startTouch, def.TouchArmorClass.TotalValue);
        }
Exemplo n.º 2
0
        public virtual void Initialize(ComponentContainer components)
        {
            foreach (var attr in this.Attributes)
            {
                var typename = attr.GetString("attribute");

                if (string.IsNullOrEmpty(typename))
                {
                    typename = "SilverNeedle.Feature";
                }

                var instance = typename.Instantiate <object>(attr);
                components.Add(instance);
            }

            foreach (var item in this.Items)
            {
                var typename = item.GetString("type");
                var instance = typename.Instantiate <object>(item);
                components.Add(instance);
            }

            foreach (var command in this.Commands)
            {
                var typename = command.GetString("command");
                var instance = typename.Instantiate <IFeatureCommand>(command);
                instance.Execute(components);
            }
        }
Exemplo n.º 3
0
 public void Initialize(ComponentContainer components)
 {
     this.usesPerDayStatistic = new BasicStat(this.UsesPerDayStatName());
     this.healingDice         = new DiceStatistic("Lay On Hands Dice", "1d6");
     components.Add(usesPerDayStatistic);
     components.Add(healingDice);
     paladinLevel = components.Get <ClassLevel>();
 }
Exemplo n.º 4
0
 public void Initialize(ComponentContainer components)
 {
     sorcererLevels = components.Get <ClassLevel>();
     coldResistance = new EnergyResistance(5, "cold");
     nonLethal      = new DamageReduction("- vs. nonlethal", 0);
     nonLethal.AddModifier(new DelegateStatModifier(
                               nonLethal.Name,
                               "level-up",
                               () => { return(sorcererLevels.Level >= 9 ? 10 : 5); }
                               ));
     components.Add(coldResistance);
     components.Add(nonLethal);
 }
Exemplo n.º 5
0
        public static void InitializeComponents(this PageControl pageControl, GameWindow window, AtomicReference <NextController> mainMenuResult, AtomicReference <Func <GameSettings> > gameSettingsProvider)
        {
            var factory = new NavigationButtonsFactory
            {
                ExpectedItems  = 3,
                FontSize       = 24,
                IdleColor      = backgroundColor,
                HighlightColor = highlightColor,
                TextColor      = textColor,
                WindowHeight   = window.Size.Y,
                Width          = navigationPanelLenght
            };

            var settingsFactory = new GameSettingsService
            {
                BackgroundColor = backgroundColor,
                ComponentColor  = componentColor,
                HighlightColor  = highlightColor,
                LeftMargin      = menuOptionsLeftMargin,
                SizeFactor      = frameSizeFactor,
                WindowSize      = window.Size,
                TextColor       = textColor,
                ComponentHeight = 40,
                ComponentMargin = 6,
                Font            = FontExtensions.Font,
                FontSize        = 24,
                TextPosition    = new Vector2f(8, 4)
            };

            var mainView      = new ComponentContainer();
            var newGameView   = new ComponentContainer();
            var optionsView   = new ComponentContainer();
            var settingsFrame = settingsFactory.NewFrame();

            pageControl.Bus.Subscribe(window);

            mainView.Add(factory.New(0, "NEW GAME", (s, e) => pageControl.Set(newGameView)));
            mainView.Add(factory.New(1, "OPTIONS", (s, e) => pageControl.Set(optionsView)));
            mainView.Add(factory.New(2, "EXIT", (s, e) => mainMenuResult.Value = NextController.Exit));

            newGameView.Add(factory.New(0, "START", (s, e) => mainMenuResult.Value = NextController.Game));
            newGameView.Add(factory.New(2, "BACK", (s, e) => pageControl.Set(mainView)));
            newGameView.Add(settingsFrame.InitializeGameSettingsFrame(settingsFactory, gameSettingsProvider));

            optionsView.Add(factory.New(2, "BACK", (s, e) => pageControl.Set(mainView)));

            pageControl.Add(mainView);
            pageControl.Add(newGameView);
            pageControl.Add(optionsView);
            pageControl.Set(mainView);
        }
Exemplo n.º 6
0
        public void StatModifiersShouldApplyToAllMatchingStatistics()
        {
            var contain = new ComponentContainer();
            var stat1   = new BasicStat("A Statistic");
            var stat2   = new BasicStat("A Statistic");

            contain.Add(stat1);
            contain.Add(stat2);

            var mod = new ValueStatModifier("A Statistic", 10, "foo");

            contain.Add(mod);
            Assert.Equal(10, stat1.TotalValue);
            Assert.Equal(10, stat2.TotalValue);
        }
Exemplo n.º 7
0
        public void IfStatModifierHasStatisticTypeSetDoNotApplyToUnmatchingTypes()
        {
            var contain = new ComponentContainer();
            var custom  = new CustomStatType("Stat");
            var stat    = new BasicStat("Stat 2");
            var mod     = new ValueStatModifier("%stat%", 10, "foo");

            mod.StatisticType = "Tests.Utility.CustomStatType";

            contain.Add(custom);
            contain.Add(stat);
            contain.Add(mod);
            Assert.Equal(10, custom.TotalValue);
            Assert.Equal(0, stat.TotalValue);
        }
Exemplo n.º 8
0
        public void CanSerializeOutTheEntitiesInTheContainerAndReloadThem()
        {
            var container = new ComponentContainer();

            container.Add(new CustomStatType("Foo"));
            container.Add(new CustomStatType("Bar"));
            var storage = new YamlObjectStore();

            storage.Serialize(container);
            var newContainer = new ComponentContainer();

            storage.Deserialize(newContainer);
            Assert.NotNull(newContainer.FindStat("Foo"));
            Assert.NotNull(newContainer.FindStat("Bar"));
        }
Exemplo n.º 9
0
 public void Initialize(ComponentContainer components)
 {
     foreach (var abl in this.abilities)
     {
         components.Add(abl.Value);
     }
 }
Exemplo n.º 10
0
        public void ThrowsExceptionIfCannotApplyModifierBecauseStatIsNotFound()
        {
            var container = new ComponentContainer();
            var mod       = new ValueStatModifier("Stat", 10, "Foo");

            Assert.Throws(typeof(StatisticNotFoundException), () => container.Add(mod));
        }
Exemplo n.º 11
0
 public void Initialize(ComponentContainer components)
 {
     foreach (var mod in Familiar.Modifiers)
     {
         components.Add(mod);
     }
 }
Exemplo n.º 12
0
        public void Execute(ComponentContainer components)
        {
            var bloodline = components.Get <Bloodline>();
            var arcana    = bloodline.BloodlineArcana.Instantiate <BloodlineArcana>();

            components.Add(arcana);
        }
Exemplo n.º 13
0
        public MovementStatsTests()
        {
            var bag30 = new ComponentContainer();

            inventory = new Inventory();
            bag30.Add(inventory);
            move30 = new MovementStats();
            bag30.Add(move30);
            move30.SetBaseSpeed(30);

            var bag20 = new ComponentContainer();

            bag20.Add(inventory);
            move20 = new MovementStats();
            bag20.Add(move20);
            move20.SetBaseSpeed(20);
        }
Exemplo n.º 14
0
        public void Initialize(ComponentContainer components)
        {
            var alignment = components.Get <CharacterAlignment>();

            if (ChoosesPositiveEnergy(alignment))
            {
                EnergyType = POSITIVE_ENERGY;
            }
            else
            {
                EnergyType = NEGATIVE_ENERGY;
            }

            components.Add(this.SaveDC);
            components.Add(this.DamageDice);
            components.Add(this.usesPerDayStatistic);
        }
Exemplo n.º 15
0
        public void IfPropertyHasAddToContainerAttributeThenMakeSureThisValueIsAdded()
        {
            var container = new ComponentContainer();
            var add       = new AddToContainerTest();

            container.Add(add);
            Assert.NotNull(container.FindStat("Add Me"));
        }
Exemplo n.º 16
0
        public static void InitializeComponents(this PageControl pageControl, GameWindow window, ResourceManager resources, TurnCycle turnCycle)
        {
            var tileset       = resources.Get <GameTilesets>().Gui;
            var mainContainer = new ComponentContainer();
            var topFrame      = new Frame
            {
                Shape = new RectangleShape
                {
                    FillColor = Color.White,
                    Size      = new Vector2f(window.Size.X, 100)
                },
                Position = new Vector2f()
            };

            mainContainer.Add(topFrame);
            pageControl.Add(mainContainer);
            pageControl.Set(mainContainer);

            var resourcesPicturesStartPosition = new Vector2f(300, 25);

            topFrame.Components.AddResourcePicture(ResourceType.Food, tileset.Food, turnCycle, resourcesPicturesStartPosition, 0);
            topFrame.Components.AddResourcePicture(ResourceType.Wood, tileset.Wood, turnCycle, resourcesPicturesStartPosition, 1);
            topFrame.Components.AddResourcePicture(ResourceType.Iron, tileset.Iron, turnCycle, resourcesPicturesStartPosition, 2);
            topFrame.Components.AddResourcePicture(ResourceType.Gems, tileset.Gems, turnCycle, resourcesPicturesStartPosition, 3);

            var bottomFrameSize     = new Vector2f(400, 40);
            var bottomFramePosition = new Vector2f(window.Size.X - bottomFrameSize.X, window.Size.Y - bottomFrameSize.Y);
            var bottomFrame         = new Frame
            {
                Shape = new RectangleShape
                {
                    FillColor = Color.White,
                    Size      = bottomFrameSize
                },
                Position = bottomFramePosition
            };

            mainContainer.Add(bottomFrame);

            var activePlayerLabel = new ActivePlayerLabel(new Vector2f(6, 0), turnCycle);
            var currentRoundLabel = new CurrentRoundLabel(new Vector2f(bottomFrameSize.X - 64, 6), turnCycle);

            bottomFrame.Components.Add(activePlayerLabel);
            bottomFrame.Components.Add(currentRoundLabel);
        }
Exemplo n.º 17
0
 public void Initialize(ComponentContainer components)
 {
     sourceLevel  = components.Get <ClassLevel>();
     initModifier = new DelegateStatModifier(
         "initiative",
         "bonus",
         () => { return((sourceLevel.Level / 2).AtLeast(1)); });
     components.Add(initModifier);
 }
Exemplo n.º 18
0
        public void LeveledUp(ComponentContainer components)
        {
            var clsLevel = components.Get <ClassLevel>();

            if (clsLevel.Level == 13 || clsLevel.Level == 17)
            {
                components.Add(LearnSpellToken.FromList("sorcerer-wizard"));
            }
        }
Exemplo n.º 19
0
        public void IfNoEquippedArmorReturnTenThousand()
        {
            var bag = new ComponentContainer();

            bag.Add(new Inventory());
            var mod = new EquippedArmorMaxDexBonuxModifier(bag);

            Assert.Equal(mod.Modifier, 10000);
        }
Exemplo n.º 20
0
        public void AddingNullComponentResultsInExceptionBeingThrown()
        {
            var contain = new ComponentContainer();

            Assert.Throws(
                typeof(System.ArgumentNullException),
                () => contain.Add(null)
                );
        }
Exemplo n.º 21
0
        public void Initialize(ComponentContainer components)
        {
            var defense = components.Get <DefenseStats>();

            defense.AddImmunity("poison");
            defense.AddDamageResistance(new EnergyResistance(10, "cold iron"));

            components.Add(new SpellBasedAbility("Shadow Walk", 1));
        }
Exemplo n.º 22
0
        public void Initialize(ComponentContainer components)
        {
            var alignment = components.Get <CharacterAlignment>();
            var good      = new FeatToken("Turn Undead", true);
            var evil      = new FeatToken("Command Undead", true);

            if (alignment.IsGood())
            {
                components.Add(good);
            }
            else if (alignment.IsEvil())
            {
                components.Add(evil);
            }
            else
            {
                components.Add(new FeatToken[] { good, evil }.ChooseOne());
            }
        }
Exemplo n.º 23
0
        public void Initialize(ComponentContainer components)
        {
            var defense = components.Get <DefenseStats>();

            defense.AddImmunity("fire");
            defense.AddImmunity("poison");
            defense.AddDamageResistance(new EnergyResistance(10, "acid"));
            defense.AddDamageResistance(new EnergyResistance(10, "cold"));
            components.Add(new Senses.PerfectDarkvision(60));
        }
Exemplo n.º 24
0
        public void Initialize(ComponentContainer components)
        {
            var def = components.Get <DefenseStats>();

            def.AddImmunity("Criticals");
            def.AddImmunity("Sneak Attacks");

            def.AddDamageResistance(new EnergyResistance(5, "-"));
            components.Add(new Blindsight(50));
        }
Exemplo n.º 25
0
        public void Execute(ComponentContainer components)
        {
            var options = _ragePowers
                          .All()
                          .GetAllQualified <RagePower>(components)
                          .Exclude(components.GetAll <RagePower>());
            var power = options.ChooseOne();

            components.Add(power);
        }
Exemplo n.º 26
0
            public void Update(EngineTime engineTime)
            {
                if (!string.IsNullOrWhiteSpace(SetTitle))
                {
                    _Engine.Form.Text = SetTitle;
                    SetTitle          = null;
                }
                if (Replacement != null)
                {
                    lock (AddQueue)
                        AddQueue.Clear();
                    _InnerContainer.Clear();
                    var l = Replacement(_Engine);
                    foreach (var c in l)
                    {
                        if (c != null)
                        {
                            _InnerContainer.Add(c);
                        }
                    }
                    Replacement = null;
                }
                EngineHelper.MultiComponentFunction[] toAdd;
                lock (AddQueue) {
                    toAdd = AddQueue.ToArray();
                    AddQueue.Clear();
                }
                foreach (var f in toAdd)
                {
                    var l = f(_Engine);
                    foreach (var c in l)
                    {
                        if (c != null)
                        {
                            _InnerContainer.Add(c);
                        }
                    }
                }


                _InnerContainer.Update(engineTime);
            }
Exemplo n.º 27
0
        public void Initialize(ComponentContainer components)
        {
            monkLevels = components.Get <ClassLevel>();
            Weapon     = new UnarmedMonk(this);
            var offense  = components.Get <OffenseStats>();
            var strength = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Strength);
            var size     = components.Get <SizeStats>().Size;

            Attack = new MeleeAttack(offense, strength, size, Weapon);
            components.Add(Attack);
        }
Exemplo n.º 28
0
        public void LeveledUp(ComponentContainer components)
        {
            var currentLevel = components.Get <ClassLevel>().Level;

            foreach (var l in levels)
            {
                if (l.Number == currentLevel)
                {
                    components.Add(l);
                }
            }
        }
Exemplo n.º 29
0
        public void AddsStatisticComponentsForScoreAndModifierToComponentBag()
        {
            var strength  = new AbilityScore(AbilityScoreTypes.Strength, 16);
            var container = new ComponentContainer();

            container.Add(strength);
            var score    = container.FindStat <IValueStatistic>("strength");
            var modifier = container.FindStat <IValueStatistic>("strength-modifier");

            Assert.Equal(16, score.TotalValue);
            Assert.Equal(3, modifier.TotalValue);
        }
Exemplo n.º 30
0
        public void Initialize(ComponentContainer components)
        {
            var draconic   = components.Get <IDraconicBloodline>();
            var dragonType = draconic.DragonType;
            var defense    = components.Get <DefenseStats>();

            defense.AddImmunity("paralysis");
            defense.AddImmunity("sleep");
            defense.AddImmunity(dragonType.EnergyType);

            components.Add(new Blindsense(60));
        }