Esempio n. 1
0
        string power_topline(CombatData cd, CardMode mode)
        {
            string str = "";

            Image  icon = null;
            string rng  = fRange.ToLower();

            if (rng.Contains("melee"))
            {
                if ((fAction != null) && (fAction.Use == PowerUseType.Basic))
                {
                    icon = Resources.MeleeBasic;
                }
                else
                {
                    icon = Resources.Melee;
                }
            }
            if (rng.Contains("ranged"))
            {
                if ((fAction != null) && (fAction.Use == PowerUseType.Basic))
                {
                    icon = Resources.RangedBasic;
                }
                else
                {
                    icon = Resources.Ranged;
                }
            }
            if (rng.Contains("area"))
            {
                icon = Resources.Area;
            }
            if (rng.Contains("close"))
            {
                icon = Resources.Close;
            }
            if ((icon == null) && (fAttack != null) && (fAction != null))
            {
                if (fAction.Use == PowerUseType.Basic)
                {
                    icon = Resources.MeleeBasic;
                }
                else
                {
                    icon = Resources.Melee;
                }
            }

            str += "<B>" + HTML.Process(fName, true) + "</B>";
            if ((mode == CardMode.Combat) && (cd != null))
            {
                bool create_link = false;

                if (!cd.UsedPowers.Contains(fID))
                {
                    if (fAttack != null)
                    {
                        create_link = true;
                    }

                    if ((fAction != null) && (fAction.Use == PowerUseType.Encounter))
                    {
                        create_link = true;
                    }
                }

                if (create_link)
                {
                    str = "<A href=\"power:" + cd.ID + ";" + fID + "\">" + str + "</A>";
                }
            }
            if (mode == CardMode.Build)
            {
                str = "<A href=power:info>" + str + "</A>";
            }

            if (icon != null)
            {
                MemoryStream ms = new MemoryStream();
                icon.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byteImage = ms.ToArray();
                string data      = Convert.ToBase64String(byteImage);
                if ((data != null) && (data != ""))
                {
                    str = "<img src=data:image/png;base64," + data + ">" + str;
                }
            }

            if (fKeywords != "")
            {
                string keywords = HTML.Process(fKeywords, true);
                if (mode == CardMode.Build)
                {
                    keywords = "<A href=power:info>" + keywords + "</A>";
                }

                str += " (" + keywords + ")";
            }

            string info = power_parenthesis(mode);

            if (info != "")
            {
                str += " &diams; " + info;
            }

            return(str);
        }
Esempio n. 2
0
        /// <summary>
        /// Draws cards from the deck to create an encounter.
        /// </summary>
        /// <param name="enc">The encounter to add to.</param>
        /// <returns>Returns true if the process succeeded; false otherwise.</returns>
        public bool DrawEncounter(Encounter enc)
        {
            if (fCards.Count == 0)
            {
                return(false);
            }

            List <EncounterCard> cards = new List <EncounterCard>();

            List <EncounterCard> available_cards = new List <EncounterCard>();

            foreach (EncounterCard card in fCards)
            {
                if (!card.Drawn)
                {
                    available_cards.Add(card);
                }
            }

            int attempts = 0;

            while (true)
            {
                attempts += 1;

                bool lurker = false;

                int hand_size = Session.Project.Party.Size;
                while ((cards.Count < hand_size) && (available_cards.Count != 0))
                {
                    int           index = Session.Random.Next() % available_cards.Count;
                    EncounterCard card  = available_cards[index];

                    cards.Add(card);
                    available_cards.Remove(card);

                    // If there's a lurker, draw an extra card
                    if ((card.Category == CardCategory.Lurker) && (!lurker))
                    {
                        hand_size += 1;
                        lurker     = true;
                    }
                }

                int soldier_cards = 0;
                foreach (EncounterCard card in cards)
                {
                    if (card.Category == CardCategory.SoldierBrute)
                    {
                        soldier_cards += 1;
                    }
                }

                if ((soldier_cards == 1) || (attempts == 1000))
                {
                    break;
                }

                available_cards.AddRange(cards);
                cards.Clear();
            }

            // If this hand contains the solo creature, take that card and return the others
            foreach (EncounterCard c in cards)
            {
                if (c.Category == CardCategory.Solo)
                {
                    cards.Remove(c);

                    available_cards.AddRange(cards);
                    cards.Clear();

                    cards.Add(c);

                    break;
                }
            }

            foreach (EncounterCard card in cards)
            {
                card.Drawn = true;
            }

            enc.Slots.Clear();

            foreach (EncounterCard card in cards)
            {
                // Do we already have a card of this type?
                EncounterSlot slot = null;
                foreach (EncounterSlot s in enc.Slots)
                {
                    if (s.Card.CreatureID == card.CreatureID)
                    {
                        slot = s;
                        break;
                    }
                }

                if (slot == null)
                {
                    slot      = new EncounterSlot();
                    slot.Card = card;
                    enc.Slots.Add(slot);
                }

                int count = 1;
                switch (card.Category)
                {
                case CardCategory.SoldierBrute:
                    count = 2;
                    break;

                case CardCategory.Minion:
                    count += 4;
                    break;
                }

                for (int n = 0; n != count; ++n)
                {
                    CombatData ccd = new CombatData();
                    slot.CombatData.Add(ccd);
                }
            }

            foreach (EncounterSlot slot in enc.Slots)
            {
                slot.SetDefaultDisplayNames();
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the HTML representation of the power.
        /// </summary>
        /// <param name="cd">The CombatData to use.</param>
        /// <param name="mode">The type of HTML to generate</param>
        /// <param name="functional_template">True if this power is from a functional template; false otherwise</param>
        /// <returns>Returns the HTML source code.</returns>
        public List <string> AsHTML(CombatData cd, CardMode mode, bool functional_template)
        {
            bool used = ((mode == CardMode.Combat) && (cd != null) && cd.UsedPowers.Contains(fID));

            string cat = "Actions";

            switch (Category)
            {
            case CreaturePowerCategory.Trait:
                cat = "Traits";
                break;

            case CreaturePowerCategory.Standard:
                cat = "Standard Actions";
                break;

            case CreaturePowerCategory.Move:
                cat = "Move Actions";
                break;

            case CreaturePowerCategory.Minor:
                cat = "Minor Actions";
                break;

            case CreaturePowerCategory.Free:
                cat = "Free Actions";
                break;

            case CreaturePowerCategory.Triggered:
                cat = "Triggered Actions";
                break;

            case CreaturePowerCategory.Other:
                cat = "Other Actions";
                break;
            }

            List <string> content = new List <string>();

            if (mode == CardMode.Build)
            {
                content.Add("<TR class=creature>");
                content.Add("<TD colspan=3>");
                content.Add("<A href=power:action style=\"color:white\"><B>" + cat + "</B> (click here to change the action)</A>");
                content.Add("</TD>");
                content.Add("</TR>");
            }

            if (!used)
            {
                content.Add("<TR class=shaded>");
            }
            else
            {
                content.Add("<TR class=shaded_dimmed>");
            }
            content.Add("<TD colspan=3>");
            content.Add(power_topline(cd, mode));
            content.Add("</TD>");
            content.Add("</TR>");

            if (!used)
            {
                content.Add("<TR>");
            }
            else
            {
                content.Add("<TR class=dimmed>");
            }
            content.Add("<TD colspan=3>");
            content.Add(power_content(mode));
            content.Add("</TD>");
            content.Add("</TR>");

            if (mode == CardMode.Combat)
            {
                if (used)
                {
                    content.Add("<TR>");
                    content.Add("<TD class=indent colspan=3>");
                    content.Add("<A href=\"refresh:" + cd.ID + ";" + fID + "\">(recharge this power)</A>");
                    content.Add("</TD>");
                    content.Add("</TR>");
                }
                else
                {
                    if (fAction != null)
                    {
                        if ((fAction.Use == PowerUseType.Encounter) || (fAction.Use == PowerUseType.Daily))
                        {
                            content.Add("<TR>");
                            content.Add("<TD class=indent colspan=3>");
                            content.Add("<A href=\"refresh:" + cd.ID + ";" + fID + "\">(use this power)</A>");
                            content.Add("</TD>");
                            content.Add("</TR>");
                        }
                    }
                }
            }

            if (functional_template)
            {
                content.Add("<TR class=shaded>");
                content.Add("<TD colspan=3>");
                content.Add("<B>Note</B>: This power is part of a functional template, and so its attack bonus will be increased by the level of the creature it is applied to.");
                content.Add("</TD>");
                content.Add("</TR>");
            }

            return(content);
        }