public bool playPropertyCardToExistingSet(Card playedCard, PropertyCardSet setToPlayPropertyTo, Guid gameLobbyGuid, Guid playerGuid, Guid playfieldModelInstanceGuid) { PlayFieldModel lastState = getPreviousState(); PlayFieldModel currentState = getCurrentState(); PlayFieldModel nextState = null; PlayerModel playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState); PropertyCard playedPropertycard = monopolyDeal.deck.getCardByID(playedCard.cardID) as PropertyCard; if (playedPropertycard != null && checkIfCardInHand(playedPropertycard, playerModelAtCurrentState) != null) { MoveInfo playPropertyCardFromHand = new MoveInfo(); playPropertyCardFromHand.playerMakingMove = playerGuid; playPropertyCardFromHand.moveBeingMade = TurnActionTypes.PlayPropertyCardFromHand; playPropertyCardFromHand.idOfCardBeingUsed = playedCard.cardID; bool isOrientedUp = (playedCard as PropertyCard).isCardUp; playPropertyCardFromHand.isPropertyToPlayOrientedUp = isOrientedUp; playPropertyCardFromHand.addPropertyToPlayToExistingSet = true;//Add to existing set playPropertyCardFromHand.guidOfExistingSetToPlayPropertyTo = setToPlayPropertyTo.guid; BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playPropertyCardFromHand.moveBeingMade, playPropertyCardFromHand); return(result.success); } return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a property card").success); }
internal bool removeEmptySet(PropertyCardSet ps) { if (playersPropertySets.Remove(ps)) { return true; } else { return false; } }
internal bool removeEmptySet(PropertyCardSet ps) { if (playersPropertySets.Remove(ps)) { return(true); } else { return(false); } }
public bool playPropertyCardFromHand(PropertyCard card, PropertyCardSet setToPlaceCardIn) { if (setToPlaceCardIn.addProperty(card)) { cardsInHand.Remove(card); return(true); } else { return(false); } }
public PropertyCardSet(PropertyCardSet pcs, PlayFieldModel state)//Clone Constructor { id = pcs.id; guid = pcs.guid; hasHouse = pcs.hasHouse; hasHotel = pcs.hasHotel; if (pcs.hotel != null) { this.hotel = state.deck.getCardByID(pcs.hotel.cardID); } if (pcs.house != null) { this.house = state.deck.getCardByID(pcs.house.cardID); } properties = pcs.properties.cloneLinkedListPropertyCard(state.deck); propertySetColor = pcs.propertySetColor; }
//Clone Constructor public PropertyCardSet(PropertyCardSet pcs, PlayFieldModel state) { id = pcs.id; guid = pcs.guid; hasHouse = pcs.hasHouse; hasHotel = pcs.hasHotel; if (pcs.hotel != null) { this.hotel = state.deck.getCardByID(pcs.hotel.cardID); } if (pcs.house != null) { this.house = state.deck.getCardByID(pcs.house.cardID); } properties = pcs.properties.cloneLinkedListPropertyCard(state.deck); propertySetColor = pcs.propertySetColor; }
public bool playPropertyCardMD(PlayerModel player, Card playedCard, PropertyCardSet setToPlayPropertyTo, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid, GuidBox turnActionGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().playPropertyCardToExistingSet(playedCard, setToPlayPropertyTo, gameLobbyGuid.guid, playerGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
public bool playPropertyCardFromHand(PropertyCard card, PropertyCardSet setToPlaceCardIn) { if (setToPlaceCardIn.addProperty(card)) { cardsInHand.Remove(card); return true; } else { return false; } }
public void addSet(PropertyCardSet ps) { playersPropertySets.Add(ps); }
public bool playPropertyCardToExistingSet(Card playedCard, PropertyCardSet setToPlayPropertyTo, Guid gameLobbyGuid, Guid playerGuid, Guid playfieldModelInstanceGuid) { PlayFieldModel lastState = getPreviousState(); PlayFieldModel currentState = getCurrentState(); PlayFieldModel nextState = null; PlayerModel playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState); PropertyCard playedPropertycard = monopolyDeal.deck.getCardByID(playedCard.cardID) as PropertyCard; if (playedPropertycard != null && checkIfCardInHand(playedPropertycard, playerModelAtCurrentState) != null) { MoveInfo playPropertyCardFromHand = new MoveInfo(); playPropertyCardFromHand.playerMakingMove = playerGuid; playPropertyCardFromHand.moveBeingMade = TurnActionTypes.PlayPropertyCardFromHand; playPropertyCardFromHand.idOfCardBeingUsed = playedCard.cardID; bool isOrientedUp = (playedCard as PropertyCard).isCardUp; playPropertyCardFromHand.isPropertyToPlayOrientedUp = isOrientedUp; playPropertyCardFromHand.addPropertyToPlayToExistingSet = true;//Add to existing set playPropertyCardFromHand.guidOfExistingSetToPlayPropertyTo = setToPlayPropertyTo.guid; BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playPropertyCardFromHand.moveBeingMade, playPropertyCardFromHand); return result.success; } return new BoolResponseBox(false, "Selected Card is not in players hand or is not a property card").success; }
/// <summary> /// Plays a Property Card from a Players Hand on their turn to a new Property Set /// </summary> /// <param name="currentState"></param> /// <param name="nextState"></param> /// <param name="playerPerformingAction"></param> /// <param name="moveInformation"></param> /// <param name="notJustSayNoAble"></param> /// <returns></returns> private BoolResponseBox playPropertyCardFromHandToNewSet(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble) { //Clone the current state to create next state nextState = currentState.clone(generateGuidForNextState()); //Get CurrentPlayFieldModelState Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed); PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState); Card card = removeCardFromHand(cardInHandToBePlayed, player); if (card != null) { PropertyCard cP = cardInHandToBePlayed as PropertyCard; cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp); PropertyCardSet ps = new PropertyCardSet(cP); player.propertySets.addSet(ps); //Change state on success //has been performed, advance the phase of the game nextState.currentPhase = notJustSayNoAble; List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>(); List<TurnActionTypes> onTurn = new List<TurnActionTypes>(); onTurn = setAllowableActionsOnTurn(onTurn, nextState); updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs); //change the current state to the next state addNextState(nextState); return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has played to a new set " + card.cardName); } return new BoolResponseBox(false, "Card is not in hand."); }
private bool undoSlyDeal(PlayFieldModel currentState, PlayFieldModel nextState) { ActionCardEvent undoSlyDeal = currentState.actionCardEvent; PlayerModel playerModelForPlayerRegainingCard = getPlayerModel(undoSlyDeal.playerAffectedByAction, nextState); PlayerModel playerModelForPlayerLoosingCard = getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, nextState); //Get the reference to the players playerModel in the current PlayFieldModel PropertyCard cardtaken = nextState.deck.getCardByID(undoSlyDeal.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].cardID) as PropertyCard; Guid guidOfSetCardWasIn = undoSlyDeal.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].setGuid; PropertyCardSet setCardWasIn = getPropertyCardSet(playerModelForPlayerRegainingCard.propertySets, guidOfSetCardWasIn); if (cardtaken != null) { PropertyCard card = playerModelForPlayerLoosingCard.removePropertyCardFromPlayersPropertySets(cardtaken); if (card != null) { if (setCardWasIn == null) { setCardWasIn = new PropertyCardSet(card); playerModelForPlayerRegainingCard.propertySets.addSet(setCardWasIn); } else { if (setCardWasIn.addProperty(card)) { return true; } else { return false; } } } } return false; }
public bool playPropertyCardMD(PlayerModel player, Card playedCard, PropertyCardSet setToPlayPropertyTo, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid, GuidBox turnActionGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return md.getMonopolyDealGameStateManager().playPropertyCardToExistingSet(playedCard, setToPlayPropertyTo, gameLobbyGuid.guid, playerGuid.guid, playfieldModelInstanceGuid.guid); } else { return false; } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
public bool playPropertyCardToNewSet(Guid gameGuid, bool isOrientedUp, Guid playerGuid, Guid gameStateActionShouldBeAppliedOnGuid, TurnActionTypes actionType, int propertyCardID) { //Get CurrentPlayFieldModelState currentPlayFieldModel = getCurrentPlayFieldModel(); PlayerModel player = getPlayerByGuid(playerGuid, currentPlayFieldModel); if (checkIfActionIsForThisState(actionType, gameStateActionShouldBeAppliedOnGuid, playerGuid, gameGuid)) { if (actionType.CompareTo(TurnActionTypes.PlayPropertyCard_New_Set) == 0) { foreach (Card c in player.hand.cardsInHand) { if (c.cardID == propertyCardID && c is PropertyCard) { Card card = removeCardFromHand(c, player); if (card != null) { PropertyCard cP = c as PropertyCard; PropertyCardSet ps = new PropertyCardSet(cP); cP.setPropertyColor(isOrientedUp); player.propertySets.addSet(ps); updateState(TurnActionTypes.PlayPropertyCard_New_Set, ActionCardAction.NotAnActionCard, currentPlayFieldModel, player.guid); return true; } } } } } return false; }
public bool playPropertyCardToExistingSet(Card playedCard, PropertyCardSet setToPlayPropertyTo, Guid gameLobbyGuid, Guid playerGuid, Guid playfieldModelInstanceGuid) { ///Check if Card is in hand bool cardIsInHand = false; int cardId = playedCard.cardID; PlayerModel pm = getPlayerModel(playerGuid, gameLobbyGuid, playfieldModelInstanceGuid); PropertyCardSet pset = getPropertySet(setToPlayPropertyTo.guid, playerGuid, gameLobbyGuid, playfieldModelInstanceGuid); Card card = null; foreach (Card c in pm.hand.cardsInHand) { if (c.cardID == cardId) { cardIsInHand = true; card = c; break; } } if (cardIsInHand) { //Check if card is a property card PropertyCard pc = card as PropertyCard; if (pc != null) { //Card is a property card if (pset.addProperty(pc)) { removeCardFromHand(pc, pm); updateState(TurnActionTypes.PlayPropertyCard_New_Set, ActionCardAction.NotAnActionCard, currentPlayFieldModel, playerGuid); return true; } else { //Is a property card in the players hand but cant be added to set return false; } } } return false; }
private BoolResponseBox replayActionCardSlyDeal(PlayFieldModel currentState, PlayFieldModel nextState, Statephase nextStatePhase, MoveInfo moveInformation) { //Check //Perform action in next state //Clone the current state to create next state then draws 5 cards in the next state nextState = currentState.clone(generateGuidForNextState()); PlayerModel playerModelForPlayer = getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, nextState); PlayerModel playerModelForPlayerToSlyDeal = getPlayerModel(currentState.actionCardEvent.playerAffectedByAction, nextState); //Get the reference to the players playerModel in the current PlayFieldModel //Do action PropertyCardSet setToSlyDealFrom = getPropertyCardSet(playerModelForPlayerToSlyDeal.propertySets, currentState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].setGuid); PropertyCard cardToSlyDeal = nextState.deck.getCardByID(currentState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].cardID) as PropertyCard; if (setToSlyDealFrom != null && cardToSlyDeal != null) { if (setToSlyDealFrom.removeProperty(cardToSlyDeal)) { //Card Removed from set //Create new set with card Sly Dealed in it PropertyCardSet newSet = new PropertyCardSet(cardToSlyDeal); playerModelForPlayer.propertySets.addSet(newSet); //Change state on success //has been performed, advance the phase of the game nextState.currentPhase = nextStatePhase; //Used to set the allowable actions for player playerModelForPlayerToSlyDeal.hasHadCardsTaken = true; //Create event information for rollback and display nextState.actionCardEvent = new ActionCardEvent(); nextState.actionCardEvent.playerAffectedByAction = currentState.actionCardEvent.playerAffectedByAction; nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove; nextState.actionCardEvent.playerOnTurnPerformingAction = true; nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard; nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.SlyDeal; List<CardIDSetGuid> listOfCardsSlyDealed = new List<CardIDSetGuid>(); listOfCardsSlyDealed.Add(new CardIDSetGuid(cardToSlyDeal.cardID, setToSlyDealFrom.guid)); nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardsSlyDealed; //change the current state to the next state List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>(); List<TurnActionTypes> onTurn = new List<TurnActionTypes>(); onTurn = setAllowableActionsOnTurn(onTurn, nextState); updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState)); addNextState(nextState); return new BoolResponseBox(true, "Player:" + playerModelForPlayer.name + " Has used a Sly Deal Card"); } else { return new BoolResponseBox(false, "Unable to remove card from set"); } } else { return new BoolResponseBox(false, "Card to Sly Deal or set the card is in does not exist"); } }
private bool undoForcedDeal(PlayFieldModel currentState, PlayFieldModel nextState) { ActionCardEvent undoForcedDeal = currentState.actionCardEvent; PlayerModel playerModelForPlayerRegainingCard = getPlayerModel(undoForcedDeal.playerAffectedByAction, nextState); PlayerModel playerModelForPlayerLoosingCard = getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, nextState); //Get the reference to the players playerModel in the current PlayFieldModel PropertyCard cardtaken = nextState.deck.getCardByID(undoForcedDeal.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].cardID) as PropertyCard; Guid guidOfSetCardWasIn = undoForcedDeal.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].setGuid; PropertyCardSet setCardWasIn = getPropertyCardSet(playerModelForPlayerRegainingCard.propertySets, guidOfSetCardWasIn); if (cardtaken != null) { PropertyCard card = playerModelForPlayerLoosingCard.removePropertyCardFromPlayersPropertySets(cardtaken); if (card != null) { if (setCardWasIn == null) { setCardWasIn = new PropertyCardSet(card, guidOfSetCardWasIn); playerModelForPlayerRegainingCard.propertySets.addSet(setCardWasIn); } else { if (setCardWasIn.addProperty(card)) { //Card Given To Player Using Forced Deal Card given back to player it was taken from PropertyCard cardGiven = nextState.deck.getCardByID(undoForcedDeal.propertyCardGivenUpInForcedDeal.cardID) as PropertyCard; Guid guidOfSetCardGivenWasIn = undoForcedDeal.propertyCardGivenUpInForcedDeal.setGuid; PropertyCardSet setCardGivenWasIn = getPropertyCardSet(playerModelForPlayerLoosingCard.propertySets, guidOfSetCardGivenWasIn); if (cardGiven != null) { PropertyCard cardGivenUp = playerModelForPlayerRegainingCard.removePropertyCardFromPlayersPropertySets(cardGiven); if (cardGiven != null) { if (setCardGivenWasIn == null) { setCardGivenWasIn = new PropertyCardSet(cardGiven, guidOfSetCardGivenWasIn); playerModelForPlayerLoosingCard.propertySets.addSet(setCardWasIn); } else { if (setCardGivenWasIn.addProperty(cardGiven)) { //Player who used Forced Deal Card given back Card they gave up in Forced Deal return true; } else { return false; } } } } } else { return false; } } } }//Card not taken return false; }
public void referenceAllDataContracts(ActionCard ac, Card c, FieldUpdateMessage fum, Message msg, MoneyCard mc, PlayerBank pb, PlayerHand ph, PlayerModel pm, PlayerPropertySets pps, PlayFieldModel pfm, PlayPile pp, PollForFieldUpdateMessage pffum, PropertyCard pc, PropertyCardSet pcs, PropertySetInfo psi, RentStandard rs, TakeActionOnTurnMessage taotm, TurnActionModel tam) { throw new NotImplementedException(); }
private BoolResponseBox playActionCardForcedDeal(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation) { //Check //Perform action in next state //Clone the current state to create next state then draws 5 cards in the next state nextState = currentState.clone(generateGuidForNextState()); PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState); PlayerModel playerModelForPlayerToForcedDeal = getPlayerModel(moveInformation.guidOfPlayerWhoIsBeingForcedDealed, nextState); Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed); //Get the reference to the players playerModel in the current PlayFieldModel //Get the reference to the Card in the current PlayFieldModel if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.ForcedDeal) == 0) { Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer); if (card != null) { ActionCard actionCard = card as ActionCard; //Do action PropertyCardSet setToForcedDealFrom = getPropertyCardSet(playerModelForPlayerToForcedDeal.propertySets, moveInformation.guidOfSetCardToBeForcedDealedIsIn); PropertyCard cardToForcedDealFor = nextState.deck.getCardByID(moveInformation.idOfCardToBeForcedDealed) as PropertyCard; PropertyCardSet setToGiveUpCardFrom = getPropertyCardSet(playerModelForPlayer.propertySets, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn); PropertyCard cardToGiveUp = nextState.deck.getCardByID(moveInformation.idOfCardToBeGivenUpInForcedDeal) as PropertyCard; if (setToForcedDealFrom != null && cardToForcedDealFor != null && setToGiveUpCardFrom != null && cardToGiveUp != null) { if (playerModelForPlayerToForcedDeal.removePropertyCardFromPlayersPropertySet(cardToForcedDealFor, moveInformation.guidOfSetCardToBeForcedDealedIsIn) != null) { //Card Removed from set //Create new set with card Forced Dealed in it PropertyCardSet newSetForcedDealCard = new PropertyCardSet(cardToForcedDealFor); playerModelForPlayer.propertySets.addSet(newSetForcedDealCard); if (playerModelForPlayer.removePropertyCardFromPlayersPropertySet(cardToGiveUp, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn) != null) { //Forced dealed player recieves card given up in forced deal PropertyCardSet newSetGivenUpCard = new PropertyCardSet(cardToGiveUp); playerModelForPlayerToForcedDeal.propertySets.addSet(newSetGivenUpCard); playerModelForPlayerToForcedDeal.hasHadCardsTaken = true; //Change state on success //has been performed, advance the phase of the game nextState.currentPhase = nextStatePhase; //Put card in discard pile nextState.playpile.playCardOnPile(actionCard); List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>(); List<TurnActionTypes> onTurn = new List<TurnActionTypes>(); onTurn = setAllowableActionsOnTurn(onTurn, nextState); nextState.actionCardEvent = new ActionCardEvent(); nextState.actionCardEvent.playerAffectedByAction = moveInformation.guidOfPlayerWhoIsBeingForcedDealed; nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove; nextState.actionCardEvent.playerOnTurnPerformingAction = true; nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard; nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.ForcedDeal; List<CardIDSetGuid> listOfCardsForcedDealed = new List<CardIDSetGuid>(); listOfCardsForcedDealed.Add(new CardIDSetGuid(moveInformation.idOfCardToBeForcedDealed, moveInformation.guidOfSetCardToBeForcedDealedIsIn)); nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardsForcedDealed; nextState.actionCardEvent.propertyCardGivenUpInForcedDeal = new CardIDSetGuid(moveInformation.idOfCardToBeGivenUpInForcedDeal, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn); //change the current state to the next state updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState)); addNextState(nextState); return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Forced Deal Card"); } else { return new BoolResponseBox(false, "Unable to remove card to be given up"); } } else { return new BoolResponseBox(false, "Unable to remove card from player being forced dealed set"); } } else { return new BoolResponseBox(false, "Card to Forced Deal or set the card is in does not exist"); } } return new BoolResponseBox(false, "Card is not in hand."); } return new BoolResponseBox(false, "Card is not in hand or is not a Forced Deal Card"); }