示例#1
0
        public async Task <SummaryDeck> CreateAsync(CreateDeck createDeck)
        {
            var deck = new Deck
            {
                Title  = createDeck.Title,
                UserId = createDeck.UserId,
                TextId = createDeck.TextId
            };

            _dbContext.Decks.Add(deck);

            await _dbContext.SaveChangesAsync();

            return(new SummaryDeck(deck.Id, deck.Title, deck.TextId));
        }
示例#2
0
        public async override Task <IdentityResult> CreateAsync(MemCheckUser user)
        {
            if (user.UserName.Length > MaxUserNameLength || user.UserName.Length < MinUserNameLength)
            {
                return(IdentityResult.Failed(new IdentityError()
                {
                    Code = BadUserNameLengthErrorCode, Description = $"User name must contain between {MinUserNameLength} and {MaxUserNameLength} chars"
                }.AsArray()));
            }

            var result = await base.CreateAsync(user);

            callContext.TelemetryClient.TrackEvent("UserAccountCreated", ("UserName", user.UserName), ("Email", user.Email), ("Success", result.Succeeded.ToString()), ("ErrorList", string.Concat(result.Errors.Select(error => error.Code + ": " + error.Description))));
            if (result.Succeeded)
            {
                var createDeck = new CreateDeck(callContext);
                await createDeck.RunAsync(new CreateDeck.Request(user.Id, DefaultDeckName, HeapingAlgorithms.DefaultAlgoId));
            }
            return(result);
        }
    void Start()
    {
        int soundEffect = PlayerPrefs.GetInt("Sound");

        if (soundEffect == 1)
        {
            // plays the card deal sound effect
            cardDeal.Play();
        }

        blackJackCheatSheet blackJackCheatSheet = randomObject.AddComponent <blackJackCheatSheet>();

        //this will look in the player preference to find the user's position of UI
        int position = PlayerPrefs.GetInt("Position");

        if (position == 0)
        {
            leftSide.SetActive(false);
            rightSide.SetActive(true);
        }
        else if (position == 1)
        {
            leftSide.SetActive(true);
            rightSide.SetActive(false);
        }



        //finds the skin stored in player preference and uses it to set the cardback
        skin = PlayerPrefs.GetString("Skin");

        List <CardObject> deckList = CreateDeck.createDeck();

        //populating the deck array
        for (int i = 0; i < 51; i++)
        {
            cardArray[i] = i;
        }

        //passing the cardArray to the shuffle method to get a shuffled array
        int[] shuffledArray = shuffleArray(cardArray);


        //player card 1
        card1             = shuffledArray[0];
        pcards1.cardIndex = card1;
        pcards1.showFace();


        //player card 2
        card2             = shuffledArray[2];
        pcards2.cardIndex = card2;
        pcards2.showFace();


        //dealer card 1
        card3             = shuffledArray[1];
        dcards1.cardIndex = card3;
        dcards1.showFace();


        //dealer card 2
        card4             = shuffledArray[3];
        dcards2.cardIndex = card4;
        dcards2.showBack(skin);



        //this will show the card totals on the UI
        SetPlayerCountText(deckList[card1], deckList[card2]);
        SetDealerCountText(deckList[card3]);

        //determines if the user should hit, stand, double or split
        returned = blackJackCheatSheet.blackJackCheatSheetMethod(deckList[card1], deckList[card2], deckList[card3]);

        //getting the faces of the cards so it can show up in the modal feedback box
        card1Face = deckList[card1].face;
        card2Face = deckList[card2].face;
        card3Face = deckList[card3].face;
    }