示例#1
0
    /// <summary>
    ///
    /// Create a new player deck
    ///
    /// </summary>
    public DeckData CreatePlayerDeck(DeckData deckTemplate, string deckName, int?campaignId = null)
    {
        //Generate the ID of the deck. Takes the last deck id in the list and adds one to it
        var newId = 0;

        if (PlayerDeckList.Count > 0)
        {
            newId = PlayerDeckList.LastOrDefault().Id.Value + 1;
        }

        //Adds the deck to the list
        var newDeck = new DeckData(deckTemplate)
        {
            Id   = newId,
            Name = deckName,
        };

        PlayerDeckList.Add(newDeck);

        if (campaignId.HasValue)
        {
            newDeck.CampaignTracker = new CampaignProgression(newDeck.Id.Value, campaignId.Value);
        }

        //Save decks to file
        SaveDecks();

        return(newDeck);
    }
示例#2
0
        private void Receiver_OnReceived(string action, string data)
        {
            switch (action)
            {
            case "BattleReady":
                Dispatcher.Invoke(() =>
                {
                    EnemyDeckList.Clear();
                });
                break;

            case "Load":
                Sender.Initialize(int.Parse(data));
                Sender.Send($"Setting:{Settings.ToString()}");
                break;

            case "EnemyPlay":
            case "EnemyAdd":
                Dispatcher.Invoke(() =>
                {
                    EnemyDeckList.Add(CardData.Parse(data, action == "EnemyPlay" ? 1 : -1));
                });
                break;

            case "PlayerDeck":
                var cardList = new List <CardData>();
                var cards    = data.Split('\n');
                foreach (var card in cards)
                {
                    cardList.Add(CardData.Parse(card));
                }

                Dispatcher.Invoke(() =>
                {
                    PlayerDeckList.Clear();
                    PlayerDeckList.Add(cardList);
                });
                break;

            case "PlayerDraw":
                Dispatcher.Invoke(() =>
                {
                    PlayerDeckList.Add(CardData.Parse(data, -1));
                });
                break;

            case "ReplayDetail":
                Dispatcher.Invoke(() =>
                {
                    ReplayGrid.DataContext = ReplayData.Parse(data);
                });
                break;
            }
            Dispatcher.Invoke(() =>
            {
                LogText.Text = $"{action}:{data}\n{LogText.Text}";
            });
        }