private void Start()
    {
        Account = GameObject.Find("ActiveAccount").GetComponent <AccountCharacteristics>();
        //TESTING
        Account.LoadExistingPlayer(Account.GetPlayerName());
        //
        GameObject             card;
        Manage_Card_Collection Collection;

        for (int i = 0; i < 3; i++)
        {
            List <string> tempCollection = Account.GetDeck(i);
            Collection = GetDeck(i);
            foreach (string cardname in tempCollection)
            {
                card = AllCards.CreateCard(cardname);
                card.GetComponent <CQBCard>().ActivatePlayable();
                card.GetComponent <CQBCard>().ActivateBase();
                Collection.AddCard(card);
                if (card.GetComponent <CQBCard>().GetFaction() == CQBCard.FactionType.TAIIDAN)
                {
                    card.transform.localScale = new Vector3(.35f, .35f);
                }
                else
                {
                    card.transform.localScale = new Vector3(.6f, .6f);
                }
            }
        }
        Change_Deck(0);
    }
        private void Lb_choice_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lb_choice.SelectedIndex == -1)
            {
                return;
            }
            string item = lb_choice.SelectedItem.ToString();

            int id = _ids[lb_choice.SelectedIndex];

            if (!_cards.ContainsKey(id))
            {
                return;
            }
            else
            {
                if (_cards[id].Quantity > 1)
                {
                    _cards[id].Quantity--;
                }
                else
                {
                    _cards.Remove(id);
                }
            }

            Collection.AddCard(id);
            _ids.RemoveAt(lb_choice.SelectedIndex);
            lb_choice.Items.RemoveAt(lb_choice.SelectedIndex);
        }
Esempio n. 3
0
        public ActionResult AddCard([Bind(Include = "CollectionId,CardId,EditionId,GameId,Quantity")] AddCardViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Collection collection = db.CardLists.OfType <Collection>().FirstOrDefault(c => c.Id == viewModel.CollectionId);

            if (collection == null)
            {
                return(HttpNotFound());
            }

            if (viewModel.CardId != null)
            {
                var card = db.Cards.Find(viewModel.CardId);
                collection.AddCard(card, viewModel.Quantity);
                db.SaveChanges();

                return(RedirectToAction("Details", new { id = viewModel.CollectionId }));
            }

            if (viewModel.GameId == null)
            {
                viewModel.GameId = db.Games.Select(g => g.Id).Min();
            }

            ViewBag.GameId    = new SelectList(db.Games, "Id", "Name", viewModel.GameId);
            ViewBag.EditionId = new SelectList(db.Editions.Where(e => e.GameId == viewModel.GameId), "Id", "Name");
            ViewBag.CardId    = new SelectList(new Card[0], "Id", "Name");

            if (viewModel.GameId != null)
            {
                ViewBag.EditionId = new SelectList(db.Editions.Where(edition => edition.GameId == viewModel.GameId),
                                                   "Id", "Name", viewModel.GameId);
            }

            if (viewModel.EditionId != null)
            {
                var edition = db.Editions.Find(viewModel.EditionId);
                if (viewModel.GameId == edition.GameId)
                {
                    ViewBag.CardId = new SelectList(db.Cards.ToList().Where(c => c.Edition.Id == viewModel.EditionId),
                                                    "Id", "Name", viewModel.CardId);
                }
            }

            ViewBag.Collection = collection;

            return(View(viewModel));
        }