Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Card"/> class.
 /// </summary>
 /// <param name="cardIndex">Index of the card.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="sequenceNumber">The sequence number.</param>
 public Card(int cardIndex, CardMode mode, int sequenceNumber)
 {
     this._suit = GetSuitFromCardIndex(cardIndex, mode);
     this._rank = GetRankFromIndex(cardIndex, mode);
     this._sequence = sequenceNumber;
     this._cardIndex = cardIndex;
 }
        public void SetModeTest()
        {
            try
            {
                // 1. set in virgin mode
                this.smartCard.SetVirginMode();
                CardMode mode = this.smartCard.GetCardMode();
                Assert.IsTrue(mode == CardMode.VIRGIN);

                // 2. set in root mode
                this.smartCard.SetCardInRootMode();
                mode = this.smartCard.GetCardMode();
                Assert.IsTrue(mode == CardMode.ROOT);

                // 3. set in working mode.
                this.smartCard.SetCardInWorkingMode();
                mode = this.smartCard.GetCardMode();
                Assert.IsTrue(mode == CardMode.WORKING);

                //reset the card again
                this.smartCard.SetVirginMode();
            }
            catch (Exception ex)
            {
                Assert.Fail(String.Format("Reset the device failed: {0}", ex.Message));
            }
        }
Example #3
0
        public void TestGetDeviceCommitment()
        {
            CardMode cardMode = this.smartCard.GetCardMode();

            Assert.AreEqual <CardMode>(CardMode.WORKING, cardMode, "Not in working mode.");

            this.smartCard.BeginCommitment(1);

            byte[] deviceCommitment = this.smartCard.GetDeviceCommitment();
            Assert.AreEqual <byte>(deviceCommitment[deviceCommitment.Length - 1], 0x00, "The BigInteger must be positive");

            this.smartCard.EndCommitment();
        }
Example #4
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);

            mode = CurrentStateService.Instance.Mode;

            await SmartCardFactory.Initialize(); // this will also clear any prev event handlers

            SmartCardFactory.CardAdded   += OnCardAdded;
            SmartCardFactory.CardRemoved += OnCardRemoved;

            Debug.WriteLine("Subscribed from smartcard factory");
        }
Example #5
0
        public void TestGetScopeExclusiveCommitment()
        {
            CardMode cardMode = this.smartCard.GetCardMode();

            Assert.AreEqual <CardMode>(CardMode.WORKING, cardMode, "Not in working mode.");

            this.smartCard.BeginCommitment(1);

            byte[] scopeExlusive = this.smartCard.GetScopeExclusiveCommitment(Utils.GetBytes("MyVeryNiceScopeThatJustKeepGettingBetterAndBetter"));
            Assert.AreEqual <byte>(scopeExlusive[scopeExlusive.Length - 1], 0x00, "The BigInteger must be positive");

            this.smartCard.EndCommitment();
        }
        public string IsEnumValid(CardMode mode, decimal money, decimal result)
        {
            string str = "";

            if (CardMode.InternetOdeme == mode)
            {
                str = $"Internet Odeme Xidmetinden Bu Tarixde {DateTime.Now} Balansizindan {money} Azn cixildi, Balansiniz {result} Azn teskil edir";
            }
            if (CardMode.BalancArtirma == mode)
            {
                str = $"Balanciniz Bu Tarixde {DateTime.Now}  {money} Azn artirildi, Balansiniz {result} Azn teskil edir";
            }
            return(str);
        }
Example #7
0
 public void OnMouseExit()
 {
     if (!isSelected)
     {
         print("Opuszczono");
         mode = CardMode.downscaling;
         StartCoroutine(Downscale());
     }
     else if (isSelected)
     {
         mode       = CardMode.selectedBlur;
         isSelected = true;
     }
 }
Example #8
0
 public void OnMouseEnter()
 {
     if (manager.gameMode == Mode.blocked)
     {
         mode = CardMode.onEnterBlur;
         Debug.Log("ZMIEN KOLOR NA BIAŁY!");
     }
     else
     {
         print("Weszlo");
         mode = CardMode.enlarging;
         StartCoroutine(Enlarge());
     }
 }
Example #9
0
 public void OnMouseDown()
 {
     if (!isSelected && manager.gameMode == Mode.blocked)
     {
         mode = CardMode.selectedBlur;
         manager.GetComponent <GameManager>().selectedCards.Add(this.gameObject);
         Debug.Log("ZMIEN KOLOR NA ZOLTY!");
         isSelected = true;
     }
     else
     {
         mode = CardMode.small;
         manager.GetComponent <GameManager>().selectedCards.Remove(this.gameObject);
         Debug.Log("ZMIEN KOLOR ZNOWU NA ZIELONY!");
         isSelected = false;
     }
 }
Example #10
0
        public BlobStoreTest()
        {
            LoggerUtils.setupLoggers();
            List <CardInfo> lst        = SmartCardUtils.GetReaderNames();
            String          readerName = lst[0].ReaderName;

            smartCard = new SmartCard(readerName, pin);
            CardMode mode = this.smartCard.GetCardMode();

            if (mode != CardMode.ROOT)
            {
                this.smartCard.SetCardInRootMode();
            }
            BigInteger.TryParse(pString, out p);
            BigInteger.TryParse(qString, out q);
            KeyPair pq  = new KeyPair(p, q);
            String  puk = this.smartCard.InitDevice(pq, pin);
        }
Example #11
0
        private string power_parenthesis(CardMode mode)
        {
            if (this.fCondition == "" && this.fAction == null)
            {
                return("");
            }
            string str = "";

            if (this.fAction != null)
            {
                string str1 = this.fAction.ToString();
                if (mode == CardMode.Build)
                {
                    str1 = string.Concat("<A href=power:action>", str1, "</A>");
                }
                str = string.Concat(str, str1);
            }
            return(str);
        }
 public void InitDevice()
 {
     try
     {
         CardMode mode = this.smartCard.GetCardMode();
         if (mode != CardMode.ROOT)
         {
             this.smartCard.SetCardInRootMode();
         }
         KeyPair pq  = new KeyPair(p, q);
         String  puk = this.smartCard.InitDevice(pq, pin);
     }
     catch (ErrorCode ex)
     {
         Assert.Fail(String.Format("Reset the device failed: {0}:{1} with command {2}", ex.SW1, ex.SW2, ex.Command));
     }
     catch (Exception ex)
     {
         Assert.Fail(String.Format("Reset the device failed: {0}", ex.Message));
     }
 }
Example #13
0
        string power_parenthesis(CardMode mode)
        {
            if ((fCondition == "") && (fAction == null))
            {
                return("");
            }

            string info = "";

            if (fAction != null)
            {
                string action = fAction.ToString();
                if (mode == CardMode.Build)
                {
                    action = "<A href=power:action>" + action + "</A>";
                }

                info += action;
            }

            return(info);
        }
Example #14
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);
        }
Example #15
0
        string power_content(CardMode mode)
        {
            List <string> lines = new List <string>();

            string desc = "";

            if (fDescription != null)
            {
                desc = HTML.Process(fDescription, true);
            }
            if (desc == null)
            {
                desc = "";
            }
            if (mode == CardMode.Build)
            {
                if (desc == "")
                {
                    desc = "Set read-aloud description (optional)";
                }

                desc = "<A href=power:desc>" + desc + "</A>";
            }
            if (desc != "")
            {
                lines.Add("<I>" + desc + "</I>");
            }

            if (mode == CardMode.Build)
            {
                lines.Add("");
            }

            if ((fAction != null) && (fAction.Trigger != ""))
            {
                string action;
                switch (fAction.Action)
                {
                case ActionType.Interrupt:
                    action = "immediate interrupt";
                    break;

                case ActionType.None:
                    action = "no action";
                    break;

                case ActionType.Reaction:
                    action = "immediate reaction";
                    break;

                default:
                    action = fAction.Action.ToString().ToLower() + " action";
                    break;
                }

                if (mode != CardMode.Build)
                {
                    lines.Add("Trigger (" + action + "): " + fAction.Trigger);
                }
                else
                {
                    lines.Add("Trigger (<A href=power:action>" + action + "</A>): <A href=power:action>" + fAction.Trigger + "</A>");
                }
            }

            string condition = HTML.Process(fCondition, true);

            if ((condition == "") && (mode == CardMode.Build))
            {
                condition = "No prerequisite";
            }
            if (condition != "")
            {
                if (mode == CardMode.Build)
                {
                    condition = "<A href=power:prerequisite>" + condition + "</A>";
                }

                condition = "Prerequisite: " + condition;

                lines.Add(condition);
            }

            string range  = (fRange != null) ? fRange : "";
            string attack = (fAttack != null) ? fAttack.ToString() : "";

            if (mode == CardMode.Build)
            {
                if (range == "")
                {
                    range = "<A href=power:range>" + "The power's range and its target(s) are not set" + "</A>";
                }
                else
                {
                    range = "<A href=power:range>" + range + "</A>";
                }

                if (attack == "")
                {
                    attack = "<A href=power:attack>Click here to make this an attack power</A>";
                }
                else
                {
                    attack = "<A href=power:attack>" + attack + "</A> <A href=power:clearattack>(clear attack)</A>";
                }
            }
            if (range != "")
            {
                lines.Add("Range: " + range);
            }
            if (attack != "")
            {
                lines.Add("Attack: " + attack);
            }

            if (mode == CardMode.Build)
            {
                lines.Add("");
            }

            string details = HTML.Process(fDetails, true);

            if (details == null)
            {
                details = "";
            }
            if (mode == CardMode.Build)
            {
                if (details == "")
                {
                    details = "Specify the power's effects";
                }

                details = "<A href=power:details>" + details + "</A>";
            }
            if (details != "")
            {
                lines.Add(details);
            }

            if (mode == CardMode.Build)
            {
                lines.Add("");
            }

            if ((fAction != null) && (fAction.SustainAction != ActionType.None))
            {
                string sustain = fAction.SustainAction.ToString();

                if (mode == CardMode.Build)
                {
                    sustain = "<A href=power:action>" + sustain + "</A>";
                }

                lines.Add("Sustain: " + sustain);
            }

            string str = "";

            foreach (string line in lines)
            {
                if (str != "")
                {
                    str += "<BR>";
                }

                str += line;
            }

            if (str == "")
            {
                str = "(no details)";
            }

            return(str);
        }
 public ErrorCode GetMode(out CardMode mode)
 {
   CommandApdu apdu = card.ConstructCommandApdu(IsoCase.Case2Short);
   apdu.CLA = CLA; // Class
   apdu.INS = 0x02; // Instruction: GET MODE
   apdu.P1 = 0x00;  // Parameter 1
   apdu.P2 = 0x00;  // Parameter 2
   apdu.Le = 0x01;  // Expected length of the returned data
   DebugUtils.DebugPrintBegin( null);
   // Transmit the Command APDU to the card and receive the response
   Response resp = card.Transmit(apdu);
   ErrorCode err = new ErrorCode(resp.SW1, resp.SW2);
   if (!err.IsOK)
   {
     mode = CardMode.UNKNOWN;
     return err;
   }
   byte[] data;
   bool hasData = getDataFromResponse(resp, out data);
   if (hasData)
   {
     mode = (CardMode)data[0];
     DebugUtils.DebugPrintEnd( data);
     return err;
     
   }
   mode = CardMode.UNKNOWN;
   return new ErrorCode(0x90, 0x01);
 }
Example #17
0
 public void ResetCard()
 {
     gameObject.SetActive(true);
     Hidden   = false;
     CardMode = CardMode.Landed;
 }
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the  
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method 
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);

            mode = CurrentStateService.Instance.Mode;

            await SmartCardFactory.Initialize(); // this will also clear any prev event handlers

            SmartCardFactory.CardAdded += OnCardAdded;
            SmartCardFactory.CardRemoved += OnCardRemoved;

            Debug.WriteLine("Subscribed from smartcard factory");
        }
Example #19
0
        private string power_topline(CombatData cd, CardMode mode)
        {
            string str   = "";
            Image  area  = null;
            string lower = this.fRange.ToLower();

            if (lower.Contains("melee"))
            {
                area = (this.fAction == null || this.fAction.Use != PowerUseType.Basic ? Resources.Melee : Resources.MeleeBasic);
            }
            if (lower.Contains("ranged"))
            {
                area = (this.fAction == null || this.fAction.Use != PowerUseType.Basic ? Resources.Ranged : Resources.RangedBasic);
            }
            if (lower.Contains("area"))
            {
                area = Resources.Area;
            }
            if (lower.Contains("close"))
            {
                area = Resources.Close;
            }
            if (area == null && this.fAttack != null && this.fAction != null)
            {
                area = (this.fAction.Use != PowerUseType.Basic ? Resources.Melee : Resources.MeleeBasic);
            }
            str = string.Concat(str, "<B>", HTML.Process(this.fName, true), "</B>");
            if (mode == CardMode.Combat && cd != null)
            {
                bool flag = false;
                if (!cd.UsedPowers.Contains(this.fID))
                {
                    if (this.fAttack != null)
                    {
                        flag = true;
                    }
                    if (this.fAction != null && this.fAction.Use == PowerUseType.Encounter)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    object[] d = new object[] { "<A href=\"power:", cd.ID, ";", this.fID, "\">", str, "</A>" };
                    str = string.Concat(d);
                }
            }
            if (mode == CardMode.Build)
            {
                str = string.Concat("<A href=power:info>", str, "</A>");
            }
            if (area != null)
            {
                MemoryStream memoryStream = new MemoryStream();
                area.Save(memoryStream, ImageFormat.Png);
                string base64String = Convert.ToBase64String(memoryStream.ToArray());
                if (base64String != null && base64String != "")
                {
                    str = string.Concat("<img src=data:image/png;base64,", base64String, ">", str);
                }
            }
            if (this.fKeywords != "")
            {
                string str1 = HTML.Process(this.fKeywords, true);
                if (mode == CardMode.Build)
                {
                    str1 = string.Concat("<A href=power:info>", str1, "</A>");
                }
                str = string.Concat(str, " (", str1, ")");
            }
            string str2 = this.power_parenthesis(mode);

            if (str2 != "")
            {
                str = string.Concat(str, " &diams; ", str2);
            }
            return(str);
        }
Example #20
0
        private string power_content(CardMode mode)
        {
            string        str;
            List <string> strs = new List <string>();
            string        str1 = "";

            if (this.fDescription != null)
            {
                str1 = HTML.Process(this.fDescription, true);
            }
            if (str1 == null)
            {
                str1 = "";
            }
            if (mode == CardMode.Build)
            {
                if (str1 == "")
                {
                    str1 = "Set read-aloud description (optional)";
                }
                str1 = string.Concat("<A href=power:desc>", str1, "</A>");
            }
            if (str1 != "")
            {
                strs.Add(string.Concat("<I>", str1, "</I>"));
            }
            if (mode == CardMode.Build)
            {
                strs.Add("");
            }
            if (this.fAction != null && this.fAction.Trigger != "")
            {
                ActionType action = this.fAction.Action;
                if (action == ActionType.None)
                {
                    str = "no action";
                }
                else
                {
                    switch (action)
                    {
                    case ActionType.Reaction:
                    {
                        str = "immediate reaction";
                        break;
                    }

                    case ActionType.Interrupt:
                    {
                        str = "immediate interrupt";
                        break;
                    }

                    default:
                    {
                        str = string.Concat(this.fAction.Action.ToString().ToLower(), " action");
                        break;
                    }
                    }
                }
                if (mode == CardMode.Build)
                {
                    string[] trigger = new string[] { "Trigger (<A href=power:action>", str, "</A>): <A href=power:action>", this.fAction.Trigger, "</A>" };
                    strs.Add(string.Concat(trigger));
                }
                else
                {
                    strs.Add(string.Concat("Trigger (", str, "): ", this.fAction.Trigger));
                }
            }
            string str2 = HTML.Process(this.fCondition, true);

            if (str2 == "" && mode == CardMode.Build)
            {
                str2 = "No prerequisite";
            }
            if (str2 != "")
            {
                if (mode == CardMode.Build)
                {
                    str2 = string.Concat("<A href=power:prerequisite>", str2, "</A>");
                }
                str2 = string.Concat("Prerequisite: ", str2);
                strs.Add(str2);
            }
            string str3 = (this.fRange != null ? this.fRange : "");
            string str4 = (this.fAttack != null ? this.fAttack.ToString() : "");

            if (mode == CardMode.Build)
            {
                str3 = (str3 != "" ? string.Concat("<A href=power:range>", str3, "</A>") : "<A href=power:range>The power's range and its target(s) are not set</A>");
                str4 = (str4 != "" ? string.Concat("<A href=power:attack>", str4, "</A> <A href=power:clearattack>(clear attack)</A>") : "<A href=power:attack>Click here to make this an attack power</A>");
            }
            if (str3 != "")
            {
                strs.Add(string.Concat("Range: ", str3));
            }
            if (str4 != "")
            {
                strs.Add(string.Concat("Attack: ", str4));
            }
            if (mode == CardMode.Build)
            {
                strs.Add("");
            }
            string str5 = HTML.Process(this.fDetails, true) ?? "";

            if (mode == CardMode.Build)
            {
                if (str5 == "")
                {
                    str5 = "Specify the power's effects";
                }
                str5 = string.Concat("<A href=power:details>", str5, "</A>");
            }
            if (str5 != "")
            {
                strs.Add(str5);
            }
            if (mode == CardMode.Build)
            {
                strs.Add("");
            }
            if (this.fAction != null && this.fAction.SustainAction != ActionType.None)
            {
                string str6 = this.fAction.SustainAction.ToString();
                if (mode == CardMode.Build)
                {
                    str6 = string.Concat("<A href=power:action>", str6, "</A>");
                }
                strs.Add(string.Concat("Sustain: ", str6));
            }
            string str7 = "";

            foreach (string str8 in strs)
            {
                if (str7 != "")
                {
                    str7 = string.Concat(str7, "<BR>");
                }
                str7 = string.Concat(str7, str8);
            }
            if (str7 == "")
            {
                str7 = "(no details)";
            }
            return(str7);
        }
Example #21
0
        public List <string> AsHTML(CombatData cd, CardMode mode, bool functional_template)
        {
            bool   flag = (mode != CardMode.Combat || cd == null ? false : cd.UsedPowers.Contains(this.fID));
            string str  = "Actions";

            switch (this.Category)
            {
            case CreaturePowerCategory.Trait:
            {
                str = "Traits";
                break;
            }

            case CreaturePowerCategory.Standard:
            {
                str = "Standard Actions";
                break;
            }

            case CreaturePowerCategory.Move:
            {
                str = "Move Actions";
                break;
            }

            case CreaturePowerCategory.Minor:
            {
                str = "Minor Actions";
                break;
            }

            case CreaturePowerCategory.Free:
            {
                str = "Free Actions";
                break;
            }

            case CreaturePowerCategory.Triggered:
            {
                str = "Triggered Actions";
                break;
            }

            case CreaturePowerCategory.Other:
            {
                str = "Other Actions";
                break;
            }
            }
            List <string> strs = new List <string>();

            if (mode == CardMode.Build)
            {
                strs.Add("<TR class=creature>");
                strs.Add("<TD colspan=3>");
                strs.Add(string.Concat("<A href=power:action style=\"color:white\"><B>", str, "</B> (click here to change the action)</A>"));
                strs.Add("</TD>");
                strs.Add("</TR>");
            }
            if (flag)
            {
                strs.Add("<TR class=shaded_dimmed>");
            }
            else
            {
                strs.Add("<TR class=shaded>");
            }
            strs.Add("<TD colspan=3>");
            strs.Add(this.power_topline(cd, mode));
            strs.Add("</TD>");
            strs.Add("</TR>");
            if (flag)
            {
                strs.Add("<TR class=dimmed>");
            }
            else
            {
                strs.Add("<TR>");
            }
            strs.Add("<TD colspan=3>");
            strs.Add(this.power_content(mode));
            strs.Add("</TD>");
            strs.Add("</TR>");
            if (mode == CardMode.Combat)
            {
                if (flag)
                {
                    strs.Add("<TR>");
                    strs.Add("<TD class=indent colspan=3>");
                    object[] d = new object[] { "<A href=\"refresh:", cd.ID, ";", this.fID, "\">(recharge this power)</A>" };
                    strs.Add(string.Concat(d));
                    strs.Add("</TD>");
                    strs.Add("</TR>");
                }
                else if (this.fAction != null && (this.fAction.Use == PowerUseType.Encounter || this.fAction.Use == PowerUseType.Daily))
                {
                    strs.Add("<TR>");
                    strs.Add("<TD class=indent colspan=3>");
                    object[] objArray = new object[] { "<A href=\"refresh:", cd.ID, ";", this.fID, "\">(use this power)</A>" };
                    strs.Add(string.Concat(objArray));
                    strs.Add("</TD>");
                    strs.Add("</TR>");
                }
            }
            if (functional_template)
            {
                strs.Add("<TR class=shaded>");
                strs.Add("<TD colspan=3>");
                strs.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.");
                strs.Add("</TD>");
                strs.Add("</TR>");
            }
            return(strs);
        }
Example #22
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);
        }
Example #23
0
 /// <summary>
 /// Toes the index of the card.
 /// </summary>
 /// <param name="suit">The suit.</param>
 /// <param name="rank">The rank.</param>
 /// <param name="mode">The mode.</param>
 /// <returns></returns>
 public static int ToCardIndex(CardSuit suit, CardRank rank, CardMode mode)
 {
     int result = -1;
     switch (mode)
     {
         case CardMode.RankCollated:
         {
             result = ((int)rank * (int)CardRank.Five + (int)suit);
             break;
         }
         case CardMode.SuitCollated:
         {
             result = ((int)CardRank.Two + (int)rank + (13 * (int)suit));
             break;
         }
         default:
         {
             result = 0;
             break;
         }
     }
     return result;
 }
Example #24
0
 /// <summary>
 /// Gets the index of the suit from card.
 /// </summary>
 /// <param name="cardIndex">Index of the card.</param>
 /// <param name="mode">The mode.</param>
 /// <returns></returns>
 public static CardSuit GetSuitFromCardIndex(int cardIndex, CardMode mode)
 {
     if (mode == CardMode.SuitCollated && cardIndex >= 1 && cardIndex <= 52)
     {
         return (CardSuit)((cardIndex - 1) / 13);
     }
     if (mode == CardMode.RankCollated && cardIndex >= 0 && cardIndex <= 51)
     {
         return (CardSuit)(cardIndex % 4);
     }
     throw new ApplicationException("Suite only valid to SuitCollated, RankCollated modes.");
 }
Example #25
0
 /// <summary>
 /// Gets the index of the rank from.
 /// </summary>
 /// <param name="cardIndex">Index of the card.</param>
 /// <param name="mode">The mode.</param>
 /// <returns></returns>
 public static CardRank GetRankFromIndex(int cardIndex, CardMode mode)
 {
     if (mode == CardMode.SuitCollated && cardIndex >= 1 && cardIndex <= 52)
     {
         return (CardRank)((cardIndex - 1) % 13);
     }
     if (mode == CardMode.RankCollated && cardIndex >= 0 && cardIndex <= 51)
     {
         return (CardRank)(cardIndex / 4);
     }
     throw new ApplicationException("Rank only valid to SuitCollated, RankCollated modes.");
 }