public async Task <IActionResult> AddTag(DeckEditorModel model)
        {
            var user = await _userManager.GetUserAsync(User);

            var deck = await _context.Decks
                       .Where(deck => deck.Id == model.Deck.Id)
                       .Include(deck => deck.Tags)
                       .FirstOrDefaultAsync();

            if (deck.CreatorId == user.Id && !String.IsNullOrEmpty(model.TagInput))
            {
                string tagName = model.TagInput.ToLower().Split(' ').Aggregate((x, y) => x += "_" + y);
                var    tag     = await _context.DeckTags.FindAsync(tagName);

                if (tag is null)
                {
                    tag = new DeckTag {
                        Name = tagName
                    };
                    await _context.DeckTags.AddAsync(tag);
                }

                deck.Tags.Add(tag);
                _context.Decks.Update(deck);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(EditDeck), new { model.Deck.Id }));
        }
Beispiel #2
0
 public void PlayerCardMoveDeck(DeckTag deckTag, int playerIndex, bool isReverse, float reverseTime)
 {
     Players[playerIndex].AllCardMoveDeck(
         deckTag,
         isReverse,
         reverseTime);
 }
Beispiel #3
0
    public void PutCard(DeckTag putDeck, int playerCardIndex, bool isBack = false, float reverseTime = 0.5f)
    {
        var deck        = DeckSystem.GetInstance().GetDeck(putDeck);
        var putCardIdx  = PlayerCard[playerCardIndex].GetCardIndex();
        var putShapeIdx = PlayerCard[playerCardIndex].GetShapeIndex();

        PlayerCard[playerCardIndex].transform.DOMove(deck.GetPosition(), 0.5f);
        PlayerCard[playerCardIndex].transform.DORotate(deck.GetAngle(), 0.5f);

        if (isBack)
        {
            CardAnimationSystem.GetInstance().ReverseAnimation(
                PlayerCard[playerCardIndex], reverseTime);
        }

        deck.AddCard(PlayerCard[playerCardIndex]);

        //////////////////////////////////////
        /// TODO : 커플링으로 인해 분리해야함
        RuleSystem.GetInstance().AddAttackCardDamage(putCardIdx, putShapeIdx);
        AlertSystem.GetInstance().AddAlerts(putCardIdx, putShapeIdx);
        //////////////////////////////////////

        IsPutCard = true;

        PlayerCard.RemoveAt(playerCardIndex);

        RePosition();

        NetworkSystem.GetInstance().SendServer(string.Format("PUT-CARD:{0}:{1}", PlayerId, playerCardIndex));
    }
Beispiel #4
0
    public IEnumerator ShareCard(DeckTag deck, int cardNum, float shareDelay)
    {
        WaitForSeconds delay = new WaitForSeconds(shareDelay);

        int tempTurn = TurnSystem.GetInstance().GetNowTurnPlayerIndex();

        if (tempTurn < 0)
        {
            tempTurn = 0;
        }

        for (int i = 0; i < Players.Count; i++)
        {
            for (int j = 0; j < cardNum; j++)
            {
                Card card = DeckSystem.GetInstance().GetTopCardWithDeck(deck);

                if (tempTurn + i >= Players.Count)
                {
                    tempTurn -= Players.Count;
                }

                Players[tempTurn + i].AddPlayerCard(card);

                yield return(delay);
            }
        }
    }
Beispiel #5
0
    /// <summary>해당 id를 가진 플레이어에게 카드 추가 </summary>
    /// <param name="deckTag">카드를 가져올 덱</param>
    /// <param name="playerName">플레이어 이름</param>
    /// <param name="cardNum">카드 갯수</param>
    public void PlayerAddCardWithDeck(DeckTag deckTag, string playerId, int cardNum)
    {
        Observable.Interval(TimeSpan.FromSeconds(0.05f))
        .Take(cardNum)
        .Subscribe(_ =>
        {
            var player = Players.Find(p => p.PlayerId == playerId);

            if (player == null)
            {
                Debug.Log("Player not found : " + playerId);
                return;
            }

            var card = DeckSystem.GetInstance().GetTopCardWithDeck(deckTag);

            if (card == null)
            {
                return;
            }

            if (player.PlayerId == MyPlayerId)
            {
                CardAnimationSystem.GetInstance().ReverseAnimation(card, 0.5f);
            }

            player.AddPlayerCard(card);
        });
    }
Beispiel #6
0
    public void MoveCardDecktoDeck(DeckTag deckTag1, DeckTag deckTag2, float delayTime, int startCardIdx, int cardNum, float intervalTime, float moveTime, Action complete = null)
    {
        int tag1 = (int)deckTag1;
        int tag2 = (int)deckTag2;

        Observable.Timer(TimeSpan.FromSeconds(delayTime))
        .Subscribe(_ => Decks[tag1].MoveCardDecktoDeck(Decks[tag2], startCardIdx, cardNum, intervalTime, moveTime, complete));
    }
Beispiel #7
0
    public void AllCardMoveDeck(DeckTag cardDeck, bool isReverse, float reverseTime)
    {
        int count = PlayerCard.Count;

        for (int i = 0; i < count; i++)
        {
            PutCard(cardDeck, 0, isReverse, reverseTime);
        }
    }
Beispiel #8
0
 public void AllPlayerCardMoveDeck(DeckTag deckTag, bool isReverse, float reverseTime)
 {
     for (int i = 0; i < Players.Count; i++)
     {
         Players[i].AllCardMoveDeck(
             deckTag,
             isReverse,
             reverseTime);
     }
 }
Beispiel #9
0
    /// <summary>deck1의 카드가 부족할 때 deck2의 카드로 채우고 섞음 </summary>
    /// <param name="deck1"></param>
    /// <param name="deck2"></param>
    public void FillDecktoDeckofAttack(DeckTag deck1, DeckTag deck2)
    {
        var nowTurn = TurnSystem.GetInstance().GetNowTurnPlayerIndex();
        var isPut   = PlayerSystem.GetInstance().Players[nowTurn].IsPutCard;
        var damage  = RuleSystem.GetInstance().GetAttackDamage(isPut);

        var deck2Count = DeckSystem.GetInstance().GetCardCountWithDeck(deck2);

        Action addCardAction = () =>
        {
            DeckSystem.GetInstance().ShuffleDeck(DeckTag.DRAW_DECK, 1000);
            NextTurn(nowTurn, damage);
        };


        if (damage > deck2Count)
        {
            var count = DeckSystem.GetInstance().GetCardCountWithDeck(deck1);

            if (count + deck2Count <= damage)
            {
                return;
            }

            Debug.Log("move put -> draw : " + count);

            DeckSystem.GetInstance().MoveCardDecktoDeck(
                deck1,
                deck2,
                0,
                0,
                count - 1,
                0,
                0.2f,
                addCardAction);
        }
        else
        {
            NextTurn(nowTurn, damage);
        }
    }
Beispiel #10
0
    public void FillDecktoDeckofDraw(DeckTag deck1, DeckTag deck2, int damage)
    {
        Action addCardAction = () =>
        {
            DeckSystem.GetInstance().ShuffleDeck(DeckTag.DRAW_DECK, 1000);
        };

        var count = DeckSystem.GetInstance().GetCardCountWithDeck(deck1);

        if (damage > count)
        {
            Debug.Log("move put -> draw : " + count);

            DeckSystem.GetInstance().MoveCardDecktoDeck(
                deck1,
                deck2,
                0,
                0,
                count - 1,
                0,
                0.2f,
                addCardAction);
        }
    }
 public CollectionDeck StartEditingDeck(DeckTag tag, long deckId, object callbackData)
 {
     object[] objArray1 = new object[] { tag, deckId, callbackData };
     return(base.method_14 <CollectionDeck>("StartEditingDeck", objArray1));
 }
Beispiel #12
0
 /// <summary>덱 오브젝트 반환 함수</summary>
 /// <param name="deckTag">덱 tag</param>
 /// <returns>덱 오브젝트</returns>
 public Deck GetDeck(DeckTag deckTag)
 {
     return(Decks[(int)deckTag]);
 }
Beispiel #13
0
 /// <summary>덱의 맨 위에 있는 카드를 큐에서 빼지 않고 반환 </summary>
 /// <param name="deckTag">덱 tag</param>
 /// <returns>맨 위 카드</returns>
 public Card GetTopCardPeekWithDeck(DeckTag deckTag)
 {
     return(Decks[(int)deckTag].GetTopCardPeek());
 }
Beispiel #14
0
    /// <summary>플레이어가 카드를 덱에 놓음 </summary>
    /// <param name="deckTag">카드를 놓을 덱</param>
    /// <param name="playerName">플레이어 id</param>
    /// <param name="cardListIndex">플레이어의 카드 index</param>
    /// <param name="isBack">뒤집을지</param>
    /// <param name="reverseTime">뒤집는 duration</param>
    public void PlayerPutCard(DeckTag deckTag, string playerId, int cardListIndex, bool isBack = false, float reverseTime = 0.5f)
    {
        var player = Players.Find(p => p.PlayerId == playerId);

        player.PutCard(deckTag, cardListIndex, isBack, reverseTime);
    }
Beispiel #15
0
 /// <summary>덱이 가지고 있는 카드 수 반환 </summary>
 /// <param name="deckTag">덱 tag</param>
 /// <returns>카드 개수</returns>
 public int GetCardCountWithDeck(DeckTag deckTag)
 {
     return(Decks[(int)deckTag].DeckList.Count);
 }
 public void ClearTaggedDeck(DeckTag tag)
 {
     object[] objArray1 = new object[] { tag };
     base.method_8("ClearTaggedDeck", objArray1);
 }
Beispiel #17
0
 public void ShuffleDeck(DeckTag deckTag, int shuffleNum)
 {
     Decks[(int)deckTag].ShuffleDeck(shuffleNum);
 }
 public void SetTaggedDeck(DeckTag tag, CollectionDeck deck, object callbackData)
 {
     object[] objArray1 = new object[] { tag, deck, callbackData };
     base.method_9("SetTaggedDeck", new Class272.Enum20[] { Class272.Enum20.ValueType }, objArray1);
 }
 public CollectionDeck SetTaggedDeck(DeckTag tag, long deckId, object callbackData)
 {
     object[] objArray1 = new object[] { tag, deckId, callbackData };
     return(base.method_15 <CollectionDeck>("SetTaggedDeck", new Class272.Enum20[] { Class272.Enum20.ValueType }, objArray1));
 }
 public CollectionDeck GetTaggedDeck(DeckTag tag)
 {
     object[] objArray1 = new object[] { tag };
     return(base.method_14 <CollectionDeck>("GetTaggedDeck", objArray1));
 }