private void ConcludeTurn() { PlayedCard winner = null; Broadcast("The contract is: " + _contracts[(int)_contract.type]); switch (_contract.type) { case CoincheServer.Contract.ContractType.Clubs: case CoincheServer.Contract.ContractType.Spades: case CoincheServer.Contract.ContractType.Hearts: case CoincheServer.Contract.ContractType.Diamonds: winner = GetHigherCard(); break; case CoincheServer.Contract.ContractType.NoTrumps: winner = GetHigherCardNoTrump(); break; case CoincheServer.Contract.ContractType.AllTrumps: winner = GetHigherCardAllTrump(); break; } Broadcast(winner.player.Name + " won this turn"); while (winner.orderPlay != 0) { foreach (PlayedCard played in turn) { played.orderPlay = (played.orderPlay + 1) % 4; } } if (winner.player.Team == Team.Blue) { foreach (PlayedCard card in turn) { blue.stack.Add(card.card); } } else { foreach (PlayedCard card in turn) { red.stack.Add(card.card); } } // Debug System.Console.Out.WriteLine("Blue has: " + blue.stack.Count); System.Console.Out.WriteLine("Red has: " + red.stack.Count); // turn.ElementAt(0).card = null; turn.ElementAt(1).card = null; turn.ElementAt(2).card = null; turn.ElementAt(3).card = null; }
private PlayedCard GetHigherCardNoTrump() { PlayedCard winner = getFirstPlayed(); foreach (PlayedCard played in turn) { if (played != winner) { if (played.card.color == winner.card.color) { if (Card._scores[(int)played.card.face][(int)Card.Type.NoTrumps] > Card._scores[(int)winner.card.face][(int)Card.Type.NoTrumps]) { winner = played; } } } } return(winner); }
private PlayedCard GetHigherCard() { PlayedCard winner = null; if (!HereIsTrump()) { return(GetHigherCardNoTrump()); } foreach (PlayedCard card in turn) { if ((int)card.card.color == (int)_contract.type) { if (winner == null || Card._scores[(int)card.card.face][(int)Card.Type.OneTrump] > Card._scores[(int)winner.card.face][(int)Card.Type.OneTrump]) { winner = card; } } } return(winner); }