Пример #1
0
        public static Object Main(string operation, params object[] args)
        {
            if (args.Length > 0)
            {
                if (operation == "create")
                {
                    byte[]     id       = (byte[])args[0];
                    BigInteger suit     = (BigInteger)args[1];
                    BigInteger value    = (BigInteger)args[2];
                    bool       isPlayed = (bool)args[3];

                    PlayCard.Card card = new PlayCard.Card
                    {
                        id       = id,
                        suit     = PlayCard.BigInteger2Suit(suit),
                        value    = PlayCard.BigInteger2Value(value),
                        isPlayed = isPlayed
                    };

                    SaveCard(card);
                    return(card);
                }
                if (operation == "get")
                {
                    byte[] id = (byte[])args[0];
                    return(ReadCard(id));
                }
                return(false);
            }
            return(false);
        }
Пример #2
0
 public static byte[] Card2Bytes(PlayCard.Card card)
 {
     if (card == null)
     {
         return(Op.Void());
     }
     else
     {
         BigInteger suit  = PlayCard.CardSuit2BigInteger(card.suit);
         BigInteger value = PlayCard.CardValue2BigInteger(card.value);
         return(NuSD.Seg(card.id)
                .AddSegInt(suit)
                .AddSegInt(value)
                .AddSegBool(card.isPlayed));
     }
 }
Пример #3
0
        public static PlayCard.Card Bytes2Card(byte[] data)
        {
            if (data.Length == 0)
            {
                return(null);
            }

            PlayCard.Card card = new PlayCard.Card
            {
                id       = data.SplitTbl(0),
                suit     = PlayCard.BigInteger2Suit(data.SplitTblInt(1)),
                value    = PlayCard.BigInteger2Value(data.SplitTblInt(2)),
                isPlayed = data.SplitTblBool(3)
            };

            return(card);
        }
Пример #4
0
 static byte SaveCard(PlayCard.Card card)
 {
     return(NuIO.SetStorageWithKeyPath(Card2Bytes(card), "c", Op.Bytes2String(card.id)));
 }