public void updateAllowAbleActions(MonopolyDealServiceReference.PlayerModel pm) { buttonDraw2.Enabled = false; buttonBankCard.Enabled = false; buttonDraw5OnTurnStart.Enabled = false; buttonPlayPropNewSetFromHand.Enabled = false; buttonDiscard1.Enabled = false; buttonEndTurn.Enabled = false; buttonAdd.Enabled = false; buttonRemove.Enabled = false; buttonPay.Enabled = false; if (!(pm.actionsCurrentlyAllowed == null || pm.actionsCurrentlyAllowed.Length == 0)) { foreach (MonopolyDealServiceReference.TurnActionTypes tAT in pm.actionsCurrentlyAllowed) { if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.drawTwoCardsAtStartOfTurn) == 0) { buttonDraw2.Enabled = true; timerForPollingState.Stop(); } else if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.BankActionCard) == 0) { buttonBankCard.Enabled = true; timerForPollingState.Stop(); } else if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.PlayPropertyCard_New_Set) == 0) { buttonPlayPropNewSetFromHand.Enabled = true; timerForPollingState.Stop(); } else if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.drawFiveCardsAtStartOfTurn) == 0) { buttonDraw5OnTurnStart.Enabled = true; timerForPollingState.Stop(); } else if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.Discard_1_Card) == 0 || tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.Discard_2_Cards) == 0 || tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.Discard_3_Cards) == 0 || tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.Discard_4_Cards) == 0 || tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.Discard_5_Cards) == 0) { buttonDiscard1.Enabled = true; timerForPollingState.Stop(); } else if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.EndTurn) == 0) { buttonEndTurn.Enabled = true; timerForPollingState.Stop(); } else if (tAT.CompareTo(MonopolyDealServiceReference.TurnActionTypes.PayDebt) == 0) { buttonAdd.Enabled = true; buttonRemove.Enabled = true; buttonPay.Enabled = true; timerForPollingState.Stop(); MessageBox.Show("You are in debt! Pay Debt or Just Say No!"); } } } }
private void displayOriginalSet(MonopolyDealServiceReference.PlayFieldModel pfm, Guid thisClientGuid) { //Get correct player MonopolyDealServiceReference.PlayerModel playerClient = null; foreach (MonopolyDealServiceReference.PlayerModel p in pfm.playerModels) { if (p.guid.CompareTo(thisClientGuid) == 0) { playerClient = p; break; } } if (playerClient != null) { this.listBoxSet.DataSource = playerClient.propertySets.playersPropertySets; this.listBoxSet.DisplayMember = "propertySetColor"; } }
private void listBoxCardToGiveUp_SelectedIndexChanged(object sender, EventArgs e) { foreach (MonopolyDealServiceReference.PlayerModel player in this.request.CurrentPlayFieldModel.playerModels) { if (player.guid.CompareTo(request.thisClientGuid) == 0) { thisClientPlayer = player; break; } } if (thisClientPlayer != null) { listBoxSetCardToGiveUpIsIn.DataSource = thisClientPlayer.propertySets.playersPropertySets; listBoxSetCardToGiveUpIsIn.DisplayMember = "propertySetColor"; if (listBoxSetCardToGiveUpIsIn.SelectedValue != null) { listBoxCardToGiveUp.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSetCardToGiveUpIsIn.SelectedValue).properties.ToArray <MonopolyDealServiceReference.Card>(); listBoxCardToGiveUp.DisplayMember = "description"; listBoxCardToGiveUp.ValueMember = "cardID"; } } }
private void listBoxSetCardToGiveUpIsIn_SelectedIndexChanged(object sender, EventArgs e) { foreach (MonopolyDealServiceReference.PlayerModel player in this.request.CurrentPlayFieldModel.playerModels) { if (player.guid.CompareTo(request.thisClientGuid) == 0) { thisClientPlayer = player; break; } } if (thisClientPlayer != null) { listBoxSetCardToGiveUpIsIn.DataSource = thisClientPlayer.propertySets.playersPropertySets; listBoxSetCardToGiveUpIsIn.DisplayMember = "propertySetColor"; if (listBoxSetCardToGiveUpIsIn.SelectedValue != null) { listBoxCardToGiveUp.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSetCardToGiveUpIsIn.SelectedValue).properties.ToArray<MonopolyDealServiceReference.Card>(); listBoxCardToGiveUp.DisplayMember = "description"; listBoxCardToGiveUp.ValueMember = "cardID"; } } }
public UseActionCardForm(MonopolyDealServiceReference.PlayFieldModel pfm, Guid thisClientGuid, RequestHanderMonopolyDeal rqmd, MonopolyDealServiceReference.ActionCard card) { InitializeComponent(); if (card != null) { if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.DealBreaker) == 0) { this.Text = "Use DealBreaker Card"; buttonUseDealBreaker.Text = "DealBreaker"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.SlyDeal) == 0) { this.Text = "Use Sly Deal Card"; buttonUseDealBreaker.Text = "Sly Deal"; groupBox1.Text = "Pick a Card to Sly Deal"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.House) == 0) { this.Text = "Use House Card"; buttonUseDealBreaker.Text = "Add House"; groupBox1.Text = "Pick a Full Set to add a House to"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.Hotel) == 0) { this.Text = "Use Hotel Card"; buttonUseDealBreaker.Text = "Add Hotel"; groupBox1.Text = "Pick a Full Set to add a Hotel to"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.ForcedDeal) == 0) { this.Text = "Use Forced Deal Card"; this.Height = 567; buttonUseDealBreaker.Text = "Use Forced Deal"; groupBox1.Text = "Pick a Card to take in a Forced Deal"; } } request = rqmd; this.Card = card; if (pfm.playerModels != null) { listBoxPlayers.DataSource = pfm.playerModels; listBoxPlayers.DisplayMember = "name"; if (listBoxPlayers.SelectedValue != null) { listBoxSets.DataSource = ((MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedValue).propertySets.playersPropertySets; listBoxSets.DisplayMember = "propertySetColor"; if (listBoxSets.SelectedValue != null) { listBoxCardsInSet.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSets.SelectedValue).properties.ToArray<MonopolyDealServiceReference.Card>(); listBoxCardsInSet.DisplayMember = "description"; listBoxCardsInSet.ValueMember = "cardID"; } } } foreach (MonopolyDealServiceReference.PlayerModel player in this.request.CurrentPlayFieldModel.playerModels) { if (player.guid.CompareTo(request.thisClientGuid) == 0) { thisClientPlayer = player; break; } } if (thisClientPlayer != null) { listBoxSetCardToGiveUpIsIn.DataSource = thisClientPlayer.propertySets.playersPropertySets; listBoxSetCardToGiveUpIsIn.DisplayMember = "propertySetColor"; if (listBoxSetCardToGiveUpIsIn.SelectedValue != null) { listBoxCardToGiveUp.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSetCardToGiveUpIsIn.SelectedValue).properties.ToArray<MonopolyDealServiceReference.Card>(); listBoxCardToGiveUp.DisplayMember = "description"; listBoxCardToGiveUp.ValueMember = "cardID"; } } }
private void button3_Click(object sender, EventArgs e) { MonopolyDealServiceReference.Card card = (MonopolyDealServiceReference.Card)listBox1.SelectedValue; MonopolyDealServiceReference.ActionCard actionCard = card as MonopolyDealServiceReference.ActionCard; MonopolyDealServiceReference.PlayerModel playerTargeted = (MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedItem; if (actionCard != null) { if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.PassGo) == 0) { //card is a pass go card MessageBox.Show("Playing A Pass Go Action Card"); bool result = requestHandler.passGo(card.cardID); } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.DebtCollector) == 0) { MessageBox.Show("Playing a Debt Collector Card"); //card is a Debt Collector card if (playerTargeted.guid.CompareTo(requestHandlerMD.thisClientGuid) == 0) { MessageBox.Show("You can not play a Debt Collector card against yourself. Action canceled"); } else { MessageBox.Show("Playing A Debt Collector Action Card against " + playerTargeted.name); bool result = requestHandler.debtCollector(card.cardID, playerTargeted.guid); if (result) { MessageBox.Show("Action Performed"); } else { MessageBox.Show("Action not performed"); } } } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.ItsMyBirthday) == 0) { MessageBox.Show("Playing a It's My Birthday Card"); bool result = requestHandler.itsMyBirthday(card.cardID); if (result) { MessageBox.Show("Action Performed"); } else { MessageBox.Show("Action not performed"); } } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.RentMultiColor) == 0) { MessageBox.Show("Playing a wild rent card"); if (playerTargeted.guid.CompareTo(requestHandlerMD.thisClientGuid) == 0) { MessageBox.Show("Can not rent yourself"); } else { PickSetToRentOn rent = new PickSetToRentOn(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, card, playerTargeted.guid); rent.ShowDialog(); } } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.RentStandard) == 0) { MessageBox.Show("Playing a standard rent card"); PickSetToRentOn rent = new PickSetToRentOn(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, card, new Guid()); rent.ShowDialog(); } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.DealBreaker) == 0) { MessageBox.Show("Playing a DealBreaker card"); UseActionCardForm dealBreak = new UseActionCardForm(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, (MonopolyDealServiceReference.ActionCard)card); dealBreak.ShowDialog(); } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.ForcedDeal) == 0) { MessageBox.Show("Playing a Forced Deal card"); UseActionCardForm forcedDeal = new UseActionCardForm(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, (MonopolyDealServiceReference.ActionCard)card); forcedDeal.ShowDialog(); } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.SlyDeal) == 0) { MessageBox.Show("Playing a Sly Deal card"); UseActionCardForm slyDeal = new UseActionCardForm(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, (MonopolyDealServiceReference.ActionCard)card); slyDeal.ShowDialog(); } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.House) == 0) { MessageBox.Show("Playing a House card"); UseActionCardForm house = new UseActionCardForm(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, (MonopolyDealServiceReference.ActionCard)card); house.ShowDialog(); } else if (actionCard.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.Hotel) == 0) { MessageBox.Show("Playing a Hotel card"); UseActionCardForm hotel = new UseActionCardForm(requestHandlerMD.CurrentPlayFieldModel, requestHandlerMD.thisClientGuid, requestHandlerMD, (MonopolyDealServiceReference.ActionCard)card); hotel.ShowDialog(); } } //Update State buttonPollMD_Click(null, null); timerForPollingState.Start(); }
public UseActionCardForm(MonopolyDealServiceReference.PlayFieldModel pfm, Guid thisClientGuid, RequestHanderMonopolyDeal rqmd, MonopolyDealServiceReference.ActionCard card) { InitializeComponent(); if (card != null) { if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.DealBreaker) == 0) { this.Text = "Use DealBreaker Card"; buttonUseDealBreaker.Text = "DealBreaker"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.SlyDeal) == 0) { this.Text = "Use Sly Deal Card"; buttonUseDealBreaker.Text = "Sly Deal"; groupBox1.Text = "Pick a Card to Sly Deal"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.House) == 0) { this.Text = "Use House Card"; buttonUseDealBreaker.Text = "Add House"; groupBox1.Text = "Pick a Full Set to add a House to"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.Hotel) == 0) { this.Text = "Use Hotel Card"; buttonUseDealBreaker.Text = "Add Hotel"; groupBox1.Text = "Pick a Full Set to add a Hotel to"; } else if (card.actionType.CompareTo(MonopolyDealServiceReference.ActionCardAction.ForcedDeal) == 0) { this.Text = "Use Forced Deal Card"; this.Height = 567; buttonUseDealBreaker.Text = "Use Forced Deal"; groupBox1.Text = "Pick a Card to take in a Forced Deal"; } } request = rqmd; this.Card = card; if (pfm.playerModels != null) { listBoxPlayers.DataSource = pfm.playerModels; listBoxPlayers.DisplayMember = "name"; if (listBoxPlayers.SelectedValue != null) { listBoxSets.DataSource = ((MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedValue).propertySets.playersPropertySets; listBoxSets.DisplayMember = "propertySetColor"; if (listBoxSets.SelectedValue != null) { listBoxCardsInSet.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSets.SelectedValue).properties.ToArray <MonopolyDealServiceReference.Card>(); listBoxCardsInSet.DisplayMember = "description"; listBoxCardsInSet.ValueMember = "cardID"; } } } foreach (MonopolyDealServiceReference.PlayerModel player in this.request.CurrentPlayFieldModel.playerModels) { if (player.guid.CompareTo(request.thisClientGuid) == 0) { thisClientPlayer = player; break; } } if (thisClientPlayer != null) { listBoxSetCardToGiveUpIsIn.DataSource = thisClientPlayer.propertySets.playersPropertySets; listBoxSetCardToGiveUpIsIn.DisplayMember = "propertySetColor"; if (listBoxSetCardToGiveUpIsIn.SelectedValue != null) { listBoxCardToGiveUp.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSetCardToGiveUpIsIn.SelectedValue).properties.ToArray <MonopolyDealServiceReference.Card>(); listBoxCardToGiveUp.DisplayMember = "description"; listBoxCardToGiveUp.ValueMember = "cardID"; } } }
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; } } } } } }