public async Task LoadAsync()
        {
            // Delete any old temp data
            try
            {
                var tempResultsFolder = await ApplicationData.Current.TemporaryFolder.GetFolderAsync("Results");

                if (tempResultsFolder != null)
                {
                    await tempResultsFolder.DeleteAsync();
                }
            }
            catch { }

            await UWPTestLibrary.FileLoadHelpers.LoadAsync(Cards, HostConfigs);

            foreach (var c in Cards)
            {
                SelectedCards.Add(c);
            }

            foreach (var hc in HostConfigs)
            {
                SelectedHostConfigs.Add(hc);
            }
        }
Example #2
0
    public void ExchangeCards()
    {
        int temp = NumberOfChanges;

        for (int i = 0; i < CurrentDeck.Count; i++)
        {
            if (SelectedCards.Contains(CurrentDeck[i]))
            {
                GameObject card = CurrentDeck[i].gameObject;

                dealer.ExchangeCards[0].transform.position = card.transform.position;

                Destroy(card);
                CurrentDeck[i] = dealer.ExchangeCards[0];

                dealer.ExchangeCards.RemoveAt(0);
            }
        }

        if (temp > 0)
        {
            if (temp - SelectedCards.Count <= 0)
            {
                noMoreChanges.Raise();
            }
        }

        NumberOfChanges -= SelectedCards.Count;

        SelectedCards.Clear();
    }
Example #3
0
    public void FillWithZeros()
    {
        listOfSelectedCards = DeckFill.GetComponent <SelectedCards>();
        DeckFill            = GameObject.FindGameObjectWithTag("Deck");
        if (listOfSelectedCards.selectedCards.Count > 2)
        {
            while (listOfSelectedCards.selectedCards.Count > 2 && listOfSelectedCards.selectedCards.Count < 5)
            {
                listOfSelectedCards.selectedCards.Insert(0, 0);
            }

            selectedCardsSent = listOfSelectedCards.selectedCards;
            selectedCardsSent.Sort();
            hasBeenSend = true;
            Debug.Log(selectedCardsSent);
            if (Sent != null)
            {
                Sent();
            }

            /*Debug.Log(listOfSelectedCards.selectedCards[0]);
             * Debug.Log(listOfSelectedCards.selectedCards[1]);
             * Debug.Log(listOfSelectedCards.selectedCards[2]);
             * Debug.Log(listOfSelectedCards.selectedCards[3]);
             * Debug.Log(listOfSelectedCards.selectedCards[4]);
             */
        }
    }
Example #4
0
        public async Task LoadAsync()
        {
            // Delete any old temp data
            try
            {
                var tempResultsFolder = await ApplicationData.Current.TemporaryFolder.GetFolderAsync("Results");

                if (tempResultsFolder != null)
                {
                    await tempResultsFolder.DeleteAsync();
                }
            }
            catch { }

            await LoadFilesAsync("LinkedCards", Cards);
            await LoadFilesAsync("LinkedHostConfigs", HostConfigs);

            // Remove the WeatherLarge card since it contains a background image and often fails image comparisons
            var weatherLarge = Cards.FirstOrDefault(i => i.Name.EndsWith("WeatherLarge"));

            if (weatherLarge != null)
            {
                Cards.Remove(weatherLarge);
            }

            foreach (var c in Cards)
            {
                SelectedCards.Add(c);
            }

            foreach (var hc in HostConfigs)
            {
                SelectedHostConfigs.Add(hc);
            }
        }
Example #5
0
    public static DeckBuilderCard CreateCard(
        DeckBuilderCardSlot hiddenCards,
        AvailableCards availableCards,
        SelectedCards selectedCards,
        Toggle doubleClickToggle,
        String id,
        IList <CombatType> combatTypes,
        IList <CardAttribute> attributes,
        int?basePower,
        String faction)
    {
        GameObject      cardObject = Instantiate((GameObject)Resources.Load("DeckBuilderCard"), hiddenCards.transform);
        DeckBuilderCard card       = cardObject.GetComponent <DeckBuilderCard>();

        card.cardObject        = cardObject;
        card.id                = id;
        card.combatTypes       = new List <CombatType>(combatTypes);
        card.attributes        = new List <CardAttribute>(attributes);
        card.basePower         = basePower;
        card.faction           = faction;
        card.hiddenCards       = hiddenCards;
        card.availableCards    = availableCards;
        card.selectedCards     = selectedCards;
        card.cardSlot          = hiddenCards;
        card.doubleClickToggle = doubleClickToggle;
        card.image             = Resources.Load <Sprite>("CardImages/" + id);
        return(card);
    }
Example #6
0
 internal void ResetSelection()
 {
     DetachAll();
     foreach (var c in SelectableCards)
     {
         c.Selectable     = false;
         c.Selected       = false;
         c.SelectionParam = 0;
     }
     SelectableCards.Clear();
     SelectedCards.ForEach((c) => c.Selected = false);
     SelectedCards.Clear();
     Finishable = false;
     Cancelabel = false;
 }
Example #7
0
 protected override void RecalculateSelectionIndices()
 {
     for (int i = 0; i < Cards.Count; i++)
     {
         Card c = Cards[i];
         if (SelectedCards.Contains(c))
         {
             c.BackColor = Color.FromArgb(225, 225, 255);
         }
         else
         {
             c.BackColor = SystemColors.ControlLightLight;
         }
     }
 }
Example #8
0
 public IList <DeckBuilderCard> ToDeckBuilderCards(
     HiddenCards hiddenCards,
     AvailableCards availableCards,
     SelectedCards selectedCards,
     Toggle doubleClickToggle
     )
 {
     return(this.cards.Select(dCard =>
                              dCard.ToDeckBuilderCard(
                                  hiddenCards,
                                  availableCards,
                                  selectedCards,
                                  doubleClickToggle
                                  )
                              ).ToList());
 }
Example #9
0
    protected void BtnTrade_OnClick(object sender, EventArgs e)
    {
        try
        {
            var userCards  = UcPlayer.SelectedCards.ToList();
            var tableCards = SelectedCards.ToList();

            GameData.TradeCards(UserData.User, userCards, tableCards);
            GameData.Save();

            Response.Redirect(Request.Url.ToString());
        }
        catch (Exception ex)
        {
            //TODO: Show error message.
        }
    }
Example #10
0
        private void TuneControls()
        {
            var selected     = SelectedCards.Select(c => c.Id).ToArray();
            var cardControls = _data.Cards.OrderBy(c => c.Name).Select(c => new CardControl {
                Card = c
            });

            _lb.ItemsSource = cardControls;
            if (selected.Any())
            {
                var selectedCard = _data.Cards.FirstOrDefault(c => selected.Any(s => s == c.Id));
                _lb.SelectedItem = cardControls.FirstOrDefault(cc => cc.Card == selectedCard);
            }

            _btnEdit.IsEnabled   = SelectedCard != null;
            _btnRemove.IsEnabled = SelectedCards.Any();
        }
Example #11
0
 public DeckBuilderCard ToDeckBuilderCard(
     HiddenCards hiddenCards,
     AvailableCards availableCards,
     SelectedCards selectedCards,
     Toggle doubleClickToggle)
 {
     return(DeckBuilderCard.CreateCard(
                hiddenCards,
                availableCards,
                selectedCards,
                doubleClickToggle,
                id,
                ParseCombatTypes(this.combatTypes),
                ParseCardAttributes(this.attributes),
                basePower,
                faction));
 }
Example #12
0
 public void Init()
 {
     Players.Clear();
     SelectedCards.Clear();
     HandCards.Clear();
     CurrentDiscards.Clear();
     BaseCards.Clear();
     CurrentStatus = GameStatus.CallLandlord;
     ClaimCount    = 4;
     CurrentTurn   = 0;
     RestCardNum   = 17;
     Mutiple       = 1;
     CurrentMode   = GameMode.MutiPlayer;
     LastPlayer    = "";
     Landlord      = "";
     BaseScore     = 1000;
 }
Example #13
0
    public void SelectCard(CardInfo selectedCard)
    {
        if (SelectedCards.Contains(selectedCard))
        {
            selectedCard.Selected = false;
            SelectedCards.Remove(selectedCard);
            return;
        }

        if (SelectedCards.Count >= NumberOfChanges && SelectedCards.Count > 0)
        {
            SelectedCards[0].Selected = false;
            SelectedCards.RemoveAt(0);
        }

        selectedCard.Selected = true;
        SelectedCards.Add(selectedCard);
    }
Example #14
0
    protected void BtnBuy_OnClick(object sender, EventArgs e)
    {
        try
        {
            var card = SelectedCards.Single();

            GameData.TakeCard(UserData.User, card);
            GameData.Save();

            CheckGameEnd();

            Response.Redirect(Request.Url.ToString());
        }
        catch (Exception ex)
        {
            //TODO: Show error message.
        }
    }
Example #15
0
    void LegitCombination()
    {
        selectedCards = GetComponent <SelectedCards>();
        myList        = selectedCards.selectedCards;
        myList.Sort();

        for (int i = 0; cardCombinations.Count - 1 > i; i++)
        {
            cardCombinations[i].combination.Sort();//sort all combinations
        }


        for (int i = 0; i < cardCombinations.Count - 1; i++)
        {
            counter = 0;

            if (cardCombinations[i].combination.Count == myList.Count)
            {
                for (int b = 0; b < cardCombinations[i].combination.Count; b++)
                {
                    if (cardCombinations[i].combination[b] == myList[b])
                    {
                        counter++;
                    }
                    else
                    {
                        Debug.Log("Not a valid combination");
                        break;
                    }
                }
                if (counter == myList.Count)
                {
                    TotalScore += cardCombinations[i].score;
                    Debug.Log(i);
                    Debug.Log(TotalScore);
                    break;
                }
                counter = 0;
                selectedCards.selectedCards.Clear();
            }
        }
    }
Example #16
0
 public void Reward(int winner)
 {
     // for (int i = 0; i < Players.Length; i++)
     // {
     //     if (Players[i].Active)
     //     {
     //         Players[winner].Deck.Add(Players[i].Deck[CallCards[i]]);
     //         Players[i].Deck.RemoveAt(CallCards[i]);
     //     }
     // }
     for (int i = 0; i < SelectedCards.Count; i++)
     {
         SelectedCards[i].PreviousOwnerID = SelectedCards[i].CurrentOwnerID;
         SelectedCards[i].CurrentOwnerID  = winner;
     }
     Table.Clear();
     Table.AddRange(SelectedCards);
     Players[winner].Deck.AddRange(SelectedCards);
     SelectedCards.Clear();
 }
Example #17
0
 protected override void card_Click(object sender, EventArgs e)
 {
     if (CanSelectCards)
     {
         var card = (Card)sender;
         if (SelectedCards.Count != 0)
         {
             SelectedCards.Clear();
         }
         int index = Cards.IndexOf(card);
         // Integer division will return the index of the first location divided by GroupNumber.
         // Then we multiply by GroupNumber to get the index of the first location.
         int start = (index / GroupNumber) * GroupNumber;
         // After this, we can simply select the card for every next index.
         for (int i = start; i < start + GroupNumber; i++)
         {
             SelectedCards.Add(Cards[i]);
         }
         RecalculateSelectionIndices();
     }
 }
 private void BtnSelect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     SelectedCards?.Invoke(_cards);
     Close();
 }
Example #19
0
 public override string ToString()
 {
     return("Carre de " + SelectedCards.First());
 }
Example #20
0
 public override string ToString()
 {
     return("Quinte au " + SelectedCards.First());
 }
Example #21
0
 public override string ToString()
 {
     return("Paire de " + SelectedCards.First() + " et de " + SelectedCards[2]);
 }
Example #22
0
 public override string ToString()
 {
     return("Full de " + SelectedCards.First() + " par les " + SelectedCards[3]);
 }
Example #23
0
        internal void OnCardSelected(ClientCard card)
        {
            Debug.Log(string.Format("-->{0} is selected by clicking", DataService.GetName(card.Data.Code)));
            switch (GameInfo.Instance.CurrentMessage)
            {
            case GameMessage.SelectCounter:
                card.SelectionParam--;
                if ((card.SelectionParam & 0xffff) == 0)
                {
                    card.Selectable = false;
                }
                SelectMin--;
                if (SelectMin == 0)
                {
                    byte[]       response = new byte[SelectableCards.Count * 2];
                    BinaryWriter writer   = new BinaryWriter(new MemoryStream(response));
                    for (int i = 0; i < SelectableCards.Count; ++i)
                    {
                        writer.Write((ushort)((SelectableCards[i].SelectionParam >> 16) - (SelectableCards[i].SelectionParam & 0xffff)));
                    }
                    ResetSelection();
                    MainGame.Instance.SendCToSResponse(response);
                }
                else
                {
                    MainGame.Instance.DuelWindow.ShowSelectHint(
                        string.Format(DataService.SysString(204), SelectMin, DataService.CounterName(CounterToBeSelected)));
                }
                break;

            case GameMessage.SelectCard:
                if (card.Selected)
                {
                    SelectedCards.Remove(card);
                    card.Selected = false;
                }
                else
                {
                    SelectedCards.Add(card);
                    card.Selected = true;
                }
                if ((SelectedCards.Count >= SelectMax) || (SelectedCards.Count == SelectableCards.Count))
                {
                    SendSelectResponse();
                }
                else if (SelectedCards.Count >= SelectMin)
                {
                    Finishable = true;
                    MainGame.Instance.DuelWindow.SetCancelOrFinish(2);
                }
                break;

            case GameMessage.SelectTribute:
                if (card.Selected)
                {
                    SelectedCards.Remove(card);
                    card.Selected = false;
                }
                else
                {
                    SelectedCards.Add(card);
                    card.Selected = true;
                }
                if (SelectedCards.Count == SelectMax || (SelectedCards.Count == SelectableCards.Count))
                {
                    SendSelectResponse();
                    return;
                }
                int acc = 0;
                foreach (var c in SelectedCards)
                {
                    acc += c.SelectionParam;
                }
                if (acc > SelectMin)
                {
                    MainGame.Instance.DuelWindow.SetCancelOrFinish(2);
                    Finishable = true;
                }
                break;

            case GameMessage.SelectSum:
                if (card.Selected)
                {
                    SelectedCards.Remove(card);
                    card.Selected = false;
                }
                else
                {
                    SelectedCards.Add(card);
                    card.Selected = true;
                }
                UpdateSelectSum(spreadingTranforms.Count != 0);
                break;

            case GameMessage.SelectUnSelectCard:
                SelectedCards.Add(card);
                SendSelectResponse();
                break;

            case GameMessage.SortCard:
                //todo impl
                break;

            default: break;
            }
        }
Example #24
0
        internal void UpdateSelectSum(bool spreading)
        {
            sumAssist.Clear();
            sumAssist.Add(0);
            int count, p1, p2, maxParam = -1, minParam = int.MaxValue, selectedCount = SelectedCards.Count - SelectSumFixedCount;
            HashSet <ClientCard> available = new HashSet <ClientCard>();
            var remains = new List <ClientCard>(SelectableCards);

            remains.RemoveAll((c) => c.Selected);
            for (int i = 0; i < SelectedCards.Count; ++i)
            {
                count = sumAssist.Count;
                p1    = SelectedCards[i].SelectionParam & 0xffff;
                p2    = SelectedCards[i].SelectionParam >> 16;
                int pmin = (p2 > 0 && p2 < p1) ? p2 : p1;
                minParam = minParam < pmin ? minParam : pmin;
                maxParam = maxParam > p1 ? maxParam : p1;
                maxParam = maxParam > p2 ? maxParam : p2;
                for (int j = 0; j < count; ++j)
                {
                    if (p2 > 0)
                    {
                        sumAssist.Add(sumAssist[j] + p2);
                    }
                    sumAssist[j] += p1;
                }
            }
            if (Overflowable)
            {
                sumAssist.Sort();
                int sumMax = sumAssist[sumAssist.Count - 1];
                int sumMin = sumAssist[0];
                if (sumMin >= SelectSumVal)
                {
                    SendSelectResponse();
                    return;
                }
                else if (sumMax >= SelectSumVal && sumMax - maxParam < SelectSumVal)
                {
                    Finishable = true;
                    MainGame.Instance.DuelWindow.SetCancelOrFinish(2);
                }
                int sum;
                for (int i = 0; i < remains.Count; ++i)
                {
                    remains.Swap(0, i);
                    p1       = remains[0].SelectionParam & 0xffff;
                    p2       = remains[0].SelectionParam >> 16;
                    sum      = sumMin + p1;
                    minParam = minParam < p1 ? minParam : p1;
                    if (sum >= SelectSumVal)
                    {
                        if (sum - minParam < SelectSumVal)
                        {
                            available.Add(remains[0]);
                        }
                    }
                    else if (CheckMin(1, remains, SelectSumVal - sum, SelectSumVal - sum + minParam - 1))
                    {
                        available.Add(remains[0]);
                    }
                    if (p2 == 0)
                    {
                        continue;
                    }
                    sum      = sumMin + p2;
                    minParam = minParam < p2 ? minParam : p2;
                    if (sum >= SelectSumVal)
                    {
                        if (sum - minParam < SelectSumVal)
                        {
                            available.Add(remains[0]);
                        }
                    }
                    else if (CheckMin(1, remains, SelectSumVal - sum, SelectSumVal - sum + minParam - 1))
                    {
                        available.Add(remains[0]);
                    }
                }
            }
            else
            {
                if (sumAssist.Contains(SelectSumVal) && selectedCount >= SelectMin && selectedCount <= SelectMax)
                {
                    SendSelectResponse();
                    return;
                }
                HashSet <int> noduplicate = new HashSet <int>(sumAssist);
                foreach (int val in noduplicate)
                {
                    int tarValue = SelectSumVal - val;
                    for (int i = 0; i < remains.Count; ++i)
                    {
                        if (available.Contains(remains[i]))
                        {
                            continue;
                        }
                        remains.Swap(0, i);
                        p1 = remains[0].SelectionParam & 0xffff;
                        p2 = remains[0].SelectionParam >> 16;
                        if (CheckSum(1, remains, tarValue - p1, selectedCount + 1) ||
                            (p2 > 0 && CheckSum(1, remains, tarValue - p2, selectedCount + 1)))
                        {
                            available.Add(remains[0]);
                        }
                    }
                }
            }
            if (!Finishable && available.Count == 1)
            {
                SelectedCards.AddRange(available);
                SendSelectResponse();
                return;
            }
            if (spreading)
            {
                DetachAll();
                Spread(available);
            }
            else
            {
                SelectableCards.ForEach((c) => c.Selectable = false);
                foreach (var c in available)
                {
                    c.Selectable = true;
                }
            }
        }
Example #25
0
 public override string ToString()
 {
     return("Couleur " + SelectedCards.First().Color);
 }