/// <summary> /// Gets all of the clients property, house, hotel and banked cards and puts them in a list passed to the method. /// Returns the total value of the players played cards /// </summary> /// <param name="pfm">The current game state</param> /// <param name="playersPlayedCards">List to place cards in.</param> /// <returns>Total value of all of a players played cards</returns> public int getAllPlayersPlayedCards(MonopolyDealServiceReference.PlayFieldModel pfm, List <MonopolyDealServiceReference.Card> playersPlayedCards) { int totalValue = 0; foreach (MonopolyDealServiceReference.PlayerModel player in pfm.playerModels) { if (requestHandler.thisClientGuid.CompareTo(player.guid) == 0) { foreach (MonopolyDealServiceReference.Card c in player.bank.cardsInBank) { playersPlayedCards.Add(c); totalValue += c.cardValue; } foreach (MonopolyDealServiceReference.PropertyCardSet ps in player.propertySets.playersPropertySets) { foreach (MonopolyDealServiceReference.Card property in ps.properties) { playersPlayedCards.Add(property); totalValue += property.cardValue; } if (ps.hasHouse && ps.house != null) { playersPlayedCards.Add(ps.house); totalValue += ps.house.cardValue; if (ps.hasHotel && ps.hotel != null) { playersPlayedCards.Add(ps.hotel); totalValue += ps.hotel.cardValue; } } } } } return(totalValue); }
internal void pollState() { getServiceReady(); try { MonopolyDealServiceReference.GuidBox thisClientGuidB = new MonopolyDealServiceReference.GuidBox(); thisClientGuidB.guid = thisClientGuid; MonopolyDealServiceReference.GuidBox gameOnServiceGuidB = new MonopolyDealServiceReference.GuidBox(); gameOnServiceGuidB.guid = gameOnServiceGuid; MonopolyDealServiceReference.PlayFieldModel pfm = monopolyDealService.pollStateMonopolyDeal(thisClientGuidB, gameOnServiceGuidB); CurrentPlayFieldModel = pfm; mainForm.drawField(CurrentPlayFieldModel); addToLog(pfm.currentPhase.ToString()); foreach (MonopolyDealServiceReference.PlayerModel p in pfm.playerModels) { if (p.isThisPlayersTurn) { addToLog("Player: " + p.name + "'s Turn"); } } } catch (Exception ex) { addToLog(ex.ToString()); //monopolyDealService.Close(); } }
public void drawPlayer4(MonopolyDealServiceReference.PlayFieldModel pfm) { textBoxHand5.Text = ""; textBoxBank5.Text = ""; textBoxProp5.Text = ""; foreach (MonopolyDealServiceReference.Card card in pfm.playerModels[4].hand.cardsInHand) { textBoxHand5.Text = textBoxHand5.Text + "ID:" + card.cardID + " " + card.cardName + " $" + card.cardValue + Environment.NewLine; if (thisPlayerGuid.CompareTo(pfm.playerModels[4].guid) == 0) { updateTextBoxLog(card.ToString()); popluateHandListBox(card); } } foreach (MonopolyDealServiceReference.Card card in pfm.playerModels[4].bank.cardsInBank) { textBoxBank5.Text = textBoxBank5.Text + "ID:" + card.cardID + " " + card.cardName + " $" + card.cardValue + Environment.NewLine; } foreach (MonopolyDealServiceReference.PropertyCardSet cardSet in pfm.playerModels[4].propertySets.playersPropertySets) { foreach (MonopolyDealServiceReference.Card card in cardSet.properties) { textBoxProp5.Text = textBoxProp5.Text + "ID:" + card.cardID + " " + card.cardName + " $" + card.cardValue + Environment.NewLine; } } }
public PickSetToRentOn(MonopolyDealServiceReference.PlayFieldModel pfm, Guid thisClientGuid, RequestHanderMonopolyDeal rqmd, MonopolyDealServiceReference.Card card, Guid targetedPlayerWildRent) { request = rqmd; this.RentCard = card; targetedPlayer = targetedPlayerWildRent; InitializeComponent(); displayOriginalSet(pfm, thisClientGuid); displayCardsInHand(pfm); }
public void displayField(MonopolyDealServiceReference.PlayFieldModel pfm) { displayHandsBanksPropertySets(pfm); //Check if you can take an action //Display anyActions taken last turn //Display the whose turn it is //prevent players whose turn is is not from doing anything but watch //Present the player whose turn it is with the actions they can take this turn }
public void drawPlayer4(MonopolyDealServiceReference.PlayFieldModel pfm) { bindPlayer4(pfm); if (requestHandler.thisClientGuid.CompareTo(pfm.playerModels[4].guid) == 0) { BindListBox(4); updateAllowAbleActions(pfm.playerModels[4]); playerIDNum = 4; } }
public void drawPlayer0(MonopolyDealServiceReference.PlayFieldModel pfm) { bindPlayer0(pfm); if (requestHandler.thisClientGuid.CompareTo(pfm.playerModels[0].guid) == 0) { //This is the player on this client BindListBox(0); updateAllowAbleActions(pfm.playerModels[0]); playerIDNum = 0; } }
private void displayCardsInHand(MonopolyDealServiceReference.PlayFieldModel pfm) { foreach (MonopolyDealServiceReference.PlayerModel p in this.request.CurrentPlayFieldModel.playerModels) { if (p.guid.CompareTo(request.thisClientGuid) == 0) { listBoxCardsInHand.DataSource = p.hand.cardsInHand; listBoxCardsInHand.DisplayMember = "description"; } } }
public void bindPlayer4(MonopolyDealServiceReference.PlayFieldModel pfm) { listBoxPlayer4Hand.DataSource = requestHandler.CurrentPlayFieldModel.playerModels.ElementAt(4).hand.cardsInHand; listBoxPlayer4Hand.DisplayMember = "description"; // listBoxPlayer4Hand.ValueMember = "cardID"; listBoxPlayer4Bank.DataSource = requestHandler.CurrentPlayFieldModel.playerModels.ElementAt(4).bank.cardsInBank; listBoxPlayer4Bank.DisplayMember = "description"; //listBoxPlayer4Bank.ValueMember = "cardID"; listBoxPSetsP4.DataSource = requestHandler.CurrentPlayFieldModel.playerModels.ElementAt(4).propertySets.playersPropertySets; listBoxPSetsP4.DisplayMember = "propertySetColor"; }
private void bindPlayerPayDebt(MonopolyDealServiceReference.PlayFieldModel pfm) { int playersTotalValue = getAllPlayersPlayedCards(pfm, playersPlayedCards); listBoxAllPlayersPlayedCards.DataSource = playersPlayedCards; listBoxAllPlayersPlayedCards.DisplayMember = "description"; listBoxCardsToPayWith.DataSource = playersSelectedToPayWithCards; listBoxCardsToPayWith.DisplayMember = "description"; foreach (MonopolyDealServiceReference.PlayerModel p in requestHandlerMD.CurrentPlayFieldModel.playerModels) { if (p.guid.CompareTo(requestHandlerMD.thisClientGuid) == 0) { labelAmountToPay.Text = "Total Amount of Debt: $M" + p.amountOwedToAnotherPlayer.ToString(); break; } } }
private void displayHandsBanksPropertySets(MonopolyDealServiceReference.PlayFieldModel pfm) { // The UI thread won't be handling the callback, but it is the only one allowed to update the controls. // So, we will dispatch the UI update back to the UI sync context. //Create a SendOrPostCallback delegate with an anon method which recieves an Object called state and runs code in the SychronisationContext it is marshalled to using Post SendOrPostCallback callback = delegate(object state) { mainForm.drawField((MonopolyDealServiceReference.PlayFieldModel)state); //state is a string object example //mainForm.updateTextBoxLog(state.ToString()); }; //Post takes a delagate and a State object and runs the delegate(State object) in the context Post is called on. uiSync.Post(callback, pfm); }
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"; } }
//public void displayThisClientHand(MonopolyDealServiceReference. player) // { //player //throw private new NotImplementedException(); // } public void drawField(MonopolyDealServiceReference.PlayFieldModel pfm) { textBoxHand1.Text = ""; //Player0 int numPlayers = pfm.playerModels.Count(); switch (numPlayers) { case 0: break; case 1: drawPlayer0(pfm); break; case 2: drawPlayer0(pfm); drawPlayer1(pfm); break; case 3: drawPlayer0(pfm); drawPlayer1(pfm); drawPlayer2(pfm); break; case 4: drawPlayer0(pfm); drawPlayer1(pfm); drawPlayer2(pfm); drawPlayer3(pfm); break; case 5: drawPlayer0(pfm); drawPlayer1(pfm); drawPlayer2(pfm); drawPlayer3(pfm); drawPlayer4(pfm); break; } }
private void bindSelectPlayersPropertyCardSetsPropertyCards(MonopolyDealServiceReference.PlayFieldModel pfm) { if (pfm.playerModels != null) { listBoxPlayers.DataSource = pfm.playerModels; listBoxPlayers.DisplayMember = "name"; if (listBoxPlayers.SelectedValue != null) { listBoxSelectedPlayersPropertySets.DataSource = ((MonopolyDealServiceReference.PlayerModel)listBoxPlayers.SelectedValue).propertySets.playersPropertySets; listBoxSelectedPlayersPropertySets.DisplayMember = "propertySetColor"; if (listBoxSelectedPlayersPropertySets.SelectedValue != null) { listBoxSelectedPlayersSelectedSetPropertyCards.DataSource = ((MonopolyDealServiceReference.PropertyCardSet)listBoxSelectedPlayersPropertySets.SelectedValue).properties.ToArray <MonopolyDealServiceReference.Card>(); listBoxSelectedPlayersSelectedSetPropertyCards.DisplayMember = "description"; listBoxSelectedPlayersSelectedSetPropertyCards.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"; } } }
public MovePropertyToNewSetForm(MonopolyDealServiceReference.PlayFieldModel pfm, Guid thisClientGuid, RequestHanderMonopolyDeal rqmd) { request = rqmd; InitializeComponent(); displayOriginalSet(pfm, thisClientGuid); }
/* public void processMessage(MonopolyDealServiceReference.Message message) { //INCOMPLETE if (message is MonopolyDealServiceReference.FieldUpdateMessage) { MonopolyDealServiceReference.FieldUpdateMessage messageFM = (MonopolyDealServiceReference.FieldUpdateMessage)message; displayField(messageFM.fieldModel); savefield(messageFM.fieldModel); } } */ public void savefield(MonopolyDealServiceReference.PlayFieldModel pfm) { this.playFieldModel = pfm; }
public void savefield(MonopolyDealServiceReference.PlayFieldModel pfm) { this.playFieldModel = pfm; }
public void checkIfClientTurn(MonopolyDealServiceReference.PlayFieldModel pfm) { //MonopolyDealServiceReference.TurnActionModel tam = pfm. }
public void drawField(MonopolyDealServiceReference.PlayFieldModel pfm) { //Player0 int numPlayers = pfm.playerModels.Count(); //Draw playpile listBoxDiscardPile.DataSource = pfm.playpile.playPile; listBoxDiscardPile.DisplayMember = "description"; switch (numPlayers) { case 0: break; case 1: drawPlayer0(pfm); playersPlayedCards = new List <MonopolyDealServiceReference.Card>(); playersSelectedToPayWithCards = new List <MonopolyDealServiceReference.Card>(); bindSelectPlayersPropertyCardSetsPropertyCards(pfm); bindPlayerPayDebt(pfm); break; case 2: drawPlayer0(pfm); drawPlayer1(pfm); playersPlayedCards = new List <MonopolyDealServiceReference.Card>(); playersSelectedToPayWithCards = new List <MonopolyDealServiceReference.Card>(); bindSelectPlayersPropertyCardSetsPropertyCards(pfm); bindPlayerPayDebt(pfm); break; case 3: drawPlayer0(pfm); drawPlayer1(pfm); drawPlayer2(pfm); playersPlayedCards = new List <MonopolyDealServiceReference.Card>(); playersSelectedToPayWithCards = new List <MonopolyDealServiceReference.Card>(); bindSelectPlayersPropertyCardSetsPropertyCards(pfm); bindPlayerPayDebt(pfm); break; case 4: drawPlayer0(pfm); drawPlayer1(pfm); drawPlayer2(pfm); drawPlayer3(pfm); playersPlayedCards = new List <MonopolyDealServiceReference.Card>(); playersSelectedToPayWithCards = new List <MonopolyDealServiceReference.Card>(); bindSelectPlayersPropertyCardSetsPropertyCards(pfm); bindPlayerPayDebt(pfm); break; case 5: drawPlayer0(pfm); drawPlayer1(pfm); drawPlayer2(pfm); drawPlayer3(pfm); drawPlayer4(pfm); playersPlayedCards = new List <MonopolyDealServiceReference.Card>(); playersSelectedToPayWithCards = new List <MonopolyDealServiceReference.Card>(); bindSelectPlayersPropertyCardSetsPropertyCards(pfm); bindPlayerPayDebt(pfm); break; } }