/// <summary> /// Adds client to game /// </summary> /// <param name="client"></param> /// <returns>Returns true if client added. False if client is not added /// </returns> private void numberOfClientsInGameLobbyChanged() { if (status.CompareTo(GameLobbyStatus.Game_Ended) == 0) { if (clientsConnectedToGame.Count <= 0) { //no players left //Game should be cleaned up. } } if (clientsConnectedToGame.Count > MonopolyDeal.getMaxPlayers()) { setStatus(GameLobbyStatus.overFull); //To many players to start game } else if (clientsConnectedToGame.Count == MonopolyDeal.getMaxPlayers()) { setStatus(GameLobbyStatus.Full); } else if (clientsConnectedToGame.Count == 0) { setStatus(GameLobbyStatus.Empty); } else if (clientsConnectedToGame.Count == 1) { setStatus(GameLobbyStatus.Not_Enough_Players_To_Start); } else if (clientsConnectedToGame.Count >= MonopolyDeal.getMinPlayers()) { setStatus(GameLobbyStatus.Enough_Players_To_Start); } }
public BoolResponseBox playStandardRentActionCardOnTurnMD(int playedCard, GuidBox setOfPropertiesToRentOn, bool usingDoubleTheRent, int doubleTheRentCard, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().standardRentCard(playedCard, setOfPropertiesToRentOn.guid, usingDoubleTheRent, doubleTheRentCard, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(new BoolResponseBox(false, "Can not find game")); } }
public BoolResponseBox playActionCardForcedDealMD(int forcedDealCardID, int playersCardToSwapWith, GuidBox setPlayersCardIsIn, GuidBox targetedPlayerGuid, int targetedCard, GuidBox setTargetCardIn, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().forcedDealCard(forcedDealCardID, playersCardToSwapWith, setPlayersCardIsIn.guid, targetedPlayerGuid.guid, targetedCard, setTargetCardIn.guid, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(new BoolResponseBox(false, "Can not find game")); } }
public BoolResponseBox playActionCardDealBreakerMD(int dealBreakerCardID, GuidBox targetedPlayerGuid, GuidBox setTargeted, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().dealBreakerCard(dealBreakerCardID, targetedPlayerGuid.guid, setTargeted.guid, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(new BoolResponseBox(false, "Can not find game")); } }
public BoolResponseBox playHotelMD(int playedCardID, GuidBox setOfPropertiesToAddHotelTo, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().hotelCard(playedCardID, setOfPropertiesToAddHotelTo.guid, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(new BoolResponseBox(false, "Can not find game")); } }
public BoolResponseBox doNotPlayJustSayNoMD(GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().doNotJustSayNo(playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(new BoolResponseBox(false, "Can not find game")); } }
public bool playJustSayNoMD(int playedCard, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().playActionCardJustSayNo(playedCard, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } }
public bool playActionCardItsMyBirthdayMD(int myBirthdayCardID, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().playActionCardItsMyBirthday(myBirthdayCardID, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } }
public bool playActionCardDebtCollectorMD(int debtCollectorCardID, GuidBox targetedPlayerGuid, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().playDebtCollector(debtCollectorCardID, targetedPlayerGuid.guid, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } }
public bool payCardsMD(GuidBox playerPaying, List <int> cardsToPayWith, GuidBox gameLobbyGuid, GuidBox serverGuid, GuidBox playfieldModelInstanceGuid, GuidBox turnActionGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().payDebt(cardsToPayWith, playerPaying.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } }
public BoolResponseBox movePropertyCardMD(int propertyCardToMoveID, bool isCardUp, bool moveToExistiongSet, GuidBox oldSetGuid, GuidBox setToPlayPropertyToGuid, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().movePropertyCard(propertyCardToMoveID, isCardUp, moveToExistiongSet, oldSetGuid.guid, setToPlayPropertyToGuid.guid, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(new BoolResponseBox(false, "Can not find game")); } }
public BoolResponseBox cleanUpGame(Guid guidForGame, ILobby lobby) { MonopolyDeal GameToCleanUp = null; foreach (MonopolyDeal md in games) { if (md.MONOPOLY_DEAL_GAME_GUID.CompareTo(guidForGame) == 0) { GameToCleanUp = md; break; } } GameToCleanUp.Dispose(); return(new BoolResponseBox(false, "Game not cleaned up")); }
/// <summary> /// Clients call this method to bank a card on their turn. /// </summary> /// <param name="playedCardID"></param> /// <param name="playerGuid"></param> /// <param name="gameLobbyGuid"></param> /// <param name="playfieldModelInstanceGuid"></param> /// <param name="turnActionGuid"></param> /// <returns></returns> public bool playCardFromHandToBankMD(int playedCardID, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid, GuidBox turnActionGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().bankCard(playedCardID, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } } catch (Exception) { return(false); } }
public bool playActionCardPassGoMD(int passGoCardID, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().playActionCardPassGo(passGoCardID, gameLobbyGuid.guid, playerGuid.guid, playfieldModelInstanceGuid.guid, TurnActionTypes.PlayActionCard)); } else { return(false); } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
public bool discardMD(int cardsToDiscardIDs, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().discard(cardsToDiscardIDs, playerGuid.guid, gameLobbyGuid.guid, playfieldModelInstanceGuid.guid)); } else { return(false); } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
public bool playPropertyCardNewSetMD(int playedCardID, bool isOrientedUp, GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().playPropertyCardToNewSet(gameLobbyGuid.guid, isOrientedUp, playerGuid.guid, playfieldModelInstanceGuid.guid, TurnActionTypes.PlayPropertyCard_New_Set, playedCardID)); } else { return(false); } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
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 draw5AtStartOfTurnMD(GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { return(md.getMonopolyDealGameStateManager().drawFiveCards(playerGuid.guid, playfieldModelInstanceGuid.guid).success); } else { return(false); } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
public bool createGame(List<LobbyClient> clients, Guid guidForGame, ILobby lobby) { try { List<PlayerModel> playersMD = new List<PlayerModel>(); foreach (LobbyClient lc in clients) { PlayerModel p = new PlayerModel(lc.getName()); p.guid = lc.getGuid(); p.isReadyToStartGame = true; playersMD.Add(p); } MonopolyDeal game = new MonopolyDeal(playersMD, guidForGame, lobby); games.Add(game); return true; } catch (Exception) { return false; } }
/// <summary> /// Creates a new instance of MonopolyDeal and adds it to the list of games on service /// </summary> /// <param name="clients"></param> /// <param name="guidForGame"></param> /// <returns></returns> public bool startNewMonopolyDealGame(List <LobbyClient> clients, Guid guidForGame) { try { List <PlayerModel> players = new List <PlayerModel>(); foreach (LobbyClient lc in clients) { PlayerModel p = new PlayerModel(lc.getName()); p.guid = lc.getGuid(); p.isReadyToStartGame = true; players.Add(p); } MonopolyDeal game = new MonopolyDeal(players, guidForGame, lobby); monopolyDealGamesOnService.Add(game); return(true); } catch (System.ServiceModel.CommunicationException ex) { throw new NotImplementedException(ex.Message); } }
/// <summary> /// Clients call this method to draw 2 cards at the start of their turn. /// </summary> /// <param name="playerGuid"></param> /// <param name="gameLobbyGuid"></param> /// <param name="playfieldModelInstanceGuid"></param> /// <param name="turnActionGuid"></param> /// <returns></returns> public bool draw2AtStartOfTurnMD(GuidBox playerGuid, GuidBox gameLobbyGuid, GuidBox playfieldModelInstanceGuid, GuidBox turnActionGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameLobbyGuid.guid); if (md != null) { BoolResponseBox result = md.getMonopolyDealGameStateManager().drawTwoCardsAtTurnStart(playerGuid.guid, playfieldModelInstanceGuid.guid); return(result.success); } else { return(new BoolResponseBox(false, "Unable to find game with specified Guid").success); } } catch (Exception) { return(false); } }
public bool createGame(List <LobbyClient> clients, Guid guidForGame, ILobby lobby) { try { List <PlayerModel> playersMD = new List <PlayerModel>(); foreach (LobbyClient lc in clients) { PlayerModel p = new PlayerModel(lc.getName()); p.guid = lc.getGuid(); p.isReadyToStartGame = true; playersMD.Add(p); } MonopolyDeal game = new MonopolyDeal(playersMD, guidForGame, lobby); games.Add(game); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Gets the current state of a Monopoly Deal Game on service hiding cards of other players /// </summary> /// <param name="playerGuid">Guid of player</param> /// <param name="gameGuid">Guid of MonopolyDeal game instance</param> /// <returns>PlayFieldModel of current state</returns> public PlayFieldModel pollStateMonopolyDealPerPlayer(GuidBox playerGuid, GuidBox gameGuid) { try { //Find MonopolyDealGame MonopolyDeal md = getMonopolyDeal(gameGuid.guid); if (md != null) { //Ask GameStateManager for currentState PlayFieldModel currentState = md.getMonopolyDealGameStateManager().getCurrentState(); //TODO:Current state should be filtered here so players cant see other players hands //TODO:Could send Acknowledgement at this point but currently will have client send Acknowledgement return(currentState); } else { return(null); } } catch (System.ServiceModel.CommunicationException ex) { throw new FaultException(ex.Message); } }
public GameStateManagerToMoveAdapter(MonopolyDeal md) { monopolyDeal = md; move = new Move(monopolyDeal); }
/// <summary> /// Creates a new instance of MonopolyDeal and adds it to the list of games on service /// </summary> /// <param name="clients"></param> /// <param name="guidForGame"></param> /// <returns></returns> public bool startNewMonopolyDealGame(List<LobbyClient> clients, Guid guidForGame) { try { List<PlayerModel> players = new List<PlayerModel>(); foreach (LobbyClient lc in clients) { PlayerModel p = new PlayerModel(lc.getName()); p.guid = lc.getGuid(); p.isReadyToStartGame = true; players.Add(p); } MonopolyDeal game = new MonopolyDeal(players, guidForGame, lobby); monopolyDealGamesOnService.Add(game); return true; } catch (System.ServiceModel.CommunicationException ex) { throw new NotImplementedException(ex.Message); } }
public MonopolyDeal_GameStateManager(MonopolyDeal monopolyDeal) { // TODO: Complete member initialization this.monopolyDeal = monopolyDeal; }
public int getMaxPlayersPerGame() { return(MonopolyDeal.getMaxPlayers()); }
public Move(MonopolyDeal monopolyDeal) { // TODO: Complete member initialization this.monopolyDeal = monopolyDeal; }