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); } }
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); }
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 }
public Shoe Create(Shoe newShoe) { newShoe.Id = Guid.NewGuid().ToString(); _repo.Create(newShoe); return(newShoe); }
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); }
public void UpdateShoe(Shoe shoe) { _repository.UpdateShoe(shoe); }
public void DeleteShoe(Shoe shoe) { _repository.DeleteShoe(shoe); }
public ActionResult <bool> Post(int id, [FromBody] Shoe shoe) { shoeRepo.Update(shoe); return(true); }
public bool Update(Shoe newShoe) { bool result = new ShoeDAO().Update(newShoe); return(result); }
public IActionResult Delete(Shoe shoe) { context.Shoes.Remove(shoe); context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public IPlayAction ExecuteStrategy(Hand currentHand, Shoe shoe) { return(inputFromPlayer.GetPlayAction()); }
public void UpdateShoe(Shoe shoe) { _db.SaveChanges(); }
public void CreateShoe(Shoe shoe) { _db.Shoes.Add(shoe); _db.SaveChanges(); }
public ShoeRemaining(Shoe shoe, Suit suit) { this.shoe = shoe; this.Suit = suit; }
public BaseCardCountingStrategy(Shoe shoe) { this.shoe = shoe; }
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; } } }
public Game(int initialBalance, int numberOfDecks = 6) { Shoe = new Shoe(numberOfDecks); Dealer = new Player(this, Shoe); Player = new Player(this, Shoe, initialBalance); }
public bool AddItem(Shoe newShoe) { bool result = new ShoeDAO().Insert(newShoe); return(result); }
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)); } } }
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); } }
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 } }
public ActionResult <bool> Post([FromBody] Shoe shoe) { shoeRepo.Create(shoe); return(true); }