public async Task <BetrayedCircle> BetrayCircle(
            Guid betrayedCircleId,
            Guid circleId,
            Guid playerId,
            string key
            )
        {
            await _circleKeyMustBeValidInOrderToJoinOrBetrayCircleRule.Verify(circleId, key);

            await _playersMayNotJoinOrBetrayCircleThatHasBeenBetrayedRule.Verify(circleId);

            await _playersMayNotJoinOrBetrayTheirOwnCircleRule.Verify(circleId, playerId);

            await _playersMayNotBetrayCircleTheyAreAMemberOfRule.Verify(circleId, playerId);

            BetrayedCircle betrayedCircle = new BetrayedCircle(betrayedCircleId, circleId, playerId);

            betrayedCircle.RaiseEvent(new CircleBetrayedEvent(betrayedCircle.Id, betrayedCircle.CircleId, betrayedCircle.PlayerId));
            return(betrayedCircle);
        }
Example #2
0
        public async Task <Member> JoinCircle(
            Guid memberId,
            Guid playerId,
            Guid circleId,
            string key
            )
        {
            await _circleKeyMustBeValidInOrderToJoinOrBetrayCircleRule.Verify(circleId, key);

            await _playersMayNotJoinOrBetrayCircleThatHasBeenBetrayedRule.Verify(circleId);

            await _playersMayNotJoinOrBetrayTheirOwnCircleRule.Verify(circleId, playerId);

            await _playersMayOnlyJoinACircleOnceRule.Verify(circleId, playerId);

            Member member = new Member(memberId, playerId, circleId);

            member.RaiseEvent(new MemberJoinedEvent(member.Id, member.PlayerId, member.CircleId));
            return(member);
        }