public void IsValidTest2() { CurrentTrickState currentTrickState = new CurrentTrickState { Trump = Suit.Heart, Rank = 0, Learder = "p1" }; currentTrickState.ShowedCards.Add("p1", new List <int> { 39, 39, 0, 0 }); currentTrickState.ShowedCards.Add("p2", new List <int> { }); currentTrickState.ShowedCards.Add("p3", new List <int> { }); currentTrickState.ShowedCards.Add("p4", new List <int> { }); List <int> selectedCards = new List <int> { 1, 2, 5, 5 }; CurrentPoker currentCards = new CurrentPoker(new int[] { 1, 2, 3, 4, 5, 5 }, Suit.Heart, 0); ShowingCardsValidationResultType expected = ShowingCardsValidationResultType.Valid; ShowingCardsValidationResultType actual; actual = TractorRules.IsValid(currentTrickState, selectedCards, currentCards).ResultType; Assert.AreEqual(expected, actual); }
private void ToShowCards() { var pigRect = new Rectangle(296, 300, 53, 46); Graphics g = Graphics.FromImage(bmp); if (ThisPlayer.CurrentHandState.CurrentHandStep == HandStep.Playing && ThisPlayer.CurrentTrickState.NextPlayer() == ThisPlayer.PlayerId) { ShowingCardsValidationResult showingCardsValidationResult = TractorRules.IsValid(ThisPlayer.CurrentTrickState, SelectedCards, ThisPlayer.CurrentPoker); //如果我准备出的牌合法 if (showingCardsValidationResult.ResultType == ShowingCardsValidationResultType.Valid) { //擦去小猪 g.DrawImage(image, pigRect, pigRect, GraphicsUnit.Pixel); foreach (int card in SelectedCards) { ThisPlayer.CurrentPoker.RemoveCard(card); } ThisPlayer.ShowCards(SelectedCards); drawingFormHelper.DrawMyShowedCards(); SelectedCards.Clear(); } else if (showingCardsValidationResult.ResultType == ShowingCardsValidationResultType.TryToDump) { //擦去小猪 g.DrawImage(image, pigRect, pigRect, GraphicsUnit.Pixel); ShowingCardsValidationResult result = ThisPlayer.ValidateDumpingCards(SelectedCards); if (result.ResultType == ShowingCardsValidationResultType.DumpingSuccess) //甩牌成功. { foreach (int card in SelectedCards) { ThisPlayer.CurrentPoker.RemoveCard(card); } ThisPlayer.ShowCards(SelectedCards); drawingFormHelper.DrawMyShowedCards(); SelectedCards.Clear(); } //甩牌失败 else { foreach (int card in result.MustShowCardsForDumpingFail) { ThisPlayer.CurrentPoker.RemoveCard(card); } Thread.Sleep(2000); ThisPlayer.ShowCards(result.MustShowCardsForDumpingFail); SelectedCards = result.MustShowCardsForDumpingFail; SelectedCards.Clear(); } } } g.Dispose(); }