コード例 #1
0
        //Show Card Detail
        public ActionResult Show(int?id)
        {
            //Debug Purpose to see if we are getting the id
            Debug.WriteLine("I'm pulling data of " + id.ToString());

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //Query statement to get the specific Card
            string       query    = "SELECT * FROM cards WHERE cardid=@CardID";
            SqlParameter sqlparam = new SqlParameter("@CardID", id);

            //Get the Specific Card
            Card selectedCard = db.Cards.SqlQuery(query, sqlparam).FirstOrDefault();

            //Get the all the trait that the card has
            string       aside_query  = "SELECT * FROM Traits INNER JOIN TraitCards ON Traits.TraitID = TraitCards.Trait_TraitID WHERE TraitCards.Card_CardID=@id";
            var          fk_parameter = new SqlParameter("@id", id);
            List <Trait> traits       = db.Traits.SqlQuery(aside_query, fk_parameter).ToList();

            //ViewModel for the ShowCard
            ShowCard viewmodel = new ShowCard();

            viewmodel.card   = selectedCard;
            viewmodel.traits = traits;

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

            //Show the result
            return(View(viewmodel));
        }
コード例 #2
0
        public async Task AddCard_EmptyPayload_ReturnsBadRequest()
        {
            var command  = new ShowCard();
            var response = await client.PutAsync($"/games/{Guid.NewGuid()}/statistics/card", command.ToContent());

            response.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
コード例 #3
0
        // Decreases the episode number for this specific showcard
        public IActionResult MinusEpisode(int showCardID)
        {
            int userID = GetUserID();

            if (userID == 0)
            {
                return(RedirectToAction("Login", "User"));
            }

            string   message = null;
            ShowCard show    = new ShowCard();

            using (WeWatchContext context = new WeWatchContext())
            {
                // Get the show that the showcard is referencing
                show = context.ShowCard.Include(x => x.Show).Where(x => x.ShowCardID == showCardID).Single();

                // Get the show season attached to that card
                ShowSeason currentSeason = context.ShowSeason.Where(x => x.ShowID == show.ShowID && x.ShowSeasonID == show.CurrentSeason).Single();

                // Check if we are at the minimum episode of any season
                if (show.CurrentEpisode == 1)
                {
                    // Check to see if there is a lower season recorded for this show
                    ShowSeason pastSeason = context.ShowSeason.Include(x => x.Show).Where(x => x.ShowID == show.ShowID && x.IndividualSeason < currentSeason.IndividualSeason).OrderBy(x => x.IndividualSeason).FirstOrDefault();

                    // Prompt user to add a season to the list if there is no lower season
                    if (pastSeason == null)
                    {
                        message = "Sorry you no season to go back to. Would you like to add a season to the list?";
                    }

                    // Roll back to the next lowest season, max episode
                    else
                    {
                        show.CurrentEpisode = pastSeason.SeasonEpisodes;
                        show.CurrentSeason  = pastSeason.ShowSeasonID;
                        message             = "You went back a SEASON";
                    }
                }

                // Can simply minus one episode from the episode number
                else
                {
                    show.CurrentEpisode--;
                    message = "Went back an EPISODE";
                }

                context.SaveChanges();
            }

            TempData["message"] = message;

            return(RedirectToAction("ByShow", new { showID = show.ShowID }));
        }
コード例 #4
0
 private void Start()
 {
     handCardManage = CardManage.Instance;
     boss           = Boss.Instance;
     generator      = CardGroup.Instance;
     feeshow        = Feeshow.Instance;
     hero           = Hero.Instance;
     showCard       = ShowCard.Instance;
     chooseCards    = ChooseCards.Instance;
     gameControll   = GameControll.Instance;
 }
コード例 #5
0
        // Create the show card
        public IActionResult Connect(int showID, int watcherID, int seasonID, int episode)
        {
            int userID = GetUserID();

            if (userID == 0)
            {
                return(RedirectToAction("Login", "User"));
            }

            string message = "";

            // If we are missing any fields, redirect the user to the CreateCard Action
            if (showID == 0 || watcherID == 0 || seasonID == 0 || episode == 0)
            {
                return(RedirectToAction("CreateCard", new { showID, watcherID, seasonID, episode }));
            }

            using (WeWatchContext context = new WeWatchContext())
            {
                // Check to see if this user already has a card with this watcher and this show
                if (context.ShowCard.Where(x => x.ShowID == showID && x.UserID == userID && x.WatcherID == watcherID).Count() > 0)
                {
                    message = "You must fill in all fields before you can Watch";
                    return(Redirect("CreateCard"));
                }

                // Create the card with
                ShowCard newShowCard = new ShowCard()
                {
                    ShowID         = showID,
                    WatcherID      = watcherID,
                    CurrentSeason  = seasonID,
                    CurrentEpisode = episode,
                    UserID         = userID,
                };

                try
                {
                    context.ShowCard.Add(newShowCard);
                    context.SaveChanges();
                    message = "Success";
                }

                catch
                {
                    message = "Something went wrong. Your connection was not saved. Please refresh and try again.";
                }

                TempData["showCardID"] = (int)context.ShowCard.Where(x => x.ShowID == showID && x.UserID == userID && x.WatcherID == watcherID).Select(x => x.ShowCardID).Single();
                TempData["message"]    = message;
            }

            return(Redirect("CreateCard"));
        }
コード例 #6
0
ファイル: UIUtility.cs プロジェクト: PenpenLi/BIG_HEAD
    /// <summary>
    /// 展示装备
    /// </summary>
    /// <param name="go"></param>需要添加脚本的go
    /// <param name="cardId"></param>
    public static void SetEquipTips(GameObject go, int equipId, int cardNum = 1)
    {
        ShowCard ShowCard = go.GetComponent <ShowCard>();

        if (ShowCard == null)
        {
            go.AddComponent <ShowCard>().SetShow(0, equipId, cardNum);
        }
        else
        {
            ShowCard.SetShow(0, equipId, cardNum);
        }
    }
コード例 #7
0
ファイル: ResultWindow.cs プロジェクト: GouGit/stac
    public void SetOption(int goldCount, int topazCount, int rubyCount, int sapphireCount, int diamondCount)
    {
        GoldText.text     = goldCount.ToString();
        TopazText.text    = topazCount.ToString();
        RubyText.text     = rubyCount.ToString();
        SapphireText.text = sapphireCount.ToString();
        DiamondText.text  = diamondCount.ToString();

        GameManager.instance.goldCount     += goldCount;
        GameManager.instance.topazCount    += topazCount;
        GameManager.instance.rubyCount     += rubyCount;
        GameManager.instance.sapphireCount += sapphireCount;
        GameManager.instance.diamondCount  += diamondCount;

        if (cardLayout == null)
        {
            Debug.LogError("cardLayout이 없어 보상창에 추가카드를 표시할 수 없습니다.");
            return;
        }

        if (cardPrefabList.Count == 0)
        {
            Debug.LogError("추가로 제공할 카드가 없습니다.");
            return;
        }

        // 일단은 추가카드 선택은 랜덤으로 해뒀음 나중에 수정할 예정
        for (int i = 0; i < 3; i++)
        {
            int randomIndex = Random.Range(0, cardPrefabList.Count);

            ShowCard   additionalCard = cardPrefabList[randomIndex];
            CardPicker picker         = Instantiate(cardPicker);

            picker.SetOption(additionalCard, (cardpicker) => {
                if (!this.isSelected)
                {
                    GameManager.instance.AllCards.Add(new CardSet(additionalCard, 0));
                    cardpicker.image.sprite = null;
                    this.isSelected         = true;
                    GameDataHandler.SaveCards(GameManager.instance.AllCards);
                }
            });

            picker.transform.SetParent(cardLayout.transform);
        }
    }
コード例 #8
0
        public static ShowCard convertToShowCard(CreditCard creditCard)
        {
            ShowCard card = new ShowCard();

            string[] split = creditCard.creditCardID.Split(':');

            card.id              = creditCard.id;
            card.creditCardID    = "**** **** **** " + split[split.Length - 1];
            card.card4Digits     = split[split.Length - 1];
            card.creditType      = creditCard.creditType;
            card.expirationMonth = creditCard.expirationMonth;
            card.expirationYear  = creditCard.expirationYear;
            card.ownerName       = creditCard.ownerName;
            card.securityDigits  = creditCard.securityDigits;
            card.userId          = creditCard.userId;
            card.Customer        = creditCard.Customer;

            return(card);
        }
コード例 #9
0
ファイル: CardText.cs プロジェクト: GouGit/stac
    void Start()
    {
        MeshRenderer mesh = GetComponent <MeshRenderer> ();

        textMesh = GetComponent <TextMesh>();
        mesh.sortingLayerName = sortingLayerName;
        mesh.sortingOrder     = sortingOrder;
        ShowCard show = transform.parent.GetComponent <ShowCard>();

        if (show.level > 0)
        {
            textMesh.text = "+" + show.level;
        }
        else
        {
            textMesh.text = "";
        }
        transform.position += Vector3.back;
    }
コード例 #10
0
ファイル: CardName.cs プロジェクト: GouGit/stac
    void Start()
    {
        MeshRenderer mesh = GetComponent <MeshRenderer> ();

        textMesh = GetComponent <TextMesh>();
        mesh.sortingLayerName = sortingLayerName;
        mesh.sortingOrder     = sortingOrder;
        ShowCard show = transform.parent.GetComponent <ShowCard>();

        if (show.card.cost == 0)
        {
            cost = "X";
        }
        else
        {
            cost = "" + show.card.cost;
        }
        textMesh.text       = cost;
        transform.position += Vector3.back;
    }
コード例 #11
0
        // Increases the Episode number on a specific showcard
        public IActionResult AddEpisode(int showCardID)
        {
            int userID = GetUserID();

            if (userID == 0)
            {
                return(RedirectToAction("Login", "User"));
            }

            string   message = null;
            ShowCard show    = new ShowCard();

            using (WeWatchContext context = new WeWatchContext())
            {
                show = context.ShowCard.Include(x => x.Show).Where(x => x.ShowCardID == showCardID).Single();
                ShowSeason currentSeason = context.ShowSeason.Where(x => x.ShowID == show.ShowID && x.ShowSeasonID == show.CurrentSeason).Single();
                if (show.CurrentEpisode >= currentSeason.SeasonEpisodes)
                {
                    ShowSeason nextSeason = context.ShowSeason.Include(x => x.Show).Where(x => x.ShowID == show.ShowID && x.IndividualSeason > currentSeason.IndividualSeason).OrderBy(x => x.IndividualSeason).FirstOrDefault();
                    if (nextSeason == null)
                    {
                        message = "Sorry you have reached the end. Would you like to add another season?";
                    }
                    else
                    {
                        show.CurrentEpisode = 1;
                        show.CurrentSeason  = nextSeason.ShowSeasonID;
                        message             = "You started a new Season!";
                    }
                }
                else
                {
                    show.CurrentEpisode++;
                    message = "Next episode";
                }

                context.SaveChanges();
            }
            TempData["message"] = message;
            return(RedirectToAction("ByShow", new { showID = show.ShowID }));
        }
コード例 #12
0
ファイル: GameDataHandler.cs プロジェクト: GouGit/stac
    public static List<CardSet> LoadCards()
    {
#if UNITY_EDITOR
        UnityEditor.AssetDatabase.Refresh();
#endif        
        List<CardSet> cardList = new List<CardSet>();
        string jsonData = null;
        
        try
        {
            jsonData = File.ReadAllText(Application.persistentDataPath + "/TemporaryFiles/CardList.json");
        }
        catch (FileNotFoundException)
        {
            SaveCards(GameManager.instance.AllCards);
            return null;
        }
        JObject list = JObject.Parse(jsonData);

        JArray cards = (JArray)list["CardList"];

        if (cards.Count == 0)
        {
            File.Delete(Application.persistentDataPath + "/TemporaryFiles/CardList.json");
            return LoadCards();
        }

        foreach (JObject card in cards)
        {
            ShowCard cardObj = (Resources.Load("CardsPrefabs/" + card["name"].ToString()) as GameObject).GetComponent<ShowCard>();
            int upgradeLevel = card["upgradeLevel"].ToInt();
            cardObj.level = upgradeLevel;

            // Debug.Log(upgradeLevel);

            cardList.Add(new CardSet(cardObj, upgradeLevel));
        }

        return cardList;
    }
コード例 #13
0
ファイル: GameDataHandler.cs プロジェクト: GouGit/stac
    public static void SaveCards(List<CardSet> cardList)
    {
        JObject list = new JObject();

        JArray cards = new JArray();
        foreach(CardSet set in cardList)
        {
            JObject card = new JObject();
            
            ShowCard cardObj = set.showCard;

            card.Add("name", cardObj.name);
            card.Add("upgradeLevel", set.upgradeLevel);

            cards.Add(card);
        }

        list.Add("CardList", cards);

        File.WriteAllText(Application.persistentDataPath + "/TemporaryFiles/CardList.json", list.ToString());
#if UNITY_EDITOR
        UnityEditor.AssetDatabase.Refresh();
#endif
    }
        public async Task <IActionResult> ShowCard([NotEmptyGuid, FromRoute] Guid id, [BindRequired, FromBody] ShowCard command)
        {
            command.GameId = id;
            await this.commandBus.Send(command);

            return(Ok());
        }
コード例 #15
0
        private async Task ShowCard(ShowCard command)
        {
            var response = await client.PutAsync($"/games/{command.GameId}/statistics/card", command.ToContent());

            response.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
コード例 #16
0
ファイル: ShowCard.cs プロジェクト: GouGit/stac
 public CardSet(ShowCard showCard, int upgradeLevel)
 {
     this.showCard = showCard;
     // Debug.Log(showCard.level);
     this.upgradeLevel = upgradeLevel;
 }
コード例 #17
0
        // Ensure all the neccessary information to  create a show card is received
        public IActionResult CreateCard(int showID, int watcherID, int seasonID, int episode)
        {
            string message = TempData["message"]?.ToString();
            int    userID  = GetUserID();

            if (userID == 0)
            {
                return(RedirectToAction("Login", "User"));
            }

            using WeWatchContext context = new WeWatchContext();
            Show              selectedShow    = new Show();
            ShowSeason        selectedSeason  = new ShowSeason();
            Watcher           selectedWatcher = new Watcher();
            List <ShowSeason> seasons         = new List <ShowSeason>();
            DisplayCard       card            = new DisplayCard();

            // A show and a watcher must be selected before seasons can be determined
            if (showID != 0 && watcherID != 0)
            {
                card = new DisplayCard(showID, watcherID);

                // Check to see if this user already has a card with this watcher and this show
                if (context.ShowCard.Where(x => x.ShowID == card.ShowID && x.WatcherID == card.WatcherID && x.UserID == userID).Count() != 0)
                {
                    message = $"You are already watching {card.ShowTitle} with {card.WatcherName}";
                }

                // Populate the seasons for this show
                else
                {
                    seasons = context.ShowSeason.Where(x => x.ShowID == showID).OrderBy(x => x.IndividualSeason).ToList();

                    // Populate episodes if season has been selected
                    if (seasonID != 0)
                    {
                        card.SeasonID       = seasonID;
                        selectedSeason      = context.ShowSeason.Where(x => x.ShowSeasonID == seasonID).Single();
                        card.CurrentEpisode = episode;
                    }
                }
            }
            // If we were passed a ShowCardID  from another action, create a displayCard
            if (TempData["showCardID"] != null)
            {
                int      showCardID = int.Parse(TempData["showCardID"].ToString());
                ShowCard show       = context.ShowCard.Where(x => x.ShowCardID == showCardID).Single();
                card = new DisplayCard(show.ShowID, show.WatcherID)
                {
                    SeasonID       = show.CurrentSeason,
                    CurrentEpisode = show.CurrentEpisode
                };
            }

            ViewBag.Card = card;
            List <Show>    allShows    = context.Show.OrderBy(x => x.Title).ToList();
            List <Watcher> allWatchers = context.Watcher.OrderBy(x => x.Name).ToList();

            ViewBag.Message     = message;
            ViewBag.AllShows    = allShows;
            ViewBag.AllWatchers = allWatchers;
            ViewBag.Seasons     = seasons;

            return(View());
        }
コード例 #18
0
 private void Awake()
 {
     Instance = this;
     gameObject.SetActive(false);
 }
コード例 #19
0
ファイル: CardPicker.cs プロジェクト: GouGit/stac
 public void SetOption(ShowCard card, UnityAction <CardPicker> action)
 {
     this.card    = card;
     image.sprite = this.card.card.image;
     GetComponent <Button>().onClick.AddListener(delegate { action(this); });
 }