Example #1
0
        static void add_templates(ICreature creature)
        {
            // Can't add a template to a minion
            if (creature.Role is Minion)
            {
                return;
            }

            // Can't add a template to a solo
            ComplexRole role = creature.Role as ComplexRole;

            if (role.Flag == RoleFlag.Solo)
            {
                return;
            }

            foreach (Library lib in Session.Libraries)
            {
                foreach (CreatureTemplate tmpl in lib.Templates)
                {
                    EncounterCard card = new EncounterCard();
                    card.CreatureID = creature.ID;
                    card.TemplateIDs.Add(tmpl.ID);
                }
            }
        }
Example #2
0
        public ThemeForm(EncounterCard card)
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);

            Browser.DocumentText = "";

            fCard = card.Copy();

            if (fCard.ThemeID != Guid.Empty)
            {
                MonsterTheme mt = Session.FindTheme(fCard.ThemeID, SearchType.Global);
                update_selected_theme(mt, false);

                ThemePowerData attack = mt.FindPower(fCard.ThemeAttackPowerID);
                AttackBox.SelectedItem = attack;

                ThemePowerData utility = mt.FindPower(fCard.ThemeUtilityPowerID);
                UtilityBox.SelectedItem = utility;
            }
            else
            {
                update_selected_theme(null, true);
            }
        }
Example #3
0
        public void ShowEncounterCard(EncounterCard card)
        {
            string str = HTML.StatBlock(card, null, null, true, false, true, CardMode.View, PlayerViewForm.DisplaySize);

            this.set_html(str);
            base.Show();
        }
Example #4
0
        public CombatForm(EncounterCard e)
            : base()
        {
            var x = new EncounterCardPnl(e);

            this.Controls.Add(x);
        }
Example #5
0
        void update_stat_block()
        {
            EncounterSlot slot = fEncounter.FindSlot(SelectedCombatant);
            EncounterCard card = slot != null ? slot.Card : null;

            Browser.DocumentText = HTML.StatBlock(card, SelectedCombatant, fEncounter, true, false, true, CardMode.View, Session.Preferences.TextSize);
        }
Example #6
0
        public CombatDataForm(CombatData data, EncounterCard card, Encounter enc, CombatData current_actor, int current_round, bool allow_name_edit)
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);
            EffectList_SizeChanged(null, null);

            fData      = data.Copy();
            fCard      = card;
            fEncounter = enc;

            fCurrentActor = current_actor;
            fCurrentRound = current_round;

            if (fData.Initiative == int.MinValue)
            {
                fData.Initiative = 0;
            }

            Text          = fData.DisplayName;
            LabelBox.Text = fData.DisplayName;

            if (!allow_name_edit)
            {
                LabelBox.Enabled = false;
            }

            update_hp();
            InitBox.Value     = fData.Initiative;
            AltitudeBox.Value = fData.Altitude;
            update_effects();
        }
Example #7
0
 public CombatDataForm(CombatData data, EncounterCard card, Encounter enc, CombatData current_actor, int current_round, bool allow_name_edit)
 {
     this.InitializeComponent();
     Application.Idle += new EventHandler(this.Application_Idle);
     this.EffectList_SizeChanged(null, null);
     this.fData         = data.Copy();
     this.fCard         = card;
     this.fEncounter    = enc;
     this.fCurrentActor = current_actor;
     this.fCurrentRound = current_round;
     if (this.fData.Initiative == -2147483648)
     {
         this.fData.Initiative = 0;
     }
     this.Text          = this.fData.DisplayName;
     this.LabelBox.Text = this.fData.DisplayName;
     if (!allow_name_edit)
     {
         this.LabelBox.Enabled = false;
     }
     this.update_hp();
     this.InitBox.Value     = this.fData.Initiative;
     this.AltitudeBox.Value = this.fData.Altitude;
     this.update_effects();
 }
 private void CreatureList_DoubleClick(object sender, EventArgs e)
 {
     if (this.SelectedCreature != null)
     {
         EncounterCard encounterCard = new EncounterCard(this.SelectedCreature.ID);
         (new CreatureDetailsForm(encounterCard)).ShowDialog();
     }
 }
Example #9
0
        public CreatureDetailsForm(EncounterCard card)
        {
            InitializeComponent();

            fCard = card;

            Browser.DocumentText = HTML.StatBlock(fCard, null, null, true, false, true, CardMode.View, Session.Preferences.TextSize);
        }
Example #10
0
        public void ShowEncounterCard(EncounterCard card)
        {
            string html = HTML.StatBlock(card, null, null, true, false, true, CardMode.View, Session.Preferences.PlayerViewTextSize);

            set_html(html);

            Show();
        }
Example #11
0
 private static bool match_token(EncounterCard card, string token)
 {
     if (!card.Title.ToLower().Contains(token) && !card.Category.ToString().ToLower().Contains(token))
     {
         return(false);
     }
     return(true);
 }
Example #12
0
 private void CreatureList_DoubleClick(object sender, EventArgs e)
 {
     if (SelectedCreature != null)
     {
         EncounterCard       card = new EncounterCard(SelectedCreature.ID);
         CreatureDetailsForm dlg  = new CreatureDetailsForm(card);
         dlg.ShowDialog();
     }
 }
Example #13
0
        private void update_creature_list()
        {
            this.CreatureList.BeginUpdate();
            this.CreatureList.ShowGroups = true;
            List <ListViewItem> listViewItems = new List <ListViewItem>();

            if (!this.DeckView.IsCellSelected)
            {
                this.CreatureList.ShowGroups = false;
                ListViewItem listViewItem = new ListViewItem("(no cell selected)")
                {
                    ForeColor = SystemColors.GrayText
                };
                listViewItems.Add(listViewItem);
            }
            else
            {
                List <ICreature> creatures = new List <ICreature>();
                foreach (Creature creature in Session.Creatures)
                {
                    creatures.Add(creature);
                }
                foreach (CustomCreature customCreature in Session.Project.CustomCreatures)
                {
                    creatures.Add(customCreature);
                }
                foreach (ICreature creature1 in creatures)
                {
                    EncounterCard encounterCard = new EncounterCard()
                    {
                        CreatureID = creature1.ID
                    };
                    if (!this.DeckView.InSelectedCell(encounterCard))
                    {
                        continue;
                    }
                    ListViewItem listViewItem1 = new ListViewItem(creature1.Name)
                    {
                        Tag   = creature1,
                        Group = this.CreatureList.Groups[(creature1.Category != "" ? creature1.Category : "Miscellaneous Creatures")]
                    };
                    listViewItems.Add(listViewItem1);
                }
                if (listViewItems.Count == 0)
                {
                    this.CreatureList.ShowGroups = false;
                    ListViewItem listViewItem2 = new ListViewItem("(no creatures)")
                    {
                        ForeColor = SystemColors.GrayText
                    };
                    listViewItems.Add(listViewItem2);
                }
            }
            this.CreatureList.Items.Clear();
            this.CreatureList.Items.AddRange(listViewItems.ToArray());
            this.CreatureList.EndUpdate();
        }
Example #14
0
        /// <summary>
        /// Determine whether a given creature fits this slot.
        /// </summary>
        /// <param name="card">The creature.</param>
        /// <param name="encounter_level">The level of the encounter.</param>
        /// <returns>True if the creature matches; false otherwise.</returns>
        public bool Match(EncounterCard card, int encounter_level)
        {
            ICreature creature = Session.FindCreature(card.CreatureID, SearchType.Global);

            // Check the level
            int level = encounter_level + fLevelAdjustment;

            if (level < 1)
            {
                level = 1;
            }
            if (creature.Level != level)
            {
                return(false);
            }

            // Check minion status
            bool is_minion = (creature.Role is Minion);

            if (is_minion != fMinions)
            {
                return(false);
            }

            // Check the role matches
            bool role_ok = false;

            if (fRoles.Count == 0)
            {
                // We match any role
                role_ok = true;
            }
            else
            {
                ComplexRole role = creature.Role as ComplexRole;
                foreach (RoleType r in card.Roles)
                {
                    if (fRoles.Contains(role.Type))
                    {
                        role_ok = true;
                        break;
                    }
                }
            }
            if (!role_ok)
            {
                return(false);
            }

            // Check the elite / solo flag matches
            if (fFlag != card.Flag)
            {
                return(false);
            }

            return(true);
        }
Example #15
0
 public OngoingDamageForm(CombatData data, EncounterCard card, Encounter enc)
 {
     this.InitializeComponent();
     this.fData      = data;
     this.fCard      = card;
     this.fEncounter = enc;
     this.Text       = string.Concat("Ongoing Damage: ", this.fData.DisplayName);
     this.update_list();
 }
Example #16
0
 private void DuplicateBtn_Click(object sender, EventArgs e)
 {
     if (this.SelectedCard != null)
     {
         EncounterCard encounterCard = this.SelectedCard.Copy();
         this.fDeck.Cards.Add(encounterCard);
         this.DeckView.Invalidate();
         this.update_card_list();
     }
 }
Example #17
0
    public EncounterCardWrapper(EncounterCard card, string guid = "")
    {
        if (guid == "")
        {
            guid = System.Guid.NewGuid().ToString();
        }

        CardId = card.Id;
        Guid   = guid;
    }
Example #18
0
        private void DuplicateBtn_Click(object sender, EventArgs e)
        {
            if (SelectedCard != null)
            {
                EncounterCard card = SelectedCard.Copy();
                fDeck.Cards.Add(card);

                DeckView.Invalidate();
                update_card_list();
            }
        }
Example #19
0
        public OngoingDamageForm(CombatData data, EncounterCard card, Encounter enc)
        {
            InitializeComponent();

            fData      = data;
            fCard      = card;
            fEncounter = enc;

            Text = "Ongoing Damage: " + fData.DisplayName;

            update_list();
        }
Example #20
0
 private static bool match(EncounterCard card, string query)
 {
     string[] strArrays = query.ToLower().Split(new char[0]);
     for (int i = 0; i < (int)strArrays.Length; i++)
     {
         if (!EncounterBuilder.match_token(card, strArrays[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Example #21
0
        void draw_card(EncounterCard card, int count, bool topmost, RectangleF rect, Graphics g)
        {
            int alpha = (card != null) ? 255 : 100;

            GraphicsPath gp = RoundedRectangle.Create(rect, fRadius, RoundedRectangle.RectangleCorners.TopLeft | RoundedRectangle.RectangleCorners.TopRight);

            using (Brush b = new SolidBrush(Color.FromArgb(alpha, 54, 79, 39)))
            {
                g.FillPath(b, gp);
            }
            g.DrawPath(Pens.White, gp);

            float      card_delta_y = Font.Height * 1.5f;
            RectangleF text_rect    = new RectangleF(rect.X + fRadius, rect.Y, rect.Width - (2 * fRadius), card_delta_y);

            if (card != null)
            {
                string title = card.Title;
                if (count > 1)
                {
                    title = "(" + count + "x) " + title;
                }

                Color text_colour = (card != fHoverCard) ? Color.White : Color.PaleGreen;
                using (Brush b = new SolidBrush(text_colour))
                {
                    using (Font f = new Font(Font, Font.Style | FontStyle.Bold))
                    {
                        g.DrawString(title, f, b, text_rect, fTitle);
                    }

                    g.DrawString(card.Info, Font, b, text_rect, fInfo);
                }

                if (topmost)
                {
                    float      dx      = fRadius * 0.2f;
                    RectangleF content = new RectangleF(rect.X + dx, rect.Y + text_rect.Height, rect.Width - (2 * dx), rect.Height - text_rect.Height);
                    using (Brush b = new SolidBrush(Color.FromArgb(225, 231, 197)))
                    {
                        g.FillRectangle(b, content);
                    }

                    string msg = "Click on a card to move it to the front of the deck.";
                    g.DrawString(msg, Font, Brushes.Black, content, fCentred);
                }
            }
            else
            {
                int remaining = fCards.Count - fVisibleCards;
                g.DrawString("(" + remaining + " more cards)", Font, Brushes.White, text_rect, fCentred);
            }
        }
Example #22
0
		public bool InSelectedCell(EncounterCard card)
		{
			if (fSelectedCell == Point.Empty)
				return false;

			int diff_index = fSelectedCell.X - 1;
			Difficulty diff = fColumns[diff_index];

			int cat_index = fSelectedCell.Y - 1;
			CardCategory cat = fRows[cat_index];

			return ((card.Category == cat) && (card.GetDifficulty(fDeck.Level) == diff));
		}
Example #23
0
 private void CreatureList_ItemDrag(object sender, ItemDragEventArgs e)
 {
     if (this.SelectedCreature != null && base.DoDragDrop(this.SelectedCreature, DragDropEffects.Copy) == DragDropEffects.Copy)
     {
         EncounterCard encounterCard = new EncounterCard()
         {
             CreatureID = this.SelectedCreature.ID
         };
         this.fDeck.Cards.Add(encounterCard);
         this.DeckView.Invalidate();
         this.update_card_list();
     }
 }
Example #24
0
 private static void build_creature_list(int min_level, int max_level, List <string> categories, List <string> keywords, bool include_templates)
 {
     EncounterBuilder.fCreatures.Clear();
     foreach (Creature creature in Session.Creatures)
     {
         if (creature == null || min_level != -1 && creature.Level < min_level || max_level != -1 && creature.Level > max_level || categories != null && categories.Count != 0 && !categories.Contains(creature.Category))
         {
             continue;
         }
         if (keywords != null && keywords.Count != 0)
         {
             bool flag = false;
             foreach (string keyword in keywords)
             {
                 if (!creature.Phenotype.ToLower().Contains(keyword.ToLower()))
                 {
                     continue;
                 }
                 flag = true;
                 break;
             }
             if (!flag)
             {
                 continue;
             }
         }
         EncounterCard encounterCard = new EncounterCard()
         {
             CreatureID = creature.ID
         };
         EncounterBuilder.fCreatures.Add(encounterCard);
         if (!include_templates)
         {
             continue;
         }
         EncounterBuilder.add_templates(creature);
     }
     foreach (CustomCreature customCreature in Session.Project.CustomCreatures)
     {
         EncounterCard encounterCard1 = new EncounterCard()
         {
             CreatureID = customCreature.ID
         };
         EncounterBuilder.fCreatures.Add(encounterCard1);
         if (!include_templates)
         {
             continue;
         }
         EncounterBuilder.add_templates(customCreature);
     }
 }
Example #25
0
        void apply_damage()
        {
            foreach (ListViewItem lvi in RollList.Items)
            {
                Pair <CombatData, int> roll = lvi.Tag as Pair <CombatData, int>;
                if (roll.First == null)
                {
                    continue;
                }

                int damage = 0;
                if (roll.Second == 20)
                {
                    damage = int.Parse(CritValueLbl.Text);
                }
                else if (lvi.ForeColor == SystemColors.WindowText)
                {
                    // Hit
                    damage = (int)DamageBox.Value;
                }
                else
                {
                    // Miss
                    // TODO: Does the power do half damage on a miss?
                    // Remember that minions are unaffected by this
                }

                if (damage == 0)
                {
                    continue;
                }

                // Determine damage type(s)
                Array             array = Enum.GetValues(typeof(DamageType));
                List <DamageType> types = new List <DamageType>();
                foreach (DamageType type in array)
                {
                    string details = fPower.Details.ToLower();
                    string dmg     = type.ToString().ToLower();
                    if (details.Contains(dmg))
                    {
                        types.Add(type);
                    }
                }

                EncounterSlot slot = fEncounter.FindSlot(roll.First);
                EncounterCard card = (slot != null) ? slot.Card : null;

                DamageForm.DoDamage(roll.First, card, damage, types, false);
            }
        }
Example #26
0
 public static void FillDeck(EncounterDeck deck)
 {
     EncounterBuilder.build_creature_list(deck.Level - 2, deck.Level + 5, null, null, false);
     if (EncounterBuilder.fCreatures.Count == 0)
     {
         return;
     }
     while (deck.Cards.Count < 50)
     {
         int           num  = Session.Random.Next() % EncounterBuilder.fCreatures.Count;
         EncounterCard item = EncounterBuilder.fCreatures[num];
         deck.Cards.Add(item);
     }
 }
Example #27
0
        static bool match(EncounterCard card, string query)
        {
            string[] tokens = query.ToLower().Split();

            foreach (string token in tokens)
            {
                if (!match_token(card, token))
                {
                    return(false);
                }
            }

            return(true);
        }
        void update_stats()
        {
            List <string> lines = HTML.GetHead("", "", Session.Preferences.TextSize);

            lines.Add("<BODY>");

            if (fCreatures.Count != 0)
            {
                lines.Add("<P class=table>");
                lines.Add("<TABLE>");
                lines.Add("<TR class=heading>");
                lines.Add("<TD colspan=3><B>Selected Creatures</B></TD>");
                lines.Add("</TR>");

                foreach (ICreature c in fCreatures)
                {
                    lines.Add("<TR class=header>");
                    lines.Add("<TD colspan=2>" + c.Name + "</TD>");
                    lines.Add("<TD align=center><A href=remove:" + c.ID + ">remove</A></TD>");
                    lines.Add("</TR>");
                }

                lines.Add("</TABLE>");
                lines.Add("</P>");
            }
            else
            {
                lines.Add("<P class=instruction>");
                lines.Add("You have not yet selected any creatures; to select a creature, drag it from the list at the left onto the box above");
                lines.Add("</P>");
            }

            foreach (ICreature creature in fCreatures)
            {
                EncounterCard card = new EncounterCard(creature);

                lines.Add("<P class=table>");
                lines.AddRange(card.AsText(null, CardMode.View, false));
                lines.Add("</P>");
            }

            lines.Add("</BODY>");
            lines.Add("</HTML>");

            string html = HTML.Concatenate(lines);

            Browser.Document.OpenNew(true);
            Browser.Document.Write(html);
        }
Example #29
0
        private ListViewItem add_card(EncounterCard card)
        {
            ListViewItem listViewItem = new ListViewItem(card.Title);

            listViewItem.SubItems.Add(card.Info);
            listViewItem.Tag = card;
            if (card.Drawn)
            {
                listViewItem.ForeColor = SystemColors.GrayText;
            }
            ICreature creature = Session.FindCreature(card.CreatureID, SearchType.Global);

            listViewItem.Group = this.CardList.Groups[(creature.Category != "" ? creature.Category : "Miscellaneous Creatures")];
            return(listViewItem);
        }
Example #30
0
        private void draw_card(EncounterCard card, int count, bool topmost, RectangleF rect, Graphics g)
        {
            int          num          = (card != null ? 255 : 100);
            GraphicsPath graphicsPath = RoundedRectangle.Create(rect, this.fRadius, RoundedRectangle.RectangleCorners.TopLeft | RoundedRectangle.RectangleCorners.TopRight);

            using (Brush solidBrush = new SolidBrush(Color.FromArgb(num, 54, 79, 39)))
            {
                g.FillPath(solidBrush, graphicsPath);
            }
            g.DrawPath(Pens.White, graphicsPath);
            float      height     = (float)this.Font.Height * 1.5f;
            RectangleF rectangleF = new RectangleF(rect.X + this.fRadius, rect.Y, rect.Width - 2f * this.fRadius, height);

            if (card == null)
            {
                int num1 = this.fCards.Count - this.fVisibleCards;
                g.DrawString(string.Concat("(", num1, " more cards)"), this.Font, Brushes.White, rectangleF, this.fCentred);
            }
            else
            {
                string title = card.Title;
                if (count > 1)
                {
                    object[] objArray = new object[] { "(", count, "x) ", title };
                    title = string.Concat(objArray);
                }
                using (Brush brush = new SolidBrush((card != this.fHoverCard ? Color.White : Color.PaleGreen)))
                {
                    using (System.Drawing.Font font = new System.Drawing.Font(this.Font, this.Font.Style | FontStyle.Bold))
                    {
                        g.DrawString(title, font, brush, rectangleF, this.fTitle);
                    }
                    g.DrawString(card.Info, this.Font, brush, rectangleF, this.fInfo);
                }
                if (topmost)
                {
                    float      single      = this.fRadius * 0.2f;
                    RectangleF rectangleF1 = new RectangleF(rect.X + single, rect.Y + rectangleF.Height, rect.Width - 2f * single, rect.Height - rectangleF.Height);
                    using (Brush solidBrush1 = new SolidBrush(Color.FromArgb(225, 231, 197)))
                    {
                        g.FillRectangle(solidBrush1, rectangleF1);
                    }
                    string str = "Click on a card to move it to the front of the deck.";
                    g.DrawString(str, this.Font, Brushes.Black, rectangleF1, this.fCentred);
                    return;
                }
            }
        }