Exemple #1
0
    /// <summary>
    /// Tos the special card. 根据数据,返回特殊卡牌
    /// </summary>
    /// <returns>The special card.</returns>
    /// <param name="jsonValue">Json value.</param>
    public static SpecialCard ToSpecialCard(JsonData jsonValue)
    {
        var cardVo = new SpecialCard();

        cardVo.id = int.Parse(jsonValue["id"].ToString());

        cardVo.title = jsonValue["name"].ToString();

        cardVo.desc = jsonValue["instructions"].ToString();

        cardVo.cardPath = jsonValue["path"].ToString();

        if (((IDictionary)jsonValue).Contains("tipData"))
        {
            var tipData = jsonValue["tipData"];

            var tipType    = tipData["type"].ToString();
            var tipContent = tipData["content"].ToString();
            Client.UI.UIOtherCardWindowController.netKnowledge.title   = tipType;
            Client.UI.UIOtherCardWindowController.netKnowledge.content = tipContent;
        }

        /// <summary>
        /// The rank score.排名积分
        /// </summary>
        cardVo.rankScore = int.Parse(jsonValue["cardIntegral"].ToString());

        return(cardVo);
    }
Exemple #2
0
	void testSpecialNegative(){
		Vector3 effect = new Vector3 (1, 2, 8);
		Card sp = new SpecialCard ("TestSpecialN", effect, false);
		SpecialCard sp1 = (SpecialCard)sp;
		//the 1st argument doesn't matter because it's a SpecialNegative. Player3 is target
		sp1.Play (1, 3);
	}
Exemple #3
0
 public void AddWeather(SpecialCard c)
 {
     if (c.WeatherType == SpecialCard.WeatherTypes.Frost)
     {
         frost = c;
     }
     else if (c.WeatherType == SpecialCard.WeatherTypes.Fog)
     {
         fog = c;
     }
     else if (c.WeatherType == SpecialCard.WeatherTypes.Rain)
     {
         rain = c;
     }
     else if (c.WeatherType == SpecialCard.WeatherTypes.Storm)
     {
         storm = c;
     }
     else if (c.WeatherType == SpecialCard.WeatherTypes.Clear)
     {
         ClearWeather();
     }
     else
     {
         //do nothing
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("CardID,CardName,CardImageURL,CardImageHiURL,CardCatID,CardTypeID,SetID,CardNum,Artist,CardRarityID,LastUpdateDate")] SpecialCard specialCard)
        {
            if (id != specialCard.CardID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(specialCard);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecialCardExists(specialCard.CardID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CardCatID"]    = new SelectList(_context.CardCats, "CardCatID", "CardCatID", specialCard.CardCatID);
            ViewData["CardRarityID"] = new SelectList(_context.CardRarities, "CardRarityID", "CardRarityID", specialCard.CardRarityID);
            ViewData["CardTypeID"]   = new SelectList(_context.CardTypes, "CardTypeID", "CardTypeID", specialCard.CardTypeID);
            ViewData["SetID"]        = new SelectList(_context.Sets, "SetID", "SetID", specialCard.SetID);
            return(View(specialCard));
        }
Exemple #5
0
	void testSpecialPositive(){
		Vector3 effect = new Vector3 (1, 2, 4);
		Card sp = new SpecialCard ("TestSpecialP", effect, true);
		SpecialCard sp1 = (SpecialCard)sp;
		//the 2nd argument doesn't matter because it's a SpecialPositive and has no target
		sp1.Play (1, 0);
	}
 public static void ShowDecks(List <Deck> decks)
 {
     Console.WriteLine("Select one Deck:");
     for (int i = 0; i < decks.Count; i++)
     {
         Console.WriteLine($"({i}) Deck {i+1}");
         foreach (Card card in decks[i].Cards)
         {
             Console.WriteLine();
             if (card.Type == EnumType.melee || card.Type == EnumType.range || card.Type == EnumType.longRange)
             {
                 CombatCard    nuevo          = (CombatCard)card;
                 List <string> caracteristica = nuevo.GetCharacteristics();
                 foreach (string mensaje in caracteristica)
                 {
                     ShowProgramMessage(mensaje);
                 }
             }
             else
             {
                 SpecialCard   nuevoSpecial  = (SpecialCard)card;
                 List <string> caracteristic = nuevoSpecial.GetCharacteristics();
                 foreach (string mensse in caracteristic)
                 {
                     ShowProgramMessage(mensse);
                 }
             }
             Console.WriteLine();
         }
     }
 }
Exemple #7
0
    public override void OnInspectorGUI()
    {
        SpecialCard card = ((GameObject)target).GetComponent <SpecialCard>();

        //SpecialCard card = (SpecialCard)target;
        base.OnInspectorGUI();
        DrawInspector(card);
    }
        public void DecksRead( )
        {
            string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + @"\Files\Decks.txt";

            List <Deck> decks_txt = new List <Deck>();

            int contador = 0;

            Deck deckt = new Deck();

            using (StreamReader reader = new StreamReader(path))
            {
                while (true)
                {
                    string line = reader.ReadLine();

                    if (line == "START")
                    {
                        Deck deckt = new Deck();
                    }
                    if (line == "END")
                    {
                        decks_txt.Add(deckt);
                    }
                    if (line == null)
                    {
                        break;
                    }
                    else
                    {
                        string[] attributes = line.Split(",");

                        int tipecard = 0;

                        foreach (string attribute in attributes)
                        {
                            tipecard++;
                        }

                        if (tipecard == 3)
                        {
                            SpecialCard specialCard = new SpecialCard(attributes[1], attributes[0], attributes[2]);
                            deckt.AddCard(specialCard);
                        }
                        if (tipecard == 5)
                        {
                            CombatCard combatcard = new CombatCard(attributes[1], attributes[0], attributes[2], Int32.Parse(attributes[3]), Boolean.Parse(attributes[4]));
                            deckt.AddCard(combatcard);
                        }
                    }

                    contador++;
                }
            }

            this.decks = decks_txt;
        }
 public Player(int lifePoints, int attackPoints, Deck deck, Hand hand, Board board, SpecialCard captain)
 {
     this.lifePoints   = lifePoints;
     this.attackPoints = attackPoints;
     this.deck         = deck;
     this.hand         = hand;
     this.board        = board;
     this.captain      = captain;
 }
Exemple #10
0
 public static void DrawInspector(SpecialCard card)
 {
     EditorGUILayout.LabelField("ID", card.ID.ToString());
     EditorGUILayout.LabelField("Name", card.Name);
     EditorGUILayout.LabelField("Art", card.Art);
     EditorGUILayout.LabelField("Ability", card.Ability.ToString());
     if (card.Ability == Card.Abilities.Weather)
     {
         EditorGUILayout.LabelField("Weather", card.WeatherType.ToString());
     }
 }
Exemple #11
0
        public void Leer_archivo()
        {
            StreamReader reader = new StreamReader("Decks.txt");
            int          i      = 0;

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == "START" || line == "END")
                {
                    i++;
                }
                else
                {
                    if (line.Contains("Combat"))
                    {
                        var        c = line.Split(",");
                        CombatCard carta_de_combate = new CombatCard(c[1], c[2], c[3], int.Parse(c[4]), bool.Parse(c[5]));
                        if (i == 1)
                        {
                            player1_cards.Add(carta_de_combate);
                        }
                        else
                        {
                            player2_cards.Add(carta_de_combate);
                        }

                        if (line.Contains("Special"))
                        {
                            var         x = line.Split(",");
                            SpecialCard carta_especial = new SpecialCard(x[1], x[2], x[3]);
                            if (i == 2)
                            {
                                player2_cards.Add(carta_especial);
                            }
                            else
                            {
                                player2_cards.Add(carta_especial);
                            }
                        }
                    }

                    /*
                     * decks.Add(player1_cards);
                     * decks.Add(player2_cards);
                     */
                }
                //Agrego el mazo a la lista decks

                Console.WriteLine(line);
            }

            reader.Close();
        }
Exemple #12
0
        private static TichuCard GetCard(string parsedCard)
        {
            SpecialCard special = SpecialCard.None;

            // Early out for specials
            switch (parsedCard)
            {
            case "Ph":
                special = SpecialCard.Phoenix;
                break;

            case "Hu":
                special = SpecialCard.Dog;
                break;

            case "Dr":
                special = SpecialCard.Dragon;
                break;

            case "Ma":
                special = SpecialCard.Mahjong;
                break;
            }

            // First character is suit
            string   suit     = parsedCard.Substring(0, 1);
            CardSuit cardSuit = default(CardSuit);

            switch (suit)
            {
            case "G":
                cardSuit = CardSuit.Hearts;
                break;

            case "R":
                cardSuit = CardSuit.Clubs;
                break;

            case "B":
                cardSuit = CardSuit.Diamonds;
                break;

            case "S":
                cardSuit = CardSuit.Spades;
                break;
            }

            // Rank is 1 or 2 characters
            string   rank     = parsedCard.Substring(1);
            CardRank cardRank = (CardRank)RankFromParsedString(rank);

            return(new TichuCard(cardSuit, cardRank, special));
        }
Exemple #13
0
 /**
  * Helper method.
  * Does steps common for displaying SpecialCard - TreasureCard or RiskCard.
  */
 private void DisplaySpecialCard(SpecialCard card)
 {
     HideElements();
     detailBox.Show();
     textBox.Text = "You played a special card!";
     cardNameLabel.BorderStyle    = BorderStyle.FixedSingle;
     cardContentLabel.BorderStyle = BorderStyle.FixedSingle;
     cardContentLabel.Text        = card.Description;
     gameButton1.Text             = "Continue";
     gameButton1.Show();
     cardNameLabel.Show();
     cardContentLabel.Show();
 }
        public async Task <IActionResult> Create([Bind("CardID,CardName,CardImageURL,CardImageHiURL,CardCatID,CardTypeID,SetID,CardNum,Artist,CardRarityID,LastUpdateDate")] SpecialCard specialCard)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialCard);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CardCatID"]    = new SelectList(_context.CardCats, "CardCatID", "CardCatID", specialCard.CardCatID);
            ViewData["CardRarityID"] = new SelectList(_context.CardRarities, "CardRarityID", "CardRarityID", specialCard.CardRarityID);
            ViewData["CardTypeID"]   = new SelectList(_context.CardTypes, "CardTypeID", "CardTypeID", specialCard.CardTypeID);
            ViewData["SetID"]        = new SelectList(_context.Sets, "SetID", "SetID", specialCard.SetID);
            return(View(specialCard));
        }
Exemple #15
0
        public void Read_file_captain()
        {
            StreamReader reader = new StreamReader("Captains.txt");



            string linea = reader.ReadLine();

            if (linea.Contains("captain"))
            {
                var         z       = linea.Split(",");
                SpecialCard capitan = new SpecialCard(z[1], z[2], z[3]);
            }
            Console.WriteLine(linea);
            reader.Close();
        }
Exemple #16
0
    /// <summary>
    /// Tos the special card. 根据数据,返回特殊卡牌
    /// </summary>
    /// <returns>The special card.</returns>
    /// <param name="jsonValue">Json value.</param>
    public static SpecialCard ToSpecialCard(JsonData jsonValue)
    {
        var cardVo = new SpecialCard();

        cardVo.id = int.Parse(jsonValue["id"].ToString());

        cardVo.title = jsonValue["name"].ToString();

        cardVo.desc = jsonValue["instructions"].ToString();

        cardVo.cardPath = jsonValue["path"].ToString();

        /// <summary>
        /// The rank score.排名积分
        /// </summary>
        cardVo.rankScore = int.Parse(jsonValue["cardIntegral"].ToString());

        return(cardVo);
    }
Exemple #17
0
        public void AttachReferences(CardStorage cardStorage)
        {
            foreach (CardProgress entry in cardProgress)
            {
                Card card = cardStorage.ForId(entry.id);
                if (card != null)
                {
                    card.progress = entry;
                }
            }
            foreach (SpecialCardProgress entry in specialCardProgress)
            {
                SpecialCard specialCard = cardStorage.SpecialCard(entry.id);
                if (specialCard != null)
                {
                    specialCard.progress = entry;
                }
            }

            // Fill in the missing card progress entries
            foreach (KeyValuePair <int, Card> entry in cardStorage.Cards)
            {
                if (entry.Value.progress == null)
                {
                    CardProgress progress = new CardProgress(
                        entry.Key, CardStatus.None);
                    cardProgress.Add(progress);
                    entry.Value.progress = progress;
                }
            }
            foreach (KeyValuePair <string, SpecialCard> entry in cardStorage.SpecialCards)
            {
                if (entry.Value.progress == null)
                {
                    SpecialCardProgress progress = new SpecialCardProgress(
                        entry.Key, CardStatus.None);
                    specialCardProgress.Add(progress);
                    entry.Value.progress = progress;
                }
            }
        }
Exemple #18
0
 public void HighlightZone(Card c)
 {
     if (c.Special)
     {
         SpecialCard card = (SpecialCard)c;
         if (card.WeatherType != SpecialCard.WeatherTypes.None)
         {
             //Highlight weather zone;
         }
         else if (card.Ability == Card.Abilities.Horn)
         {
             //Highlight horn zones;
         }
         else //if ability = Scorch, Mushroom, or Decoy
         {
             //Highlight all battlefield zones;
         }
     }
     else
     {
         UnitCard card = (UnitCard)c;
         if (card.Section == UnitCard.Sections.Agile)
         {
             //Highlights melee;
             //Highlight ranged;
         }
         else if (card.Section == UnitCard.Sections.Melee)
         {
             //Highlight melee;
         }
         else if (card.Section == UnitCard.Sections.Ranged)
         {
             //Highlight ranged;
         }
         else if (card.Section == UnitCard.Sections.Siege)
         {
             //Highlight Siege;
         }
     }
 }
Exemple #19
0
 public static void Play(Player player, Deck deck, SpecialCard captain, Hand hand)
 {
     Visualization.ShowHand(hand);
 }
Exemple #20
0
 public TichuCard(CardSuit suit, CardRank rank, SpecialCard special = SpecialCard.None)
 {
     Suit    = suit;
     Rank    = rank;
     Special = special;
 }
Exemple #21
0
	void testSpecialNegativeCard(){
		Vector3 effect = new Vector3 (1, 2, 3);
		Card sp = new SpecialCard ("TestSpecialN", effect, false);
		print (sp);
	}
Exemple #22
0
	void testSpecialPositiveCard(){
		Vector3 effect = new Vector3 (2, 3, 4);
		Card sp = new SpecialCard ("TestSpecialP", effect, true);
		print (sp);
	}
Exemple #23
0
    public void ApplyEffects(Zone zone, bool apply = true)
    {
        if (zone.Type != Zone.Types.Hand && zone.Type != Zone.Types.Deck && zone.Type != Zone.Types.Discard)
        {
            if (Card.Special)
            {
                SpecialCard c = (SpecialCard)Card;
                if (c.WeatherType != SpecialCard.WeatherTypes.None)
                {
                    if (c.WeatherType == SpecialCard.WeatherTypes.Frost)
                    {
                        c.WeatherEffect(zone); //Melee row
                    }
                    else if (c.WeatherType == SpecialCard.WeatherTypes.Fog)
                    {
                        c.WeatherEffect(zone); //Ranged row
                    }
                    else if (c.WeatherType == SpecialCard.WeatherTypes.Rain)
                    {
                        c.WeatherEffect(zone); //Siege row
                    }
                    else if (c.WeatherType == SpecialCard.WeatherTypes.Storm)
                    {
                        c.WeatherEffect(zone); //Ranged row
                        c.WeatherEffect(zone); //Siege row
                    }
                    else //if (c.WeatherType == SpecialCard.WeatherTypes.Clear)
                    {
                        c.WeatherEffect(zone); //Clear Weather row
                    }
                }
                else
                {
                    //Horn, Scorch, Mushrom, Decoy stuff
                }
            }
            else
            {
                Battlefield bf = (Battlefield)Zone;

                //None, Medic, Morale, Muster, Spy, Bond, Berserker, Horn, Scorch, Mushroom
                if (apply && Card.Ability == Card.Abilities.Medic && !((UnitCard)Card).AbilityUsed)
                {
                    ((UnitCard)Card).AbilityUsed = true;
                    //display all graveyard cards
                }
                else if (Card.Ability == Card.Abilities.Morale)
                {
                    if (apply && !((UnitCard)Card).AbilityUsed)
                    {
                        bf.Morale++; //+1 morale to zone
                        ((UnitCard)Card).AbilityUsed = true;
                    }
                    else if (!apply && ((UnitCard)Card).AbilityUsed)
                    {
                        bf.Morale--;
                        ((UnitCard)Card).AbilityUsed = false;
                    }
                    //Recalc strength for zone

                    /*
                     * bf.CalcStats();
                     */
                    //StartCoroutine(((Battlefield)zone).RecalcStatsAtEndOfFrame());
                }
                else if (apply && Card.Ability == Card.Abilities.Muster)
                {
                    //select all muster cards from hand/deck

                    List <CardGO> cardsToMove = new List <CardGO>();
                    foreach (CardGO cardGO in Manager.manager.GetZone(Zone.Types.Hand).Cards)
                    {
                        if (!cardGO.Card.Special && ((UnitCard)cardGO.Card).Muster != null)
                        {
                            if (IsMusterCard(cardGO.Card, ((UnitCard)cardGO.Card).Muster))
                            {
                                cardsToMove.Add(cardGO);
                            }
                        }
                    }
                    foreach (CardGO cardGO in Manager.manager.GetZone(Zone.Types.Deck).Cards)
                    {
                        if (!cardGO.Card.Special && ((UnitCard)cardGO.Card).Muster != null)
                        {
                            if (IsMusterCard(cardGO.Card, ((UnitCard)cardGO.Card).Muster))
                            {
                                cardsToMove.Add(cardGO);
                            }
                        }
                    }
                    ((UnitCard)Card).AbilityUsed = true;

                    //play selected cards
                    while (cardsToMove.Count > 0)
                    {
                        cardsToMove[0].MoveTo(Manager.manager.GetZone(((UnitCard)cardsToMove[0].Card).GetZone));
                        ((UnitCard)cardsToMove[0].Card).AbilityUsed = true;
                        cardsToMove.Remove(cardsToMove[0]);
                    }
                }
                else if (apply && Card.Ability == Card.Abilities.Spy)
                {
                    //draw card from deck
                    ((Deck)Manager.manager.GetZone(Zone.Types.Deck)).DrawCard(Manager.manager.GetZone(Zone.Types.Hand));
                }
                else if (Card.Ability == Card.Abilities.Bond)
                {
                    //Recalc strength for zone

                    /*
                     * bf.CalcStats();
                     */
                    //StartCoroutine(((Battlefield)zone).RecalcStatsAtEndOfFrame());
                }
                else if (apply && Card.Ability == Card.Abilities.Berserker)
                {
                    //if mushroom in zone, do berseker thing
                }
                else if (Card.Ability == Card.Abilities.Horn)
                {
                    //add card to HornZorn horn units
                    if (apply && !((UnitCard)Card).AbilityUsed)
                    {
                        //if (apply && !bf.ZoneHorn.UnitHorns.Contains(this))
                        bf.ZoneHorn.UnitHorns.Add(this);
                        ((UnitCard)Card).AbilityUsed = true;
                    }
                    //else if (!apply && bf.ZoneHorn.UnitHorns.Contains(this))
                    else if (!apply && ((UnitCard)Card).AbilityUsed)
                    {
                        bf.ZoneHorn.UnitHorns.Remove(this);
                        ((UnitCard)Card).AbilityUsed = false;
                    }
                    //Recalc strength for zone

                    /*
                     * bf.CalcStats();
                     */
                    //StartCoroutine(((Battlefield)zone).RecalcStatsAtEndOfFrame());
                }
                else if (apply && Card.Ability == Card.Abilities.Scorch)
                {
                    //destroy strongest card(s) in zone
                }
                else if (apply && Card.Ability == Card.Abilities.Mushroom)
                {
                    //trigger berserker stuff
                }
                StartCoroutine(((Battlefield)zone).RecalcStatsAtEndOfFrame());
            }
        }
    }
Exemple #24
0
    public static List <GameObject> ParseText(string text)
    {
        List <GameObject> factions = new List <GameObject>();
        //Match m = Regex.Match(text, @"(faction)\s*(=)\s*({)(?s).*");
        string factionName        = null;
        bool   factionExclusivity = false;


        List <Card> cardList = new List <Card>();


        List <Match> regexMatches = new List <Match>();// = Regex.Matches(text, @"(faction)\s*(=)\s*({)(?s).*");
        string       regexInput   = text;

        //match:    'faction' + (0+ spaces) + '=' + (0+ spaces) + '{' +
        //          (everything until the end of file)
        Match ma = Regex.Match(regexInput, @"(faction)\s*=\s*{(?'data'[\s|\S]*)");

        while (ma.Success)
        {
            if (!regexMatches.Contains(ma))
            {
                regexMatches.Add(ma);
                ma = Regex.Match(ma.Groups["data"].Value, @"(faction)\s*=\s*{(?'data'[\s|\S]*)");
            }
        }
        foreach (Match factionMatch in regexMatches)
        {
            List <string> matches = new List <string>();
            //matches.Add(m.Value);
            int   OpenBracketCount  = 0;
            int   CloseBracketCount = 0;
            Match factionValues     = Regex.Match(factionMatch.Value, @"{([^{]+){");

            #region Get faction Name & Exclusivity

            factionName = GetStringProperty("Name", factionValues.Value);
            if (factionValues == null)
            {
                throw new GwantExceptions.MissingFactionName();
            }
            factionExclusivity = GetBoolProperty("Exclusive", factionValues.Value);

            #endregion

            #region Brackets
            for (int i = 0; i < factionMatch.Value.Length; i++)
            {
                char ch = factionMatch.Value[i];
                if (ch == '{')
                {
                    OpenBracketCount++;
                }
                else if (ch == '}')
                {
                    CloseBracketCount++;
                }

                if (OpenBracketCount == CloseBracketCount && OpenBracketCount > 1)
                {
                    matches.Add(factionMatch.Value.Substring(0, i));
                    break;
                }
            }

            #endregion

            foreach (string s in matches)
            {
                //List<GameObject> cardGameObjects = new List<GameObject>();

                #region Unit matches
                MatchCollection matchCollection = Regex.Matches(s, @"(unit)\s*=\s{[^{]+}");
                foreach (Match unitMatch in matchCollection)
                {
                    //get id
                    int id = GetIntProperty("ID", unitMatch.Value);
                    if (idList.Contains(id))
                    {
                        throw new GwantExceptions.DuplicateIDException(id);
                    }
                    else
                    {
                        idList.Add(id);
                    }

                    //get name
                    string name = GetStringProperty("Name", unitMatch.Value);

                    //get art
                    string art = GetStringProperty("Art", unitMatch.Value);
                    if (art == null)
                    {
                        art = name.Replace(" ", string.Empty);
                    }
                    //art = art.Replace(@"(\P{L})*", string.Empty);
                    //DO REGEX TO REPLACE INVALID FILE NAME CHARACTERS
                    art = art.Replace(":", "").Replace("'", "");
                    art = "art/" + art.ToLower() + ".jpg";

                    //get strength
                    int strength = GetIntProperty("Strength", unitMatch.Value);
                    if (strength == DEFAULT_INT_VALUE)
                    {
                        throw new GwantExceptions.InvalidStrengthException(id);
                    }

                    //get hero
                    bool hero = GetBoolProperty("Hero", unitMatch.Value); //invalid result defaults to false


                    //get ability
                    Enum           ab      = GetEnumProperty(EnumProperties.Ability, unitMatch.Value);
                    Card.Abilities ability = (ab != null) ? (Card.Abilities)ab : Card.Abilities.None;

                    //get section
                    UnitCard.Sections section = (UnitCard.Sections)GetEnumProperty(EnumProperties.Section, unitMatch.Value);


                    //if ability = muster
                    //get muster name
                    string muster = (ability == Card.Abilities.Muster) ? GetStringProperty("Muster", unitMatch.Value) : null;
                    if (muster == null && ability == Card.Abilities.Muster)
                    {
                        muster = name;
                    }

                    //if ability = scorch
                    //get scorch threshold
                    int scorch = INACTIVE_INT;
                    if (ability == Card.Abilities.Scorch)
                    {
                        scorch = GetIntProperty("Scorch", unitMatch.Value);
                        scorch = (scorch == DEFAULT_INT_VALUE) ? 10 : scorch;
                    }

                    //if ability = avenger
                    //get avenger id
                    int avenger = INACTIVE_INT;
                    if (ability == Card.Abilities.Avenger)
                    {
                        avenger = GetIntProperty("Avenger", unitMatch.Value);
                        if (avenger == DEFAULT_INT_VALUE)
                        {
                            throw new GwantExceptions.InvalidAvengerException(id);
                        }
                    }

                    //get count
                    int count = GetIntProperty("Count", unitMatch.Value);
                    count = (count == DEFAULT_INT_VALUE) ? 1 : count;

                    //Create the cards
                    for (int i = 0; i < count; i++)
                    {
                        /*
                         * GameObject go = new GameObject();
                         * UnitCard.AddComponentTo(go, id, name, art, section, strength, hero, ability, avenger, muster, scorch);
                         * go.name = name;
                         * cardGameObjects.Add(go);
                         */
                        //GameObject go = new GameObject();
                        UnitCard c = new UnitCard(id, name, art, section, strength, hero, ability, avenger, muster, scorch);
                        cardList.Add(c);
                    }
                }
                #endregion

                #region Special matches
                matchCollection = Regex.Matches(s, @"(special)\s*=\s{[^{]+}");
                foreach (Match specialMatch in matchCollection)
                {
                    //get id
                    int id = GetIntProperty("ID", specialMatch.Value);
                    if (idList.Contains(id))
                    {
                        throw new GwantExceptions.DuplicateIDException(id);
                    }
                    else
                    {
                        idList.Add(id);
                    }

                    //get name
                    string name = GetStringProperty("Name", specialMatch.Value);

                    //get art
                    string art = GetStringProperty("Art", specialMatch.Value);
                    if (art == null)
                    {
                        art = name.Replace(" ", string.Empty);
                    }
                    art = "art/" + art.ToLower() + ".jpg";


                    //get ability
                    Enum           ab      = GetEnumProperty(EnumProperties.Ability, specialMatch.Value);
                    Card.Abilities ability = (ab != null) ? (Card.Abilities)ab : Card.Abilities.None;

                    //get weather type
                    SpecialCard.WeatherTypes weatherType;
                    if (ability == Card.Abilities.Weather)
                    {
                        Enum w = GetEnumProperty(EnumProperties.Ability, specialMatch.Value);
                        weatherType = (w != null) ? (SpecialCard.WeatherTypes)w :
                                      SpecialCard.WeatherTypes.None;
                    }
                    else
                    {
                        weatherType = SpecialCard.WeatherTypes.None;
                    }


                    //get count
                    int count = GetIntProperty("Count", specialMatch.Value);
                    count = (count == DEFAULT_INT_VALUE) ? 1 : count;

                    //Create the cards
                    for (int i = 0; i < count; i++)
                    {
                        /*
                         * GameObject go = new GameObject();
                         * SpecialCard.AddComponentTo(go, id, name, art, ability, weatherType);
                         * go.name = name;
                         * cardGameObjects.Add(go);
                         */
                        SpecialCard c = new SpecialCard(id, name, art, ability, weatherType);
                        cardList.Add(c);
                    }
                }
                #endregion

                //List<Card> cardList = new List<Card>();
                //foreach (GameObject go in cardGameObjects)
                //{
                //cardList.Add(go.GetComponent<Card>());
                //}
                //GameObject go = Faction.CreateFaction(factionName, cardList, factionExclusivity);
                factions.Add(Faction.CreateFaction(factionName, cardList, factionExclusivity));
                //factions.Add(go.GetComponent<Faction>());
                //factions.Add(new Faction(factionName, cardList, factionExclusivity));
            }
        }
        //strings = matches;


        //string name = "";

        //strings = matches;
        //strings.Add(name);
        //return cards;
        return(factions);
    }
Exemple #25
0
	//loads some cards in deck
	public void initDeck(){



		deck = new List<Card> ();
		//here's just a starter deck--nothing special or significant about my choices, basically from all the previous art I've done/some intuition judgement--just to be consistent with the game

		//add 3 portals
		for (int i=0;i<3;i++){
			Card p = new PortalCard ("teleport");
			deck.Add (p);
		}

		//add attack cards (except virtual attack) and hidden passion (I believe it's too powerful/too much time to compute result of attack)
		int[] attackVal = new int[4];

		attackVal [0] = 30;
		attackVal [1] = 0;
		attackVal [2] = 0;
		attackVal [3] = 0;

		Card curveset = new AttackCard ("curveset", attackVal);
		deck.Add (curveset);
		//since no hidden passion and flowers is also rather too powerful, I'll add 2 more curvesets and just 1 more flowers
		deck.Add (curveset);
		deck.Add (curveset);

		/* weird this is causing curveset to have flowers' attack val that is rather than 30, 20+HT+CF
		attackVal [0] = 20;
		attackVal [1] = 0;
		attackVal [2] = 1;
		attackVal [3] = 1;
		*/
		int[] attackVal2 = new int[4];
		attackVal2 [0] = 20;
		attackVal2 [1] = 0;
		attackVal2 [2] = 1;
		attackVal2 [3] = 1;
		Card flowers = new AttackCard ("flowers", attackVal2);
		deck.Add (flowers);


		//add specials (2 sets)
		Vector3 effect = new Vector3 (0, 0, 0);
		for (int i=0;i<2;i++){
			effect = new Vector3(5,0,0);
			Card adderall = new SpecialCard ("adderall", effect, true);
			deck.Add (adderall);

			effect = new Vector3(5,0,0);
			Card caffeinepill = new SpecialCard ("caffeinepill", effect, true);
			deck.Add (caffeinepill);

			effect = new Vector3(5,0,0);
			Card drunk = new SpecialCard ("drunk", effect, false);
			deck.Add (drunk);

			effect = new Vector3(0,0,3);
			Card hairdo = new SpecialCard ("hairdo", effect, true);
			deck.Add (hairdo);

			effect = new Vector3(0,0,5);
			Card intimidate = new SpecialCard ("intimidate", effect, false);
			deck.Add (intimidate);

			effect = new Vector3(0,5,0);
			Card steroids = new SpecialCard ("steroids", effect, true);
			deck.Add (steroids);

			effect = new Vector3(0,5,0);
			Card trashtalk = new SpecialCard ("trashtalk", effect, false);
			deck.Add (trashtalk);

			effect = new Vector3(0,0,10);
			Card wallflowerbloom = new SpecialCard ("wallflowerbloom", effect, true);
			deck.Add (wallflowerbloom);

			effect = new Vector3(0,3,3);
			Card workout = new SpecialCard ("workout", effect, true);
			deck.Add (workout);


		}

	}
 public Board(CombatCard meleeCards, CombatCard rangeCards, CombatCard longRangeCards, SpecialCard specialMeleeCards, SpecialCard specialRangeCards, SpecialCard specialLongRangeCards, SpecialCard captainCards, SpecialCard weatherCards)
 {
     this.meleeCards            = meleeCards;
     this.rangeCards            = rangeCards;
     this.longRangeCards        = longRangeCards;
     this.specialMeleeCards     = specialMeleeCards;
     this.specialRangeCards     = specialRangeCards;
     this.specialLongRangeCards = specialLongRangeCards;
     this.captainCards          = captainCards;
     this.weatherCards          = weatherCards;
 }
        public void Play()
        {
            int  userInput         = 0;
            int  firstOrSecondUser = ActivePlayer.Id == 0 ? 0 : 1;
            int  winner            = -1;
            bool bothPlayersPlayed = false;
            int  contadorDeCambios = 0;


            while (turn < 4 && !CheckIfEndGame())
            {
                bool verificar = Visualization.ShowMenuCarga();
                if (verificar == false)
                {
                    bool drawCard = false;
                    //turno 0 o configuracion
                    if (turn == 0)
                    {
                        for (int _ = 0; _ < Players.Length; _++)
                        {
                            ActivePlayer = Players[firstOrSecondUser];
                            Visualization.ClearConsole();
                            //Mostrar mensaje de inicio
                            Visualization.ShowProgramMessage($"Player {ActivePlayer.Id + 1} select Deck and Captain:");
                            //Preguntar por deck
                            Visualization.ShowDecks(this.Decks);
                            userInput = Visualization.GetUserInput(this.Decks.Count - 1);
                            Deck deck = new Deck();
                            deck.Cards        = new List <Card>(Decks[userInput].Cards);
                            ActivePlayer.Deck = deck;
                            //Preguntar por capitan
                            Visualization.ShowCaptains(Captains);
                            userInput = Visualization.GetUserInput(this.Captains.Count - 1);
                            ActivePlayer.ChooseCaptainCard(new SpecialCard(Captains[userInput].Name, Captains[userInput].Type, Captains[userInput].Effect));
                            //Asignar mano
                            ActivePlayer.FirstHand();
                            //Mostrar mano
                            Visualization.ShowHand(ActivePlayer.Hand);
                            //Mostar opciones, cambiar carta o pasar
                            Visualization.ShowListOptions(new List <string>()
                            {
                                "Change Card", "Pass"
                            }, "Change 3 cards or ready to play:");
                            userInput = Visualization.GetUserInput(1);
                            if (userInput == 0)
                            {
                                if (contadorDeCambios < 3)
                                {
                                    Visualization.ClearConsole();
                                    Visualization.ShowProgramMessage($"Player {ActivePlayer.Id + 1} change cards:");
                                    Visualization.ShowHand(ActivePlayer.Hand);
                                    for (int i = 0; i < DEFAULT_CHANGE_CARDS_NUMBER; i++)
                                    {
                                        Visualization.ShowProgramMessage($"Input the numbers of the cards to change (max {DEFAULT_CHANGE_CARDS_NUMBER}). To stop enter -1");
                                        userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count, true);
                                        if (userInput == -1)
                                        {
                                            break;
                                        }
                                        ActivePlayer.ChangeCard(userInput);
                                        Visualization.ShowHand(ActivePlayer.Hand);
                                    }
                                }
                                else
                                {
                                    Visualization.ShowProgramMessage("Ya no puedes hacer mas cambios");
                                    Visualization.ShowProgramMessage("Presiona una tecla para continuar");
                                    Console.ReadKey();
                                    Visualization.ClearConsole();
                                }
                            }
                            else if (userInput == 1)
                            {
                                Visualization.ClearConsole();
                                Visualization.ShowHand(activePlayer.Hand);
                                Visualization.ShowProgramMessage("Ingrese el id de la carta para ver la informacion de esta");
                                userInput = Visualization.GetUserInput(activePlayer.Hand.Cards.Count, true);
                                if (userInput != -1)
                                {
                                    if (activePlayer.Hand.Cards[userInput] is CombatCard)
                                    {
                                        CombatCard    card       = activePlayer.Hand.Cards[userInput] as CombatCard;
                                        List <string> componente = new List <string>()
                                        {
                                            "Name: ", "Type: ", "Effect: ", "Attack Points: ", "Hero: "
                                        };
                                        int i = 0;
                                        foreach (string com in componente)
                                        {
                                            Visualization.ShowProgramMessage(com + card.GetCharacteristics()[i]);
                                            i++;
                                        }
                                    }
                                    else
                                    {
                                        SpecialCard   card       = activePlayer.Hand.Cards[userInput] as SpecialCard;
                                        List <string> componente = new List <string>()
                                        {
                                            "Name: ", "Type: ", "Effect: ", "Buff: "
                                        };
                                        int i = 0;
                                        foreach (string co in componente)
                                        {
                                            Visualization.ShowProgramMessage(co + card.GetCharacteristics()[i]);
                                            i++;
                                        }
                                    }
                                }
                            }
                            else if (userInput == 2)
                            {
                                firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0;
                            }
                            contadorDeCambios = 0;
                        }
                        turn += 1;
                        Save();
                    }


                    //turnos siguientes
                    else
                    {
                        while (true)
                        {
                            ActivePlayer = Players[firstOrSecondUser];
                            //Obtener lifePoints
                            int[] lifePoints = new int[2] {
                                Players[0].LifePoints, Players[1].LifePoints
                            };
                            //Obtener total de ataque:
                            int[] attackPoints = new int[2] {
                                Players[0].GetAttackPoints()[0], Players[1].GetAttackPoints()[0]
                            };
                            //Mostrar tablero, mano y solicitar jugada
                            Visualization.ClearConsole();
                            Visualization.ShowBoard(boardGame, ActivePlayer.Id, lifePoints, attackPoints);
                            //Robar carta
                            if (!drawCard)
                            {
                                ActivePlayer.DrawCard();
                                drawCard = true;
                            }
                            Visualization.ShowHand(ActivePlayer.Hand);
                            Visualization.ShowListOptions(new List <string> {
                                "Play Card", "Pass"
                            }, $"Make your move player {ActivePlayer.Id + 1}:");
                            userInput = Visualization.GetUserInput(1);
                            if (userInput == 0)
                            {
                                //Si la carta es un buff solicitar a la fila que va.
                                Visualization.ShowProgramMessage($"Input the number of the card to play. To cancel enter -1");
                                userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count, true);
                                if (userInput != -1)
                                {
                                    if (ActivePlayer.Hand.Cards[userInput].Type == EnumType.buff)
                                    {
                                        Visualization.ShowListOptions(new List <string> {
                                            "Melee", "Range", "LongRange"
                                        }, $"Choose row to buff {ActivePlayer.Id}:");
                                        int cardId = userInput;
                                        userInput = Visualization.GetUserInput(2);
                                        if (userInput == 0)
                                        {
                                            ActivePlayer.PlayCard(cardId, EnumType.buffmelee);
                                        }
                                        else if (userInput == 1)
                                        {
                                            ActivePlayer.PlayCard(cardId, EnumType.buffrange);
                                        }
                                        else
                                        {
                                            ActivePlayer.PlayCard(cardId, EnumType.bufflongRange);
                                        }
                                    }
                                    else
                                    {
                                        ActivePlayer.PlayCard(userInput);
                                    }
                                }
                                //Revisar si le quedan cartas, si no le quedan obligar a pasar.
                                if (ActivePlayer.Hand.Cards.Count == 0)
                                {
                                    firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0;
                                    Save();
                                    break;
                                }
                            }
                            else if (userInput == 1)
                            {
                                Visualization.ClearConsole();
                                Visualization.ShowHand(activePlayer.Hand);
                                Visualization.ShowProgramMessage("Ingrese el id de la carta para ver la informacion de esta");
                                userInput = Visualization.GetUserInput(activePlayer.Hand.Cards.Count, true);
                                if (userInput != -1)
                                {
                                    if (activePlayer.Hand.Cards[userInput] is CombatCard)
                                    {
                                        CombatCard    card       = activePlayer.Hand.Cards[userInput] as CombatCard;
                                        List <string> componente = new List <string>()
                                        {
                                            "Name: ", "Type: ", "Effect: ", "Attack Points: ", "Hero: "
                                        };
                                        int i = 0;
                                        foreach (string com in componente)
                                        {
                                            Visualization.ShowProgramMessage(com + card.GetCharacteristics()[i]);
                                            i++;
                                        }
                                    }
                                    else
                                    {
                                        SpecialCard   card       = activePlayer.Hand.Cards[userInput] as SpecialCard;
                                        List <string> componente = new List <string>()
                                        {
                                            "Name: ", "Type: ", "Effect: ", "Buff: "
                                        };
                                        int i = 0;
                                        foreach (string co in componente)
                                        {
                                            Visualization.ShowProgramMessage(co + card.GetCharacteristics()[i]);
                                            i++;
                                        }
                                    }
                                }
                            }
                            else if (userInput == 2)
                            {
                                firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0;
                                Save();
                                break;
                            }
                        }
                    }
                    //Cambiar al oponente si no ha jugado
                    if (!bothPlayersPlayed)
                    {
                        bothPlayersPlayed = true;
                        drawCard          = false;
                    }
                    //Si ambos jugaron obtener el ganador de la ronda, reiniciar el tablero y pasar de turno.
                    else
                    {
                        winner = GetRoundWinner();
                        if (winner == 0)
                        {
                            Players[1].LifePoints -= 1;
                        }
                        else if (winner == 1)
                        {
                            Players[0].LifePoints -= 1;
                        }
                        else
                        {
                            Players[0].LifePoints -= 1;
                            Players[1].LifePoints -= 1;
                        }
                        bothPlayersPlayed = false;
                        turn += 1;
                        //Destruir Cartas
                        BoardGame.DestroyCards();
                    }
                }
            }
            //Definir cual es el ganador.
            winner = GetWinner();
            if (winner == 0)
            {
                Visualization.ShowProgramMessage($"Player 1 is the winner!");
            }
            else if (winner == 1)
            {
                Visualization.ShowProgramMessage($"Player 2 is the winner!");
            }
            else
            {
                Visualization.ShowProgramMessage($"Draw!");
            }
            Save();
        }
Exemple #28
0
        public void SetCardId(int id)
        {
            _cardID = id;

            var tmpCard = new SpecialCard();

            if (GameModel.GetInstance.isPlayNet == true)
            {
                tmpCard = GameModel.GetInstance.netSpecialCard;
            }
            else
            {
                var tmplate = MetadataManager.Instance.GetTemplateTable <SpecialCard> ();
                var it      = tmplate.GetEnumerator();
                while (it.MoveNext())
                {
                    var value = it.Current.Value as SpecialCard;
                    if (value.id == id)
                    {
                        tmpCard = value;
                        //	isGetCard=true;
                        break;
                    }
                }
            }



            if ((int)SpecialCardType.CharityType == id)
            {
                // 慈善事业
                cardTitle     = SubTitleManager.Instance.subtitle.cardCharity;
                cardTitlePath = CardTitlePath.Special_Charity;

                var payMoney = player.cashFlow + player.totalIncome + player.innerFlowMoney;

                cardInfor = string.Format(tmpCard.desc, HandleStringTool.HandleMoneyTostring((int)(payMoney * 0.1f)));
                cardPath  = tmpCard.cardPath;

                portType = Protocol.Game_BuyCharityCard;
            }
            else if ((int)SpecialCardType.CheckDayType == id)
            {
                // 结账日

                cardTitle     = tmpCard.title;
                cardTitlePath = CardTitlePath.Special_CheckDay;

                var checkoutMoney = (player.cashFlow + player.totalIncome + player.innerFlowMoney - player.MonthPayment);
//				var paymentmoney =HandleStringTool.HandleMoneyTostring( player.MonthPayment);
//				var incomeMoney = HandleStringTool.HandleMoneyTostring(player.cashFlow + player.totalIncome + player.innerFlowMoney);

                if (GameModel.GetInstance.isPlayNet == true)
                {
                    checkoutMoney = player.netCheckDayNum;
                }

                var tmpcheckstr = HandleStringTool.HandleMoneyTostring(checkoutMoney);

                cardInfor = string.Format(tmpCard.desc, tmpcheckstr);
                cardPath  = tmpCard.cardPath;

                portType = Protocol.Game_BuyCheckDayCard;
            }
            else if ((int)SpecialCardType.InnerCheckDayType == id)
            {
                cardTitle     = tmpCard.title;
                cardTitlePath = CardTitlePath.Special_CheckDay;

                var checkoutMoney = (player.cashFlow + player.totalIncome + player.innerFlowMoney - player.MonthPayment);
                if (GameModel.GetInstance.isPlayNet == true)
                {
                    checkoutMoney = player.netCheckDayNum;
                }

                var tmpcheckstr = HandleStringTool.HandleMoneyTostring(checkoutMoney);

                cardInfor = string.Format(tmpCard.desc, tmpcheckstr, tmpcheckstr);

                cardPath = tmpCard.cardPath;

                portType = Protocol.Game_BuyCheckDayCard;
            }
            else if ((int)SpecialCardType.GiveChildType == id)
            {
                // 生孩子
                cardTitle     = SubTitleManager.Instance.subtitle.cardGetChild;
                cardTitlePath = CardTitlePath.Special_GiveChild;

                var tmpChildNum = player.childNum;

                if (GameModel.GetInstance.isPlayNet == false)
                {
                    if (tmpChildNum >= player.childNumMax)
                    {
                        var tmpMoney = (int)(player.totalMoney * 0.1f);

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

                        cardPath  = tmpCard.cardPath;
                        cardInfor = string.Format(SubTitleManager.Instance.subtitle.moreChildForBoard, player.childNumMax.ToString(), tmpMoney.ToString());
                        return;
                    }
                }
                else
                {
                    if (GameModel.GetInstance.isGiveChild == 1)
                    {
                        var tmpMoney = (int)(player.totalMoney * 0.1f);
                        if (tmpMoney < 0)
                        {
                            tmpMoney = 0;
                        }
                        cardPath  = tmpCard.cardPath;
                        cardInfor = string.Format(SubTitleManager.Instance.subtitle.moreChildForBoard, player.childNumMax.ToString(), tmpMoney.ToString());
                        return;
                    }
                }



                tmpChildNum += 1;

                if (tmpChildNum > player.childNumMax)
                {
                    tmpChildNum = player.childNumMax;
                }
                cardInfor = string.Format(tmpCard.desc, tmpChildNum.ToString(), (tmpChildNum * player.oneChildPrise).ToString());
                cardPath  = tmpCard.cardPath;

                portType = Protocol.Game_BuyGiveChildCard;
            }
            else if ((int)SpecialCardType.HealthType == id || (int)SpecialCardType.InnerHealthType == id)
            {
                // 外圈健康管理 内圈健康管理
                cardTitle     = SubTitleManager.Instance.subtitle.cardHealth;
                cardTitlePath = CardTitlePath.Special_Health;

                var payMoney = player.cashFlow + player.totalIncome + player.innerFlowMoney;
                cardInfor = string.Format(tmpCard.desc, HandleStringTool.HandleMoneyTostring(((int)(payMoney * 0.1f))));
                cardPath  = tmpCard.cardPath;

                portType = Protocol.Game_BuyHealthCard;
            }
            else if ((int)SpecialCardType.InnerStudyType == id || (int)SpecialCardType.StudyType == id)
            {
                // 进修学习 和外圈进修学习
                cardTitle     = SubTitleManager.Instance.subtitle.cardStudy;
                cardTitlePath = CardTitlePath.Special_Study;

                var payMoney = player.cashFlow + player.totalIncome + player.innerFlowMoney;
                Console.WriteLine("dddddddddddddd" + tmpCard.desc);
                cardInfor = string.Format(tmpCard.desc, HandleStringTool.HandleMoneyTostring((int)(payMoney * 0.1f)));
                cardPath  = tmpCard.cardPath;
                portType  = Protocol.Game_BuyStudyCard;
            }
        }
Exemple #29
0
        public async Task <ImportedCards> Import()
        {
            ProtoCollection collection;

            if (remoteCollectionFirst)
            {
                try {
                    collection = await new GoogleSheetsCollection().Fetch();
                }
                catch (Exception e) when(e is WebException || e is FormatException)
                {
                    Debug.LogError("[CollectionImporter] Import from Google Sheets failed: " + e.Message);
                    Debug.LogWarning("[CollectionImporter] Trying local collection...");
                    collection = LocalCollection.Fetch();
                    if (collection.cards.Count == 0)
                    {
                        Debug.LogWarning("[CollectionImporter] Import from local collection returned 0 cards");
                    }
                }
            }
            else
            {
                collection = LocalCollection.Fetch();
                if (collection.cards.Count == 0)
                {
                    Debug.LogWarning("[CollectionImporter] Import from local collection returned 0 cards, "
                                     + "trying Google Sheets...");
                    try {
                        collection = await new GoogleSheetsCollection().Fetch();
                    }
                    catch (Exception e) when(e is WebException || e is FormatException)
                    {
                        Debug.LogError("[CollectionImporter] Import from Google Sheets failed: " + e.Message);
                    }
                }
            }

            Dictionary <int, Sprite> sprites = new Dictionary <int, Sprite>();

            foreach (ProtoImage image in collection.images)
            {
                if (sprites.ContainsKey(image.id))
                {
                    Debug.LogWarning("[CollectionImporter] Duplicate id found in Images");
                    continue;
                }
                if (image.url == null)
                {
                    Debug.LogWarning("[CollectionImporter] Image (id: " + image.id + ") has a null URL");
                    continue;
                }

                Debug.Log("[CollectionImporter] Fetching image from " + image.url + " ...");
                HttpWebResponse imageResponse;
                try {
                    HttpWebRequest imageRequest = WebRequest.CreateHttp(image.url);
                    imageResponse = (HttpWebResponse)await imageRequest.GetResponseAsync();
                }
                catch (WebException e) {
                    Debug.LogError("[CollectionImporter] Request failed: " + e.Message);
                    continue;
                }

                if (imageResponse.StatusCode != HttpStatusCode.OK)
                {
                    Debug.LogWarning(
                        "[CollectionImporter] "
                        + image.url
                        + ": "
                        + (int)imageResponse.StatusCode
                        + " "
                        + imageResponse.StatusDescription);
                    continue;
                }

                Stream imageStream;
                if ((imageStream = imageResponse.GetResponseStream()) == null)
                {
                    Debug.LogWarning(
                        "[CollectionImporter] Remote host returned no image in response (URL: "
                        + image.url
                        + ")");
                    continue;
                }

                byte[]    imageData = Util.BytesFromStream(imageStream);
                Texture2D texture   = new Texture2D(1, 1);
                if (!texture.LoadImage(imageData))
                {
                    Debug.LogWarning(
                        "[CollectionImporter] Could not create sprite texture from image (URL: "
                        + image.url
                        + ")");
                    continue;
                }

                Sprite sprite = Sprite.Create(
                    texture,
                    new Rect(0.0f, 0.0f, texture.width, texture.height),
                    new Vector2(0.5f, 0.5f));
                sprites.Add(image.id, sprite);
            }

            Dictionary <int, Character> characters = new Dictionary <int, Character>();

            foreach (ProtoCharacter protoCharacter in collection.characters)
            {
                if (characters.ContainsKey(protoCharacter.id))
                {
                    Debug.LogWarning("[CollectionImporter] Duplicate id found in Characters");
                    continue;
                }
                Character character = new Character(protoCharacter.name, defaultSprite);
                sprites.TryGetValue(protoCharacter.imageId, out character.sprite);
                characters.Add(protoCharacter.id, character);
            }

            Dictionary <int, Card> cards = new Dictionary <int, Card>();

            foreach (ProtoCard protoCard in collection.cards)
            {
                if (cards.ContainsKey(protoCard.id))
                {
                    Debug.LogWarning("[CollectionImporter] Duplicate id found in Cards");
                    continue;
                }

                IFollowup   leftActionFollowup = null;
                ProtoAction leftAction         = protoCard.leftAction;
                if (leftAction.followup != null && leftAction.followup.Count > 0)
                {
                    if (leftAction.followup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] Card (id: "
                            + protoCard.id
                            + ") left action has more than one Followup");
                        continue;
                    }
                    leftActionFollowup = leftAction.followup[0];
                }
                if (leftAction.specialFollowup != null && leftAction.specialFollowup.Count > 0)
                {
                    if (leftAction.specialFollowup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] Card (id: "
                            + protoCard.id
                            + ") left action has more than one SpecialFollowup");
                        continue;
                    }
                    if (leftActionFollowup != null)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] Card (id: "
                            + protoCard.id
                            + ") left action has both types of followups");
                        continue;
                    }
                    leftActionFollowup = leftAction.specialFollowup[0];
                }

                IFollowup   rightActionFollowup = null;
                ProtoAction rightAction         = protoCard.rightAction;
                if (rightAction.followup != null && rightAction.followup.Count > 0)
                {
                    if (rightAction.followup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] Card (id: "
                            + protoCard.id
                            + ") right action has more than one Followup");
                        continue;
                    }
                    rightActionFollowup = rightAction.followup[0];
                }
                if (rightAction.specialFollowup != null && rightAction.specialFollowup.Count > 0)
                {
                    if (rightAction.specialFollowup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] Card (id: "
                            + protoCard.id
                            + ") right action has more than one SpecialFollowup");
                        continue;
                    }
                    if (rightActionFollowup != null)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] Card (id: "
                            + protoCard.id
                            + ") right action has both types of followups");
                        continue;
                    }
                    rightActionFollowup = rightAction.specialFollowup[0];
                }

                ActionOutcome leftActionOutcome  = new ActionOutcome(leftAction.statsModification, leftActionFollowup);
                ActionOutcome rightActionOutcome = new ActionOutcome(rightAction.statsModification, rightActionFollowup);

                List <ICardPrerequisite> prerequisites = new List <ICardPrerequisite>();

                bool failed = false;
                foreach (ProtoCardPrerequisite prereq in protoCard.cardPrerequisites)
                {
                    CardPrerequisite cardPrerequisite = new CardPrerequisite(prereq.id);
                    try {
                        foreach (string s in prereq.status)
                        {
                            cardPrerequisite.Status |= CardStatusFor(s);
                        }
                    }
                    catch (ArgumentException e) {
                        Debug.LogWarning("[CollectionImporter] Card (id: " + protoCard.id + "): " + e.Message);
                        failed = true;
                        break;
                    }
                    prerequisites.Add(cardPrerequisite);
                }
                if (failed)
                {
                    continue;
                }

                foreach (ProtoSpecialCardPrerequisite prereq in protoCard.specialCardPrerequisites)
                {
                    SpecialCardPrerequisite cardPrerequisite = new SpecialCardPrerequisite(prereq.id);
                    try {
                        foreach (string s in prereq.status)
                        {
                            cardPrerequisite.Status |= CardStatusFor(s);
                        }
                    }
                    catch (ArgumentException e) {
                        Debug.LogWarning("[CollectionImporter] Card (id: " + protoCard.id + "): " + e.Message);
                        failed = true;
                        break;
                    }
                    prerequisites.Add(cardPrerequisite);
                }
                if (failed)
                {
                    continue;
                }

                Card card = new Card(
                    protoCard.cardText,
                    leftAction.text,
                    rightAction.text,
                    null,
                    leftActionOutcome,
                    rightActionOutcome,
                    prerequisites);

                characters.TryGetValue(protoCard.characterId, out card.character);

                cards.Add(protoCard.id, card);
            }

            Dictionary <string, SpecialCard> specialCards = new Dictionary <string, SpecialCard>();

            foreach (ProtoSpecialCard protoSpecialCard in collection.specialCards)
            {
                if (protoSpecialCard.id == null)
                {
                    Debug.LogWarning("[CollectionImporter] Null id found in SpecialCards");
                    continue;
                }
                if (specialCards.ContainsKey(protoSpecialCard.id))
                {
                    Debug.LogWarning("[CollectionImporter] Duplicate id found in SpecialCards");
                    continue;
                }

                IFollowup          leftActionFollowup = null;
                ProtoSpecialAction leftAction         = protoSpecialCard.leftAction;
                if (leftAction.followup != null && leftAction.followup.Count > 0)
                {
                    if (leftAction.followup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] SpecialCard (id: "
                            + protoSpecialCard.id
                            + ") left action has more than one Followup");
                        continue;
                    }
                    leftActionFollowup = leftAction.followup[0];
                }
                if (leftAction.specialFollowup != null && leftAction.specialFollowup.Count > 0)
                {
                    if (leftAction.specialFollowup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] SpecialCard (id: "
                            + protoSpecialCard.id
                            + ") left action has more than one SpecialFollowup");
                        continue;
                    }
                    if (leftActionFollowup != null)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] SpecialCard (id: "
                            + protoSpecialCard.id
                            + ") left action has both types of followups");
                        continue;
                    }
                    leftActionFollowup = leftAction.specialFollowup[0];
                }

                IFollowup          rightActionFollowup = null;
                ProtoSpecialAction rightAction         = protoSpecialCard.rightAction;
                if (rightAction.followup != null && rightAction.followup.Count > 0)
                {
                    if (rightAction.followup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] SpecialCard (id: "
                            + protoSpecialCard.id
                            + ") right action has more than one Followup");
                        continue;
                    }
                    rightActionFollowup = rightAction.followup[0];
                }
                if (rightAction.specialFollowup != null && rightAction.specialFollowup.Count > 0)
                {
                    if (rightAction.specialFollowup.Count > 1)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] SpecialCard (id: "
                            + protoSpecialCard.id
                            + ") right action has more than one SpecialFollowup");
                        continue;
                    }
                    if (rightActionFollowup != null)
                    {
                        Debug.LogWarning(
                            "[CollectionImporter] SpecialCard (id: "
                            + protoSpecialCard.id
                            + ") right action has both types of followups");
                        continue;
                    }
                    rightActionFollowup = rightAction.specialFollowup[0];
                }

                IActionOutcome leftActionOutcome  = null;
                IActionOutcome rightActionOutcome = null;

                if (protoSpecialCard.id == "gameover_coal" ||
                    protoSpecialCard.id == "gameover_food" ||
                    protoSpecialCard.id == "gameover_health" ||
                    protoSpecialCard.id == "gameover_hope")
                {
                    leftActionOutcome  = new GameOverOutcome();
                    rightActionOutcome = new GameOverOutcome();
                }

                SpecialCard specialCard = new SpecialCard(
                    protoSpecialCard.cardText,
                    leftAction.text,
                    rightAction.text,
                    null,
                    leftActionOutcome,
                    rightActionOutcome);

                characters.TryGetValue(protoSpecialCard.characterId, out specialCard.character);

                specialCards.Add(protoSpecialCard.id, specialCard);
            }

            return(new ImportedCards(cards, specialCards));
        }
 public void ChooseCaptainCardlayCard(SpecialCard captainCard)
 {
     ;
 }
        //Nuevo metodo

        public void ReadAddCard()
        {
            //esta es la direccion de donde esta nuestro archivo
            string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + @"\Files\Decks.txt";
            //leer el archivo
            StreamReader reader = new StreamReader("path");
            string       line   = reader.ReadLine();
            List <Card>  mazo   = new List <Card>();

            while (true)
            {
                line = reader.ReadLine();
                if (line == "END")
                {
                    break;
                }
                string[] aux = line.Split(",");
                if (aux[0] == "CombatCard")
                {
                    CombatCard newlist = new CombatCard(aux[1], (EnumType)Enum.Parse(typeof(EnumType), aux[2]), aux[3], int.Parse(aux[4]), bool.Parse(aux[5]));
                    mazo.Add(newlist);
                }
                else
                {
                    SpecialCard newcarta = new SpecialCard(aux[1], (EnumType)Enum.Parse(typeof(EnumType), aux[2]), aux[3]);
                    mazo.Add(newcarta);
                }
            }
            //subir las cartas del jugador 1 al deck
            this.decks[0].Cards = mazo;


            line = "";
            List <Card> mazo2 = new List <Card>();

            line = reader.ReadLine();
            while (true)
            {
                line = reader.ReadLine();
                if (line == "END")
                {
                    break;
                }
                string[] separar = line.Split(",");
                if (separar[0] == "CombatCard")
                {
                    CombatCard newlist = new CombatCard(separar[1], (EnumType)Enum.Parse(typeof(EnumType), separar[2]), separar[3], int.Parse(separar[4]), bool.Parse(separar[5]));
                    mazo2.Add(newlist);
                }
                else
                {
                    SpecialCard newcarta = new SpecialCard(separar[1], (EnumType)Enum.Parse(typeof(EnumType), separar[2]), separar[3]);
                    mazo2.Add(newcarta);
                }
            }
            //añadir las cartas del juggador 2 al deck
            this.decks[1].Cards = mazo2;

            //cerrar el archivo txt
            reader.Close();
        }
        public void leer()
        {
            StreamReader reader  = new StreamReader("Decks.txt");
            StreamReader reader2 = new StreamReader("Captains.txt");
            int          i       = 0;

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();

                if (line == "START" || line == "END")
                {
                    if (line == "START")
                    {
                        i++;
                    }
                }
                else
                {
                    if (line.Contains("Combat"))
                    {
                        var a = line.Split(',');


                        EnumType enumTipo = (EnumType)Enum.Parse(typeof(EnumType), a[2]);

                        CombatCard carta = new CombatCard(a[1], enumTipo, a[3], int.Parse(a[4]), bool.Parse(a[5]));
                        if (i == 1)
                        {
                            mazo1.Add(carta);
                        }
                        else
                        {
                            mazo2.Add(carta);
                        }
                    }
                    else if (line.Contains("Special"))
                    {
                        var         a        = line.Split(',');
                        EnumType    enumTipo = (EnumType)Enum.Parse(typeof(EnumType), a[2]);
                        SpecialCard carta    = new SpecialCard(a[1], enumTipo, a[3]);
                        if (i == 1)
                        {
                            mazo1.Add(carta);
                        }
                        else
                        {
                            mazo2.Add(carta);
                        }
                    }
                }
            }

            decks[0].Cards = mazo1;
            decks[1].Cards = mazo2;



            while (!reader2.EndOfStream)
            {
                string line = reader2.ReadLine();
                var    a    = line.Split(',');
                if (line.Contains("Special"))
                {
                    EnumType    enumTipo = (EnumType)Enum.Parse(typeof(EnumType), a[2]);
                    SpecialCard carta    = new SpecialCard(a[1], enumTipo, a[3]);
                    capitanes.Add(carta);
                }
            }


            //agregar los mazos al deck



            reader.Close();
        }