public IActionResult AddCard(int id)
        {
            var card = _context.CardModels.SingleOrDefault(c => c.ID == id);

            if (card != null)
            {
                var exists = _context.CardCollectionModels
                             .Include(c => c.CardModel)
                             .Where(c => c.CardModelID == card.ID)
                             .SingleOrDefault();

                if (exists != null)
                {
                    exists.Quantity++;
                }
                else
                {
                    CardCollectionModel newCard = new CardCollectionModel()
                    {
                        CardModelID       = card.ID,
                        CollectionModelID = 1,
                        Quantity          = 1
                    };
                    _context.Add(newCard);
                }
                _context.SaveChanges();
            }
            return(RedirectToAction("ViewCollection"));
        }
Exemplo n.º 2
0
 public override bool IsAllowed(Card chosenCard, CardCollectionModel cardCollection)
 {
     if (cardCollection.GetType().ToString().Equals(DiscardPile.DISCARD_PILE) &&
         chosenCard.GetType().ToString().Equals("UnoCard"))
     {
         return(IsAllowed((UnoCard)chosenCard, cardCollection.CheckCard(0)));
     }
     return(false);
 }
Exemplo n.º 3
0
 protected void Update()
 {
     if (myTurn && Input.GetMouseButtonDown(0))
     {
         if (SetTarget())
         {
             Actions();
         }
     }
     else
     {
         Target = null;
     }
 }
Exemplo n.º 4
0
    public static CardCollectionModel DetectCardCollection(GameObject gameObject)
    {
        CardCollectionModel cardCollection = gameObject.GetComponent <DeckModel>();

        if (cardCollection == null)
        {
            cardCollection = gameObject.GetComponent <HandModel>();
        }
        if (cardCollection != null)
        {
            Debug.Log(cardCollection.GetType().Name);
            return(cardCollection);
        }
        else
        {
            Debug.Log("Collection is null");
            return(null);
        }
    }
Exemplo n.º 5
0
    protected bool SetTarget()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (!hit.collider.gameObject.tag.Equals("Card"))
            {
                Target = DetectCardCollection(hit.collider.gameObject);
                if (Target != null)
                {
                    defaultPosition = Target.gameObject.transform.position;
                }
            }
            else if (CardTarget == null)
            {
                CardTarget = hit.collider.gameObject;
                return(true);
            }
        }
        return(Target != null);
    }
Exemplo n.º 6
0
 public override bool IsAllowed(Card chosenCard, CardCollectionModel cardCollection)
 {
     return(cardCollection.GetName().Equals(DungeonDeck.DUNGEON_DECK));
 }
Exemplo n.º 7
0
 public virtual bool IsAllowed(Card chosenCard, CardCollectionModel cardCollection)
 {
     return(true);
 }
Exemplo n.º 8
0
 public void PutCard(Card chosenCard, CardCollectionModel model)
 {
 }