/// <summary> /// Moves a card to a position that is either before or after another card within the set. /// </summary> /// <param name="moving">The card that is moving.</param> /// <param name="location">The card that marks the position where the moving card will go.</param> /// <param name="before">True if moving to a position before the location. False if after.</param> virtual public void SwitchCardOrder(ICardModel moving, ICardModel location, bool before = true) { ValidateCards(); if (moving == null || location == null) { return; } _Cards.Remove(moving as Card); for (int index = 0; index < _Cards.Count; index++) { if (_Cards[index] == location) { if (before) { _Cards.Insert(index, moving as Card); } else { _Cards.Insert(index + 1, moving as Card); } return; } } return; }
public PlacePiece(IPlayerModel player, ICardModel card, Coord coord) : base(player, EActionType.PlacePiece) { Assert.IsNotNull(card); Card = card; Coord = coord; }
override public void RegisterCard(ICardModel card) { if (card == null) { return; } ValidateCards(); if (Multiples == null) { Multiples = new List <int>(); } int index = _Cards.IndexOf(card as Card); if (index < 0) { //registering a new card for the first time card.RegisterWithDeck(this); _Cards.Add(card as Card); Multiples.Add(1); } else { Multiples[index]++; } }
private void OnSelectCardClick(object sender, RoutedEventArgs e) { if (Frame.Navigate(typeof(CardView), new CardViewParams { CustomerKey = order.CustomerKey, CardId = cardId })) { SetPreviousSettings(); cardIsLoaded = true; var cardView = (CardView)Frame.Content; if (cardView == null) { return; } cardView.Selected += card => { Frame.GoBack(); cardIsLoaded = true; if (card != null) { CardModel = new SavedCardModel(card.Pan, "**/**"); cardId = card.CardId; } else { CardModel = new DefaultCardModel(); cardId = null; } }; cardView.Cancelled += () => { Frame.GoBack(); }; } }
private async void PaymentView_OnLoading(FrameworkElement sender, object args) { if (cardIsLoaded) { cardIsLoaded = false; } else { try { var cardManager = new CardManager(); var cards = await cardManager.GetAllCards(order.CustomerKey); if (cards.Count() != 0) { var card = (order.CardId != null ? await cardManager.GetCardById(order.CustomerKey, order.CardId) : null) ?? cards.First(); cardId = card.CardId; CardModel = new SavedCardModel(card.Pan, "**/**"); } } catch { } } CardControl.Focus(FocusState.Programmatic); }
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)); } }
public Card ReplaceCard(ICardModel unassignedCard, CardContainer container) { int index = model.GetIndexOf(container.GetCard().GetCardAssignment()); cardManager.UnassignCard(container.GetCard().GetCardAssignment()); return(AcceptCard(unassignedCard, index)); }
private void Validate(ICardModel selectedCard) { if (selectedCard != null && !Candidates.Contains(selectedCard)) { throw new InteractionValidationFailException("Selection is not candidate."); } }
public Response CardDrawn(ICardModel card) { if (Hand.NumCards.Value == Hand.MaxCards) { return(Response.Fail); } return(Hand.Add(card) ? Response.Ok : Response.Fail); }
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)); } }
virtual public int GetMultiples(ICardModel card) { ValidateCards(); if (_Cards.Contains(card)) { return(1); } return(0); }
public PieceModel(IOwner player, ICardModel card) : base(player) { Card = card; Dead.Subscribe(dead => { if (dead) { Died(); } }); // TODO ADDTO .AddTo(); }
public PieceModel(IPlayerModel player, ICardModel card) : base(player) { Card = card; Dead.Subscribe(dead => { if (dead) { Died(); } }).AddTo(this); }
public Card AcceptAssignedCard(ICardAssignmentModel assignedCard, int index = -1) { Debug.Assert(assignedCard != null, "AcceptAssignedCard called with null assignment"); ICardModel unassignedCard = assignedCard.GetCard(); // We need to unassign it. But make sure we keep the property assignments. PropEditor[] props = assignedCard.GetProperties(); cardManager.UnassignCard(assignedCard); return(AcceptCard(unassignedCard, index, props)); }
internal void Reset(ICardModel newModel) { Behaviors.RemoveAll(); if (newModel != null) { Model = newModel; } InstantiateBehaviors(); m_counters.Clear(); }
public string CardToRep(ICardModel model) { if (model == null) { return(" "); } var ch = $"{model.PieceType.ToString()[0]} "; return(ch); }
public Card AcceptCard(ICardModel unassignedCard, int index = -1, PropEditor[] initProps = null) { var assigned = this.model.OnAssignCard(unassignedCard, index); if (initProps != null) { assigned.SetProperties(initProps); } return(AddCardFromModel(assigned)); }
private void CardDropAction(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(ITreeViewItem).Name)) { TreeViewItem targetItem = sender as TreeViewItem; ITreeViewItem target = targetItem.DataContext as ITreeViewItem; ITreeViewItem card = e.Data.GetData(typeof(ITreeViewItem).Name) as ITreeViewItem; //did we drop onto a card or a deck ICardModel dropTarget = target as ICardModel; ICardSetViewItem setModel = TreeHelper.InferSet(targetItem); if (setModel != null && card != null) { ICardSetModel set = setModel as ICardSetModel; if (setModel == card.Parent) { //moving within the same set //did we drop on a deck or a card if (dropTarget != null) { if (dropTarget != card as ICardModel) { set.SwitchCardOrder(card as ICardModel, dropTarget, true); } } } else { //moving to a new set - first, move to the set ICardSetModel owner = card.Parent as ICardSetModel; owner.UnregisterCard(card as ICardModel); owner = set as ICardSetModel; owner.RegisterCard(card as ICardModel); //did we drop on a deck or a card - move card within the set if (dropTarget != null) { if (dropTarget != card as ICardModel) { set.SwitchCardOrder(card as ICardModel, dropTarget, true); } } } NotifyPropertyChanged("ObservableSets"); } else { MessageBox.Show("There was an error attempting to determine the card or deck during the drag operation.\n " + "Hell! I don't even know if it was a card or a deck!"); return; } } }
/// <summary> /// /// </summary> /// <param name="moving"></param> /// <param name="location"></param> /// <param name="before"></param> override public void SwitchCardOrder(ICardModel moving, ICardModel location, bool before = true) { ValidateCards(); if (Multiples == null) { Multiples = new List <int>(); } if (moving == null || location == null) { return; } if (Multiples.Count != _Cards.Count) { throw new Exception("Invalid state. The number of cards does not match the multiples indexer."); } //TODO: We need to move the index around for the Multiples!! int indexMoving = _Cards.IndexOf(moving as Card); if (indexMoving < 0) { throw new Exception("Invalid state. The moving card's multiples indexer is out of sync."); } int multiples = Multiples[indexMoving]; _Cards.Remove(moving as Card); int indexLocation = _Cards.IndexOf(location as Card); if (indexLocation < 0) { throw new Exception("Invalid state. The location card's multiples indexer is out of sync."); } for (int index = 0; index < _Cards.Count; index++) { if (_Cards[index] == location) { if (before) { //place card and multiples just before new location reference point _Cards.Insert(index, moving as Card); Multiples.Insert(index, multiples); } else { //place card and multiples just after new location reference point _Cards.Insert(index + 1, moving as Card); Multiples.Insert(index + 1, multiples); } return; } } return; }
virtual public void RegisterCard(ICardModel card) { ValidateCards(); if (!_Cards.Contains(card)) { card.RegisterWithSet(this); _Cards.Add(card as Card); NotifyPropertyChanged("Cards"); NotifyPropertyChanged("ObservableCards"); } }
override public int GetMultiples(ICardModel card) { ValidateCards(); int index = _Cards.IndexOf(card as Card); if (index < 0) { return(0); } return(Multiples[index]); }
private int GetInitialScore(ICardModel cardModel) { var manaCost = cardModel.Behaviors.FirstOrDefault(bm => bm is Behaviors.ManaCost.ModelType); if (manaCost == null) { return 0; } else { return (manaCost as Behaviors.ManaCost.ModelType).Cost * 10; } }
// TODO: save/load score library private int GetScore(ICardModel cardModel) { int score; if (m_scoreLibrary.TryGetValue(cardModel.Id, out score)) { return score; } var initialScore = GetInitialScore(cardModel); m_scoreLibrary.Add(cardModel.Id, initialScore); return initialScore; }
public void ShowSquares(ICardModel model, ISquareView sq) { Assert.IsNotNull(sq); Assert.IsNotNull(model); var board = Agent.Model; var movements = board.GetMovements(sq.Coord, model.PieceType); var attacks = board.GetAttacks(sq.Coord, model.PieceType); AddOverlays(movements.Coords, attacks.Coords); OverlayView.Add(movements.Interrupts.Select(p => p.Coord.Value), Color.yellow); OverlayView.Add(attacks.Interrupts.Select(p => p.Coord.Value), Color.magenta); }
virtual public void UnregisterCard(ICardModel card) { ValidateCards(); if (_Cards.Contains(card)) { _Cards.Remove(card as Card); card.UnregisterWithSet(this); // this will remove this card from all decks. NotifyPropertyChanged("Cards"); NotifyPropertyChanged("ObservableCards"); //this card should be deleted at this point so it doesn't //need to unregister with any sets } }
private void Populate( string selectedCardUri, bool isUnsavedNewCard, VoosEngine.BehaviorLogItem?error = null) { Depopulate(); this.isUnsavedNewCard = isUnsavedNewCard; this.hasCardChanges = false; this.card = new BehaviorCards.UnassignedCard(new UnassignedBehavior( selectedCardUri, behaviorSystem)); CreateCardUI(); editableCardUi.Populate(this.card); codeEditor.Set(this.card.GetUnassignedBehaviorItem(), error); }
private CardInstance(ICardModel model, Player owner, bool hasGuid) : this() { if (model == null) { throw new ArgumentNullException("model"); } else if (owner == null) { throw new ArgumentNullException("owner"); } Model = model; Owner = owner; Guid = hasGuid ? owner.Game.GenerateNextCardGuid() : 0; InstantiateBehaviors(); }
void Depopulate() { codeEditor.Clear(); if (this.card != null) { if (isUnsavedNewCard) { // Not saved - discard it for now. behaviorSystem.DeleteBehavior(this.card.GetId()); } this.card = null; } isUnsavedNewCard = false; hasCardChanges = false; }
void Awake() { addPanelButton.onClick.AddListener(OnAddPanelButtonClick); Util.FindIfNotSet(this, ref cursorManager); centerButton.onClick.AddListener(panelManager.ZoomOutToAllPanels); organizePanelsButton.onClick.AddListener(() => panelManager.SetOrganizedPanels(true)); cardDetail = Instantiate(cardDetailPrefab, null); cardDetail.onTrashCard += (unassignedModel, assignedModel) => { UnassignCard(assignedModel); }; cardDetail.onCodeCard += (card, assignment, container) => { if (!card.IsValid()) { return; } if (card.IsBuiltin()) { // Builtin card. Create a custom copy of it and change the assignment to // refer to the copy instead. ICardModel cardCustomCopy = card.MakeCopy(); int index = container.deck.GetModel().GetIndexOf(assignment); container.deck.AcceptCard(cardCustomCopy, index, assignment.GetProperties()); // Remove the old assignment assignment.Unassign(); // Maybe open the code editor for the custom copy onCodeRequest?.Invoke(cardCustomCopy.GetUri()); } else { onCodeRequest?.Invoke(card.GetUri()); } }; cardDetail.onPreviewCard += (card) => { onCodeRequest?.Invoke(card.GetUri()); }; closeButton.onClick.AddListener(() => { onCloseRequest?.Invoke(); }); }
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 SummonMove(ICardModel model, Player owner, int toZone, ICause cause) : base(cause) { if (model == null) { throw new ArgumentNullException("model"); } else if (owner == null) { throw new ArgumentNullException("owner"); } m_toZone = owner.m_zones.GetZone(toZone); Subject = null; Model = model; Owner = owner; }
public Transform(CardInstance cardToTransform, ICardModel newModel) { if (cardToTransform == null) { throw new ArgumentNullException("cardToTransform"); } else if (newModel == null) { throw new ArgumentNullException("newModel"); } else if (newModel == cardToTransform.Model) { throw new ArgumentException("Card will not be transformed."); } CardToTransform = cardToTransform; NewCardModel = newModel; }
public void Populate(ICardModel unassignedCard) { if (unassignedCard == null || !unassignedCard.IsValid()) { return; } cardContainer = null; card.Populate(unassignedCard, true); if (unassignedCard.IsBuiltin()) { codeText.SetText("Duplicate and edit JavaScript"); trashButton.gameObject.SetActive(false); previewButton.gameObject.SetActive(true); } else { codeText.SetText("Edit JavaScript"); previewButton.gameObject.SetActive(false); string behaviorUri = unassignedCard.GetUnassignedBehaviorItem().behaviorUri; VoosActor user = voosEngine.FindOneActorUsing(behaviorUri); string fromActorLib = actorLib.FindOneActorUsingBehavior(behaviorUri); if (user != null) { trashText.SetText($"Cannot delete - used by actor '{user.GetDisplayName()}'"); trashButton.interactable = false; } else if (fromActorLib != null) { trashText.SetText($"Cannot delete - used by creation library actor '{fromActorLib}'"); trashButton.interactable = false; } else { trashText.SetText($"Remove card"); trashButton.interactable = true; } trashButton.gameObject.SetActive(true); } noPropertiesObject.SetActive(!card.HasAnyProps()); UpdateAddToSlotButton(); }
public ReviveMove(Player player, ICardModel cardToRevive, int fromZone, int toZone, ICause cause) : base(cause) { if (player == null) { throw new ArgumentNullException("player"); } else if (cardToRevive == null) { throw new ArgumentNullException("cardToRevive"); } m_fromZone = player.m_zones.GetZone(fromZone); m_toZone = player.m_zones.GetZone(toZone); Subject = null; Player = player; CardToRevive = cardToRevive; }
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); }
override public void UnregisterCard(ICardModel card) { ValidateCards(); if (Multiples == null) { Multiples = new List <int>(); } int index = _Cards.IndexOf(card as Card); if (index > 0) { //we have multiples of this card, remove one Multiples[index]--; } else if (index == 1) { //this is the last multiple, complete remove this card card.UnregisterWithDeck(this); Multiples.RemoveAt(index); _Cards.Remove(card as Card); } }
private async Task SetCardModel(ICardModel model) { if (model is DefaultCardModel) { CardNumberInputTextBox.Text = string.Empty; DateTextBox.Text = string.Empty; SecurityCodePasswordBox.Password = string.Empty; SetState(ControlState.Initial); HideAdditionalButtons(); EnsurePaymentSystemState(); } else if (model is SavedCardModel) { modelJustSet = true; numberJustSet = true; CardNumberInputTextBox.Text = model.Number.FormattedData; dateJustSet = true; DateTextBox.Text = model.ExpiryDate.FormattedData; SecurityCodePasswordBox.Password = model.SecurityCode.FormattedData; EnsurePaymentSystemState(); numberJustSet = dateJustSet = false; await SetNextStateAsync(); } }
public SummonMove(ICardModel model, Player owner, int toZone) : this(model, owner, toZone, null) { }
public bool Contains(ICardModel cardModel) { return m_orderedCardModels.Contains(cardModel); }
/// <summary> /// Add one card to the bottom of the pile. /// </summary> /// <param name="card">The card to be added.</param> public void AddToBottom(ICardModel cardModel) { m_orderedCardModels.Insert(0, cardModel); }
/// <summary> /// Add one card to the top of the pile. /// </summary> /// <param name="card">The card to be added.</param> public void AddToTop(ICardModel cardModel) { m_orderedCardModels.Add(cardModel); }
internal CardInstance(ICardModel model, Player owner) : this(model, owner, true) { }
public void Add(ICardModel cardModel) { if (cardModel == null) { throw new ArgumentNullException("cardModel"); } Cards.Add(cardModel); }
public int IndexOf(ICardModel element) { return Cards.IndexOf(element); }
public SacrificeChoice(int cardIndex, ICardModel cardModel) : base(1) { CardIndex = cardIndex; CardModel = cardModel; }
public void Respond(ICardModel selectedCard) { Validate(selectedCard); RespondBack(selectedCard); }
public ReviveMove(Player player, ICardModel cardToRevive, int fromZone, int toZone) : this(player, cardToRevive, fromZone, toZone, null) { }