コード例 #1
0
 private void buttonUseDealBreaker_Click(object sender, EventArgs e)
 {
     if (Card != null)
     {
         if (Card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.DealBreaker) == 0)
         {
             //this.Text = "Use DealBreaker Card";
             if (listBoxPlayers.SelectedItem != null)
             {
                 MonopolyDealServiceReference.PlayerModel playerTargeted = (MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedItem;
                 if (playerTargeted.guid.CompareTo(request.thisClientGuid) == 0)
                 {
                     MessageBox.Show("Can not DealBreaker yourself");
                     return;
                 }
                 else
                 {
                     MonopolyDealServiceReference.PropertyCardSet targetedSet = listBoxSets.SelectedItem as MonopolyDealServiceReference.PropertyCardSet;
                     if (targetedSet != null)
                     {
                         request.dealBreaker(Card, playerTargeted.guid, targetedSet);
                         this.Close();
                     }
                     else
                     {
                         MessageBox.Show("No set selected");
                         return;
                     }
                 }
             }
         }
         else if (Card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.SlyDeal) == 0)
         {
             //this.Text = "Use Sly Deal Card";
             //buttonUseDealBreaker.Text = "Sly Deal";
             //this.Text = "Use DealBreaker Card";
             if (listBoxPlayers.SelectedItem != null)
             {
                 MonopolyDealServiceReference.PlayerModel playerTargeted = (MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedItem;
                 if (playerTargeted.guid.CompareTo(request.thisClientGuid) == 0)
                 {
                     MessageBox.Show("Can not Sly Deal yourself");
                     return;
                 }
                 else
                 {
                     MonopolyDealServiceReference.PropertyCardSet targetedSet = listBoxSets.SelectedItem as MonopolyDealServiceReference.PropertyCardSet;
                     if (targetedSet != null)
                     {
                         MonopolyDealServiceReference.Card targetedCard = listBoxCardsInSet.SelectedItem as MonopolyDealServiceReference.Card;
                         if (targetedCard != null)
                         {
                             request.slyDeal(Card, playerTargeted.guid, targetedSet, targetedCard);
                             this.Close();
                         }
                         else
                         {
                             MessageBox.Show("No Card selected");
                         }
                     }
                     else
                     {
                         MessageBox.Show("No set selected");
                         return;
                     }
                 }
             }
         }
         else if (Card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.House) == 0)
         {
             //this.Text = "Use House Card";
             //buttonUseDealBreaker.Text = "Add House";
             if (listBoxPlayers.SelectedItem != null)
             {
                 MonopolyDealServiceReference.PlayerModel playerTargeted = (MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedItem;
                 if (playerTargeted.guid.CompareTo(request.thisClientGuid) != 0)
                 {
                     MessageBox.Show("Can not add a House to another Players Sets");
                     return;
                 }
                 else
                 {
                     MonopolyDealServiceReference.PropertyCardSet targetedSet = listBoxSets.SelectedItem as MonopolyDealServiceReference.PropertyCardSet;
                     if (targetedSet != null)
                     {
                         if (targetedSet.hasHouse)
                         {
                             MessageBox.Show("Can not add more than one house to a set");
                             this.Close();
                         }
                         else
                         {
                             request.house(Card, targetedSet);
                             this.Close();
                         }
                     }
                     else
                     {
                         MessageBox.Show("No set selected");
                         return;
                     }
                 }
             }
         }
         else if (Card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.Hotel) == 0)
         {
             //this.Text = "Use Hotel Card";
             //buttonUseDealBreaker.Text = "Add Hotel";
             if (listBoxPlayers.SelectedItem != null)
             {
                 MonopolyDealServiceReference.PlayerModel playerTargeted = (MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedItem;
                 if (playerTargeted.guid.CompareTo(request.thisClientGuid) != 0)
                 {
                     MessageBox.Show("Can not add a Hotel to another Players Sets");
                     return;
                 }
                 else
                 {
                     MonopolyDealServiceReference.PropertyCardSet targetedSet = listBoxSets.SelectedItem as MonopolyDealServiceReference.PropertyCardSet;
                     if (targetedSet != null)
                     {
                         if (targetedSet.hasHouse != true)
                         {
                             MessageBox.Show("Can not add a Hotel to a set that does not have a House");
                             this.Close();
                         }
                         else if (targetedSet.hasHotel)
                         {
                             MessageBox.Show("Can not add more than one Hotel to a Set");
                         }
                         else
                         {
                             request.hotel(Card, targetedSet);
                             this.Close();
                         }
                     }
                     else
                     {
                         MessageBox.Show("No set selected");
                         return;
                     }
                 }
             }
         }
         else if (Card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.ForcedDeal) == 0)
         {
             if (listBoxPlayers.SelectedItem != null)
             {
                 MonopolyDealServiceReference.PlayerModel playerTargeted = (MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedItem;
                 if (playerTargeted.guid.CompareTo(request.thisClientGuid) == 0)
                 {
                     MessageBox.Show("Can not Forced Deal yourself");
                     return;
                 }
                 else
                 {
                     MonopolyDealServiceReference.PropertyCardSet targetedSet = listBoxSets.SelectedItem as MonopolyDealServiceReference.PropertyCardSet;
                     if (targetedSet != null)
                     {
                         MonopolyDealServiceReference.Card targetedCard = listBoxCardsInSet.SelectedItem as MonopolyDealServiceReference.Card;
                         if (targetedCard != null)
                         {
                             if (listBoxSetCardToGiveUpIsIn.SelectedItem != null)
                             {
                                 MonopolyDealServiceReference.PropertyCardSet givenUpCardSet = (MonopolyDealServiceReference.PropertyCardSet)listBoxSetCardToGiveUpIsIn.SelectedItem;
                                 if (listBoxCardToGiveUp.SelectedItem != null)
                                 {
                                     MonopolyDealServiceReference.Card givenUpCard = (MonopolyDealServiceReference.Card)listBoxCardToGiveUp.SelectedItem;
                                     request.forcedDeal(Card, playerTargeted.guid, targetedSet, targetedCard, givenUpCardSet, givenUpCard);
                                 }
                                 else
                                 {
                                     MessageBox.Show("No Card selected to be given up in Forced Deal");
                                 }
                             }
                             else
                             {
                                 MessageBox.Show("No set to give up Card from in Forced Deal selected");
                             }
                         }
                         else
                         {
                             MessageBox.Show("No Card to take in Forced Deal selected");
                         }
                     }
                     else
                     {
                         MessageBox.Show("No set to take Card from in Forced Deal selected");
                         return;
                     }
                 }
             }
         }
     }
 }