public static GameState GenerateGameState(string newGameId, int howManyPlayers, List <string> playersNicknames, string firstPlayerNickname) { string newId = newGameId; var mainDeck = DeckGenerator.GenerateActionsDeck(); var animalsDeck = DeckGenerator.GenerateAnimalsDeck(); var goodsDeck = DeckGenerator.GenerateGoodsDeck(); var projectCards = PrepareProjectCards(mainDeck, howManyPlayers); var players = PreparePlayers(animalsDeck, goodsDeck, howManyPlayers, playersNicknames); var bonuses = PrepareAvailableBonuses(howManyPlayers); return(new GameState(newId, players, mainDeck, animalsDeck, goodsDeck, projectCards, bonuses, Round.A, firstPlayerNickname, 1, players.Count, false)); }
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 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()); }
private void InitPlayerDecks() { int p1Id = PhotonNetwork.isMasterClient ? 1 : 0; int p2Id = p1Id == 0 ? 1 : 0; var p1LessonsBytes = PhotonNetwork.playerList[p1Id].customProperties["lessons"] as byte[]; var p2LessonsBytes = PhotonNetwork.playerList[p2Id].customProperties["lessons"] as byte[]; if (p1LessonsBytes == null || p2LessonsBytes == null) { Log.Error("p1 or p2 selected lessons are null, report this error!"); return; } var p1SelectedLessons = p1LessonsBytes.Select(n => (LessonTypes)n).ToList(); var p2SelectedLessons = p2LessonsBytes.Select(n => (LessonTypes)n).ToList(); GameManager.NetworkIdCounter = 0; GameManager.AllCards.Clear(); DeckGenerator.ResetStartingCharacterPool(); Log.Write("Generating Player Decks"); this.Player1.InitDeck(p1SelectedLessons); this.Player2.InitDeck(p2SelectedLessons); }
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); }
internal TestCardDistributer(string p0, string p1, string p2) { ret = new[] { DeckGenerator.FromCardsetString(p0), DeckGenerator.FromCardsetString(p1), DeckGenerator.FromCardsetString(p2), }; }
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"))); }
public void Rule_CheckPut_場あり_1枚() { _ctx._history.Clear(); _ctx._history.Add(new HE_PutCards(0, DeckGenerator.Generate(Suit.HRT, 3).ToArray())); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.CLB, 4)); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 3), SimplestRule.ERR_NOT_STRONG); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.JKR, 0)); }
public async Task <IActionResult> Patch(Guid id, [FromBody] Deck deck) { using (var repository = new Repository(HttpContext.GetUserGuid())) { if (repository.ServiceUser == null) { return(Forbid()); } await repository.Context.Factions.LoadAsync(); await repository.Context.CardTypes.LoadAsync(); var deckModel = await repository.Context.Decks.Include(x => x.DeckCards) .ThenInclude(dc => dc.Card) .Where(x => x.Guid == id).FirstOrDefaultAsync(); if (deckModel == null) { return(NotFound()); } await repository.Context.Entry(deckModel).Reference(x => x.Creator).LoadAsync(); await repository.Context.Entry(deckModel).Reference(x => x.Status).LoadAsync(); await repository.Context.Entry(repository.ServiceUser).Reference(x => x.Role).LoadAsync(); if (repository.ServiceUser.Role.Guid != PredefinedGuids.Administrator && deckModel.Creator.Guid != repository.ServiceUser.Guid) { return(Forbid()); } StatusModel statusModel = null; if (deck.Status != null) { statusModel = await repository.Context.Statuses.FindByGuidAsync(deck.Status.Guid); } deckModel.Patch(deck, statusModel, repository.ServiceUser); deck = deckModel.FromDal(true); System.IO.File.WriteAllText(Repository.GetDeckJsonFile(deck.Guid), JsonConvert.SerializeObject(deck)); System.IO.File.WriteAllText(Repository.GetDeckFormatFile(deck.Guid), GetDeckFormat(deckModel)); await repository.Context.Entry(repository.ServiceUser).Reference(x => x.Role).LoadAsync(); var generateMissing = repository.ServiceUser.Guid == PredefinedGuids.Administrator || repository.ServiceUser.Guid == PredefinedGuids.ServiceUser; await repository.Context.SaveChangesAsync(); BackgroundJob.Schedule( () => DeckGenerator.GenerateDeck(deck.Guid, deck.GeneratePdf, deck.ExportTiles, generateMissing, true), TimeSpan.Zero); deck.IsEditable = true; return(Ok(deck)); } }
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 Should_Contain_52_Cards() { var deckGenerator = new DeckGenerator(); var deck = deckGenerator.GenerateDeck(); var cardCount = deck.Count(); Assert.Equal(52, cardCount); }
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_CheckPut_場あり_2枚() { _ctx._history.Clear(); _ctx._history.Add(new HE_PutCards(0, DeckGenerator.Generate(Suit.DIA, 4, Suit.SPD, 4).ToArray())); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.CLB, 5, Suit.SPD, 5)); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.JKR, 0, Suit.SPD, 5)); // ジョーカーまじり _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 4, Suit.SPD, 4), SimplestRule.ERR_NOT_STRONG); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 5), SimplestRule.ERR_COUNT_DOESNT_MATCH); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.JKR, 0), SimplestRule.ERR_COUNT_DOESNT_MATCH); }
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 Rule_CheckPut_場あり革命中_1枚() { _ctx._history.Clear(); _ctx._history.Add(new HE_PutCards(0, DeckGenerator.Generate(Suit.CLB, 5).ToArray())); _ctx.IsKakumei = true; _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.CLB, 4)); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 5), SimplestRule.ERR_NOT_STRONG); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 6), SimplestRule.ERR_NOT_STRONG); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 2), SimplestRule.ERR_NOT_STRONG); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.JKR, 0)); }
public void Should_Have_Four_Of_Each_Rank() { var deckGenerator = new DeckGenerator(); var deck = deckGenerator.GenerateDeck(); var rankCounts = deck .GroupBy( card => card.Rank, (rank, cards) => cards.Count()); Assert.True(rankCounts.All(rankCount => rankCount == 4)); }
public void Should_Have_13_Of_Each_Suit() { var deckGenerator = new DeckGenerator(); var deck = deckGenerator.GenerateDeck(); var suitCounts = deck .GroupBy( card => card.Suit, (rank, cards) => cards.Count()); Assert.True(suitCounts.All(rankCount => rankCount == 13)); }
public override void Initialize() { Lobby.Broadcast("Distribution of cards."); var decks = DeckGenerator.GenerateAllDecks(); foreach (var client in Lobby.Info.Clients) { client.Deck = decks[0]; decks.RemoveAt(0); } IsGenerated = true; }
public void Generate() { var deckGenerator = new DeckGenerator(); var cards = deckGenerator.Generate(); Assert.AreEqual(4, cards.Select(x => x.Suit).Distinct().Count()); Assert.AreEqual(13, cards.Where(x => x.Suit == "Clubs").Select(x => x.Rank).Distinct().Count()); Assert.AreEqual(13, cards.Where(x => x.Suit == "Diamonds").Select(x => x.Rank).Distinct().Count()); Assert.AreEqual(13, cards.Where(x => x.Suit == "Hearts").Select(x => x.Rank).Distinct().Count()); Assert.AreEqual(13, cards.Where(x => x.Suit == "Spades").Select(x => x.Rank).Distinct().Count()); }
public void GetPackNamesContainsName() { //Arrange var dGen = new DeckGenerator(); string name = "Hilarious!"; //Act IEnumerable <string> packNames = dGen.GetPackNames(); //Assert Assert.Contains(name, packNames); }
public void Rule_CheckPut_場あり革命中_2枚() { _ctx._history.Clear(); _ctx._history.Add(new HE_PutCards(0, DeckGenerator.Generate(Suit.DIA, 2, Suit.SPD, 2).ToArray())); _ctx.IsKakumei = true; _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.CLB, 1, Suit.SPD, 1)); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.CLB, 3, Suit.SPD, 3)); _assertCheckPutCardsIsOK(DeckGenerator.Generate(Suit.CLB, 3, Suit.JKR, 0)); // ジョーカーまじり _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 2, Suit.DIA, 2), SimplestRule.ERR_NOT_STRONG); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 2, Suit.JKR, 2), SimplestRule.ERR_NOT_STRONG); // ジョーカーまじり _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.CLB, 5), SimplestRule.ERR_COUNT_DOESNT_MATCH); _assertCheckPutCardsIsNG(DeckGenerator.Generate(Suit.JKR, 0), SimplestRule.ERR_COUNT_DOESNT_MATCH); }
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 Should_Have_Distinct_Cards() { var deckGenerator = new DeckGenerator(); var deck = deckGenerator.GenerateDeck(); var cardCount = deck.Count(); var distinctCardCount = deck .Distinct() .Count(); Assert.Equal(cardCount, distinctCardCount); }
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 override void OnInspectorGUI() { DrawDefaultInspector(); DeckGenerator cg = (DeckGenerator)target; if (GUILayout.Button("Generate")) { cg.generate(); } if (GUILayout.Button("Open Folder")) { cg.openCardFolder(); } }
public void InitDeck(List <LessonTypes> selectedLessons) { List <BaseCard> cards; if (GameManager.DebugModeEnabled) { var prebuiltCards = GameManager.GetPlayerTestDeck(NetworkId); cards = DeckGenerator.GenerateDeck(prebuiltCards, selectedLessons); } else { cards = DeckGenerator.GenerateDeck(selectedLessons); } Deck.Initialize(cards, DeckGenerator.GetRandomCharacter()); }
public void GetDeckFromPacknamesContainsNoEmpty() { //Arrange string[] packnames = { "Hilarious!", "Cows Against Hamburgers - Patty Pack #1", }; var dGen = new DeckGenerator(); //Act Deck deck = dGen.GetDeck(packnames); //Assert Assert.NotNull(deck); }
public void GetDeckFromPacknamesContainsCardsFromPacknames() { //Arrange string[] packnames = { "Hilarious!", "Cows Against Hamburgers - Patty Pack #1", }; var dGen = new DeckGenerator(); //Act Deck deck = dGen.GetDeck(packnames); //Assert Assert.Equal(packnames[0], (deck.BlackCards.First()).PackName); }
public static void ShouldHaveUniqueCards() { var uniqueCards = new List <string>(); var deck = DeckGenerator.GenerateDeck(); foreach (var card in deck) { if (uniqueCards.Any(x => x == card.ToString())) { Assert.False(true, $"Duplicate card found: {card}"); } else { uniqueCards.Add(card.ToString()); } } }