Ejemplo n.º 1
0
        public Card(Guid id,
            Int64 cardID,
            String name,
            String purpose,
            CardBuzzWord[] words)
        {
            EventSourceId = id;
            var clock = NcqrsEnvironment.Get<IClock>();

            ApplyEvent(new BuzzyGo.Events.Card.CardCreated()
            {
                CardID = cardID,
                DateCreated = clock.UtcNow(),
                Name = name,
                Purpose = purpose,
                Squares = CreateCardSquares(cardID, name, clock, words)
            });
        }
Ejemplo n.º 2
0
        private BuzzyGo.Repository.CardSquare[] CreateCardSquares(Int64 cardID, String cardName, IClock clock, CardBuzzWord[] words)
        {
            CardBuzzWord[] wordsWithFree = new CardBuzzWord[25];
            for (int i = 0; i < 12; i++)
            {
                wordsWithFree[i] = words[i];
            }
            wordsWithFree[12] = new CardBuzzWord() { BuzzWordID = 0, BuzzWord = "FREE" };
            for (int i = 0; i < 12; i++)
            {
                wordsWithFree[13 + i] = words[12 + i];
            }

            List<BuzzyGo.Repository.CardSquare> squares = new List<Repository.CardSquare>();
            for (int i = 0; i < wordsWithFree.Length; i++)
            {
                squares.Add(new Repository.CardSquare()
                {
                    CardID = cardID,
                    IsMarked = (i==12), //if it's the 12th square, it's the free square
                    Name = cardName,
                    DateCreated = clock.UtcNow(),
                    DateUpdated = clock.UtcNow(),
                    SquareID = Guid.NewGuid(),
                    Value = wordsWithFree[i].BuzzWord,
                    BuzzID = wordsWithFree[i].BuzzWordID,
                    RowNum = ((int)(i / 5)) + 1,
                    ColNum = (i % 5) + 1
                });
            }

            return squares.ToArray();
        }