private void triggerOwnSendTo(SpecialEffect se)
        {
            GUIWindows.GUISelect gUISelect;
            List <CardGUIModel>  validSelections;
            string selectMessage, friendlyFrom;

            validSelections = new List <CardGUIModel>();

            validSelections.Clear();

            getValidSelections(se, out validSelections, out friendlyFrom);

            if (validSelections.Count > 0)
            {
                gUISelect = null;
                List <int> selectedTargetIndexes;

                // if you must select a number of cards from opponent's mana zone
                if (se.Arguments[0] != ALL)
                {
                    selectMessage = string.Format("You must select a total of {0} card(s) from your {1}.", Math.Min(se.Arguments[0], validSelections.Count), friendlyFrom);

                    gUISelect = new GUIWindows.GUISelect(validSelections, selectMessage, se.Arguments[0], null);
                    gUISelect.removeCancelButton();
                    gUISelect.ShowDialog();

                    selectedTargetIndexes = gUISelect.selected;
                }
                else
                {
                    selectedTargetIndexes = new List <int>();

                    for (int i = 0; i < validSelections.Count; i++)
                    {
                        selectedTargetIndexes.Add(i);
                    }
                }

                switch (se.TargetTo)
                {
                case "OppHand":
                    sendToOppHand(se, selectedTargetIndexes);
                    break;

                case "OwnHand":
                    sendToOwnHand(se, selectedTargetIndexes);
                    break;

                case "OppGrave":
                    sendToOppGrave(se, selectedTargetIndexes);
                    break;

                case "OwnGround":
                    sendToOwnGround(se, selectedTargetIndexes);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void triggerOwnSendTo(SpecialEffect se)
        {
            GUIWindows.GUISelect gUISelect;
            Tuple <List <CardGUIModel>, List <CardGUIModel> > validSelections, fullSelections;
            string selectMessage, friendlyFrom;
            bool   treatCountAsOne;

            if (se.TargetFrom == "OwnDeck")
            {
                switch (se.TargetTo)
                {
                case "OwnMana":
                    ctrl.send(new GameMessage("DECKTOMANA", ctrl.GameRoomID, se.Arguments));
                    return;

                default:
                    return;
                }
            }

            fullSelections  = getValidSelections(se, out friendlyFrom);
            treatCountAsOne = se.TargetFrom.Contains("Any") ? true : false;

            if (se.Condition == "LessOrEqual")
            {
                validSelections = new Tuple <List <CardGUIModel>, List <CardGUIModel> >(
                    fullSelections.Item1.Where(x => (x.Card.Type == "Creature" && x.Card.Power <= se.Arguments[1])).ToList <CardGUIModel>(),
                    fullSelections.Item2.Where(x => (x.Card.Type == "Creature" && x.Card.Power <= se.Arguments[1])).ToList <CardGUIModel>());
            }
            else
            {
                validSelections = new Tuple <List <CardGUIModel>, List <CardGUIModel> >(
                    fullSelections.Item1,
                    fullSelections.Item2);
            }

            if (validSelections.Item1.Count > 0 || validSelections.Item2.Count > 0)
            {
                gUISelect = null;
                List <int> selectedTargetIndexesOwn, selectedTargetIndexesOpp, translatedIndexesOwn, translatedIndexesOpp;

                // if you must select a number of cards from opponent's mana zone
                if (se.Arguments[0] != ALL)
                {
                    selectMessage = "";
                    if (validSelections.Item1.Count > 0)
                    {
                        if (validSelections.Item2.Count > 0)
                        {
                            selectMessage = string.Format("You must select a total of {0} cards from your {3} {1} {2} cards from your opponent's {3}.",
                                                          treatCountAsOne ? Math.Min(validSelections.Item1.Count + validSelections.Item1.Count, se.Arguments[0]) : Math.Min(validSelections.Item1.Count, se.Arguments[0]),
                                                          treatCountAsOne ? "or" : "and",
                                                          treatCountAsOne ? Math.Min(validSelections.Item1.Count + validSelections.Item1.Count, se.Arguments[0]) : Math.Min(validSelections.Item2.Count, se.Arguments[0]),
                                                          friendlyFrom);
                        }
                        else
                        {
                            selectMessage = string.Format("You must select a total of {0} card(s) from your {1}.",
                                                          Math.Min(se.Arguments[0], validSelections.Item1.Count),
                                                          friendlyFrom);
                        }
                    }
                    else
                    {
                        if (validSelections.Item2.Count > 0)
                        {
                            selectMessage = string.Format("You must select a total of {0} card(s) from your opponent's {1}.",
                                                          Math.Min(se.Arguments[0], validSelections.Item2.Count),
                                                          friendlyFrom);
                        }
                    }
                    gUISelect = new GUIWindows.GUISelect(
                        validSelections.Item1,
                        validSelections.Item2,
                        selectMessage,
                        friendlyFrom,
                        validSelections.Item1.Count == 0 ? 0 : Math.Min(validSelections.Item1.Count, se.Arguments[0]),
                        validSelections.Item2.Count == 0 ? 0 : Math.Min(validSelections.Item2.Count, se.Arguments[0]),
                        se.TargetFrom.Contains("Any") ? true : false);
                    gUISelect.removeCancelButton();
                    gUISelect.ShowDialog();

                    selectedTargetIndexesOwn = gUISelect.ownSelected;
                    selectedTargetIndexesOpp = gUISelect.oppSelected;
                }
                else
                {
                    selectedTargetIndexesOwn = new List <int>();
                    selectedTargetIndexesOpp = new List <int>();

                    for (int i = 0; i < validSelections.Item1.Count; i++)
                    {
                        selectedTargetIndexesOwn.Add(i);
                    }
                    for (int i = 0; i < validSelections.Item2.Count; i++)
                    {
                        selectedTargetIndexesOpp.Add(i);
                    }
                }

                // translate indexes

                translatedIndexesOwn = new List <int>();
                translatedIndexesOpp = new List <int>();

                foreach (int index in selectedTargetIndexesOwn)
                {
                    translatedIndexesOwn.Add(fullSelections.Item1.IndexOf(validSelections.Item1[index]));
                }
                foreach (int index in selectedTargetIndexesOpp)
                {
                    translatedIndexesOpp.Add(fullSelections.Item2.IndexOf(validSelections.Item2[index]));
                }

                switch (se.TargetTo)
                {
                case "OppHand":
                    sendToOppHand(se, translatedIndexesOwn, translatedIndexesOpp);
                    break;

                case "OwnHand":
                    sendToOwnHand(se, translatedIndexesOwn, translatedIndexesOpp);
                    break;

                case "OwnGrave":
                    sendToOwnGrave(se, translatedIndexesOwn, translatedIndexesOpp);
                    break;

                case "OppGrave":
                    sendToOppGrave(se, translatedIndexesOwn, translatedIndexesOpp);
                    break;

                case "OwnGround":
                    sendToOwnGround(se, translatedIndexesOwn, translatedIndexesOpp);
                    break;

                case "OwnersHand":
                    sendToOwnersHand(se, translatedIndexesOwn, translatedIndexesOpp);
                    break;
                }
            }
        }