Example #1
0
        /* - Dont do this as it will remove valid duplicate cards. Rely on the regular Sync instead,
         *
         * public void removeDupeCards()
         * {
         *  //loop through each pack. Pack filter should be up-to date even if this is called from the startup-checks.
         *  foreach (cardcast_pack pack in packs)
         *  {
         *      //add each card to one of these lists depending on whether it has been seen or not. Remove the removal ones afterwards.
         *      List<mod_xyzzy_card> validQCards = new List<mod_xyzzy_card>();
         *      List<mod_xyzzy_card> removeQCards = new List<mod_xyzzy_card>();
         *      foreach (mod_xyzzy_card c in questions.Where(y => y.category == pack.name) )
         *      {
         *          //is there a matching card already?
         *          List<mod_xyzzy_card> matchList = validQCards.Where(x => (x.category == pack.name && Helpers.common.cleanseText(x.text) == Helpers.common.cleanseText(c.text))).ToList();
         *          if (matchList.Count() > 1)
         *          {
         *              removeQCards.Add(c);
         *              //updating any references in active games.
         *              replaceCardReferences(c, matchList[0], "Q");
         *          }
         *          else
         *          {
         *              validQCards.Add(c);
         *          }
         *      }
         *      //remove any flagged cards
         *      foreach (mod_xyzzy_card c in removeQCards) { questions.Remove(c); }
         *
         *      //Repeat for answers
         *      List<mod_xyzzy_card> validACards = new List<mod_xyzzy_card>();
         *      List<mod_xyzzy_card> removeACards = new List<mod_xyzzy_card>();
         *      foreach (mod_xyzzy_card c in answers.Where(y => y.category == pack.name))
         *      {
         *          //is there a matching card already?
         *          List<mod_xyzzy_card> matchList = validACards.Where(x => (x.category == pack.name && Helpers.common.cleanseText(x.text) == Helpers.common.cleanseText(c.text))).ToList();
         *          if (matchList.Count() > 1)
         *          {
         *              removeACards.Add(c);
         *              //updating any references in active games.
         *              replaceCardReferences(c, matchList[0], "A");
         *          }
         *          else
         *          {
         *              validACards.Add(c);
         *          }
         *      }
         *      //remove any flagged cards
         *      int total = removeQCards.Count() + removeACards.Count();
         *      foreach (mod_xyzzy_card c in removeACards) { answers.Remove(c); }
         *      log("Removed " + removeQCards.Count() + " / " + removeACards.Count()
         + " duplicate q/a from " + pack.name
         + " new totals are " + questions.Where(y => y.category == pack.name).Count()
         + " / " + answers.Where(y => y.category == pack.name).Count() + " q/a."
         +          , total > 0? logging.loglevel.warn:logging.loglevel.verbose);
         +
         +
         +  }
         + }*/

        private void replaceCardReferences(mod_xyzzy_card old, mod_xyzzy_card newcard, string cardType)
        {
            foreach (chat c in Roboto.Settings.chatData)
            {
                mod_xyzzy_chatdata chatdata = (mod_xyzzy_chatdata)c.getPluginData(typeof(mod_xyzzy_chatdata));
                if (chatdata != null)
                {
                    chatdata.replaceCard(old, newcard, cardType);
                }
            }
        }