Ejemplo n.º 1
0
        public void TestBarbarianMeleeRageExpiration()
        {
            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            History.TimeClock = new DndTimeClock();
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);
            DndGame   game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(fred);
            game.Start();

            fred.StartTurnResetState();
            AssignedFeature barbarianMelee = fred.GetFeature("BarbarianMelee");

            Assert.IsFalse(barbarianMelee.ShouldActivateNow());

            fred.ActivateFeature("WildSurgeRage");
            PlayerActionShortcut greataxe = fred.GetShortcut("Greataxe");

            fred.Use(greataxe);

            Assert.IsTrue(barbarianMelee.ShouldActivateNow());

            // Now test alarm system to turn off rage after one minute....
            History.TimeClock.Advance(DndTimeSpan.FromSeconds(59));
            Assert.IsTrue(barbarianMelee.ShouldActivateNow());
            History.TimeClock.Advance(DndTimeSpan.FromSeconds(1));
            Assert.IsFalse(barbarianMelee.ShouldActivateNow());
        }
Ejemplo n.º 2
0
        public override string printTree(string indent)
        {
            string        thisIndent      = ReferenceEquals(indent, null) ? " |-" : indent + " |-";   //$NON-NLS-1$ //$NON-NLS-2$
            string        childIndent     = ReferenceEquals(indent, null) ? " | " : indent + " | ";   //$NON-NLS-1$ //$NON-NLS-2$
            string        lastIndent      = ReferenceEquals(indent, null) ? " \\-" : indent + " \\-"; //$NON-NLS-1$ //$NON-NLS-2$
            string        lastChildIndent = ReferenceEquals(indent, null) ? "   " : indent + "   ";   //$NON-NLS-1$ //$NON-NLS-2$
            StringBuilder print           = new StringBuilder();

            print.Append("PhraseElement: category=").Append(Category.ToString()).Append(", features=");             //$NON-NLS-1$ - $NON-NLS-1$

            print.Append(AllFeatures.ToStringNLG()).Append("\n");
            IList <NLGElement> children = Children;
            int length = children.Count - 1;
            int index  = 0;

            for (index = 0; index < length; index++)
            {
                print.Append(thisIndent).Append(children[index].printTree(childIndent));
            }
            if (length >= 0)
            {
                print.Append(lastIndent).Append(children[length].printTree(lastChildIndent));
            }
            return(print.ToString());
        }
Ejemplo n.º 3
0
        public void TestBarbarianMeleeDeactivate()
        {
            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);

            game.AddPlayer(fred);
            game.Start();

            PlayerActionShortcut greataxe = fred.GetShortcut("Greataxe");

            fred.Use(greataxe);

            CharacterClass barbarianClass = fred.Classes.FirstOrDefault(x => x.Name == "Barbarian");

            Assert.IsNotNull(barbarianClass);
            barbarianClass.Level = 16;
            fred.ResetPlayerActionBasedState();

            Assert.AreEqual(0, fred.damageOffsetThisRoll);

            fred.ActivateFeature("WildSurgeRage");
            Assert.AreEqual(0, fred.damageOffsetThisRoll);
            fred.Use(greataxe);
            Assert.AreEqual(4, fred.damageOffsetThisRoll);

            AssignedFeature rageFeature = fred.GetFeature("WildSurgeRage");

            Assert.IsTrue(rageFeature.Feature.IsActive);

            Expressions.Do("Set(_rage,false)", fred);

            Assert.IsFalse(rageFeature.Feature.IsActive);
            Assert.IsFalse(fred.GetFeature("BarbarianMelee").Feature.IsActive);
            fred.Use(greataxe);
            Assert.IsFalse(fred.GetFeature("BarbarianMelee").Feature.IsActive);

            Assert.AreEqual(0, fred.damageOffsetThisRoll);


            fred.ActivateFeature("WildSurgeRage");
            Assert.IsTrue(fred.GetFeature("BarbarianMelee").Feature.IsActive);
            Assert.AreEqual(4, fred.damageOffsetThisRoll);

            fred.DeactivateFeature("WildSurgeRage");
            Assert.IsFalse(fred.GetFeature("BarbarianMelee").Feature.IsActive);
            Assert.AreEqual(0, fred.damageOffsetThisRoll);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string _filePath = @"c:\Users\Jason Hiskey\Documents\codefellows\#401\labs\DN_Lab08_LINQ_In_Manhattan\DN_Lab08_LINQ_In_Manhattan\DN_Lab08_LINQ_In_Manhattan\assets\data.json";

            JObject jObject = CreateJsonObject(_filePath);

            AllFeatures masterList = new AllFeatures();

            masterList = ParseJsonObjectToDotNetObject(jObject);

            Query(masterList);

            Console.ReadLine();
        }
Ejemplo n.º 5
0
        public void LoadData(string csv)
        {
            FeatureNames.Clear();
            AllFeatures.Clear();
            data         = LoadCSV(csv);
            ActiveData   = new DataSet();
            FeatureNames = data[0].ToList();
            FeatureNames.Remove(FeatureNames[FeatureNames.Count - 1]);// target feature
            for (int i = 0; i < FeatureNames.Count; i++)
            {
                AllFeatures.Add(i);
            }

            data.RemoveAt(0);
        }
Ejemplo n.º 6
0
        private static Character StartNewGame(string playerClass, int level, string weapon = null)
        {
            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character player = PlayerHelper.GetPlayerAtLevel(playerClass, level);

            game.AddPlayer(player);
            if (weapon != null)
            {
                player.AddWeapon(weapon);
            }
            game.Start();
            return(player);
        }
Ejemplo n.º 7
0
        public void TestLoad()
        {
            AllPlayers.Invalidate();
            Feature barbarianMelee = AllFeatures.Get("BarbarianMelee");

            Assert.IsNotNull(barbarianMelee);
            Character fred = AllPlayers.GetFromId(PlayerID.Fred);
            DndGame   game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(fred);
            game.Start();

            fred.StartTurnResetState();

            Assert.IsFalse(Expressions.GetBool("BarbarianMelee(strength)", fred));
            //Expressions.LogHistory = true;
            Expressions.Do("Set(_rage,true)", fred);
            Assert.IsFalse(Expressions.GetBool("BarbarianMelee(strength)", fred));
            fred.GetAttackingAbilityModifier(WeaponProperties.Melee, AttackType.Melee);
            Assert.IsTrue(Expressions.GetBool("BarbarianMelee(strength)", fred));
        }
Ejemplo n.º 8
0
        public void TestSpellRangeTest()
        {
            Spell chaosBolt = AllSpells.Get(SpellNames.ChaosBolt);

            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character sorcerer = PlayerHelper.GetPlayerAtLevel("Sorcerer", 6);

            sorcerer.name = "Mark";
            game.AddPlayer(sorcerer);
            Monster joe = MonsterBuilder.BuildVineBlight("Joe");

            game.AddCreature((Creature)joe);
            game.Start();

            PositionCreatures(@"
┌───────────────┐
│               │
│               │
│           M   │
│               │
│               └───────────────┐
│                               │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           J   │
│               │
│               │
│               │
│               │
└───────────────┘", game.AllCreatures);
            Assert.AreEqual(40, sorcerer.CanCast(chaosBolt).DistanceTo(joe));
            Assert.IsTrue(sorcerer.CanCast(chaosBolt).At(joe));


            PositionCreatures(@"
┌───────────────┐
│               │
│               │
│           M   │
│               │
│               └───────────────┐
│                               │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           J   │
│               │
│               │
│               │
│               │
└───────────────┘", game.AllCreatures);

            Assert.AreEqual(125, sorcerer.CanCast(chaosBolt).DistanceTo(joe));
            Assert.IsFalse(sorcerer.CanCast(chaosBolt).At(joe));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Runs queries
        /// </summary>
        /// <param name="allFeatures"></param>
        static void Query(AllFeatures allFeatures)
        {
            //Query One
            var allNeighborhoods = allFeatures.Features.Select(x => x.Properties.Neighborhood);

            Console.WriteLine();
            Console.WriteLine("Query 1) Output all Neighborhoods. LAMBDA");
            Console.WriteLine();

            foreach (string neighborhood in allNeighborhoods)
            {
                if (neighborhood.Equals(""))
                {
                    Console.Write("NO NAME");
                }
                Console.Write($"{neighborhood}, ");
            }

            Console.WriteLine();
            Console.WriteLine();

            //Query Two
            var namedNeighborhoods = allNeighborhoods.Where(x => x != "");

            Console.WriteLine("Query 2) Filter out neighborhoods that dont have a name. LAMBDA");
            Console.WriteLine();

            foreach (string namedNeighborhood in namedNeighborhoods)
            {
                Console.Write($"{namedNeighborhood}, ");
            }

            Console.WriteLine();
            Console.WriteLine();

            //Query Three
            var uniqueNeighborhoods = namedNeighborhoods.Distinct();

            Console.WriteLine("Query 3) Only prints neighborhoods that have a unique name. LAMBDA");
            Console.WriteLine();

            foreach (string uniqueNeighborhood in uniqueNeighborhoods)
            {
                Console.Write($"{uniqueNeighborhood}, ");
            }

            Console.WriteLine();
            Console.WriteLine();

            //Query Four
            var allFiltersNeighborhoodsLambda = allFeatures.Features.Where(x => x.Properties.Neighborhood != "").Select(x => x.Properties.Neighborhood).Distinct();

            Console.WriteLine("Query 4) Only prints neighborhoods that have a unique name and filters out neigborhoods that have no name. LAMBDA");
            Console.WriteLine();

            foreach (string filteredNeighborhoodLambda in allFiltersNeighborhoodsLambda)
            {
                Console.Write($"{filteredNeighborhoodLambda}, ");
            }

            Console.WriteLine();
            Console.WriteLine();

            //Query Five
            var allFiltersNeighborhoodsLinq = (from item in allFeatures.Features
                                               where item.Properties.Neighborhood != ""
                                               select item.Properties.Neighborhood).Distinct();

            Console.WriteLine("Query 5) Only prints neighborhoods that have a unique name and filters out neigborhoods that have no name. LINQ");
            Console.WriteLine();

            foreach (string filteredNeigborhoodLinq in allFiltersNeighborhoodsLinq)
            {
                Console.Write($"{filteredNeigborhoodLinq}, ");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Takes JObject and converts it to .NET object.
        /// </summary>
        /// <param name="jsonData"></param>
        /// <returns>Object</returns>
        public static AllFeatures ParseJsonObjectToDotNetObject(JObject jsonData)
        {
            AllFeatures allFeatures = jsonData.ToObject <AllFeatures>();

            return(allFeatures);
        }