public void Card_FullSet() { var r = DeckGenerator.DeckWithJoker(); // 全体枚数 Assert.AreEqual(53, r.Count()); // スート毎の枚数 var r_clv = from t1 in r where t1.suit == Suit.CLB select 1; Assert.AreEqual(13, r_clv.Count()); var r_dia = from t1 in r where t1.suit == Suit.DIA select 1; Assert.AreEqual(13, r_dia.Count()); var r_hrt = from t1 in r where t1.suit == Suit.HRT select 1; Assert.AreEqual(13, r_hrt.Count()); var r_spd = from t1 in r where t1.suit == Suit.SPD select 1; Assert.AreEqual(13, r_spd.Count()); // ジョーカー var r_jkr = from t1 in r where t1.suit == Suit.JKR select 1; Assert.AreEqual(1, r_jkr.Count()); }
public void Card_ToString() { var r = DeckGenerator.DeckWithJoker(); object[] tests = { Suit.CLB, 1, "CA", Suit.CLB, 5, "C5", Suit.DIA, 7, "D7", Suit.HRT, 10, "H0", Suit.HRT, 11, "HJ", Suit.SPD, 12, "SQ", Suit.SPD, 13, "SK", Suit.JKR, 0, "JK", }; for (int i = 0; i < tests.Length; i += 3) { var x = from t1 in r where t1.suit.Equals(tests[i]) && ((int)t1.num).Equals(tests[i + 1]) select t1; Assert.AreEqual(1, x.Count(), "対象カードがみつからない:" + tests[i] + "," + tests[i + 1]); var x0 = x.First(); Assert.AreEqual(tests[i + 2], x0.ToString()); } }
public void Start() { IsPlaing = true; context.Reset(); foreach (var c in playerContexts.Values) { c.Reset(); } // 開始通知 Start(_getContext); //_broadCastForPlayers((p, pc) => p.Start(pc)); // カードを生成し、配布する { var ret = CardDistributer.Distribute(context.PlayerInfo, DeckGenerator.DeckWithJoker()); // 1枚ずつカードを手札に移し替え、5枚配るごとに通知する。 while (ret.Any(l => l.Count() > 0)) { for (int i = 0; i < ret.Length; i++) { var pi = context.PlayerInfo.ElementAt(i); var l = ret[i]; if (l.Count <= 0) { continue; } var pc = playerContexts.ElementAt(i).Value; pc._deck.Add(l[0]); l.RemoveAt(0); } if (playerContexts.ElementAt(0).Value._deck.Count % 5 == 0) { _wait(); CardDistributed(_getContext); } } } // 最終的にカード配布通知。 _wait(); //_broadcast((evt, f) => evt.CardDistributed(f)); CardDistributed(_getContext); //context._players.ForEach(px => px.CardDistributed(playerContexts[px])); { var tmp = new Dictionary <IPlayerInfo, IList <Card> >(); for (int i = 0; i < context._players.Count; i++) { var p = context._players[i]; var pi = context.PlayerInfo.ElementAt(i); tmp.Add(pi, playerContexts[p]._deck); } // 手番を決める。 context.Teban = context.Rule.GetFirstDealer(tmp); // カード交換 _wait(); if (CardDistributer.SwapCards(tmp)) { CardSwapped(_getContext); } } // 手札ソート foreach (var pc in playerContexts.Values) { pc._deck.Sort(); } _wait(); //_broadcast((evt, f) => evt.CardDistributed(f)); CardDistributed(_getContext); //context._players.ForEach(px => //{ // px.CardDistributed(playerContexts[px]); //}); // 次の手を求める RunAsyncLater(() => { //_broadcast((evt, f) => evt.Thinking(f)); Thinking(_getContext); var pxc = context.GetCurrentPlayer(); //context._players.ForEach(px => {if(px!=pxc) px.Thinking(playerContexts[px]);}); pxc.ProcessTurn(playerContexts[pxc]); }); }