예제 #1
0
        public void shuffled_deck_returns_different_order()
        {
            // Arrange

            // Return "random" numbers 2 then 1 then 0
            // to reverse the card order
            var rng = Substitute.For<IRandom>();
            rng.Next(100).ReturnsForAnyArgs(2, 1, 0);

            var stackedDeck = GetStackedDeck();

            var deck = Substitute.For<IDeck>();
            deck.GetCards().Returns(stackedDeck);

            IShoe shoe = new Shoe(deck);
            shoe.CardCount().Should().Equal(3);

            // Act
            shoe.Shuffle(rng);

            // Assert
            for (var i = 2; i >= 0; i--)
            {
                shoe.Deal().Should().Be.SameAs(stackedDeck[i]);
                shoe.CardCount().Should().Equal(i);
            }
        }
예제 #2
0
        public void shoe_is_initialized_with_correct_number_of_cards([Values(1,2,6)] int decks)
        {
            // Act
            IShoe shoe = new Shoe(decks);

            // Assert
            shoe.CardCount().Should().Equal(decks * 52);
        }
예제 #3
0
        public void shoe_throws_exception_if_deal_when_empty()
        {
            // Arrange
            var card = Substitute.For<IBlackjackCard>();
            IEnumerable<ICard> cards = new List<IBlackjackCard>() { card };

            var deck = Substitute.For<IDeck>();
            deck.GetCards().Returns(cards);

            IShoe shoe = new Shoe(deck);
            shoe.CardCount().Should().Equal(1);

            shoe.Deal();
            shoe.CardCount().Should().Equal(0);

            // Act
            shoe.Deal();  // Should throw a ShoeOutOfCardsException
        }
예제 #4
0
 public Shoe Create(Shoe newShoe)
 {
     newShoe.Id = Guid.NewGuid().ToString();
     _repo.Create(newShoe);
     return(newShoe);
 }
예제 #5
0
        public static BaseCardCountingStrategy GetStrategy(CardCountingStrategy strategyLookup, Shoe shoe)
        {
            BaseCardCountingStrategy result = null;

            switch (strategyLookup)
            {
            case CardCountingStrategy.HiLo:
                result = new HighLo(shoe);
                break;

            case CardCountingStrategy.HiOp1:
                result = new HighOpt1(shoe);
                break;

            case CardCountingStrategy.HiOpt2:
                result = new HighOpt2(shoe);
                break;

            case CardCountingStrategy.KO:
                result = new KO(shoe);
                break;

            case CardCountingStrategy.Omega3:
                result = new OmegaIII(shoe);
                break;

            case CardCountingStrategy.ZenCount:
                result = new ZenCount(shoe);
                break;
            }
            return(result);
        }
예제 #6
0
 public void UpdateShoe(Shoe shoe)
 {
     _repository.UpdateShoe(shoe);
 }
예제 #7
0
 public void DeleteShoe(Shoe shoe)
 {
     _repository.DeleteShoe(shoe);
 }
예제 #8
0
 public ActionResult <bool> Post(int id, [FromBody] Shoe shoe)
 {
     shoeRepo.Update(shoe);
     return(true);
 }
예제 #9
0
        public bool Update(Shoe newShoe)
        {
            bool result = new ShoeDAO().Update(newShoe);

            return(result);
        }
예제 #10
0
 public IActionResult Delete(Shoe shoe)
 {
     context.Shoes.Remove(shoe);
     context.SaveChanges();
     return(RedirectToAction("Index", "Home"));
 }
예제 #11
0
 public IPlayAction ExecuteStrategy(Hand currentHand, Shoe shoe)
 {
     return(inputFromPlayer.GetPlayAction());
 }
예제 #12
0
 public void UpdateShoe(Shoe shoe)
 {
     _db.SaveChanges();
 }
예제 #13
0
 public void CreateShoe(Shoe shoe)
 {
     _db.Shoes.Add(shoe);
     _db.SaveChanges();
 }
예제 #14
0
 public ShoeRemaining(Shoe shoe, Suit suit)
 {
     this.shoe = shoe;
     this.Suit = suit;
 }
예제 #15
0
 public BaseCardCountingStrategy(Shoe shoe)
 {
     this.shoe = shoe;
 }
예제 #16
0
    public void EquipShoe(Shoe newShoe)
    {
        if (CurrentShoe == newShoe)
        {
            return;
        }
        if (newShoe != null && newShoe.IsEquipped)
        {
            Debug.LogAssertion("attempted to equip already equipped shoe");
            return;
        }

        if (CurrentShoe != null)                // swap old shoe with new one
        {
            switch (CurrentShoe.Type)           // shoe specific unequip logic
            {
            case ShoeType.Gun:
                Debug.Assert(CurrentShoe is GunShoe);
                var gun = CurrentShoe as GunShoe;

                gun.Charge = 0;
                break;

            case ShoeType.Sticky:
                Debug.Assert(CurrentShoe is StickyShoe);
                var sticky = CurrentShoe as StickyShoe;

                if (sticky.IgnoreCollider != null)                              // ensure that collision is re-enabled
                {
                    Physics2D.IgnoreCollision(Player.HeadCollider, sticky.IgnoreCollider, false);
                    sticky.IgnoreCollider = null;
                }

                Destroy(sticky.HingeInstance);
                break;

            case ShoeType.Heely:
                Debug.Assert(CurrentShoe is HeelyShoe);
                var heely = CurrentShoe as HeelyShoe;

                Rigidbody.sharedMaterial = heely.OriginalMaterial;
                break;
            }

            CurrentShoe.transform.parent = null;
            if (newShoe != null)
            {
                CurrentShoe.transform.position = newShoe.transform.position;
                CurrentShoe.transform.rotation = newShoe.transform.rotation;
            }
            CurrentShoe.IsEquipped = false;
        }

        CurrentShoe = newShoe;
        if (CurrentShoe != null)
        {
            // check shoe orientation
            if (CurrentShoe.transform.localScale.x * Orientation < 0)
            {
                var scale = CurrentShoe.transform.localScale;
                scale.x *= -1;
                CurrentShoe.transform.localScale = scale;
            }
            CurrentShoe.transform.parent = this.transform;

            var offset = (Vector3)ShoePosOffset;
            offset.x *= Orientation;
            offset.z  = -1;
            CurrentShoe.transform.localPosition = offset;

            CurrentShoe.transform.localRotation = Quaternion.identity;

            CurrentShoe.IsEquipped = true;

            switch (CurrentShoe.Type)
            {
            case ShoeType.Sticky:
                Debug.Assert(CurrentShoe is StickyShoe);
                var sticky = CurrentShoe as StickyShoe;

                var hinge = gameObject.AddComponent <HingeJoint2D>();
                hinge.enableCollision = false;
                hinge.autoConfigureConnectedAnchor = true;
                hinge.motor = new JointMotor2D
                {
                    motorSpeed     = 0,
                    maxMotorTorque = sticky.HingeResistance,
                };
                hinge.useMotor = true;

                sticky.HingeInstance = hinge;
                hinge.enabled        = false;
                break;

            case ShoeType.Heely:
                Debug.Assert(CurrentShoe is HeelyShoe);
                var heely = CurrentShoe as HeelyShoe;

                heely.OriginalMaterial = Rigidbody.sharedMaterial;
                break;
            }
        }
    }
예제 #17
0
 public Game(int initialBalance, int numberOfDecks = 6)
 {
     Shoe = new Shoe(numberOfDecks);
     Dealer = new Player(this, Shoe);
     Player = new Player(this, Shoe, initialBalance);
 }
예제 #18
0
        public bool AddItem(Shoe newShoe)
        {
            bool result = new ShoeDAO().Insert(newShoe);

            return(result);
        }
예제 #19
0
        private void InitializeSimulationWithUserInput()
        {
            string input = string.Empty;
            int    bettingStrategy;
            int    startingFunds;
            int    minimumBet;

            Console.WriteLine("\nPlease enter the number of players.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out numberOfPlayers))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the number of players.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the number of total iterations to simulate (one iteration is a full played hand per player)");
            input = Console.ReadLine();

            while (!int.TryParse(input, out numberOfIterations))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the number of iterations.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the number of decks in the shoe.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out numberOfDecksInShoe))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the number of decks in the shoe.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the starting funds of the players.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out startingFunds))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the starting funds of the players.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the minimum bet of the players.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out minimumBet))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the minimum bet of the players.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease choose a betting strategy: \n\t1 - Manhattan\n\t2 - Martingale");
            input = Console.ReadLine();

            while (!int.TryParse(input, out bettingStrategy))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer (1 or 2) for a betting strategy.");
                input = Console.ReadLine();
            }

            shoe    = new Shoe(numberOfDecksInShoe);
            counter = new HiLoCounter(numberOfDecksInShoe);

            for (int i = 0; i < numberOfPlayers; i++)
            {
                if (bettingStrategy == 1)
                {
                    playerList.Add(new Player(typeof(Manhattan), startingFunds, minimumBet));
                }
                else
                {
                    playerList.Add(new Player(typeof(Martingale), startingFunds, minimumBet));
                }
            }
        }
예제 #20
0
    private void Update()
    {
        if (CurrentPlayerInfo == null)          // check ready to be used
        {
            NoControllerMenu.SetActive(true);
            SelectionMenu.SetActive(false);
            return;
        }

        var prevMenu = _selectionMenu;

        if (Controller.Action1.WasPressed)
        {
            _selectionMenu++;
        }
        if (Controller.Action2.WasPressed)
        {
            _selectionMenu--;
        }
        _selectionMenu = Mathf.Clamp(_selectionMenu, 0, MenuIsReadyIndex);

        var shift = 0;          // shift item selection

        if (Controller.LeftBumper.WasPressed)
        {
            shift--;
        }
        if (Controller.RightBumper.WasPressed)
        {
            shift++;
        }
        if (shift != 0 || prevMenu != _selectionMenu)
        {
            switch (_selectionMenu)
            {
            case 0:
                TitleText.text = "SELECT OUTFIT";

                _selectedCostume          = Mod(_selectedCostume + shift, GameplayManager.Instance.PlayerCostumes.Length);
                CurrentPlayerInfo.Costume = GameplayManager.Instance.PlayerCostumes[_selectedCostume];

                SelectionText.text = CurrentPlayerInfo.Costume.Name;
                break;

#if false       // remember to update MenuIsReadyIndex!
            case 1:
                TitleText.text = "SELECT SHOE";

                var nextShoe = Controller.LeftTrigger ? CurrentPlayerInfo.ShoeLeft : CurrentPlayerInfo.ShoeRight;
                if (shift > 0)
                {
                    nextShoe = Shoe.NextType(nextShoe ?? default(ShoeType));
                }
                else if (shift < 0)
                {
                    nextShoe = Shoe.PrevType(nextShoe ?? default(ShoeType));
                }

                // secret feature: hold trigger to change only that shoe :--)
                if (!Controller.RightTrigger)
                {
                    CurrentPlayerInfo.ShoeLeft = nextShoe;
                }
                if (!Controller.LeftTrigger)
                {
                    CurrentPlayerInfo.ShoeRight = nextShoe;
                }

                SelectionText.text = nextShoe.ToString();
                break;

            case 2:
#else
            case 1:
#endif
                TitleText.text = "SELECT TEAM";

                _selectedTeam          = Mod(_selectedTeam + shift, GameplayManager.Instance.PlayerTeams.Length);
                CurrentPlayerInfo.Team = GameplayManager.Instance.PlayerTeams[_selectedTeam];

                SelectionText.text  = CurrentPlayerInfo.Team.Name;
                SelectionText.color = CurrentPlayerInfo.Team.Color;
                break;

            default:                            // final case: player is ready
                TitleText.text     = "PLAYER READY";
                SelectionText.text = "B: CANCEL";
                break;
            }

            // finally, refresh onscreen player avatar
            PlayerModel.SetPlayerInfo(CurrentPlayerInfo);
        }
    }
예제 #21
0
        public void unshuffled_deck_returns_expected_order()
        {
            // Arrange
            var stackedDeck = GetStackedDeck();

            var deck = Substitute.For<IDeck>();
            deck.GetCards().Returns(stackedDeck);

            IShoe shoe = new Shoe(deck);
            shoe.CardCount().Should().Equal(3);

            // Act

            // Assert
            for (var i = 0; i <= 2; i++)
            {
                var card = shoe.Deal();
                card.Should().Be.SameAs(stackedDeck[i]);  // 0, 1, 2
                shoe.CardCount().Should().Equal(2-i);     // 2, 1, 0
            }
        }
예제 #22
0
 public ActionResult <bool> Post([FromBody] Shoe shoe)
 {
     shoeRepo.Create(shoe);
     return(true);
 }