Пример #1
0
        public string Print()
        {
            string result = "o " + x + "," + y + " " + width + "x" + height + " " + ValueDetail + "/" + CostDetail + " " +
                            ScoreDetail.ToString("#.##") + " " + Risk.ToString("#.##");

            return(result);
        }
Пример #2
0
    public bool SaveToFile(string productCodeName, string versionCodeName)
    {
        var dirPath         = Path.Combine(AppGlobal.AppDataDirectory, productCodeName, versionCodeName);
        var XMLFilePath     = Path.Combine(dirPath, string.Format("{0}.{1}", CodeName, RelXMLExtension));
        var xDoc            = new XmlDocument();
        var declarationNode = xDoc.CreateXmlDeclaration("1.0", "", "");

        xDoc.AppendChild(declarationNode);
        var comment = xDoc.CreateComment(string.Format("This file contains information about {0} - {1}", CodeName, DisplayName));

        xDoc.AppendChild(comment);
        var     docRoot       = xDoc.CreateElement(xtRelease);
        XmlNode ndCodeName    = xDoc.CreateElement(xtReleaseCode),
                ndDisplayName = xDoc.CreateElement(xtDisplayName),
                ndDescription = xDoc.CreateElement(xtDescription),
                ndStage       = xDoc.CreateElement(xtStage),
                ndTargetDate  = xDoc.CreateElement(xtTargetDate),
                ndRiskLevel   = xDoc.CreateElement(xtRiskLevel),
                ndBuildNumber = xDoc.CreateElement(xtBuildNumber),
                ndReleaseType = xDoc.CreateElement(xtReleaseType);

        ndCodeName.InnerText    = CodeName;
        ndDisplayName.InnerText = DisplayName;
        ndDescription.InnerText = Description;
        ndStage.InnerText       = Stage.ToString();
        ndTargetDate.InnerText  = TargetDate;
        ndRiskLevel.InnerText   = Risk.ToString();
        ndBuildNumber.InnerText = BuildNumber.ToString();
        ndReleaseType.InnerText = ReleaseType.ToString();
        docRoot.AppendChild(ndCodeName);
        docRoot.AppendChild(ndDisplayName);
        docRoot.AppendChild(ndDescription);
        docRoot.AppendChild(ndStage);
        docRoot.AppendChild(ndTargetDate);
        docRoot.AppendChild(ndRiskLevel);
        docRoot.AppendChild(ndBuildNumber);
        docRoot.AppendChild(ndReleaseType);
        xDoc.AppendChild(docRoot);
        try
        {
            AppGlobal.CreateDirectory(dirPath);
            xDoc.Save(XMLFilePath);
            return(true);
        }
        catch (Exception e)
        {
            throw new Exception(string.Format("Unable to save Version {0} to file.{1}Message:{2}.", CodeName, Environment.NewLine, e.Message), e);
        }
    }
Пример #3
0
        public Embed Generate()
        {
            EmbedBuilder       e = EmbedData.DefaultEmbed;
            EmbedFooterBuilder f = new EmbedFooterBuilder();

            f.WithText(ToString());

            // Colors
            Color onEmptyColor = EmbedData.GetColor("steamerror");
            Color onLoseColor  = EmbedData.GetColor("error");
            Color onWinColor   = EmbedData.GetColor("origreen");

            // Titles
            string onWinTitle  = "+ {0}";
            string onLoseTitle = "- {0}";
            string onOORTitle  = "> {0}";

            // Money display
            string money = $"{EmojiIndex.Balance}" + "{0}".MarkdownBold();

            string defLoseDesc  = "You lost at chance at {0}.";
            string defWinDesc   = "You have earned " + "(x{0})".MarkdownBold() + " the initial bet!";
            string defEmptyDesc = "You do know you need money, right?";
            string defOORDesc   = "You asked to wager a bit too much.";

            // exceptions based on balance.
            if (Player.Balance == 0)
            {
                e.WithColor(onEmptyColor);
                e.WithTitle(string.Format(money, "null"));
                e.WithDescription(defEmptyDesc);

                return(e.Build());
            }
            if (Player.Balance - Wager < 0)
            {
                if (!Player.Config.Overflow)
                {
                    e.WithColor(onEmptyColor);
                    e.WithTitle(string.Format(onOORTitle, string.Format(money, Player.Balance.ToPlaceValue())));
                    e.WithDescription(defOORDesc);

                    return(e.Build());
                }
                Wager = Player.Balance;
            }

            Player.Take((ulong)Wager);
            e.WithFooter(f);

            if (Victory)
            {
                Player.Give((ulong)Reward);
                e.WithColor(onWinColor);
                e.WithTitle(string.Format(onWinTitle, string.Format(money, Reward.ToPlaceValue())));
                e.WithDescription(string.Format(defWinDesc, Risk.ToString("##,0.0#")));

                return(e.Build());
            }
            else
            {
                e.WithColor(onLoseColor);
                e.WithTitle(string.Format(onLoseTitle, string.Format(money, Wager.ToPlaceValue())));
                e.WithDescription(LosingSummary ?? string.Format(defLoseDesc, string.Format(money, Reward.ToPlaceValue())));

                return(e.Build());
            }
        }