public void Rule_IsKaidan_数字違い() { Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C3 C4 C6"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C6 C4 C7"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 C2 CQ"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 C2 C3"))); }
public void Rule_PutCard_Kaidan_場が階段でないとき() { _ctx._history.Clear(); _ctx._history.Add(new HE_PutCards(0, DeckGenerator.FromCardsetString("C4 D4 H4"))); _assertCheckPutCardsIsNG(DeckGenerator.FromCardsetString("C6 C7 C5"), KaidanRule.ERROR_BA_ISNOT_KAIDAN); _assertCheckPutCardsIsNG(DeckGenerator.FromCardsetString("C6 C7 C5 C8"), KaidanRule.ERROR_BA_ISNOT_KAIDAN); }
public void Rule_IsKaidan_IsOK() { Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C3 C4 C5"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C6 C4 C5"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("CK CQ CJ"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 C2 CK"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 CQ CK"))); }
internal TestCardDistributer(string p0, string p1, string p2) { ret = new[] { DeckGenerator.FromCardsetString(p0), DeckGenerator.FromCardsetString(p1), DeckGenerator.FromCardsetString(p2), }; }
public void Rule_IsKaidan_スート違い() { Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C3 D4 C5"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("D6 C4 C5"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("CK CQ HJ"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("S1 C2 CK"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 CQ DK"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 JK DK"))); }
public void Rule_PutCard_Kaidan_場なし() { _ctx._history.Clear(); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("C3 C4 C5")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("C6 C4 C5")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("CK CQ CJ")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("C1 C2 CK")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("C1 CQ CK")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("C1 C2 JK CK")); }
public void Rule_IsKaidan_ジョーカー() { Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C3 C4 JK"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("JK C4 C6"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 JK CQ"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 C2 JK"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 C2 JK JK"))); Assert.IsTrue(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 CJ JK JK"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C1 C3 JK"))); Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C4 C2 JK"))); }
protected override IEnumerable <Card> _TurnCame(IPlayerContext ctx) { var cards = DeckGenerator.FromCardsetString(hands[p]); if (cards.Count == 0 || ctx.GameContext.Rule.CheckPutCards(ctx.GameContext, cards) is CheckOK) { p++; return(cards); } return(null); }
public void ProcessTurn(IPlayerContext ctx) { Send(new Neof5Protocols.ProtocolData(playerNum, "ProcessTurn", ctx)); if (IsConnected) { // タイマースタート _startTimer(TurnTimeoutSec * 1000); } else { room.Master.PutCards(this, DeckGenerator.FromCardsetString("")); } }
public void Rule_TryGetFirstCard_1枚() { var cards = DeckGenerator.FromCardsetString("H1"); Card firstCard = null; Assert.AreEqual(true, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(Suit.HRT, firstCard.suit); Assert.AreEqual(1, firstCard.num); cards = DeckGenerator.FromCardsetString("JK"); firstCard = null; Assert.AreEqual(true, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(Suit.JKR, firstCard.suit); }
public void Rule_IsKaidan_場が4枚でジョーカーを含む階段のとき() { _ctx._history.Clear(); _ctx._history.Add(new HE_PutCards(0, DeckGenerator.FromCardsetString("S5 S6 S7 JK"))); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("S8 S9 S0 SJ")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("D8 D9 D0 DJ")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("CK CQ CJ C1")); // ジョーカーを含むパターン _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("C8 C9 JK C0")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("JK D9 D0 D8")); _assertCheckPutCardsIsOK(DeckGenerator.FromCardsetString("JK S2 SK SQ")); // 階段でない場合 _assertCheckPutCardsIsNG(DeckGenerator.FromCardsetString("C8 H8 S8 S8"), KaidanRule.ERROR_NOT_KAIDAN); // カードの数字が強い数字でない場合 _assertCheckPutCardsIsNG(DeckGenerator.FromCardsetString("C6 C7 C8 C9"), KaidanRule.ERR_NOT_STRONG); _assertCheckPutCardsIsNG(DeckGenerator.FromCardsetString("C9 C7 C8 C0"), KaidanRule.ERR_NOT_STRONG); _assertCheckPutCardsIsNG(DeckGenerator.FromCardsetString("JK C7 C8 C0"), KaidanRule.ERR_NOT_STRONG); }
/// <summary> /// クライアントメッセージの処理 /// </summary> /// <param name="jsonObj"></param> /// <returns></returns> public ProtocolData ProcMessage(JObject jsonObj) { string kind = null; try { kind = jsonObj["Kind"].ToString(); } catch (Exception) { throw new InvalidOperationException("Kindがありません"); } if (kind == "Tweet") { string message; try { message = jsonObj["Message"].ToString(); } catch (Exception) { throw new InvalidOperationException("Messageがありません"); } room.Tweet(playerNum, message); } else if (kind == "Start") { // 自動的に不足人数を追加してゲーム開始する room.DoComplementPlayers(5); room.Master.Start(); } else if (kind == "Put") { var ret = room.Master.PutCards(this, DeckGenerator.FromCardsetString(jsonObj["Cards"].ToString())); if (!(ret is CheckOK)) { return(new WebDaifugo.Neof5Protocols.ProtocolData(ret)); } myTimer.Enabled = false; } return(null); }
public void CardDistributer_swapCards() { // 手札をセット var list1 = DeckGenerator.FromCardsetString("H1 D3 DK"); var list2 = DeckGenerator.FromCardsetString("C0 SQ H4"); // D3 ⇔ SQ DefaultCardDistributer._swap(list1, list2, 1); // 枚数チェック Assert.AreEqual(3, list2.Count()); Assert.AreEqual(3, list2.Count()); // スワップされたカードの所在確認 Assert.IsFalse(list1.Contains(new Card(Suit.DIA, 3))); Assert.IsTrue(list1.Contains(new Card(Suit.SPD, 12))); Assert.IsFalse(list2.Contains(new Card(Suit.SPD, 12))); Assert.IsTrue(list2.Contains(new Card(Suit.DIA, 3))); }
public void CardDistributer_swapCards_Joker() { // 手札をセット var pc1 = DeckGenerator.FromCardsetString("H2 S4 D4 DK C4 H5 S6 S7 H7"); var pc2 = DeckGenerator.FromCardsetString("C0 H9 S6 S2 SQ SJ JK S1 H3"); // D4 ⇔ JK DefaultCardDistributer._swap(pc1, pc2, 1); // 枚数チェック Assert.AreEqual(9, pc1.Count()); Assert.AreEqual(9, pc2.Count()); // スワップされたカードの所在確認 Assert.IsFalse(pc1.Contains(new Card(Suit.CLB, 4))); Assert.IsTrue(pc1.Contains(new Card(Suit.JKR, 0))); Assert.IsFalse(pc2.Contains(new Card(Suit.JKR, 0))); Assert.IsTrue(pc2.Contains(new Card(Suit.CLB, 4))); }
public void Rule_TryGetFirstCard_3枚() { var cards = DeckGenerator.FromCardsetString("H1H2S2"); Card firstCard = null; Assert.AreEqual(false, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(null, firstCard); cards = DeckGenerator.FromCardsetString("HKSKDK"); firstCard = null; Assert.AreEqual(true, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(Suit.HRT, firstCard.suit); Assert.AreEqual(13, firstCard.num); cards = DeckGenerator.FromCardsetString("S3JKC3"); firstCard = null; Assert.AreEqual(true, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(Suit.SPD, firstCard.suit); Assert.AreEqual(3, firstCard.num); }
public void Rule_TryGetFirstCard_4枚() { var cards = DeckGenerator.FromCardsetString("HQD2S2C2"); Card firstCard = null; Assert.AreEqual(false, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(null, firstCard); cards = DeckGenerator.FromCardsetString("HJSJDJCJ"); firstCard = null; Assert.AreEqual(true, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(Suit.HRT, firstCard.suit); Assert.AreEqual(11, firstCard.num); cards = DeckGenerator.FromCardsetString("JKC0S0D0"); firstCard = null; Assert.AreEqual(true, _rule.TryGetFirstCard(cards, ref firstCard)); Assert.AreEqual(Suit.CLB, firstCard.suit); Assert.AreEqual(10, firstCard.num); }
public void Card_FromCardsetString() { var test = DeckGenerator.Generate( Suit.CLB, 5, Suit.DIA, 7, Suit.JKR, 0, Suit.SPD, 1, Suit.SPD, 13, Suit.HRT, 11, Suit.HRT, 12 ); string str = "CA C5 D7 JK SA SK HJ HQ"; var ret = DeckGenerator.FromCardsetString(str, 2); Assert.AreEqual(test.Count(), ret.Count()); for (int i = 0; i < test.Count(); i++) { Assert.AreEqual(test.ElementAt(i), ret.ElementAt(i)); } }
public void Context_Nagere() { var ctx = new GameContext(RuleFactory.GetDefaultRule()); // 最初は空 Assert.IsFalse(ctx.Yama.Any()); Assert.IsFalse(ctx.Ba.Any()); // 場にカードを置く ctx._history.Add(new HE_PutCards(ctx.Teban, DeckGenerator.FromCardsetString("HK").ToArray())); Assert.IsTrue(ctx.Ba.Any()); Assert.IsFalse(ctx.Yama.Any()); // 流す //ctx.DoNagare(); ctx._history.Add(new HE_Nagare()); Assert.AreEqual(1, ctx.Yama.Count()); Assert.AreEqual(0, ctx.Ba.Count()); // 場にカードを置く(複数枚、複数回) ctx._history.Add(new HE_PutCards(ctx.Teban, DeckGenerator.FromCardsetString("D3 H3").ToArray())); ctx._history.Add(new HE_PutCards(ctx.Teban, DeckGenerator.FromCardsetString("S5 C5").ToArray())); Assert.AreEqual(1, ctx.Yama.Count()); Assert.AreEqual(2, ctx.Ba.Count()); // 流す //ctx.DoNagare(); ctx._history.Add(new HE_Nagare()); Assert.AreEqual(5, ctx.Yama.Count()); Assert.AreEqual(0, ctx.Ba.Count()); // リセット ctx.Reset(); Assert.AreEqual(0, ctx.Yama.Count()); Assert.AreEqual(0, ctx.Ba.Count()); }
public void Rule_IsKaidan_枚数不足() { Assert.IsFalse(KaidanRule.IsKaidan(DeckGenerator.FromCardsetString("C3 C4"))); }