示例#1
0
        private void btnLaunchServer_Click(object sender, EventArgs e)
        {
            if (tbFile.Text.Length == 0)
            {
                MessageBox.Show("You must choose a set file.");
                return;
            }
            if (!int.TryParse(tbPacks.Text, out var packs) || packs < 1)
            {
                MessageBox.Show("You must enter a positive integer number of packs.");
                return;
            }
            if (!int.TryParse(tbLands.Text, out var lands) || lands < 0)
            {
                MessageBox.Show("You must enter a nonnegative integer number of lands.");
                return;
            }
            if (!int.TryParse(tbNonLands.Text, out var nonLands) || nonLands < 1)
            {
                MessageBox.Show("You must enter a positive integer number of lands.");
                return;
            }

            btnLaunchServer.Enabled          = false;
            btnBrowse.Enabled                = false;
            tbFile.Enabled                   = false;
            tbLands.Enabled                  = false;
            tbNonLands.Enabled               = false;
            tbPacks.Enabled                  = false;
            isochron.Default.SetFile         = tbFile.Text;
            isochron.Default.Packs           = tbPacks.Text;
            isochron.Default.LandsPerPack    = tbLands.Text;
            isochron.Default.NonLandsPerPack = tbNonLands.Text;
            isochron.Default.Save();
            server = new DraftServer(this, tbFile.Text, packs, lands, nonLands);
            server.PrintServerStartMessage();
        }
示例#2
0
 //Launch click event
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox2.Text.Length == 0)
     {
         MessageBox.Show("You must choose a set file.");
         return;
     }
     if (textBox3.Text.Length == 0)
     {
         MessageBox.Show("You must enter a remote image directory.");
         return;
     }
     int packs, commons, uncommons, rares;
     float mythicPercentage;
     if (!int.TryParse(textBox8.Text, out packs) || packs < 0)
     {
         MessageBox.Show("You must enter a positive integer number of packs.");
         return;
     }
     if (!int.TryParse(textBox4.Text, out commons) || commons < 0)
     {
         MessageBox.Show("You must enter a positive integer number of commons.");
         return;
     }
     if (!int.TryParse(textBox5.Text, out uncommons) || uncommons < 0)
     {
         MessageBox.Show("You must enter a positive integer number of uncommons.");
         return;
     }
     if (!int.TryParse(textBox6.Text, out rares) || rares < 0)
     {
         MessageBox.Show("You must enter a positive integer number of rares.");
         return;
     }
     if (!float.TryParse(textBox7.Text, out mythicPercentage) || mythicPercentage < 0 || mythicPercentage > 1)
     {
         MessageBox.Show("You must enter a mythic percentage between 0 and 1.");
         return;
     }
     Util.imageDirectory = textBox3.Text;
     if (!Util.imageDirectory.EndsWith("/"))
         Util.imageDirectory += "/";
     server = new DraftServer(this, textBox2.Text, packs, commons, uncommons, rares, mythicPercentage);
     if (server.IsValidSet())
     {
         isochron.Default.SetFile = textBox2.Text;
         isochron.Default.ImageDirectory = textBox3.Text;
         isochron.Default.Packs = textBox8.Text;
         isochron.Default.CommonsPerPack = textBox4.Text;
         isochron.Default.UncommonPerPack = textBox5.Text;
         isochron.Default.RaresPerPack = textBox6.Text;
         isochron.Default.MythicPercentage = textBox7.Text;
         isochron.Default.Save();
         buttonLaunch.Enabled = false;
         buttonBrowse.Enabled = false;
         textBox2.Enabled = false;
         textBox3.Enabled = false;
         textBox4.Enabled = false;
         textBox5.Enabled = false;
         textBox6.Enabled = false;
         textBox7.Enabled = false;
         textBox8.Enabled = false;
         server.PrintServerStartMessage();
     }
     else
         server.server.Close();
 }
示例#3
0
        //Launch click event
        private void btnLaunchServer_Click(object sender, EventArgs e)
        {
            if (txtSetFilePath.Text.Length == 0)
            {
                MessageBox.Show("You must choose a set file.");
                return;
            }
            if (txtImageFolderPath.Text.Length == 0)
            {
                MessageBox.Show("You must enter a remote image directory.");
                return;
            }
            int   packs, commons, uncommons, rares;
            float mythicPercentage;

            if (!int.TryParse(txtPacksCount.Text, out packs) || packs < 0)
            {
                MessageBox.Show("You must enter a positive integer number of packs.");
                return;
            }
            if (!int.TryParse(txtCommonsCount.Text, out commons) || commons < 0)
            {
                MessageBox.Show("You must enter a positive integer number of commons.");
                return;
            }
            if (!int.TryParse(txtUncommonsCount.Text, out uncommons) || uncommons < 0)
            {
                MessageBox.Show("You must enter a positive integer number of uncommons.");
                return;
            }
            if (!int.TryParse(txtRaresCount.Text, out rares) || rares < 0)
            {
                MessageBox.Show("You must enter a positive integer number of rares.");
                return;
            }
            if (!float.TryParse(txtMythicsPercent.Text, out mythicPercentage) || mythicPercentage < 0 || mythicPercentage > 1)
            {
                MessageBox.Show("You must enter a mythic percentage between 0 and 1.");
                return;
            }
            Util.imageDirectory = txtImageFolderPath.Text;
            if (!Util.imageDirectory.EndsWith("/"))
            {
                Util.imageDirectory += "/";
            }
            server = new DraftServer(this, txtSetFilePath.Text, packs, commons, uncommons, rares, mythicPercentage);
            if (server.IsValidSet())
            {
                isochron.Default.SetFile          = txtSetFilePath.Text;
                isochron.Default.ImageDirectory   = txtImageFolderPath.Text;
                isochron.Default.Packs            = txtPacksCount.Text;
                isochron.Default.CommonsPerPack   = txtCommonsCount.Text;
                isochron.Default.UncommonPerPack  = txtUncommonsCount.Text;
                isochron.Default.RaresPerPack     = txtRaresCount.Text;
                isochron.Default.MythicPercentage = txtMythicsPercent.Text;
                isochron.Default.Save();
                btnLaunchServer.Enabled    = false;
                btnSetFileBrowse.Enabled   = false;
                txtSetFilePath.Enabled     = false;
                txtImageFolderPath.Enabled = false;
                txtCommonsCount.Enabled    = false;
                txtUncommonsCount.Enabled  = false;
                txtRaresCount.Enabled      = false;
                txtMythicsPercent.Enabled  = false;
                txtPacksCount.Enabled      = false;
                server.PrintServerStartMessage();
            }
            else
            {
                server.server.Close();
            }
        }