Esempio n. 1
0
 void OnDiscardActionNeeded(object sender, MinMaxEventArgs e)
 {
     if (InvokeRequired)
     {
         // We're not in the UI thread, so we need to call BeginInvoke
         BeginInvoke(new EventHandler<MinMaxEventArgs>(OnDiscardActionNeeded), new[] { sender, e });
         return;
     }
     m_DiscardInfo = e;
     string[] cards = e.Player.Cards.Where(x => !string.IsNullOrEmpty(x)).ToArray();
     chkC1.Checked = false;
     chkC2.Checked = false;
     chkC3.Checked = false;
     chkC4.Checked = false;
     chkC5.Checked = false;
     chkC1.Visible = false;
     chkC2.Visible = false;
     chkC3.Visible = false;
     chkC4.Visible = false;
     chkC5.Visible = false;
     lblC1.Visible = false;
     lblC2.Visible = false;
     lblC3.Visible = false;
     lblC4.Visible = false;
     lblC5.Visible = false;
     switch (cards.Length)
     {
         case 1:
             chkC3.Visible = true;
             lblC3.Visible = true;
             lblC3.Text = cards[0];
             break;
         case 2:
             chkC2.Visible = true;
             lblC2.Visible = true;
             lblC2.Text = cards[0];
             chkC4.Visible = true;
             lblC4.Visible = true;
             lblC4.Text = cards[1];
             break;
         case 3:
             chkC2.Visible = true;
             lblC2.Visible = true;
             lblC2.Text = cards[0];
             chkC3.Visible = true;
             lblC3.Visible = true;
             lblC3.Text = cards[1];
             chkC4.Visible = true;
             lblC4.Visible = true;
             lblC4.Text = cards[2];
             break;
         case 4:
             chkC1.Visible = true;
             lblC1.Visible = true;
             lblC1.Text = cards[0];
             chkC2.Visible = true;
             lblC2.Visible = true;
             lblC2.Text = cards[1];
             chkC3.Visible = true;
             lblC3.Visible = true;
             lblC3.Text = cards[2];
             chkC4.Visible = true;
             lblC4.Visible = true;
             lblC4.Text = cards[3];
             break;
         case 5:
             chkC1.Visible = true;
             lblC1.Visible = true;
             lblC1.Text = cards[0];
             chkC2.Visible = true;
             lblC2.Visible = true;
             lblC2.Text = cards[1];
             chkC3.Visible = true;
             lblC3.Visible = true;
             lblC3.Text = cards[2];
             chkC4.Visible = true;
             lblC4.Visible = true;
             lblC4.Text = cards[3];
             chkC5.Visible = true;
             lblC5.Visible = true;
             lblC5.Text = cards[4];
             break;
     }
     btnDiscard.Enabled = e.Minimum == 0;
     grpDiscard.Visible = true;
 }
Esempio n. 2
0
 void OnDiscardActionNeeded_Console(object sender, MinMaxEventArgs e)
 {
     if (InvokeRequired)
     {
         // We're not in the UI thread, so we need to call BeginInvoke
         BeginInvoke(new EventHandler<MinMaxEventArgs>(OnDiscardActionNeeded_Console), new[] { sender, e });
         return;
     }
     bool isMandatory = e.Minimum > 0;
     bool hasRange = e.Minimum < e.Maximum;
     bool hasMany= e.Maximum > 1;
     WriteLine("==> Discard round started. You " + (isMandatory ? "must" : "can") + " discard " + (hasRange ? "from " + e.Minimum + " to " + e.Maximum : e.Minimum.ToString()) + " card" + (hasMany ? "s" : ""));
 }