コード例 #1
0
ファイル: DelveBuilder.cs プロジェクト: cmdrmander/Manderplan
        private static SkillChallenge select_challenge(AutoBuildData data)
        {
            List <SkillChallenge> skillChallenges = new List <SkillChallenge>();
            int level = data.Level - 3;
            int num   = data.Level + 5;

            skillChallenges.Clear();
            foreach (SkillChallenge skillChallenge in Session.SkillChallenges)
            {
                if (skillChallenge.Level != -1)
                {
                    if (skillChallenge.Level < level || skillChallenge.Level > num)
                    {
                        continue;
                    }
                    skillChallenges.Add(skillChallenge.Copy() as SkillChallenge);
                }
                else
                {
                    SkillChallenge level1 = skillChallenge.Copy() as SkillChallenge;
                    level1.Level = Session.Project.Party.Level;
                    skillChallenges.Add(level1);
                }
            }
            if (skillChallenges.Count == 0)
            {
                return(null);
            }
            int num1 = Session.Random.Next() % skillChallenges.Count;

            return(skillChallenges[num1]);
        }
コード例 #2
0
 public void Analyse(SkillChallenge sc)
 {
     this.fBreakdown                 = new Dictionary <string, int>();
     this.fBreakdown["Strength"]     = 0;
     this.fBreakdown["Constitution"] = 0;
     this.fBreakdown["Dexterity"]    = 0;
     this.fBreakdown["Intelligence"] = 0;
     this.fBreakdown["Wisdom"]       = 0;
     this.fBreakdown["Charisma"]     = 0;
     foreach (SkillChallengeData skill in sc.Skills)
     {
         if (skill.Type == SkillType.AutoFail)
         {
             continue;
         }
         string str = "";
         str = (!Skills.GetAbilityNames().Contains(skill.SkillName) ? Skills.GetKeyAbility(skill.SkillName) : skill.SkillName);
         if (!this.fBreakdown.ContainsKey(str))
         {
             continue;
         }
         Dictionary <string, int> item = this.fBreakdown;
         Dictionary <string, int> strs = item;
         string str1 = str;
         item[str1] = strs[str1] + 1;
     }
     base.Invalidate();
 }
コード例 #3
0
        public static SkillChallenge FindSkillChallenge(Guid sc_id, SearchType search_type)
        {
            if ((search_type == SearchType.External) || (search_type == SearchType.Global))
            {
                foreach (Library lib in Libraries)
                {
                    SkillChallenge sc = lib.FindSkillChallenge(sc_id);
                    if (sc != null)
                    {
                        return(sc);
                    }
                }
            }

            if ((search_type == SearchType.Project) || (search_type == SearchType.Global))
            {
                if (Project != null)
                {
                    SkillChallenge sc = Project.Library.FindSkillChallenge(sc_id);
                    if (sc != null)
                    {
                        return(sc);
                    }
                }
            }

            return(null);
        }
コード例 #4
0
        public void ShowSkillChallenge(SkillChallenge sc)
        {
            string str = HTML.SkillChallenge(sc, false, true, PlayerViewForm.DisplaySize);

            this.set_html(str);
            base.Show();
        }
コード例 #5
0
ファイル: DelveBuilder.cs プロジェクト: andyaiken/masterplan
        static SkillChallenge select_challenge(AutoBuildData data)
        {
            List <SkillChallenge> challenges = new List <SkillChallenge>();

            int min_level = data.Level - 3;
            int max_level = data.Level + 5;

            challenges.Clear();
            foreach (SkillChallenge sc in Session.SkillChallenges)
            {
                if (sc.Level == -1)
                {
                    SkillChallenge challenge = sc.Copy() as SkillChallenge;
                    challenge.Level = Session.Project.Party.Level;
                    challenges.Add(challenge);
                }
                else
                {
                    if ((sc.Level < min_level) || (sc.Level > max_level))
                    {
                        continue;
                    }

                    challenges.Add(sc.Copy() as SkillChallenge);
                }
            }

            if (challenges.Count != 0)
            {
                int index = Session.Random.Next() % challenges.Count;
                return(challenges[index]);
            }

            return(null);
        }
コード例 #6
0
ファイル: Session.cs プロジェクト: cmdrmander/Manderplan
        public static Library FindLibrary(SkillChallenge sc)
        {
            Library library;

            if (sc == null)
            {
                return(null);
            }
            foreach (Library library1 in Session.Libraries)
            {
                foreach (SkillChallenge skillChallenge in library1.SkillChallenges)
                {
                    if (skillChallenge == null || !(skillChallenge.ID == sc.ID))
                    {
                        continue;
                    }
                    library = library1;
                    return(library);
                }
            }
            if (Session.fProject != null)
            {
                foreach (SkillChallenge skillChallenge1 in Session.fProject.Library.SkillChallenges)
                {
                    if (skillChallenge1 == null || !(skillChallenge1.ID == sc.ID))
                    {
                        continue;
                    }
                    library = Session.fProject.Library;
                    return(library);
                }
            }
            return(null);
        }
コード例 #7
0
        public void ShowSkillChallenge(SkillChallenge sc)
        {
            string html = HTML.SkillChallenge(sc, false, true, Session.Preferences.PlayerViewTextSize);

            set_html(html);

            Show();
        }
コード例 #8
0
        public SkillChallengeDetailsForm(SkillChallenge sc)
        {
            InitializeComponent();

            fChallenge = sc.Copy() as SkillChallenge;

            Browser.DocumentText = HTML.SkillChallenge(fChallenge, false, true, Session.Preferences.TextSize);
        }
コード例 #9
0
 public static IDictionary <string, object> ToDictionary(this SkillChallenge skillChallenge)
 {
     return(new Dictionary <string, object>()
     {
         { "coord", new Dictionary <string, double>()
           {
               { "x", skillChallenge.Coordinates.X },
               { "y", skillChallenge.Coordinates.Y }
           } }
     });
 }
コード例 #10
0
        public void ShouldGetSpecificSkillChallenge()
        {
            Continent continent = GW2Api.V2().Continents.GetById(1);
            Floor floor = continent.Floors[2].Value;
            Region region = floor.Regions["1"];
            Map map = region.Maps["26"];
            SkillChallenge skillChallange = map.SkillChallenges.First();

            Assert.AreEqual(20381.6m, skillChallange.Coordinate.X);
            Assert.AreEqual(16613.8m, skillChallange.Coordinate.Y);
        }
コード例 #11
0
ファイル: DelveBuilder.cs プロジェクト: cmdrmander/Manderplan
        private static SkillChallenge get_challenge(Map map, MapArea ma, AutoBuildData data)
        {
            SkillChallenge d = DelveBuilder.select_challenge(data);

            if (d == null)
            {
                return(null);
            }
            d.MapID     = map.ID;
            d.MapAreaID = ma.ID;
            return(d);
        }
コード例 #12
0
        private static bool add_challenge(Encounter enc)
        {
            if (EncounterBuilder.fChallenges.Count == 0)
            {
                return(false);
            }
            int            num  = Session.Random.Next() % EncounterBuilder.fChallenges.Count;
            SkillChallenge item = EncounterBuilder.fChallenges[num];

            enc.SkillChallenges.Add(item.Copy() as SkillChallenge);
            return(true);
        }
コード例 #13
0
        static bool add_challenge(Encounter enc)
        {
            if (fChallenges.Count != 0)
            {
                int            index = Session.Random.Next() % fChallenges.Count;
                SkillChallenge sc    = fChallenges[index];
                enc.SkillChallenges.Add(sc.Copy() as SkillChallenge);

                return(true);
            }

            return(false);
        }
コード例 #14
0
ファイル: DelveBuilder.cs プロジェクト: andyaiken/masterplan
        static SkillChallenge get_challenge(Map map, MapArea ma, AutoBuildData data)
        {
            SkillChallenge sc = select_challenge(data);

            if (sc != null)
            {
                sc.MapID     = map.ID;
                sc.MapAreaID = ma.ID;

                return(sc);
            }

            return(null);
        }
コード例 #15
0
        public SkillChallengeBuilderForm(SkillChallenge sc)
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);

            fChallenge = sc.Copy() as SkillChallenge;

            update_all();

            List <string> skill_names = Skills.GetSkillNames();

            foreach (string skill in skill_names)
            {
                string ability = Skills.GetKeyAbility(skill).Substring(0, 3);
                string abbr    = ability.Substring(0, 3);

                ListViewItem lvi = SkillSourceList.Items.Add(skill);
                ListViewItem.ListViewSubItem lvsi = lvi.SubItems.Add(abbr);
                lvi.UseItemStyleForSubItems = false;
                lvsi.ForeColor = SystemColors.GrayText;
                lvi.Group      = SkillSourceList.Groups[0];
            }

            List <string> ability_names = Skills.GetAbilityNames();

            foreach (string ability in ability_names)
            {
                string abbr = ability.Substring(0, 3);

                ListViewItem lvi = SkillSourceList.Items.Add(ability);
                ListViewItem.ListViewSubItem lvsi = lvi.SubItems.Add(abbr);
                lvi.UseItemStyleForSubItems = false;
                lvsi.ForeColor = SystemColors.GrayText;
                lvi.Group      = SkillSourceList.Groups[1];
            }

            // Custom
            ListViewItem lvi_custom = SkillSourceList.Items.Add("(custom skill)");

            ListViewItem.ListViewSubItem lvsi_custom = lvi_custom.SubItems.Add("");
            lvi_custom.UseItemStyleForSubItems = false;
            lvsi_custom.ForeColor = SystemColors.GrayText;
            lvi_custom.Group      = SkillSourceList.Groups[2];
        }
コード例 #16
0
ファイル: Session.cs プロジェクト: cmdrmander/Manderplan
        public static SkillChallenge FindSkillChallenge(Guid sc_id, SearchType search_type)
        {
            SkillChallenge skillChallenge;
            SkillChallenge skillChallenge1;

            if (search_type == SearchType.External || search_type == SearchType.Global)
            {
                List <Library> .Enumerator enumerator = Session.Libraries.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        SkillChallenge skillChallenge2 = enumerator.Current.FindSkillChallenge(sc_id);
                        if (skillChallenge2 == null)
                        {
                            continue;
                        }
                        skillChallenge1 = skillChallenge2;
                        return(skillChallenge1);
                    }
                    if ((search_type == SearchType.Project || search_type == SearchType.Global) && Session.Project != null)
                    {
                        skillChallenge = Session.Project.Library.FindSkillChallenge(sc_id);
                        if (skillChallenge != null)
                        {
                            return(skillChallenge);
                        }
                    }
                    return(null);
                }
                finally
                {
                    ((IDisposable)enumerator).Dispose();
                }
            }
            if ((search_type == SearchType.Project || search_type == SearchType.Global) && Session.Project != null)
            {
                skillChallenge = Session.Project.Library.FindSkillChallenge(sc_id);
                if (skillChallenge != null)
                {
                    return(skillChallenge);
                }
            }
            return(null);
        }
コード例 #17
0
        public void EntitySubregionWithSkillChallengeToDictionary()
        {
            SkillChallenge skillChallenge = new SkillChallenge()
            {
                Coordinates = new Point2D(10, 20)
            };
            Subregion subregion = new Subregion()
            {
                SkillChallenges = new List <SkillChallenge>()
                {
                    skillChallenge
                }
            };

            var expected = skillChallenge.ToDictionary();
            var actualPointOfInterest = (ICollection <object>)subregion.ToDictionary()["skill_challenges"];
            var actual = (IDictionary <string, object>)actualPointOfInterest.First();

            Assert.AreEqual(expected, actual);
        }
コード例 #18
0
        public static Library FindLibrary(SkillChallenge sc)
        {
            if (sc == null)
            {
                return(null);
            }

            foreach (Library lib in Libraries)
            {
                foreach (SkillChallenge item in lib.SkillChallenges)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.ID == sc.ID)
                    {
                        return(lib);
                    }
                }
            }

            if (fProject != null)
            {
                foreach (SkillChallenge item in fProject.Library.SkillChallenges)
                {
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.ID == sc.ID)
                    {
                        return(fProject.Library);
                    }
                }
            }

            return(null);
        }
コード例 #19
0
        public void Analyse(SkillChallenge sc)
        {
            fBreakdown = new Dictionary <string, int>();

            fBreakdown["Strength"]     = 0;
            fBreakdown["Constitution"] = 0;
            fBreakdown["Dexterity"]    = 0;
            fBreakdown["Intelligence"] = 0;
            fBreakdown["Wisdom"]       = 0;
            fBreakdown["Charisma"]     = 0;

            foreach (SkillChallengeData scd in sc.Skills)
            {
                if (scd.Type == SkillType.AutoFail)
                {
                    continue;
                }

                string ability = "";

                if (Skills.GetAbilityNames().Contains(scd.SkillName))
                {
                    ability = scd.SkillName;
                }
                else
                {
                    ability = Skills.GetKeyAbility(scd.SkillName);
                }

                if (!fBreakdown.ContainsKey(ability))
                {
                    continue;
                }

                fBreakdown[ability] += 1;
            }

            Invalidate();
        }
コード例 #20
0
        public void EntitySkillChallengeToDictionary()
        {
            Point2D coord = new Point2D(500, 1000);

            var expected = new Dictionary <string, object>()
            {
                { "coord", new Dictionary <string, double>()
                  {
                      { "x", coord.X },
                      { "y", coord.Y }
                  } },
            };

            SkillChallenge skillChallenge = new SkillChallenge()
            {
                Coordinates = coord,
            };

            var actual = skillChallenge.ToDictionary();

            Assert.AreEqual(expected, actual, "Skill Challenge");
            CollectionAssert.AreEquivalent((IDictionary <string, double>)expected["coord"],
                                           (IDictionary <string, double>)actual["coord"], "Coords");
        }
コード例 #21
0
ファイル: DelveBuilder.cs プロジェクト: andyaiken/masterplan
        static Encounter get_encounter(Map map, MapArea ma, AutoBuildData data)
        {
            // Set up the encounter
            Encounter enc = new Encounter();

            enc.MapID     = map.ID;
            enc.MapAreaID = ma.ID;
            EncounterBuilder.Build(data, enc, false);

            Difficulty diff = enc.GetDifficulty(Session.Project.Party.Level, Session.Project.Party.Size);

            if (diff != Difficulty.Extreme)
            {
                // Add a trap or skill challenge
                switch (Session.Random.Next() % 6)
                {
                case 0:
                case 1:
                case 3:
                    // Add a trap
                    Trap t = select_trap(data);
                    if (t != null)
                    {
                        enc.Traps.Add(t);
                    }
                    break;

                case 4:
                    // Add a skill challenge
                    SkillChallenge sc = select_challenge(data);
                    if (sc != null)
                    {
                        enc.SkillChallenges.Add(sc);
                    }
                    break;

                default:
                    // Don't add anything else
                    break;
                }
            }

            // Make matrix of tile squares
            List <Rectangle> tiles = new List <Rectangle>();

            foreach (TileData td in map.Tiles)
            {
                Tile t      = Session.FindTile(td.TileID, SearchType.Global);
                int  width  = (td.Rotations % 2 == 0) ? t.Size.Width : t.Size.Height;
                int  height = (td.Rotations % 2 == 0) ? t.Size.Height : t.Size.Width;
                Size sz     = new Size(width, height);

                Rectangle rect = new Rectangle(td.Location, sz);
                tiles.Add(rect);
            }
            Dictionary <Point, bool> matrix = new Dictionary <Point, bool>();

            for (int x = ma.Region.Left; x != ma.Region.Right; ++x)
            {
                for (int y = ma.Region.Top; y != ma.Region.Bottom; ++y)
                {
                    Point pt = new Point(x, y);

                    // Is there a tile at this location?
                    bool open = false;
                    foreach (Rectangle rect in tiles)
                    {
                        if (rect.Contains(pt))
                        {
                            open = true;
                            break;
                        }
                    }
                    matrix[pt] = open;
                }
            }

            // Place creatures on the map
            foreach (EncounterSlot slot in enc.Slots)
            {
                ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                int       size     = Creature.GetSize(creature.Size);

                foreach (CombatData cd in slot.CombatData)
                {
                    // Find candidate points
                    List <Point> candidates = new List <Point>();
                    for (int x = ma.Region.Left; x != ma.Region.Right; ++x)
                    {
                        for (int y = ma.Region.Top; y != ma.Region.Bottom; ++y)
                        {
                            Point pt = new Point(x, y);

                            // Is this location free?
                            bool all_open = true;
                            for (int dx = pt.X; dx != pt.X + size; ++dx)
                            {
                                for (int dy = pt.Y; dy != pt.Y + size; ++dy)
                                {
                                    Point loc = new Point(dx, dy);
                                    if ((!matrix.ContainsKey(loc)) || (!matrix[loc]))
                                    {
                                        all_open = false;
                                    }
                                }
                            }

                            if (all_open)
                            {
                                candidates.Add(pt);
                            }
                        }
                    }

                    if (candidates.Count != 0)
                    {
                        int   index = Session.Random.Next() % candidates.Count;
                        Point loc   = candidates[index];

                        // Place creature
                        cd.Location = loc;

                        // This space is now occupied
                        for (int x = loc.X; x != loc.X + size; ++x)
                        {
                            for (int y = loc.Y; y != loc.Y + size; ++y)
                            {
                                Point pt = new Point(x, y);
                                matrix[pt] = false;
                            }
                        }
                    }
                }
            }

            // Set up notes

            enc.SetStandardEncounterNotes();
            EncounterNote light_note = enc.FindNote("Illumination");

            if (light_note != null)
            {
                int n = Session.Random.Next(6);
                switch (n)
                {
                case 0:
                case 1:
                case 2:
                    light_note.Contents = "The area is in bright light.";
                    break;

                case 3:
                case 4:
                    light_note.Contents = "The area is in dim light.";
                    break;

                case 5:
                    light_note.Contents = "None.";
                    break;
                }
            }

            EncounterNote victory_note = enc.FindNote("Victory Conditions");

            if (victory_note != null)
            {
                List <string> candidates = new List <string>();

                List <string> leaders     = new List <string>();
                bool          has_minions = false;
                int           non_minions = 0;
                foreach (EncounterSlot slot in enc.Slots)
                {
                    if (slot.CombatData.Count == 1)
                    {
                        if ((slot.Card.Leader) || (slot.Card.Flag == RoleFlag.Elite) || (slot.Card.Flag == RoleFlag.Solo))
                        {
                            leaders.Add(slot.CombatData[0].DisplayName);
                        }
                    }

                    ICreature c = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                    if (c != null)
                    {
                        if (c.Role is Minion)
                        {
                            has_minions = true;
                        }
                        else
                        {
                            non_minions += slot.CombatData.Count;
                        }
                    }
                }

                if (leaders.Count != 0)
                {
                    int    index  = Session.Random.Next() % leaders.Count;
                    string leader = leaders[index];

                    if (Session.Random.Next() % 12 == 0)
                    {
                        candidates.Add("Defeat " + leader + ".");
                        candidates.Add("Capture " + leader + ".");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        int rounds = Session.Dice(2, 4);
                        candidates.Add("The party must defeat " + leader + " within " + rounds + " rounds.");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        int rounds = Session.Dice(2, 4);
                        candidates.Add("After " + rounds + ", " + leader + " will flee or surrender.");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        int hp = 10 * Session.Dice(1, 4);
                        candidates.Add("At " + hp + "% HP, " + leader + " will flee or surrender.");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        candidates.Add("The party must obtain an item from " + leader + ".");
                    }

                    if (Session.Random.Next() % 12 == 0)
                    {
                        candidates.Add("Defeat " + leader + " by destroying a guarded object in the area.");
                    }

                    if (has_minions)
                    {
                        candidates.Add("Minions will flee or surrender when " + leader + " is defeated.");
                    }
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    int rounds = 2 + Session.Random.Next() % 4;
                    candidates.Add("The party must defeat their opponents within " + rounds + " rounds.");
                }

                if ((has_minions) && (Session.Random.Next() % 12 == 0))
                {
                    int waves = 2 + Session.Random.Next() % 4;
                    candidates.Add("The party must defend a certain area from " + waves + " waves of minions.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    int rounds = 2 + Session.Random.Next() % 4;
                    candidates.Add("At least one character must get to a certain area and stay there for " + rounds + " consecutive rounds.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    int rounds = 2 + Session.Random.Next() % 4;
                    candidates.Add("The party must leave the area within " + rounds + " rounds.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must keep the enemy away from a certain area for the duration of the encounter.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must escort an NPC safely through the encounter area.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must rescue an NPC from their opponents.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must avoid contact with the enemy in this area.");
                }

                if (Session.Random.Next() % 12 == 0)
                {
                    candidates.Add("The party must attack and destroy a feature of the area.");
                }

                if (non_minions > 1)
                {
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int n = 1 + Session.Random.Next(non_minions);
                        candidates.Add("The party must defeat " + n + " non-minion opponents.");
                    }
                }

                if (candidates.Count != 0)
                {
                    // Select an option
                    int index = Session.Random.Next() % candidates.Count;
                    victory_note.Contents = candidates[index];
                }
            }

            return(enc);
        }
コード例 #22
0
ファイル: OverviewForm.cs プロジェクト: andyaiken/masterplan
        private void ItemList_DoubleClick(object sender, EventArgs e)
        {
            switch (fType)
            {
            case OverviewType.Encounters:
            {
                if (SelectedEncounter != null)
                {
                    int level = Workspace.GetPartyLevel(SelectedEncounter.First);

                    EncounterBuilderForm dlg = new EncounterBuilderForm(SelectedEncounter.Second, level, false);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        SelectedEncounter.First.Element = dlg.Encounter;
                        Session.Modified = true;

                        update_list();
                    }

                    return;
                }
            }
            break;

            case OverviewType.Traps:
            {
                if (SelectedTrap != null)
                {
                    if (SelectedTrap.First.Element is TrapElement)
                    {
                        TrapElement te = SelectedTrap.First.Element as TrapElement;

                        TrapBuilderForm dlg = new TrapBuilderForm(SelectedTrap.Second);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            te.Trap          = dlg.Trap;
                            Session.Modified = true;

                            update_list();
                        }

                        return;
                    }

                    if (SelectedTrap.First.Element is Encounter)
                    {
                        Encounter enc   = SelectedTrap.First.Element as Encounter;
                        int       index = enc.Traps.IndexOf(SelectedTrap.Second);

                        TrapBuilderForm dlg = new TrapBuilderForm(SelectedTrap.Second);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            enc.Traps[index] = dlg.Trap;
                            Session.Modified = true;

                            update_list();
                        }

                        return;
                    }
                }
            }
            break;

            case OverviewType.SkillChallenges:
            {
                if (SelectedChallenge != null)
                {
                    if (SelectedChallenge.First.Element is SkillChallenge)
                    {
                        SkillChallenge sc = SelectedChallenge.First.Element as SkillChallenge;

                        SkillChallengeBuilderForm dlg = new SkillChallengeBuilderForm(SelectedChallenge.Second);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            sc.Name       = dlg.SkillChallenge.Name;
                            sc.Level      = dlg.SkillChallenge.Level;
                            sc.Complexity = dlg.SkillChallenge.Complexity;
                            sc.Success    = dlg.SkillChallenge.Success;
                            sc.Failure    = dlg.SkillChallenge.Failure;

                            sc.Skills.Clear();
                            foreach (SkillChallengeData scd in dlg.SkillChallenge.Skills)
                            {
                                sc.Skills.Add(scd.Copy());
                            }

                            Session.Modified = true;

                            update_list();
                        }

                        return;
                    }

                    if (SelectedChallenge.First.Element is Encounter)
                    {
                        Encounter enc   = SelectedChallenge.First.Element as Encounter;
                        int       index = enc.SkillChallenges.IndexOf(SelectedChallenge.Second);

                        SkillChallengeBuilderForm dlg = new SkillChallengeBuilderForm(SelectedChallenge.Second);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            enc.SkillChallenges[index] = dlg.SkillChallenge;
                            Session.Modified           = true;

                            update_list();
                        }

                        return;
                    }
                }
            }
            break;

            case OverviewType.Treasure:
            {
                if (SelectedParcel != null)
                {
                    int index = SelectedParcel.First.Parcels.IndexOf(SelectedParcel.Second);

                    ParcelForm dlg = new ParcelForm(SelectedParcel.Second);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        SelectedParcel.First.Parcels[index] = dlg.Parcel;
                        Session.Modified = true;

                        update_list();
                    }

                    return;
                }
            }
            break;
            }
        }
コード例 #23
0
ファイル: OverviewForm.cs プロジェクト: andyaiken/masterplan
        void update_list()
        {
            ItemList.Items.Clear();

            switch (fType)
            {
            case OverviewType.Encounters:
            {
                foreach (PlotPoint pp in fPoints)
                {
                    if (pp.Element == null)
                    {
                        continue;
                    }

                    if (pp.Element is Encounter)
                    {
                        Encounter enc = pp.Element as Encounter;

                        string creatures = "";
                        foreach (EncounterSlot slot in enc.AllSlots)
                        {
                            if (creatures != "")
                            {
                                creatures += ", ";
                            }

                            creatures += slot.Card.Title;
                            if (slot.CombatData.Count != 1)
                            {
                                creatures += " (x" + slot.CombatData.Count + ")";
                            }
                        }

                        foreach (Trap trap in enc.Traps)
                        {
                            if (creatures != "")
                            {
                                creatures += ", ";
                            }

                            creatures += trap.Name;
                        }

                        ListViewItem lvi = ItemList.Items.Add(pp.Name);
                        lvi.SubItems.Add(enc.GetXP() + " XP; " + creatures);
                        lvi.Tag = new Pair <PlotPoint, Encounter>(pp, enc);
                    }
                }
            }
            break;

            case OverviewType.Traps:
            {
                foreach (PlotPoint pp in fPoints)
                {
                    if (pp.Element == null)
                    {
                        continue;
                    }

                    if (pp.Element is TrapElement)
                    {
                        TrapElement te = pp.Element as TrapElement;

                        ListViewItem lvi = ItemList.Items.Add(pp.Name);
                        lvi.SubItems.Add(Experience.GetCreatureXP(te.Trap.Level) + " XP; " + te.Trap.Name);
                        lvi.Tag = new Pair <PlotPoint, Trap>(pp, te.Trap);
                    }

                    if (pp.Element is Encounter)
                    {
                        Encounter enc = pp.Element as Encounter;

                        foreach (Trap trap in enc.Traps)
                        {
                            ListViewItem lvi = ItemList.Items.Add(pp.Name);
                            lvi.SubItems.Add(Experience.GetCreatureXP(trap.Level) + " XP; " + trap.Name);
                            lvi.Tag = new Pair <PlotPoint, Trap>(pp, trap);
                        }
                    }
                }
            }
            break;

            case OverviewType.SkillChallenges:
            {
                foreach (PlotPoint pp in fPoints)
                {
                    if (pp.Element == null)
                    {
                        continue;
                    }

                    if (pp.Element is SkillChallenge)
                    {
                        SkillChallenge sc = pp.Element as SkillChallenge;

                        ListViewItem lvi = ItemList.Items.Add(pp.Name);
                        lvi.SubItems.Add(sc.GetXP() + " XP");
                        lvi.Tag = new Pair <PlotPoint, SkillChallenge>(pp, sc);
                    }

                    if (pp.Element is Encounter)
                    {
                        Encounter enc = pp.Element as Encounter;

                        foreach (SkillChallenge sc in enc.SkillChallenges)
                        {
                            ListViewItem lvi = ItemList.Items.Add(pp.Name);
                            lvi.SubItems.Add(sc.GetXP() + " XP");
                            lvi.Tag = new Pair <PlotPoint, SkillChallenge>(pp, sc);
                        }
                    }
                }
            }
            break;

            case OverviewType.Treasure:
            {
                foreach (PlotPoint pp in fPoints)
                {
                    foreach (Parcel parcel in pp.Parcels)
                    {
                        string name = (parcel.Name != "") ? parcel.Name : "(undefined parcel)";

                        ListViewItem lvi = ItemList.Items.Add(pp.Name);
                        lvi.SubItems.Add(name + ": " + parcel.Details);
                        lvi.Tag = new Pair <PlotPoint, Parcel>(pp, parcel);
                    }
                }
            }
            break;
            }

            if (ItemList.Items.Count == 0)
            {
                ListViewItem lvi = ItemList.Items.Add("(no items)");
                lvi.ForeColor = SystemColors.GrayText;
            }

            ItemList.Sort();
        }
コード例 #24
0
ファイル: PlotPointForm.cs プロジェクト: andyaiken/masterplan
        void element_select(object sender, WebBrowserNavigatingEventArgs e)
        {
            int level = get_party_level();

            if (e.Url.LocalPath == "encounter")
            {
                // Add an encounter
                Encounter enc = new Encounter();
                enc.SetStandardEncounterNotes();
                fPoint.Element = enc;

                update_element();
            }

            if (e.Url.LocalPath == "pasteencounter")
            {
                // Add an encounter
                Encounter enc = Clipboard.GetData(typeof(Encounter).ToString()) as Encounter;
                fPoint.Element = enc;

                update_element();
            }

            if (e.Url.LocalPath == "challenge")
            {
                // Add a skill challenge
                SkillChallenge sc = new SkillChallenge();
                sc.Name        = "Unnamed Skill Challenge";
                sc.Level       = level;
                fPoint.Element = sc;

                update_element();
            }

            if (e.Url.LocalPath == "pastechallenge")
            {
                // Add a skill challenge
                SkillChallenge sc = Clipboard.GetData(typeof(SkillChallenge).ToString()) as SkillChallenge;
                sc.Level       = level;
                fPoint.Element = sc;

                update_element();
            }

            if (e.Url.LocalPath == "trap")
            {
                // Add a trap
                TrapElement te = new TrapElement();
                te.Trap.Name   = "Unnamed Trap";
                te.Trap.Level  = level;
                fPoint.Element = te;

                update_element();
            }

            if (e.Url.LocalPath == "pastetrap")
            {
                // Add a trap
                TrapElement te = Clipboard.GetData(typeof(TrapElement).ToString()) as TrapElement;
                te.Trap.Level  = level;
                fPoint.Element = te;

                update_element();
            }

            if (e.Url.LocalPath == "quest")
            {
                // Add a quest
                Quest q = new Quest();
                q.Level        = level;
                fPoint.Element = q;

                update_element();
            }

            if (e.Url.LocalPath == "pastequest")
            {
                // Add a quest
                Quest q = Clipboard.GetData(typeof(Quest).ToString()) as Quest;
                q.Level        = level;
                fPoint.Element = q;

                update_element();
            }

            if (e.Url.LocalPath == "map")
            {
                // Add a map
                MapElement me = new MapElement();
                fPoint.Element = me;

                update_element();
            }

            if (e.Url.LocalPath == "pastemap")
            {
                // Add a map
                MapElement me = Clipboard.GetData(typeof(MapElement).ToString()) as MapElement;
                fPoint.Element = me;

                update_element();
            }
        }
コード例 #25
0
ファイル: OverviewForm.cs プロジェクト: cmdrmander/Manderplan
        private void ItemList_DoubleClick(object sender, EventArgs e)
        {
            switch (this.fType)
            {
            case OverviewType.Encounters:
            {
                if (this.SelectedEncounter == null)
                {
                    break;
                }
                int partyLevel = Workspace.GetPartyLevel(this.SelectedEncounter.First);
                EncounterBuilderForm encounterBuilderForm = new EncounterBuilderForm(this.SelectedEncounter.Second, partyLevel, false);
                if (encounterBuilderForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    this.SelectedEncounter.First.Element = encounterBuilderForm.Encounter;
                    Session.Modified = true;
                    this.update_list();
                }
                return;
            }

            case OverviewType.Traps:
            {
                if (this.SelectedTrap == null)
                {
                    break;
                }
                if (this.SelectedTrap.First.Element is TrapElement)
                {
                    TrapElement     element         = this.SelectedTrap.First.Element as TrapElement;
                    TrapBuilderForm trapBuilderForm = new TrapBuilderForm(this.SelectedTrap.Second);
                    if (trapBuilderForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        element.Trap     = trapBuilderForm.Trap;
                        Session.Modified = true;
                        this.update_list();
                    }
                    return;
                }
                if (!(this.SelectedTrap.First.Element is Encounter))
                {
                    break;
                }
                Encounter       trap             = this.SelectedTrap.First.Element as Encounter;
                int             num              = trap.Traps.IndexOf(this.SelectedTrap.Second);
                TrapBuilderForm trapBuilderForm1 = new TrapBuilderForm(this.SelectedTrap.Second);
                if (trapBuilderForm1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    trap.Traps[num]  = trapBuilderForm1.Trap;
                    Session.Modified = true;
                    this.update_list();
                }
                return;
            }

            case OverviewType.SkillChallenges:
            {
                if (this.SelectedChallenge == null)
                {
                    break;
                }
                if (this.SelectedChallenge.First.Element is SkillChallenge)
                {
                    SkillChallenge            name = this.SelectedChallenge.First.Element as SkillChallenge;
                    SkillChallengeBuilderForm skillChallengeBuilderForm = new SkillChallengeBuilderForm(this.SelectedChallenge.Second);
                    if (skillChallengeBuilderForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        name.Name       = skillChallengeBuilderForm.SkillChallenge.Name;
                        name.Level      = skillChallengeBuilderForm.SkillChallenge.Level;
                        name.Complexity = skillChallengeBuilderForm.SkillChallenge.Complexity;
                        name.Success    = skillChallengeBuilderForm.SkillChallenge.Success;
                        name.Failure    = skillChallengeBuilderForm.SkillChallenge.Failure;
                        name.Skills.Clear();
                        foreach (SkillChallengeData skill in skillChallengeBuilderForm.SkillChallenge.Skills)
                        {
                            name.Skills.Add(skill.Copy());
                        }
                        Session.Modified = true;
                        this.update_list();
                    }
                    return;
                }
                if (!(this.SelectedChallenge.First.Element is Encounter))
                {
                    break;
                }
                Encounter skillChallenge = this.SelectedChallenge.First.Element as Encounter;
                int       num1           = skillChallenge.SkillChallenges.IndexOf(this.SelectedChallenge.Second);
                SkillChallengeBuilderForm skillChallengeBuilderForm1 = new SkillChallengeBuilderForm(this.SelectedChallenge.Second);
                if (skillChallengeBuilderForm1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    skillChallenge.SkillChallenges[num1] = skillChallengeBuilderForm1.SkillChallenge;
                    Session.Modified = true;
                    this.update_list();
                }
                return;
            }

            case OverviewType.Treasure:
            {
                if (this.SelectedParcel == null)
                {
                    break;
                }
                int        parcel     = this.SelectedParcel.First.Parcels.IndexOf(this.SelectedParcel.Second);
                ParcelForm parcelForm = new ParcelForm(this.SelectedParcel.Second);
                if (parcelForm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    break;
                }
                this.SelectedParcel.First.Parcels[parcel] = parcelForm.Parcel;
                Session.Modified = true;
                this.update_list();
                break;
            }

            default:
            {
                return;
            }
            }
        }
コード例 #26
0
ファイル: OverviewForm.cs プロジェクト: cmdrmander/Manderplan
        private void update_list()
        {
            this.ItemList.Items.Clear();
            switch (this.fType)
            {
            case OverviewType.Encounters:
            {
                List <PlotPoint> .Enumerator enumerator = this.fPoints.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        PlotPoint current = enumerator.Current;
                        if (current.Element == null || !(current.Element is Encounter))
                        {
                            continue;
                        }
                        Encounter element = current.Element as Encounter;
                        string    str     = "";
                        List <EncounterSlot> .Enumerator enumerator1 = element.AllSlots.GetEnumerator();
                        try
                        {
                            while (enumerator1.MoveNext())
                            {
                                EncounterSlot encounterSlot = enumerator1.Current;
                                if (str != "")
                                {
                                    str = string.Concat(str, ", ");
                                }
                                str = string.Concat(str, encounterSlot.Card.Title);
                                if (encounterSlot.CombatData.Count == 1)
                                {
                                    continue;
                                }
                                object   obj   = str;
                                object[] count = new object[] { obj, " (x", encounterSlot.CombatData.Count, ")" };
                                str = string.Concat(count);
                            }
                        }
                        finally
                        {
                            ((IDisposable)enumerator1).Dispose();
                        }
                        List <Trap> .Enumerator enumerator2 = element.Traps.GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                Trap trap = enumerator2.Current;
                                if (str != "")
                                {
                                    str = string.Concat(str, ", ");
                                }
                                str = string.Concat(str, trap.Name);
                            }
                        }
                        finally
                        {
                            ((IDisposable)enumerator2).Dispose();
                        }
                        ListViewItem pair = this.ItemList.Items.Add(current.Name);
                        pair.SubItems.Add(string.Concat(element.GetXP(), " XP; ", str));
                        pair.Tag = new Pair <PlotPoint, Encounter>(current, element);
                    }
                    break;
                }
                finally
                {
                    ((IDisposable)enumerator).Dispose();
                }
            }

            case OverviewType.Traps:
            {
                List <PlotPoint> .Enumerator enumerator3 = this.fPoints.GetEnumerator();
                try
                {
                    while (enumerator3.MoveNext())
                    {
                        PlotPoint plotPoint = enumerator3.Current;
                        if (plotPoint.Element == null)
                        {
                            continue;
                        }
                        if (plotPoint.Element is TrapElement)
                        {
                            TrapElement  trapElement  = plotPoint.Element as TrapElement;
                            ListViewItem listViewItem = this.ItemList.Items.Add(plotPoint.Name);
                            listViewItem.SubItems.Add(string.Concat(Experience.GetCreatureXP(trapElement.Trap.Level), " XP; ", trapElement.Trap.Name));
                            listViewItem.Tag = new Pair <PlotPoint, Trap>(plotPoint, trapElement.Trap);
                        }
                        if (!(plotPoint.Element is Encounter))
                        {
                            continue;
                        }
                        List <Trap> .Enumerator enumerator4 = (plotPoint.Element as Encounter).Traps.GetEnumerator();
                        try
                        {
                            while (enumerator4.MoveNext())
                            {
                                Trap         current1 = enumerator4.Current;
                                ListViewItem pair1    = this.ItemList.Items.Add(plotPoint.Name);
                                pair1.SubItems.Add(string.Concat(Experience.GetCreatureXP(current1.Level), " XP; ", current1.Name));
                                pair1.Tag = new Pair <PlotPoint, Trap>(plotPoint, current1);
                            }
                        }
                        finally
                        {
                            ((IDisposable)enumerator4).Dispose();
                        }
                    }
                    break;
                }
                finally
                {
                    ((IDisposable)enumerator3).Dispose();
                }
            }

            case OverviewType.SkillChallenges:
            {
                List <PlotPoint> .Enumerator enumerator5 = this.fPoints.GetEnumerator();
                try
                {
                    while (enumerator5.MoveNext())
                    {
                        PlotPoint plotPoint1 = enumerator5.Current;
                        if (plotPoint1.Element == null)
                        {
                            continue;
                        }
                        if (plotPoint1.Element is SkillChallenge)
                        {
                            SkillChallenge skillChallenge = plotPoint1.Element as SkillChallenge;
                            ListViewItem   listViewItem1  = this.ItemList.Items.Add(plotPoint1.Name);
                            listViewItem1.SubItems.Add(string.Concat(skillChallenge.GetXP(), " XP"));
                            listViewItem1.Tag = new Pair <PlotPoint, SkillChallenge>(plotPoint1, skillChallenge);
                        }
                        if (!(plotPoint1.Element is Encounter))
                        {
                            continue;
                        }
                        List <SkillChallenge> .Enumerator enumerator6 = (plotPoint1.Element as Encounter).SkillChallenges.GetEnumerator();
                        try
                        {
                            while (enumerator6.MoveNext())
                            {
                                SkillChallenge skillChallenge1 = enumerator6.Current;
                                ListViewItem   pair2           = this.ItemList.Items.Add(plotPoint1.Name);
                                pair2.SubItems.Add(string.Concat(skillChallenge1.GetXP(), " XP"));
                                pair2.Tag = new Pair <PlotPoint, SkillChallenge>(plotPoint1, skillChallenge1);
                            }
                        }
                        finally
                        {
                            ((IDisposable)enumerator6).Dispose();
                        }
                    }
                    break;
                }
                finally
                {
                    ((IDisposable)enumerator5).Dispose();
                }
            }

            case OverviewType.Treasure:
            {
                List <PlotPoint> .Enumerator enumerator7 = this.fPoints.GetEnumerator();
                try
                {
                    while (enumerator7.MoveNext())
                    {
                        PlotPoint current2 = enumerator7.Current;
                        List <Parcel> .Enumerator enumerator8 = current2.Parcels.GetEnumerator();
                        try
                        {
                            while (enumerator8.MoveNext())
                            {
                                Parcel       parcel        = enumerator8.Current;
                                string       str1          = (parcel.Name != "" ? parcel.Name : "(undefined parcel)");
                                ListViewItem listViewItem2 = this.ItemList.Items.Add(current2.Name);
                                listViewItem2.SubItems.Add(string.Concat(str1, ": ", parcel.Details));
                                listViewItem2.Tag = new Pair <PlotPoint, Parcel>(current2, parcel);
                            }
                        }
                        finally
                        {
                            ((IDisposable)enumerator8).Dispose();
                        }
                    }
                    break;
                }
                finally
                {
                    ((IDisposable)enumerator7).Dispose();
                }
            }
            }
            if (this.ItemList.Items.Count == 0)
            {
                ListViewItem grayText = this.ItemList.Items.Add("(no items)");
                grayText.ForeColor = SystemColors.GrayText;
            }
            this.ItemList.Sort();
        }
コード例 #27
0
ファイル: DelveBuilder.cs プロジェクト: cmdrmander/Manderplan
        private static Encounter get_encounter(Map map, MapArea ma, AutoBuildData data)
        {
            object[]  objArray;
            Encounter encounter = new Encounter()
            {
                MapID     = map.ID,
                MapAreaID = ma.ID
            };

            EncounterBuilder.Build(data, encounter, false);
            if (encounter.GetDifficulty(Session.Project.Party.Level, Session.Project.Party.Size) != Difficulty.Extreme)
            {
                switch (Session.Random.Next() % 6)
                {
                case 0:
                case 1:
                case 3:
                {
                    Trap trap = DelveBuilder.select_trap(data);
                    if (trap == null)
                    {
                        break;
                    }
                    encounter.Traps.Add(trap);
                    break;
                }

                case 4:
                {
                    SkillChallenge skillChallenge = DelveBuilder.select_challenge(data);
                    if (skillChallenge == null)
                    {
                        break;
                    }
                    encounter.SkillChallenges.Add(skillChallenge);
                    break;
                }
                }
            }
            List <Rectangle> rectangles = new List <Rectangle>();

            foreach (TileData tile in map.Tiles)
            {
                Tile tile1 = Session.FindTile(tile.TileID, SearchType.Global);
                int  num   = (tile.Rotations % 2 == 0 ? tile1.Size.Width : tile1.Size.Height);
                Size size  = new Size(num, (tile.Rotations % 2 == 0 ? tile1.Size.Height : tile1.Size.Width));
                rectangles.Add(new Rectangle(tile.Location, size));
            }
            Dictionary <Point, bool> points = new Dictionary <Point, bool>();

            for (int i = ma.Region.Left; i != ma.Region.Right; i++)
            {
                for (int j = ma.Region.Top; j != ma.Region.Bottom; j++)
                {
                    Point point = new Point(i, j);
                    bool  flag  = false;
                    foreach (Rectangle rectangle in rectangles)
                    {
                        if (!rectangle.Contains(point))
                        {
                            continue;
                        }
                        flag = true;
                        break;
                    }
                    points[point] = flag;
                }
            }
            foreach (EncounterSlot slot in encounter.Slots)
            {
                ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                int       size1    = Creature.GetSize(creature.Size);
                foreach (CombatData combatDatum in slot.CombatData)
                {
                    List <Point> points1 = new List <Point>();
                    for (int k = ma.Region.Left; k != ma.Region.Right; k++)
                    {
                        for (int l = ma.Region.Top; l != ma.Region.Bottom; l++)
                        {
                            Point point1 = new Point(k, l);
                            bool  flag1  = true;
                            for (int m = point1.X; m != point1.X + size1; m++)
                            {
                                for (int n = point1.Y; n != point1.Y + size1; n++)
                                {
                                    Point point2 = new Point(m, n);
                                    if (!points.ContainsKey(point2) || !points[point2])
                                    {
                                        flag1 = false;
                                    }
                                }
                            }
                            if (flag1)
                            {
                                points1.Add(point1);
                            }
                        }
                    }
                    if (points1.Count == 0)
                    {
                        continue;
                    }
                    int   num1 = Session.Random.Next() % points1.Count;
                    Point item = points1[num1];
                    combatDatum.Location = item;
                    for (int o = item.X; o != item.X + size1; o++)
                    {
                        for (int p = item.Y; p != item.Y + size1; p++)
                        {
                            points[new Point(o, p)] = false;
                        }
                    }
                }
            }
            encounter.SetStandardEncounterNotes();
            EncounterNote encounterNote = encounter.FindNote("Illumination");

            if (encounterNote != null)
            {
                switch (Session.Random.Next(6))
                {
                case 0:
                case 1:
                case 2:
                {
                    encounterNote.Contents = "The area is in bright light.";
                    break;
                }

                case 3:
                case 4:
                {
                    encounterNote.Contents = "The area is in dim light.";
                    break;
                }

                case 5:
                {
                    encounterNote.Contents = "None.";
                    break;
                }
                }
            }
            EncounterNote item1 = encounter.FindNote("Victory Conditions");

            if (item1 != null)
            {
                List <string> strs  = new List <string>();
                List <string> strs1 = new List <string>();
                bool          flag2 = false;
                int           count = 0;
                foreach (EncounterSlot encounterSlot in encounter.Slots)
                {
                    if (encounterSlot.CombatData.Count == 1 && (encounterSlot.Card.Leader || encounterSlot.Card.Flag == RoleFlag.Elite || encounterSlot.Card.Flag == RoleFlag.Solo))
                    {
                        strs1.Add(encounterSlot.CombatData[0].DisplayName);
                    }
                    ICreature creature1 = Session.FindCreature(encounterSlot.Card.CreatureID, SearchType.Global);
                    if (creature1 == null)
                    {
                        continue;
                    }
                    if (!(creature1.Role is Minion))
                    {
                        count += encounterSlot.CombatData.Count;
                    }
                    else
                    {
                        flag2 = true;
                    }
                }
                if (strs1.Count != 0)
                {
                    int    num2 = Session.Random.Next() % strs1.Count;
                    string str  = strs1[num2];
                    if (Session.Random.Next() % 12 == 0)
                    {
                        strs.Add(string.Concat("Defeat ", str, "."));
                        strs.Add(string.Concat("Capture ", str, "."));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int num3 = Session.Dice(2, 4);
                        objArray = new object[] { "The party must defeat ", str, " within ", num3, " rounds." };
                        strs.Add(string.Concat(objArray));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int num4 = Session.Dice(2, 4);
                        objArray = new object[] { "After ", num4, ", ", str, " will flee or surrender." };
                        strs.Add(string.Concat(objArray));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        int num5 = 10 * Session.Dice(1, 4);
                        objArray = new object[] { "At ", num5, "% HP, ", str, " will flee or surrender." };
                        strs.Add(string.Concat(objArray));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        strs.Add(string.Concat("The party must obtain an item from ", str, "."));
                    }
                    if (Session.Random.Next() % 12 == 0)
                    {
                        strs.Add(string.Concat("Defeat ", str, " by destroying a guarded object in the area."));
                    }
                    if (flag2)
                    {
                        strs.Add(string.Concat("Minions will flee or surrender when ", str, " is defeated."));
                    }
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    int num6 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("The party must defeat their opponents within ", num6, " rounds."));
                }
                if (flag2 && Session.Random.Next() % 12 == 0)
                {
                    int num7 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("The party must defend a certain area from ", num7, " waves of minions."));
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    int num8 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("At least one character must get to a certain area and stay there for ", num8, " consecutive rounds."));
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    int num9 = 2 + Session.Random.Next() % 4;
                    strs.Add(string.Concat("The party must leave the area within ", num9, " rounds."));
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must keep the enemy away from a certain area for the duration of the encounter.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must escort an NPC safely through the encounter area.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must rescue an NPC from their opponents.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must avoid contact with the enemy in this area.");
                }
                if (Session.Random.Next() % 12 == 0)
                {
                    strs.Add("The party must attack and destroy a feature of the area.");
                }
                if (count > 1 && Session.Random.Next() % 12 == 0)
                {
                    int num10 = 1 + Session.Random.Next(count);
                    strs.Add(string.Concat("The party must defeat ", num10, " non-minion opponents."));
                }
                if (strs.Count != 0)
                {
                    int num11 = Session.Random.Next() % strs.Count;
                    item1.Contents = strs[num11];
                }
            }
            return(encounter);
        }
コード例 #28
0
ファイル: FilterPanel.cs プロジェクト: andyaiken/masterplan
        public bool AllowItem(object obj, out Difficulty diff)
        {
            diff = Difficulty.Moderate;

            if (obj is ICreature)
            {
                ICreature c = obj as ICreature;

                #region Creature

                bool outlier = false;
                diff = AI.GetThreatDifficulty(c.Level, fPartyLevel);
                if ((diff == Difficulty.Trivial) || (diff == Difficulty.Extreme))
                {
                    outlier = true;
                }

                if (outlier && FilterLevelAppropriateToggle.Checked)
                {
                    return(false);
                }

                if (FilterNameToggle.Checked && (fNameTokens != null))
                {
                    string name = c.Name.ToLower();

                    foreach (string token in fNameTokens)
                    {
                        if (!name.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterCatToggle.Checked && (fCatTokens != null))
                {
                    string cat = c.Category.ToLower();

                    foreach (string token in fCatTokens)
                    {
                        if (!cat.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterRoleToggle.Checked)
                {
                    RoleType role = (RoleType)FilterRoleBox.SelectedItem;

                    if (c.Role is ComplexRole)
                    {
                        ComplexRole cr = c.Role as ComplexRole;
                        if (cr.Type != role)
                        {
                            return(false);
                        }
                    }

                    if (c.Role is Minion)
                    {
                        Minion m = c.Role as Minion;
                        if ((!m.HasRole) || (m.Type != role))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterModToggle.Checked)
                {
                    RoleFlag flag   = RoleFlag.Standard;
                    bool     minion = false;

                    if (FilterModBox.Text == "Standard")
                    {
                    }

                    if (FilterModBox.Text == "Elite")
                    {
                        flag = RoleFlag.Elite;
                    }

                    if (FilterModBox.Text == "Solo")
                    {
                        flag = RoleFlag.Solo;
                    }

                    if (FilterModBox.Text == "Minion")
                    {
                        minion = true;
                    }

                    ComplexRole cr = c.Role as ComplexRole;
                    if (cr != null)
                    {
                        if (minion)
                        {
                            return(false);
                        }

                        if (flag != cr.Flag)
                        {
                            return(false);
                        }
                    }

                    Minion m = c.Role as Minion;
                    if (m != null)
                    {
                        if (!minion)
                        {
                            return(false);
                        }
                    }
                }

                if (FilterOriginToggle.Checked)
                {
                    CreatureOrigin origin = (CreatureOrigin)FilterOriginBox.SelectedItem;

                    if (c.Origin != origin)
                    {
                        return(false);
                    }
                }

                if (FilterTypeToggle.Checked)
                {
                    CreatureType type = (CreatureType)FilterTypeBox.SelectedItem;

                    if (c.Type != type)
                    {
                        return(false);
                    }
                }

                if (FilterKeywordToggle.Checked && (fKeyTokens != null))
                {
                    string keywords = (c.Keywords != null) ? c.Keywords.ToLower() : "";

                    foreach (string token in fKeyTokens)
                    {
                        if (!keywords.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterLevelToggle.Checked)
                {
                    if ((c.Level < LevelFromBox.Value) || (c.Level > LevelToBox.Value))
                    {
                        return(false);
                    }
                }

                if (FilterSourceToggle.Checked)
                {
                    Creature creature = c as Creature;
                    if (creature == null)
                    {
                        return(false);
                    }

                    Library lib = FilterSourceBox.SelectedItem as Library;
                    if (!lib.Creatures.Contains(creature))
                    {
                        return(false);
                    }
                }

                #endregion

                return(true);
            }

            if (obj is CreatureTemplate)
            {
                CreatureTemplate ct = obj as CreatureTemplate;

                #region Template

                if (FilterNameToggle.Checked && (fNameTokens != null))
                {
                    string name = ct.Name.ToLower();

                    foreach (string token in fNameTokens)
                    {
                        if (!name.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterCatToggle.Checked && (fCatTokens != null))
                {
                    // Ignore category for templates
                }

                if (FilterRoleToggle.Checked)
                {
                    // Match on role
                    RoleType role = (RoleType)FilterRoleBox.SelectedItem;
                    if (ct.Role != role)
                    {
                        return(false);
                    }
                }

                if (FilterOriginToggle.Checked)
                {
                    // Ignore origin for templates
                }

                if (FilterTypeToggle.Checked)
                {
                    // Ignore type for templates
                }

                if (FilterKeywordToggle.Checked && (fKeyTokens != null))
                {
                    // Ignore keywords for templates
                }

                if (FilterSourceToggle.Checked)
                {
                    Library lib = FilterSourceBox.SelectedItem as Library;
                    if (!lib.Templates.Contains(ct))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            if (obj is NPC)
            {
                NPC npc = obj as NPC;

                bool outlier = false;
                diff = AI.GetThreatDifficulty(npc.Level, fPartyLevel);
                if ((diff == Difficulty.Trivial) || (diff == Difficulty.Extreme))
                {
                    outlier = true;
                }

                if (outlier && FilterLevelAppropriateToggle.Checked)
                {
                    return(false);
                }

                if (FilterNameToggle.Checked && (fNameTokens != null))
                {
                    string name = npc.Name.ToLower();

                    foreach (string token in fNameTokens)
                    {
                        if (!name.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterCatToggle.Checked && (fCatTokens != null))
                {
                    string cat = npc.Category.ToLower();

                    foreach (string token in fCatTokens)
                    {
                        if (!cat.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterRoleToggle.Checked)
                {
                    // Match on role
                    RoleType role = (RoleType)FilterRoleBox.SelectedItem;

                    if (npc.Role is ComplexRole)
                    {
                        ComplexRole cr = npc.Role as ComplexRole;
                        if (cr.Type != role)
                        {
                            return(false);
                        }
                    }

                    if (npc.Role is Minion)
                    {
                        Minion m = npc.Role as Minion;
                        if ((!m.HasRole) || (m.Type != role))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterOriginToggle.Checked)
                {
                    CreatureOrigin origin = (CreatureOrigin)FilterOriginBox.SelectedItem;

                    if (npc.Origin != origin)
                    {
                        return(false);
                    }
                }

                if (FilterTypeToggle.Checked)
                {
                    CreatureType type = (CreatureType)FilterTypeBox.SelectedItem;

                    if (npc.Type != type)
                    {
                        return(false);
                    }
                }

                if (FilterKeywordToggle.Checked && (fKeyTokens != null))
                {
                    string keywords = (npc.Keywords != null) ? npc.Keywords.ToLower() : "";

                    foreach (string token in fKeyTokens)
                    {
                        if (!keywords.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterLevelToggle.Checked)
                {
                    if ((npc.Level < LevelFromBox.Value) || (npc.Level > LevelToBox.Value))
                    {
                        return(false);
                    }
                }

                #endregion

                return(true);
            }

            if (obj is Trap)
            {
                Trap trap = obj as Trap;

                #region Trap

                bool outlier = false;
                diff = AI.GetThreatDifficulty(trap.Level, fPartyLevel);
                if ((diff == Difficulty.Trivial) || (diff == Difficulty.Extreme))
                {
                    outlier = true;
                }

                if (outlier && FilterLevelAppropriateToggle.Checked)
                {
                    return(false);
                }

                if (FilterNameToggle.Checked && (fNameTokens != null))
                {
                    string name = trap.Name.ToLower();

                    foreach (string token in fNameTokens)
                    {
                        if (!name.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterCatToggle.Checked && (fCatTokens != null))
                {
                    // Ignore category for traps
                }

                if (FilterRoleToggle.Checked)
                {
                    // Match on role
                    RoleType role = (RoleType)FilterRoleBox.SelectedItem;

                    if (trap.Role is ComplexRole)
                    {
                        ComplexRole cr = trap.Role as ComplexRole;
                        if (cr.Type != role)
                        {
                            return(false);
                        }
                    }

                    if (trap.Role is Minion)
                    {
                        Minion m = trap.Role as Minion;
                        if ((!m.HasRole) || (m.Type != role))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterModToggle.Checked)
                {
                    RoleFlag flag   = RoleFlag.Standard;
                    bool     minion = false;

                    if (FilterModBox.Text == "Standard")
                    {
                    }

                    if (FilterModBox.Text == "Elite")
                    {
                        flag = RoleFlag.Elite;
                    }

                    if (FilterModBox.Text == "Solo")
                    {
                        flag = RoleFlag.Solo;
                    }

                    if (FilterModBox.Text == "Minion")
                    {
                        minion = true;
                    }

                    ComplexRole cr = trap.Role as ComplexRole;
                    if (cr != null)
                    {
                        if (minion)
                        {
                            return(false);
                        }

                        if (flag != cr.Flag)
                        {
                            return(false);
                        }
                    }

                    Minion m = trap.Role as Minion;
                    if (m != null)
                    {
                        if (!minion)
                        {
                            return(false);
                        }
                    }
                }

                if (FilterOriginToggle.Checked)
                {
                    // Ignore origin for traps
                }

                if (FilterTypeToggle.Checked)
                {
                    // Ignore type for traps
                }

                if (FilterKeywordToggle.Checked && (fKeyTokens != null))
                {
                    // Ignore keywords for traps
                }

                if (FilterLevelToggle.Checked)
                {
                    if ((trap.Level < LevelFromBox.Value) || (trap.Level > LevelToBox.Value))
                    {
                        return(false);
                    }
                }

                if (FilterSourceToggle.Checked)
                {
                    Library lib = FilterSourceBox.SelectedItem as Library;
                    if (!lib.Traps.Contains(trap))
                    {
                        return(false);
                    }
                }

                #endregion

                return(true);
            }

            if (obj is SkillChallenge)
            {
                SkillChallenge sc = obj as SkillChallenge;

                #region Skill challenge

                if (FilterNameToggle.Checked && (fNameTokens != null))
                {
                    string name = sc.Name.ToLower();

                    foreach (string token in fNameTokens)
                    {
                        if (!name.Contains(token))
                        {
                            return(false);
                        }
                    }
                }

                if (FilterCatToggle.Checked && (fCatTokens != null))
                {
                    // Ignore category for skill challenges
                }

                if (FilterRoleToggle.Checked)
                {
                    // Ignore roles for skill challenges
                }

                if (FilterOriginToggle.Checked)
                {
                    // Ignore origin for skill challenges
                }

                if (FilterTypeToggle.Checked)
                {
                    // Ignore type for skill challenges
                }

                if (FilterKeywordToggle.Checked && (fKeyTokens != null))
                {
                    // Ignore keywords for skill challenges
                }

                if (FilterSourceToggle.Checked)
                {
                    Library lib = FilterSourceBox.SelectedItem as Library;
                    if (!lib.SkillChallenges.Contains(sc))
                    {
                        return(false);
                    }
                }

                #endregion

                return(true);
            }

            return(false);
        }
コード例 #29
0
        public SkillChallengeBreakdownForm(SkillChallenge sc)
        {
            InitializeComponent();

            AbilitiesPanel.Analyse(sc);
        }
コード例 #30
0
 public SkillChallengeDetailsForm(SkillChallenge sc)
 {
     this.InitializeComponent();
     this.fChallenge           = sc.Copy() as SkillChallenge;
     this.Browser.DocumentText = HTML.SkillChallenge(this.fChallenge, false, true, DisplaySize.Small);
 }