Ejemplo n.º 1
0
        private static List <CardInfo> GenerateOneDeck(List <List <CardInfo> > pastDecks)
        {
            var deck = new List <CardInfo>();

            for (var i = 0; i < 8; ++i)
            {
                CardInfo card        = null;
                var      isAvailable = false;
                while (!isAvailable)
                {
                    var faceId  = Random.Next(2, 10);
                    var colorId = Random.Next(2, 6);
                    var face    = CardFace.From(faceId);
                    var color   = CardColor.From(colorId);

                    card = new CardInfo {
                        Face = face, Color = color
                    };

                    isAvailable = IsCardAvailable(pastDecks, deck, card);
                }
                deck.Add(card);
            }
            return(deck);
        }
Ejemplo n.º 2
0
        public bool Run(NetworkStream stream, string input)
        {
            var args = Regex.Split(input, @"\s+");

            if (args.Length < 3 || args[1].Length <= 0 || args[2].Length <= 0)
            {
                return(false);
            }

            var proto = new LobbyCard
            {
                Info = new CardInfo
                {
                    Face  = CardFace.From(args[1].ToLower()),
                    Color = CardColor.From(args[2].ToLower())
                }
            };

            stream.Write(proto.ProtobufTypeAsBytes, 0, 2);
            ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32);
            return(true);
        }