public async Task ShouldCloseBet() { var betId = Guid.NewGuid(); var memberId = new MemberId(Guid.Parse("1311e8c9-d993-4346-94c1-1907e3ce65d3")); var creator = new Member(memberId, "name", 300); BetState betState = GenerateBet(betId, creator); var domainEventsListener = new DomainEventsAccessor(); var repository = new InMemoryBetRepository(domainEventsListener, betState); var command = new CloseBetCommand(betId, true); var dateTimeClosed = new DateTime(2021, 4, 1); var dateTimeProvider = new FakeDateTimeProvider(dateTimeClosed); var handler = new CloseBetCommandHandler(repository, dateTimeProvider, new InMemoryAuthenticationGateway(true, memberId.Value)); await handler.Handle(command, default); var bet = await repository.GetByIdAsync(new(betId)); Assert.True(bet.State.IsSuccess); Assert.Equal(dateTimeClosed, bet.State.CloseDate); var betClosedEvent = domainEventsListener.GetDomainEvents() .SingleOrDefault(x => x.GetType() == typeof(BetClosed)) as BetClosed; var betUpdatedEvent = domainEventsListener.GetDomainEvents() .SingleOrDefault(x => x.GetType() == typeof(BetUpdated)) as BetUpdated; Assert.NotNull(betClosedEvent); Assert.NotNull(betUpdatedEvent); Assert.Equal(betId, betClosedEvent.BetId); Assert.True(betClosedEvent.IsSuccess); Assert.Equal(betId, betUpdatedEvent.BetId); }
private void frmSingleCasino_KeyDown(object sender, KeyEventArgs e) { //hotkeys if (e.KeyCode == Keys.A) { btnDeal.PerformClick(); } else if (e.KeyCode == Keys.D) { btnHold.PerformClick(); } else if (e.KeyCode == Keys.Q) { btnDouble.PerformClick(); } else if (e.KeyCode == Keys.Space) { btnConfirmBet.PerformClick(); } else if (tmrBetting.Enabled == true) { if (e.KeyCode == Keys.W) { PlayerBetState = BetState.Increase; } else if (e.KeyCode == Keys.S) { PlayerBetState = BetState.Decrease; } } }
public async Task ShouldDecreaseWalletCreatorAndIncreaseParticipants() { var betId = Guid.NewGuid(); var creator = new Member(new(Guid.NewGuid()), "creator", 200); var participant = new Member(new(Guid.NewGuid()), "participant", 100); var participant2 = new Member(new(Guid.NewGuid()), "participant2", 500); var betState = new BetState(betId, creator, new DateTime(2021, 12, 3), "description", 50, new DateTime(2020, 3, 3), new List <AnswerState>() { new AnswerState(participant, true, new DateTime(2021, 3, 4)), new AnswerState(participant2, true, new DateTime(2021, 3, 4)) }, new DateTime(2021, 3, 3), false); var domainEventListener = new DomainEventsAccessor(); IBetRepository betRepository = new InMemoryBetRepository(domainEventListener, betState); IMemberRepository memberRepository = new InMemoryMemberRepository(new() { creator, participant, participant2 }); var command = new UpdateWalletMembersCommand(betId); var handler = new UpdateWalletMembersCommandHandler(betRepository, memberRepository); await handler.Handle(command, default); var creatorUpdated = await memberRepository.GetByIdAsync(creator.Id); var participantUpdated = await memberRepository.GetByIdAsync(participant.Id); var participantUpdated2 = await memberRepository.GetByIdAsync(participant2.Id); Assert.Equal(150, creatorUpdated.Wallet); Assert.Equal(125, participantUpdated.Wallet); Assert.Equal(525, participantUpdated2.Wallet); }
public BetDto(BetState state) { Id = state.BetId; Description = state.Description; Creator = new MemberDto(state.Creator); Coins = state.Coins; EndDate = state.EndDate; Participants = state.Answers?.Select(x => new MemberDto() { Id = x.Member.Id.Value, Username = x.Member.Name }).ToList(); }
private void frmSingleCasino_KeyUp(object sender, KeyEventArgs e) { if (tmrBetting.Enabled == true) { if (e.KeyCode == Keys.W) { PlayerBetState = BetState.None; } else if (e.KeyCode == Keys.S) { PlayerBetState = BetState.None; } } }
internal static Bet ToBet(this BetEntity entity) { var betState = new BetState(entity.BetId, entity.Creator.ToMember(), entity.EndDate, entity.Description, entity.Coins, entity.CreationDate, entity.Answers?.Select(x => new AnswerState(x.Member.ToMember(), x.IsAccepted, x.DateAnswer)) .ToList(), entity.CloseDate, entity.IsSuccess); var bet = Bet.FromState(betState); return(bet); }
public async Task ShouldNotModifyWalletCreatorWhenThereAreNoParticipants() { var betId = Guid.NewGuid(); var creator = new Member(new(Guid.NewGuid()), "creator", 200); var betState = new BetState(betId, creator, new DateTime(2021, 12, 3), "description", 50, new DateTime(2020, 3, 3), new List <AnswerState>(), new DateTime(2021, 3, 3), true); var domainEventListener = new DomainEventsAccessor(); var betRepository = new InMemoryBetRepository(domainEventListener, betState); var memberRepository = new InMemoryMemberRepository(new() { creator }); var command = new UpdateWalletMembersCommand(betId); var handler = new UpdateWalletMembersCommandHandler(betRepository, memberRepository); await handler.Handle(command, default); Assert.Equal(200, creator.Wallet); }
void Start() { _numNPCs = SharedData.NumberNPC; _userMoney = SharedData.Money; _blackjackModel = new BlackjackModel(_numNPCs, _userMoney); _gameState = GameState.BET; _betState = BetState.PLAYER; _dealState = DealState.GETCARDS; _playState = PlayState.WHOSETURN; _cardList = new List <System.Tuple <int, bool> >(); _betList = new List <int>(); _currentPlayerID = -1; foreach (int j in _blackjackModel.PlayerIds) { _betList.Add(-1); } _activeSeats = new List <GameObject>(); InitializeSeatList(); _chipManagerList = new List <ChipLERP>(); foreach (int i in _blackjackModel.PlayerIds) { if (i != _blackjackModel.DealerID) { _chipManagerList.Add(_activeSeats[i].GetComponent <ChipLERP>()); } } for (int j = 0; j < aiSeats.Count; j++) { if (j < aiSeats.Count / 2) { AddCardManager(aiSeats[j], aiHandList[j], -60 + 20 * j); } else { AddCardManager(aiSeats[j], aiHandList[j], -60 + 20 * (j + 1)); } } AddCardManager(playerSeat, playerHandMarker, 0); AddCardManager(dealerHandMarker, dealerHandMarker, 0); _dealCardAnimateBool = true; _dealCardAnimateInt = 0; _cardManagerList = new List <CardLERP>(); foreach (int i in _blackjackModel.PlayerIds) { if (i != _blackjackModel.DealerID && i != _blackjackModel.UserID) { _cardManagerList.Add(_activeSeats[i].GetComponent <CardLERP>()); } else if (i == _blackjackModel.UserID) { _cardManagerList.Add(playerSeat.GetComponent <CardLERP>()); } else { _cardManagerList.Add(dealerHandMarker.GetComponent <CardLERP>()); } } for (int j = 0; j < aiSeats.Count; j++) { if (j < aiSeats.Count / 2) { aiSeats[j].transform.Rotate(0f, (-60 + j * 20), 0f); } else { aiSeats[j].transform.Rotate(0f, (-60 + (j + 1) * 20), 0f); } } peekHand.SetActive(false); _cardOffset = 0f; _currentCard = 0; _resolveBetsHelperBool = true; _animateBetsHelperBool = true; _pauseAfterWinHelperBool = true; wonLostDict = new Dictionary <int, bool>(); _pauseAfterWinHelperBool2 = true; }
void InitializeBets() { PlayerActions cs = betUI.GetComponent <PlayerActions>(); int playerbet = cs._betAmount; switch (_betState) { case BetState.PLAYER: cs._betInput.gameObject.SetActive(true); cs._betButton.gameObject.SetActive(true); if (_blackjackModel.SetUserBet(playerbet)) { _betList[_blackjackModel.UserID] = playerbet; _betState = BetState.AI; cs._betInput.gameObject.SetActive(false); cs._betButton.gameObject.SetActive(false); cs._betAmount = -1; } break; case BetState.AI: foreach (int i in _blackjackModel.PlayerIds) { // This is for animation state if (i != _blackjackModel.DealerID) { if (i != _blackjackModel.UserID) { _betList[i] = _blackjackModel.GetNPCBet(i); } _chipManagerList[i].CalculateChipCluster(_betList[i], _blackjackModel.GetMoney(i)); //calculate AI bet cluster } } _betState = BetState.ANIMATE; _startTime = Time.time; break; case BetState.ANIMATE: if (_animateBetsHelperBool) { foreach (ChipLERP chipLerper in _chipManagerList) { chipLerper.RestartAnimateBet(); _animateBetsHelperBool = false; } } else { bool doneBool = true; foreach (ChipLERP chipLerper in _chipManagerList) { doneBool = doneBool && !chipLerper.animateBetBool; } if (doneBool) { _betState = BetState.PLAYER; _gameState = GameState.DEAL; _animateBetsHelperBool = true; } } break; default: throw new System.Exception("_betState state has been thrown off. It is currently: " + _betState); } }
public BaseBetViewModel(IAccountIdentService accountIdentService) { Name = "НОВАЯ СТАВКА"; State = new BetState(); Account = new AccountViewModel(accountIdentService, null, null); }
public Task SaveAsync(Bet bet) { _domainEventsListener.AddDomainEvents(bet.DomainEvents); _bet = bet.State; return(Task.CompletedTask); }
public InMemoryBetRepository(IDomainEventsAccessor domainEventsListener = null, BetState betState = null) { _domainEventsListener = domainEventsListener; _bet = betState; }