//constructor public cardController(playerController controller) { _controllerPlayer = controller; _model = new cardModel(); _view = new cardView(this); //controller injecteren in view voor 2 richtingsverkeer flipCard(); }
private void pokerView_Load(object sender, EventArgs e) { //toevoegen views van spelers List<playerView> players = _controller.getViewsPlayers(); List<int> xPos = new List<int>(new int[] { 20,780,160,640,300,500 }); List<int> yPos = new List<int>(new int[] { 20,20,210,210,400,400, }); int curPlayerIndex = 0; foreach (playerView player in players) { playerView currentPlayer = player; currentPlayer.Location = new Point(xPos[curPlayerIndex], yPos[curPlayerIndex]); Controls.Add(currentPlayer); curPlayerIndex++; } //toevoegen view van flop, turn, river, total pot playerController flop = new playerController(_controller, 5); _controller.getModelPoker().FlopController = flop; playerView flopView = flop.getViewPlayer(); flopView.Location = new Point(280, 20); Controls.Add(flopView); //toevoegen knoppen speler buttonsController button = new buttonsController(); buttonsView buttonView = button.getViewButtons(); buttonView.Location = new Point(320, 600); Controls.Add(buttonView); }
public void createViewsPlayers(int numberOfPlayers) { for (int playerNr = 0; playerNr < numberOfPlayers; playerNr++) { playerController player = new playerController(this, 2); //Enkele player aanmaken met injectie van hoofdcontroller playerView playerView = player.getViewPlayer(); //Nieuwe view player _model.addPlayer(player); //toevoegen speler aan lijst } }
public void addPlayer(playerController player) { players.Add(player); }
public playerController giveControllerWinner() { //rondgaan per speler wat hij/zij heeft int[] scoresHand = new int[_model.NumberOfPlayers]; playerController[] arrPlayers = new playerController[_model.NumberOfPlayers]; int indexCur = 0; foreach (playerController player in _model.Players) { arrPlayers[indexCur] = player; scoresHand[indexCur] = checkHand(player); indexCur++; } //sorteer op hoogste scores Array.Sort(scoresHand, arrPlayers); Array.Reverse(arrPlayers); Array.Reverse(scoresHand); //enkel lijst van spelers overhouden met hoogste scores int hoogsteScore = scoresHand[0]; int tellerIndex = 0; List<playerController> bestPlayers = new List<playerController>(); foreach (int score in scoresHand) { if (score == hoogsteScore) { bestPlayers.Add(arrPlayers[tellerIndex]); } tellerIndex++; } playerController winner = bestPlayers[0]; if (bestPlayers.Count == 1) { winner = bestPlayers[0]; } else { List<int> arrHighestCard = new List<int>(); foreach (playerController player in bestPlayers) { int highestCard2 = 0; foreach (cardView curCardView in player.getCardsView()) { int cardValue = curCardView.getControllerCard().getModelCard().CardValue; if (cardValue > highestCard2) { highestCard2 = cardValue; } } arrHighestCard.Add(highestCard2); } int test = arrHighestCard.Distinct().Count(); IEnumerable<int> newVal = arrHighestCard.Distinct(); if (arrHighestCard.Distinct().Count() != arrHighestCard.Count) { //splitPot(); //return null; } int indexOfHighest = 0; int highestCard = 0; int indexCurPlay = 0; foreach (int highestCardPlayer in arrHighestCard) { if (highestCardPlayer > highestCard) { highestCard = highestCardPlayer; indexOfHighest = indexCurPlay; } indexCurPlay++; } winner = bestPlayers[indexOfHighest]; } winner.getModelPlayer().Kapitaal += _model.FlopController.getModelPlayer().Kapitaal; return winner; }
public int checkHand(playerController curPlayer) { //ophalen kaarten flop List<cardView> cardsFlop = _model.FlopController.getCardsView(); //maken lijst met kind en lijst met value List<int> valueAllCards = new List<int>(); List<string> kindAllCards = new List<string>(); //eerst eigen kaarten toevoegen foreach (cardView card in curPlayer.getCardsView()) { string cardKind = card.getControllerCard().getModelCard().CardKind; int cardValue = card.getControllerCard().getModelCard().CardValue; valueAllCards.Add(cardValue); kindAllCards.Add(cardKind); } //dan van flop foreach (cardView card in cardsFlop) { string cardKind = card.getControllerCard().getModelCard().CardKind; int cardValue = card.getControllerCard().getModelCard().CardValue; valueAllCards.Add(cardValue); kindAllCards.Add(cardKind); } return checkAllPossible(valueAllCards, kindAllCards); }
public void initializeViewPoker() { //toevoegen knoppen speler buttonsController button = new buttonsController(_controller); buttonsView buttonView = button.getViewButtons(); _controller.getModelPoker().View_button = buttonView; buttonView.Location = new Point(320, 600); button.getViewButtons().updateCurrentPlayer(); buttonView.toggleDisable(); Controls.Add(buttonView); //toevoegen views van spelers List<playerView> players = _controller.getViewsPlayers(); List<playerController> players_rightOrder = new List<playerController>(); List<int> xPos = new List<int>(new int[] { 20, 780, 160, 640, 300, 500 }); List<int> yPos = new List<int>(new int[] { 20, 20, 210, 210, 400, 400, }); int curPlayerIndex = 0; int curIndexAtPlace = 0; foreach (playerView player in players) { playerView currentPlayer = player; currentPlayer.Location = new Point(xPos[curPlayerIndex], yPos[curPlayerIndex]); Controls.Add(currentPlayer); curPlayerIndex++; if (curPlayerIndex % 2 == 0) { curIndexAtPlace++; } players_rightOrder.Insert(curIndexAtPlace, player.getControllerPlayer()); } int curPlayerIndex2 = 0; foreach (playerController player in players_rightOrder) { curPlayerIndex2++; player.getModelPlayer().Name = "Speler: "+ curPlayerIndex2; player.getViewPlayer().updateName(); } players_rightOrder[0].getModelPlayer().Special = "small"; players_rightOrder[1].getModelPlayer().Special = "big"; _controller.getModelPoker().Players = players_rightOrder; _controller.getModelPoker().IndexStopPlayer = 0; //toevoegen view van flop, turn, river, total pot playerController flop = new playerController(_controller, 5); /*flop.getModelPlayer().Cards[0].getModelCard().CardKind = "hearts"; flop.getModelPlayer().Cards[1].getModelCard().CardKind = "hearts"; flop.getModelPlayer().Cards[2].getModelCard().CardKind = "hearts"; flop.getModelPlayer().Cards[3].getModelCard().CardKind = "hearts"; flop.getModelPlayer().Cards[4].getModelCard().CardKind = "hearts"; flop.getModelPlayer().Cards[0].getModelCard().CardValue = 8; flop.getModelPlayer().Cards[1].getModelCard().CardValue = 8; flop.getModelPlayer().Cards[2].getModelCard().CardValue = 6; flop.getModelPlayer().Cards[3].getModelCard().CardValue = 6; flop.getModelPlayer().Cards[4].getModelCard().CardValue = 6;*/ _controller.getModelPoker().FlopController = flop; playerView flopView = flop.getViewPlayer(); flopView.Location = new Point(280, 20); Controls.Add(flopView); flopView.updateKapitaal(); _controller.makeCurrent(1); _controller.getModelPoker().FirstGame = true; _controller.getModelPoker().FirstRoundOfHand = false; }
public cardController(playerController controller) //constructor { _controllerPlayer = controller; _model = new cardModel(); _view = new cardView(this); //controller injecteren in view voor 2 richtingsverkeer }
public void initializeViewPoker() { //toevoegen knoppen speler buttonsController button = new buttonsController(_controller); buttonsView buttonView = button.getViewButtons(); _controller.getModelPoker().View_button = buttonView; buttonView.Location = new Point(320, 600); button.getViewButtons().updateCurrentPlayer(); buttonView.toggleDisable(); Controls.Add(buttonView); //toevoegen views van spelers List <playerView> players = _controller.getViewsPlayers(); List <playerController> players_rightOrder = new List <playerController>(); List <int> xPos = new List <int>(new int[] { 20, 780, 160, 640, 300, 500 }); List <int> yPos = new List <int>(new int[] { 20, 20, 210, 210, 400, 400, }); int curPlayerIndex = 0; int curIndexAtPlace = 0; foreach (playerView player in players) { playerView currentPlayer = player; currentPlayer.Location = new Point(xPos[curPlayerIndex], yPos[curPlayerIndex]); Controls.Add(currentPlayer); curPlayerIndex++; if (curPlayerIndex % 2 == 0) { curIndexAtPlace++; } players_rightOrder.Insert(curIndexAtPlace, player.getControllerPlayer()); } int curPlayerIndex2 = 0; foreach (playerController player in players_rightOrder) { curPlayerIndex2++; player.getModelPlayer().Name = "Speler: " + curPlayerIndex2; player.getViewPlayer().updateName(); } players_rightOrder[0].getModelPlayer().Special = "small"; players_rightOrder[1].getModelPlayer().Special = "big"; _controller.getModelPoker().Players = players_rightOrder; _controller.getModelPoker().IndexStopPlayer = 0; //toevoegen view van flop, turn, river, total pot playerController flop = new playerController(_controller, 5); /*flop.getModelPlayer().Cards[0].getModelCard().CardKind = "hearts"; * flop.getModelPlayer().Cards[1].getModelCard().CardKind = "hearts"; * flop.getModelPlayer().Cards[2].getModelCard().CardKind = "hearts"; * flop.getModelPlayer().Cards[3].getModelCard().CardKind = "hearts"; * flop.getModelPlayer().Cards[4].getModelCard().CardKind = "hearts"; * * flop.getModelPlayer().Cards[0].getModelCard().CardValue = 8; * flop.getModelPlayer().Cards[1].getModelCard().CardValue = 8; * flop.getModelPlayer().Cards[2].getModelCard().CardValue = 6; * flop.getModelPlayer().Cards[3].getModelCard().CardValue = 6; * flop.getModelPlayer().Cards[4].getModelCard().CardValue = 6;*/ _controller.getModelPoker().FlopController = flop; playerView flopView = flop.getViewPlayer(); flopView.Location = new Point(280, 20); Controls.Add(flopView); flopView.updateKapitaal(); _controller.makeCurrent(1); _controller.getModelPoker().FirstGame = true; _controller.getModelPoker().FirstRoundOfHand = false; }
public playerModel(int nrOfCards, playerController controller) { _controllerPlayer = controller; numberOfCards = nrOfCards; kapitaal = startKapitaal; }
public playerView(playerController controller) { _controller = controller; InitializeComponent(); }