public EncounterNoteForm(EncounterNote bg)
 {
     this.InitializeComponent();
     this.fNote           = bg.Copy();
     this.TitleBox.Text   = this.fNote.Title;
     this.DetailsBox.Text = this.fNote.Contents;
 }
示例#2
0
        public EncounterNoteForm(EncounterNote bg)
        {
            InitializeComponent();

            fNote = bg.Copy();

            TitleBox.Text   = fNote.Title;
            DetailsBox.Text = fNote.Contents;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }