public PlayFieldModel(Guid previousPlayFieldModelGuidP, Guid thisInstanceGuid, List <PlayerModel> playerModelsP, List <Card> topCardsPlayPileP, Guid guidOfPlayerWhosTurnItIsP, List <Guid> playersAffectedByActionCardGuidsP, TurnActionModel lastActionP, TurnActionModel nextActionP, DrawPile currentDrawPileState, PlayPile currentPlayPileState, int numberOfTurnsRemainingForPlayerP, bool startOfATurnP, Statephase phaseP, Deck deckP) { //The guid of this instance of PlayFieldModel thisPlayFieldModelInstanceGuid = thisInstanceGuid; //The Players playerModels = playerModelsP; //The last 4 played cards topCardsOnPlaypile = topCardsPlayPileP; //The guid of the player whos turn it currently is guidOfPlayerWhosTurnItIs = guidOfPlayerWhosTurnItIsP; //A list of players who are affected by an action card that have just been played playersAffectedByActionCardGuids = playersAffectedByActionCardGuidsP; //The TurnActionModel of the last action lastActionPlayed = lastActionP; //The current State of the deck drawPile = currentDrawPileState; //The current State of the playpile playpile = currentPlayPileState; //The maximun number of cards that the player whos turn it is can play before their turn is over numberOfTurnsRemainingForPlayerWhosTurnItIs = numberOfTurnsRemainingForPlayerP; //This is the first move of a turn so the player whose turn it is should draw two cards startOfATurn = startOfATurnP; currentTurnActionModel = nextActionP; lastActionPlayed = lastActionP; //Current Phase currentPhase = phaseP; //Previous PlayFieldModelGuid previousPlayFieldModelGuid = previousPlayFieldModelGuidP; //Deck deck = deckP; }
public void draw2AtStartOfTurn(Guid playerGuid, Guid serverGuid, Guid playfieldModelInstanceGuid, Guid turnActionGuid) { List<Guid> guids = new List<Guid>(); guids.Add(playerGuid); TurnActionModel tamDrawTwoST = new TurnActionModel(guids, serverGuid, playfieldModelInstanceGuid, turnActionGuid, new List<TurnActionModel.TurnActionTypes>(), TurnActionModel.TurnActionTypes.drawTwoCardsAtStartOfTurn, true); gameStateManager.doAction(tamDrawTwoST); }
public void draw2AtStartOfTurn(Guid playerGuid, Guid serverGuid, Guid playfieldModelInstanceGuid, Guid turnActionGuid) { List <Guid> guids = new List <Guid>(); guids.Add(playerGuid); TurnActionModel tamDrawTwoST = new TurnActionModel(guids, serverGuid, playfieldModelInstanceGuid, turnActionGuid, new List <TurnActionModel.TurnActionTypes>(), TurnActionModel.TurnActionTypes.drawTwoCardsAtStartOfTurn, true); gameStateManager.doAction(tamDrawTwoST); }
//[DataMember] //TurnActionModel actionsToTake; public TakeActionOnTurnMessage(Guid playerGuid, Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage, Guid serverGuid, PlayFieldModel playFieldModelP, Guid playFieldModelGuidP, TurnActionModel turnActionModel) : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.actionTaken, null, false, playerGuid, serverGuid, null) { //Message used for notifying all players that the field has been updated fieldModel = playFieldModelP; referenceThisGuidToRespond = guidOfThisMessage; //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field //Client of player whose turn it is should reply with an action }
private PlayFieldModel createInitialState(List <PlayerModel> players) { //guid for initial state Guid playFieldModelGuid = PlayFieldModel.generateplayFieldModelGuid(); //no cards to be shown as played in playpile List <Card> emptyTopPlayPile = new List <Card>(); //setFirstPlayerToHaveTurn(players); //set player 0 to be first to play //Guid firstPlayerGuid = players.ElementAt(FIRST_PLAYER).guid; //currentPlayerTurn = FIRST_PLAYER; Guid firstPlayerGuid = setFirstPlayerToHaveTurn(players); //no players can be affected by actioncards as none have been played List <Guid> noPlayersAffectedByActionCard = new List <Guid>(); //No actions have been taken List <TurnActionTypes> actionsAllowable = new List <TurnActionTypes>(); actionsAllowable.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn); //Set players Allowable actions foreach (PlayerModel p in players) { p.actionsCurrentlyAllowed = new List <TurnActionTypes>(); if (p.guid.CompareTo(firstPlayerGuid) == 0) { //Player whos turn it is must draw TwoCards p.actionsCurrentlyAllowed.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn); } } // TurnActionModel noActionsPlayedFirstPlayerToDraw = new TurnActionModel(this.playerIdLookup, this.gameModelGuid, playFieldModelGuid, generateTurnActionGuid(), actionsAllowable, TurnActionTypes.gameStarted, false); //create empty playpile initialPlayPile = new PlayPile(); //fill new drawpile DrawPile initialDrawPile = generateInitialDrawPile(initialPlayPile); //Deal players thier first five cards dealPlayersInitialFiveCards(players, initialDrawPile); //It is the start of a players turn bool turnStart = true; //put it all into the intial state PlayFieldModel state = new PlayFieldModel(playFieldModelGuid, players, emptyTopPlayPile, firstPlayerGuid, noPlayersAffectedByActionCard, null, noActionsPlayedFirstPlayerToDraw, initialDrawPile, initialPlayPile, NEW_TURN_NUMBER_OF_CARDS_PLAYABLE, turnStart, Statephase.Turn_Started_Draw_2_Cards, deck); //stateCreated currentState = state; return(state); }
public TurnActionModel(TurnActionModel ta) { //GameStateManager generates a TurnActionModel for each PlayFieldModel //All players recieve the field and check if the turnActionModel has their guid //if it has their guid it is their turn //The player on their turn fills a subclass of TurnActionModel for the move they want to make using the information in this TurnActionModel //The player then sends that back to the service and GameStateManager does the move playerGuids = ta.playerGuids;//List of players who can use the actions listed serverGuid = ta.serverGuid; currentPlayFieldModelGuid = ta.currentPlayFieldModelGuid; thisTurnactionGuid = ta.thisTurnactionGuid;//server side generated typesOfActionListedPlayersCanTake = ta.typesOfActionListedPlayersCanTake; typeOfActionToTake = ta.typeOfActionToTake; actionTaken = ta.actionTaken; }
public PollForFieldUpdateMessage(Guid playerSendingGuidP, Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage, Guid serverGameGuidP, PlayFieldModel playFieldModelP, Guid playFieldModelGuidP, TurnActionModel turnActionModel) : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.pollForFieldUpdate, null, false, playerSendingGuidP, serverGameGuidP, null) { //Message used for requesting updates to the games state represented by PlayFieldModel fieldModel = playFieldModelP; //Guid to reference in response to this message referenceThisGuidToRespond = guidOfThisMessage; //Guid of the turn the action was taken on fieldModelGuid = playFieldModelGuidP; //Actions taken by client sending this message actionsToTake = turnActionModel; //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field //Client of player whose turn it is should reply with an action }
/// <summary> /// Returns a copy of an instance of PlayFieldModel /// </summary> /// <returns></returns> public PlayFieldModel clone(Guid guidOfClone) { Guid oldInstanceGuid = thisPlayFieldModelInstanceGuid.cloneGuid(); //TODO Clone Deck List <PlayerModel> playersCloned = cloneListPlayerModels(this.playerModels, this); List <Card> topCardsPlayPileCloned = cloneListCards(topCardsOnPlaypile); Guid oldPlayerWhoseTurnItIsGuid = guidOfPlayerWhosTurnItIs.cloneGuid(); int numberOfTurnsForPlayerRemaining = this.numberOfTurnsRemainingForPlayerWhosTurnItIs; bool startOfATurnClone = startOfATurn.cloneBool(); if (lastActionPlayed == null) { lastActionPlayed = new TurnActionModel(null, new Guid(), new Guid(), new Guid(), null, TurnActionTypes.gameStarted, false); } PlayFieldModel pfmC = new PlayFieldModel(oldInstanceGuid, guidOfClone, playersCloned, topCardsPlayPileCloned, oldPlayerWhoseTurnItIsGuid, playersAffectedByActionCardGuids.cloneListGuids(), lastActionPlayed.clone(), currentTurnActionModel.clone(), drawPile.clone(deck), playpile.clone(deck), numberOfTurnsForPlayerRemaining, startOfATurnClone, currentPhase, deck.cloneDeck()); return(pfmC); }
private PlayFieldModel createInitialState(List<PlayerModel> players) { //guid for initial state Guid playFieldModelGuid = PlayFieldModel.generateplayFieldModelGuid(); //no cards to be shown as played in playpile List<Card> emptyTopPlayPile = new List<Card>(); //setFirstPlayerToHaveTurn(players); //set player 0 to be first to play //Guid firstPlayerGuid = players.ElementAt(FIRST_PLAYER).guid; //currentPlayerTurn = FIRST_PLAYER; Guid firstPlayerGuid = setFirstPlayerToHaveTurn(players); //no players can be affected by actioncards as none have been played List<Guid> noPlayersAffectedByActionCard = new List<Guid>(); //No actions have been taken List<TurnActionTypes> actionsAllowable = new List<TurnActionTypes>(); actionsAllowable.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn); //Set players Allowable actions foreach (PlayerModel p in players) { p.actionsCurrentlyAllowed = new List<TurnActionTypes>(); if (p.guid.CompareTo(firstPlayerGuid) == 0) { //Player whos turn it is must draw TwoCards p.actionsCurrentlyAllowed.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn); } } // TurnActionModel noActionsPlayedFirstPlayerToDraw = new TurnActionModel(this.playerIdLookup, this.gameModelGuid, playFieldModelGuid, generateTurnActionGuid(), actionsAllowable, TurnActionTypes.gameStarted, false); //create empty playpile initialPlayPile = new PlayPile(); //fill new drawpile DrawPile initialDrawPile = generateInitialDrawPile(initialPlayPile); //Deal players thier first five cards dealPlayersInitialFiveCards(players, initialDrawPile); //It is the start of a players turn bool turnStart = true; //put it all into the intial state PlayFieldModel state = new PlayFieldModel(playFieldModelGuid, players, emptyTopPlayPile, firstPlayerGuid, noPlayersAffectedByActionCard, null, noActionsPlayedFirstPlayerToDraw, initialDrawPile, initialPlayPile, NEW_TURN_NUMBER_OF_CARDS_PLAYABLE, turnStart, Statephase.Turn_Started_Draw_2_Cards, deck); //stateCreated currentState = state; return state; }
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(); }
/// <summary> /// Returns a copy of an instance of PlayFieldModel /// </summary> /// <returns></returns> public PlayFieldModel clone(Guid guidOfClone) { Guid oldInstanceGuid = thisPlayFieldModelInstanceGuid.cloneGuid(); //TODO Clone Deck List<PlayerModel> playersCloned = cloneListPlayerModels(this.playerModels, this); List<Card> topCardsPlayPileCloned = cloneListCards(topCardsOnPlaypile); Guid oldPlayerWhoseTurnItIsGuid = guidOfPlayerWhosTurnItIs.cloneGuid(); int numberOfTurnsForPlayerRemaining = this.numberOfTurnsRemainingForPlayerWhosTurnItIs; bool startOfATurnClone = startOfATurn.cloneBool(); if (lastActionPlayed == null) { lastActionPlayed = new TurnActionModel(null, new Guid(), new Guid(), new Guid(), null, TurnActionTypes.gameStarted, false); } PlayFieldModel pfmC = new PlayFieldModel(oldInstanceGuid, guidOfClone, playersCloned, topCardsPlayPileCloned, oldPlayerWhoseTurnItIsGuid, playersAffectedByActionCardGuids.cloneListGuids(), lastActionPlayed.clone(), currentTurnActionModel.clone(), drawPile.clone(deck), playpile.clone(deck), numberOfTurnsForPlayerRemaining, startOfATurnClone, currentPhase, deck.cloneDeck()); return pfmC; }
public PlayFieldModel(Guid previousPlayFieldModelGuidP, Guid thisInstanceGuid, List<PlayerModel> playerModelsP, List<Card> topCardsPlayPileP, Guid guidOfPlayerWhosTurnItIsP, List<Guid> playersAffectedByActionCardGuidsP, TurnActionModel lastActionP, TurnActionModel nextActionP, DrawPile currentDrawPileState, PlayPile currentPlayPileState, int numberOfTurnsRemainingForPlayerP, bool startOfATurnP, Statephase phaseP, Deck deckP) { //The guid of this instance of PlayFieldModel thisPlayFieldModelInstanceGuid = thisInstanceGuid; //The Players playerModels = playerModelsP; //The last 4 played cards topCardsOnPlaypile = topCardsPlayPileP; //The guid of the player whos turn it currently is guidOfPlayerWhosTurnItIs = guidOfPlayerWhosTurnItIsP; //A list of players who are affected by an action card that have just been played playersAffectedByActionCardGuids = playersAffectedByActionCardGuidsP; //The TurnActionModel of the last action lastActionPlayed = lastActionP; //The current State of the deck drawPile = currentDrawPileState; //The current State of the playpile playpile = currentPlayPileState; //The maximun number of cards that the player whos turn it is can play before their turn is over numberOfTurnsRemainingForPlayerWhosTurnItIs = numberOfTurnsRemainingForPlayerP; //This is the first move of a turn so the player whose turn it is should draw two cards startOfATurn = startOfATurnP; currentTurnActionModel = nextActionP; lastActionPlayed = lastActionP; //Current Phase currentPhase = phaseP; //Previous PlayFieldModelGuid previousPlayFieldModelGuid = previousPlayFieldModelGuidP; //Deck deck = deckP; }
public DrawOnTurnStart(TurnActionModel ta, PlayFieldModel pfm) : base(ta) { }