コード例 #1
0
ファイル: Deck.cs プロジェクト: zachary2234/gamebuilder
        public ICardAssignmentModel CreateAndAssignNewCard()
        {
            // Make sure the category is for this slot.
            CardMetadata md = CardMetadata.DefaultCardMetadata;

            md.cardSystemCardData.categories = new string[] { deckEditor.cardCategory };
            string             metadataJson = JsonUtility.ToJson(md);
            UnassignedBehavior newBehavior  = this.actorBehaviorsEditor.CreateNewBehavior(GetDefaultCodeForCategory(deckEditor.cardCategory), metadataJson);

            return(this.OnAssignCard(new UnassignedCard(newBehavior)));
        }
コード例 #2
0
        public async Task <ChargeResponse> ChargeCard(string email, string amount, string pin, string cvv, string expiry_month, string expiry_year, string number, string display_name = null, string value = null, string variable_name = null)
        {
            var client = HttpConnection.CreateClient(secretKey);
            var model  = new ChargeCardInput
            {
                Amount = amount,
                Card   = new ChargeCard
                {
                    CVV         = cvv,
                    ExpiryMonth = expiry_month,
                    ExpiryYear  = expiry_year,
                    Number      = number
                },
                Email = email,
                Pin   = pin
            };

            if (!string.IsNullOrWhiteSpace(display_name))
            {
                var metaData = new CardMetadata
                {
                    CustomFields = new List <Custom_Field>
                    {
                        new Custom_Field()
                        {
                            DisplayName  = display_name,
                            Value        = value,
                            VariableName = variable_name
                        }
                    }
                };
                model.Metadata = metaData;
            }

            var jsonObj = JsonConvert.SerializeObject(model);
            var content = new StringContent(jsonObj, Encoding.UTF8, BaseConstants.ContentTypeHeaderJson);

            content.Headers.ContentType = new MediaTypeHeaderValue(BaseConstants.ContentTypeHeaderJson);
            var response = await client.PostAsync("charge", content);

            var json = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <ChargeResponse>(json);

            return(result);
        }
コード例 #3
0
        public IEnumerable <ICardAssignmentModel> GetAssignedCards()
        {
            var bs = actorEditor.GetBehaviorSystem();

            foreach (var useEditor in actorEditor.GetAssignedBehaviors())
            {
                var behaviorData = useEditor.GetBehaviorData();
                if (CardMetadata.IsCardOfCategory(behaviorData, CUSTOM_CATEGORY))
                {
                    // TEMP HACK - it's really important to not show the default card
                    if (useEditor.GetBehaviorUri() == "builtin:Default Behavior")
                    {
                        continue;
                    }
                    yield return(new CardAssignment(useEditor, this));
                }
            }
        }
コード例 #4
0
        public CardView Create(CardMetadata metadata)
        {
            var cardView = new CardView();
            var template = ProgramManager.Cache.GetTemplate(metadata.TemplateId);
            var content  = (CustomContent)ProgramManager.Cache.GetContent(metadata.ContentId);

            cardView.CardBackground.Background = (SolidColorBrush) new BrushConverter().ConvertFromString("#4286f4");

            for (int i = 0; i < template.Front.Count; ++i)
            {
                cardView.ContentStackPanel.Children.Add(new TextBlock()
                {
                    Text = content.Fields[template.Front[i]],
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                    Margin = new System.Windows.Thickness(10)
                });
            }

            return(cardView);
        }
コード例 #5
0
        // NOTE: This is not used anymore, but keep it here for the sorting code,
        // which we should soon port to other code paths.
        public IEnumerable <ICardModel> GetCards(string category = null)
        {
            var bs = actorEditor.GetBehaviorSystem();

            List <UnassignedCard> entries = new List <UnassignedCard>();

            foreach (string uri in bs.LoadBehaviorLibrary())
            {
                Behavior data = bs.GetBehaviorData(uri);
                if (!CardMetadata.GetMetaDataFor(data).isCard)
                {
                    continue;
                }
                if (category == null || CardMetadata.IsCardOfCategory(data, category))
                {
                    // TEMP HACK: don't show builtin customs in card view - they're just
                    // there for legacy support.
                    if (BehaviorSystem.IsBuiltinBehaviorUri(uri) && category == CUSTOM_CATEGORY)
                    {
                        continue;
                    }
                    entries.Add(new UnassignedCard(new UnassignedBehavior(uri, bs)));
                }
            }

            // Sort by priority first, then by title.
            entries.Sort((UnassignedCard a, UnassignedCard b) =>
            {
                var mdA         = a.GetMetadata();
                var mdB         = b.GetMetadata();
                int prioCompare = -mdA.listPriority.CompareTo(mdB.listPriority);
                return(prioCompare != 0 ? prioCompare : mdA.title.CompareTo(mdB.title));
            });

            return(entries);
        }
コード例 #6
0
 public CardView Create(CardMetadata metadata)
 {
     return(customCardViewBuilder.Create(metadata));
 }
コード例 #7
0
 /// <summary>
 /// Retrieves a cards metadata information by card id.
 /// </summary>
 /// <param name="card"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public Boolean TryGetCardMetadata(int card, out ImmutableDictionary <string, Object> data)
 {
     return(CardMetadata.TryGetValue(card, out data));
 }
コード例 #8
0
 /// <summary>
 /// Sets a cards metadata information
 /// </summary>
 /// <param name="card"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public AgricolaPlayer SetCardMetadata(int cardId, ImmutableDictionary <string, Object> data)
 {
     CardMetadata = CardMetadata.SetItem(cardId, data);
     return(this);
 }
コード例 #9
0
        public async Task <CardMetadata> Insert(CardMetadata cardMetadata)
        {
            using (IDbConnection db = new SqlConnection(ConnectionString))
            {
                cardMetadata = await db.QuerySingleOrDefaultAsync <CardMetadata>(@"
                        INSERT INTO [dbo].[CardMetadata]
                            ([PaymentInstrumentId]
                            ,[BackgroundColor]
                            ,[ForegroundColor]
                            ,[LabelColor]
                            ,[ContactWebsite]
                            ,[ContactEmail]
                            ,[ContactNumber]
                            ,[ContactName]
                            ,[BankAppName]
                            ,[BankAppAddress]
                            ,[PrivacyPolicyURL]
                            ,[TermsAndConditionsURL]
                            ,[TermsAndConditionsID]
                            ,[ShortDescription]
                            ,[LongDescription]
                            ,[Created]
                            ,[Updated])
                         OUTPUT
                            Inserted.[Id]
                            ,Inserted.[PaymentInstrumentId]
                            ,Inserted.[BackgroundColor]
                            ,Inserted.[ForegroundColor]
                            ,Inserted.[LabelColor]
                            ,Inserted.[ContactWebsite]
                            ,Inserted.[ContactEmail]
                            ,Inserted.[ContactNumber]
                            ,Inserted.[ContactName]
                            ,Inserted.[BankAppName]
                            ,Inserted.[BankAppAddress]
                            ,Inserted.[PrivacyPolicyURL]
                            ,Inserted.[TermsAndConditionsURL]
                            ,Inserted.[TermsAndConditionsID]
                            ,Inserted.[ShortDescription]
                            ,Inserted.[LongDescription]
                            ,Inserted.[Created]
                            ,Inserted.[Updated]
                         VALUES
                            (@PaymentInstrumentId
                            ,@BackgroundColor
                            ,@ForegroundColor
                            ,@LabelColor
                            ,@ContactWebsite
                            ,@ContactEmail
                            ,@ContactNumber
                            ,@ContactName
                            ,@BankAppName
                            ,@BankAppAddress
                            ,@PrivacyPolicyURL
                            ,@TermsAndConditionsURL
                            ,@TermsAndConditionsID
                            ,@ShortDescription
                            ,@LongDescription
                            ,@Created
                            ,NULL)",
                                                                                 new
                {
                    PaymentInstrumentId   = cardMetadata.PaymentInstrumentId,
                    BackgroundColor       = cardMetadata.BackgroundColor,
                    ForegroundColor       = cardMetadata.ForegroundColor,
                    LabelColor            = cardMetadata.LabelColor,
                    ContactWebsite        = cardMetadata.ContactWebsite,
                    ContactEmail          = cardMetadata.ContactEmail,
                    ContactNumber         = cardMetadata.ContactNumber,
                    ContactName           = cardMetadata.ContactName,
                    BankAppName           = cardMetadata.BankAppName,
                    BankAppAddress        = cardMetadata.BankAppAddress,
                    PrivacyPolicyURL      = cardMetadata.PrivacyPolicyURL,
                    TermsAndConditionsURL = cardMetadata.TermsAndConditionsURL,
                    TermsAndConditionsID  = cardMetadata.TermsAndConditionsID,
                    ShortDescription      = cardMetadata.ShortDescription,
                    LongDescription       = cardMetadata.LongDescription,
                    Created = DateTime.UtcNow
                });

                return(cardMetadata);
            }
        }
コード例 #10
0
        public async Task <CardMetadata> Update(CardMetadata cardMetadata)
        {
            using (IDbConnection db = new SqlConnection(ConnectionString))
            {
                cardMetadata = await db.QuerySingleOrDefaultAsync <CardMetadata>(@"
                        UPDATE [dbo].[CardMetadata]
                        SET
                            [BackgroundColor] = @BackgroundColor
                            ,[ForegroundColor] = @ForegroundColor
                            ,[LabelColor] = @LabelColor
                            ,[ContactWebsite] = @ContactWebsite
                            ,[ContactEmail] = @ContactEmail
                            ,[ContactNumber] = @ContactNumber
                            ,[ContactName] = @ContactName
                            ,[BankAppName] = @BankAppName
                            ,[BankAppAddress] = @BankAppAddress
                            ,[PrivacyPolicyURL] = @PrivacyPolicyURL
                            ,[TermsAndConditionsURL] = @TermsAndConditionsURL
                            ,[TermsAndConditionsID] = @TermsAndConditionsID
                            ,[ShortDescription] = @ShortDescription
                            ,[LongDescription] = @LongDescription
                            ,[Updated] = @Updated
                         OUTPUT
                            Inserted.[Id]
                            ,Inserted.[PaymentInstrumentId]
                            ,Inserted.[BackgroundColor]
                            ,Inserted.[ForegroundColor]
                            ,Inserted.[LabelColor]
                            ,Inserted.[ContactWebsite]
                            ,Inserted.[ContactEmail]
                            ,Inserted.[ContactNumber]
                            ,Inserted.[ContactName]
                            ,Inserted.[BankAppName]
                            ,Inserted.[BankAppAddress]
                            ,Inserted.[PrivacyPolicyURL]
                            ,Inserted.[TermsAndConditionsURL]
                            ,Inserted.[TermsAndConditionsID]
                            ,Inserted.[ShortDescription]
                            ,Inserted.[LongDescription]
                            ,Inserted.[Created]
                            ,Inserted.[Updated]
                         WHERE
                            ID = @ID",
                                                                                 new
                {
                    ID = cardMetadata.Id,
                    BackgroundColor       = cardMetadata.BackgroundColor,
                    ForegroundColor       = cardMetadata.ForegroundColor,
                    LabelColor            = cardMetadata.LabelColor,
                    ContactWebsite        = cardMetadata.ContactWebsite,
                    ContactEmail          = cardMetadata.ContactEmail,
                    ContactNumber         = cardMetadata.ContactNumber,
                    ContactName           = cardMetadata.ContactName,
                    BankAppName           = cardMetadata.BankAppName,
                    BankAppAddress        = cardMetadata.BankAppAddress,
                    PrivacyPolicyURL      = cardMetadata.PrivacyPolicyURL,
                    TermsAndConditionsURL = cardMetadata.TermsAndConditionsURL,
                    TermsAndConditionsID  = cardMetadata.TermsAndConditionsID,
                    ShortDescription      = cardMetadata.ShortDescription,
                    LongDescription       = cardMetadata.LongDescription,
                    Updated = DateTime.UtcNow
                });

                return(cardMetadata);
            }
        }