private void FetchCardStatus() { lastCardStatus = new RuntimeCardStatus(); if (IsAssignmentValid()) { Util.Maybe <RuntimeCardStatus> maybeStatus = this.assignment.GetAssignedBehavior(). CallScriptFunction <int, RuntimeCardStatus>("getCardStatus", 0); if (!maybeStatus.IsEmpty()) { lastCardStatus = maybeStatus.Get(); } } else { lastCardStatus = new RuntimeCardStatus(); } // Fill in with defaults for nulls or empty strings: lastCardStatus.title = string.IsNullOrEmpty(lastCardStatus.title) ? card.GetTitle() : lastCardStatus.title; lastCardStatus.description = string.IsNullOrEmpty(lastCardStatus.description) ? card.GetDescription() : lastCardStatus.description; lastCardStatus.debugText = string.IsNullOrEmpty(lastCardStatus.debugText) ? "(No debug text)" : lastCardStatus.debugText; // For the error message, if there is a legacy getCardErrorMessage function in the card, use it: if (string.IsNullOrEmpty(lastCardStatus.errorMessage)) { lastCardStatus.errorMessage = GetCardErrorMessage_LEGACY() ?? ""; } }
public ICardAssignmentModel OnAssignCard(ICardModel card, int index = -1) { using (this.actorEditor.StartUndo($"Add Custom card {card.GetTitle()}")) { var assigned = actorEditor.AddBehavior(((UnassignedCard)card).GetUnassignedBehaviorItem()); return(new CardAssignment(assigned, this)); } }
bool DoesCardMatchSearch(Card card, string searchString) { ICardModel model = card.GetModel(); if (!model.IsValid()) { return(false); } if (searchString.IsNullOrEmpty()) { return(true); } string stringForSearch = model.GetTitle().ToLower() + " " + model.GetDescription().ToLower(); return(stringForSearch.Contains(searchString.ToLower())); }
public virtual void Populate(ICardModel card, bool withDetail = false) { if (card == null || !card.IsValid()) { return; } // Debug this.name = $"Card '{card.GetTitle()}'"; this.card = card; this.assignment = null; cardUI.nameField.text = card.GetTitle(); cardUI.descriptionField.text = card.GetDescription(); if (withDetail) { props.SetupPreview(card.GetUnassignedBehaviorItem()); } customFlag.SetActive(!card.IsBuiltin()); ReloadCardImage(); }
public override void Populate(ICardModel card, bool withDetail = true) { if (card == null || !card.IsValid()) { return; } base.Populate(card, withDetail); nameInput.text = card.GetTitle(); descriptionInput.text = card.GetDescription(); categoryDropdown.ClearOptions(); categoryOptions = new List <TMPro.TMP_Dropdown.OptionData>(); bool needsCustomCategory = true; foreach (string category in behaviorSystem.GetCategories()) { if (category == BehaviorCards.CUSTOM_CATEGORY) { needsCustomCategory = false; } categoryOptions.Add(new TMPro.TMP_Dropdown.OptionData(category)); } if (needsCustomCategory) { categoryOptions.Add(new TMPro.TMP_Dropdown.OptionData(BehaviorCards.CUSTOM_CATEGORY)); } categoryDropdown.AddOptions(categoryOptions); // Hack: for now, assume that custom cards only have one category string cardCategory = new List <string>(card.GetCategories())[0]; categoryDropdown.value = categoryOptions.FindIndex((option) => option.text == cardCategory); bool canEdit = !card.GetUnassignedBehaviorItem().IsBehaviorReadOnly(); nameInput.interactable = canEdit; descriptionInput.interactable = canEdit; categoryDropdown.interactable = canEdit; editIconButton.gameObject.SetActive(canEdit); }
public ICardAssignmentModel OnAssignCard(ICardModel card, int index = -1) { Debug.Assert(card != null, "Given card was null"); Debug.Assert(this.actorBehaviorsEditor != null, "Null actorBehaviorsEditor?"); using (this.actorBehaviorsEditor.StartUndo($"Add {this.GetCardCategory()} card {card.GetTitle()}")) { UnassignedBehavior behaviorEditor = ((UnassignedCard)card).GetUnassignedBehaviorItem(); AssignedBehavior assigned = this.actorBehaviorsEditor.AddBehavior(behaviorEditor); List <string> deckUseIds = new List <string>((string[])deckEditor.data); if (index >= 0) { if (index > deckUseIds.Count) { throw new System.Exception("OnAssignCard: Index greater than deckUseIds count!"); } deckUseIds.Insert(index, assigned.useId); } else { deckUseIds.Add(assigned.useId); } deckEditor.SetData(deckUseIds.ToArray()); return(new CardAssignment(assigned, this)); } }