Page 1 of 2

M15

PostPosted: 30 Jun 2014, 21:00
by quercitron
Most of M15 cards are already known, prerelease will start in two weeks. Is it possible to start working on the set? I want to implement some new cards, but I don't know how to initiate the process: add the new set and known cards in it.

Re: M15

PostPosted: 01 Jul 2014, 07:24
by LevelX
I added the M15 set to to project.

The problem with adding the new cards to the mtg-cards-data.txt file is, that the java script I used in the past to parse the spoiler page of new sets on http://www.mtgsalvation.com doesn't work, after they changed the format of the spoiler pages.

So I tend to wait until the set is added to Gatherer, where I can get the list of new cards for mtg-cards-data.txt with Gatherer Crawler.

Maybe someone can change the java script to work with the new format of the page. That would be very useful. Here the script that worked with the old format.

Code: Select all
(function(){
   var x = '';
   function printCard(card){
       var text = '';
       text += card.name + '|Magic 2014|';
       text += (card.number ? card.number : '') + '|';
       text += card.rarity[0].replace('B', 'L') + '|';
       text += ((card.cost.length > 0) ? '{' : '') + card.cost.join('}{') + ((card.cost.length > 0) ? '}|' : '|');
       text += card.type + '|';
       text += (card.pt ? card.pt.split('/').join("|") : '|') + '|';
       text += (card.abilities ? card.abilities.join('$') : '') + '|';
       return text;
   }
   $.each($('table[cellpadding=5]'), function(index, value) {
       var $value = $(value);
       var card = {};
       card.name = $value.find('td[width=220px]:eq(0) a:eq(1)').attr('name');
       card.cost = [];
       $.each($value.find('td[width=80px]:eq(0) img'), function(idx, val) {
           card.cost.push(val.alt.toUpperCase());
       });
       card.type = $value.find('td[width=220px]:eq(1)').text();
       card.rarity = $value.find('td[width=80px]:eq(1) img').attr('alt');
       var findResult = $value.find('td[colspan=2]:eq(0)');
       if(findResult.length > 0){
           var text = findResult.html().replace(/<img src="http:\/\/forums.mtgsalvation.com\/images\/smilies\/[\w\d]+?.gif" alt="/g, '{');
           text = text.replace(/">/g, '}');
           text = text.replace(/{{/g, '{');
           text = text.replace(/}}/g, '}');
           text = text.replace(/(\r\n|\n|\r)/gm,"");
           card.abilities = text.split('<br>');
       }
       findResult = $value.find('tr:last i')
       if(findResult.length > 0){
           card.number = findResult.html().replace('#', '').split('/')[0];
       }
       findResult = $value.find('tr:last td:last')
       if(findResult.length > 0){   
           card.pt = findResult.html();
       }

       if(card.name.indexOf('//') != -1){
           var card1 = {};
           var card2 = {};
           card1.name = card.name.split(' // ')[0];
           card2.name = card.name.split(' // ')[1];
           card1.cost = card.cost;
           card2.cost = [];
           card1.rarity = card.rarity;
           card2.rarity = card.rarity;
           card1.type = card.type.split(' // ')[0];
           card2.type = card.type.split(' // ')[1];
           card1.pt = card.pt.split(' // ')[0];
           card2.pt = card.pt.split(' // ')[1];
           if(card.number){
               card1.number = card.number;
               card2.number = card.number;
           }
           var first = true;
           card1.abilities = [];
           card2.abilities = [];
           for(var i = 0; i < card.abilities.length; i++){
               if(card.abilities[i].indexOf('//') != -1 || card.abilities[i].indexOf('--') != -1){
                   first = false;
               }else if (card.abilities[i].length > 0) {
                   if(first){
                       card1.abilities.push(card.abilities[i]);
                   }else{
                       card2.abilities.push(card.abilities[i]);
                   }
               }
           }
           x += printCard(card1) + '\n';
           x += printCard(card2) + '\n';
       }else{
           x += printCard(card) + '\n';
       }
   });
   console.log(x);
})();

Re: M15

PostPosted: 01 Jul 2014, 12:00
by LevelX
OK, I updated the script to work with the new format.
I'll add the current spoiler mtg-cards-data.txt.

Code: Select all
(function(){
   var x = '';
   function printCard(card){
       var text = '';
       text += card.name + '|Magic 2015|';
       text += (card.number ? card.number : '') + '|';
       text += card.rarity + '|';
       text += card.cost + '|';
       text += card.type + '|';
       text += (card.pt ? card.pt.split('/').join("|") : '|') + '|';
       text += card.abilities + '|';
       return text;
   }
   $.each($('div.t-spoiler-wrapper'), function(index, value) {
     var $value = $(value);
     var card = {};
     card.name = $value.find('div.t-spoiler').attr('id');       
     
     var findResult = $value.find('span.t-spoiler-artist').text();
     if(findResult.length > 0){
        var parts = findResult.split('#');
        card.number = parts[1].split('/')[0].trim();
     }
       
     var findResult = $value.find('span.t-spoiler-rarity').find('span:first').attr('class');
     if (findResult.substr(findResult.length - 6) == 'common') {
       card.rarity = 'C';
     } else if (findResult.substr(findResult.length - 8) == 'uncommon') {
       card.rarity = 'U';
     } else if (findResult.substr(findResult.length - 4) == 'rare') {
       card.rarity = 'R';
     } else if (findResult.substr(findResult.length - 6) == 'mythic') {
       card.rarity = 'M';
     } else if (findResult.substr(findResult.length - 4) == 'land') {
       card.rarity = 'L';
     } else {
       card.rarity = '?' + findResult;
     }
     
     var findCosts = $value.find('ul.t-spoiler-mana').find('span').text();     
     card.cost = '';
     $.each(findCosts , function (i, rowValue) {
             card.cost += '{' + rowValue + '}';
     });     

     card.type = $value.find('span.t-spoiler-type').text();
     
     card.pt = $value.find('span.t-spoiler-stat').text().replace(/\*/g,"0");
     
     var abilities = $value.find('div.t-spoiler-ability');
     abilities.find('span').replaceWith(function() { return '{' + this.innerHTML + '}' ; });
     
     card.abilities = '';
     $.each(abilities.find('p'), function (i, rowValue) {
       if (i > 0) {         
         card.abilities += '$';
       }
       card.abilities += rowValue.innerHTML.replace(/(\r\n|\n|\r)/gm,"");
     });         
     card.abilities = card.abilities.replace(/[\$]+/g,"$");
     
     x += printCard(card) + '\n';
   });   
   console.log(x);
   
})();
EDIT: Fixed the P/T bug in source code.

Re: M15

PostPosted: 01 Jul 2014, 12:56
by LevelX
Maybe you write here which cards you are going to implement, so we won't do the work twice.
I will start with the missing M15 green cards, as soon I got time and passion.

Re: M15

PostPosted: 01 Jul 2014, 15:35
by quercitron
Great, thank you!
I'll start with red cards.

Re: M15

PostPosted: 03 Jul 2014, 20:18
by LevelX
I switch to white.

Re: M15

PostPosted: 04 Jul 2014, 22:28
by quercitron
Unfortunately I'll be away for about a week and won't be able to implement new cards :(

Re: M15

PostPosted: 05 Jul 2014, 06:49
by LevelX
You're giving me a hard M15 week. #-o
Let's see what's possible.

Re: M15

PostPosted: 07 Jul 2014, 15:20
by noxx
Are we still using card tracker for dev purposes?

Re: M15

PostPosted: 07 Jul 2014, 15:27
by LevelX
noxx wrote:Are we still using card tracker for dev purposes?
Yes, as soon as the new sets are available on the Wizard gatherer I add them to the card tracker. That's because our card tracker needs the universal card id from gatherer.

Re: M15

PostPosted: 08 Jul 2014, 01:25
by emerald3x0
Sent a patch via PM to LevelX containing the M15 artifacts other than Chain Veil.

EDIT: Realized a forgot a couple. Will do them tomorrow.

Re: M15

PostPosted: 08 Jul 2014, 14:02
by LevelX
emerald3x0 wrote:Sent a patch via PM to LevelX containing the M15 artifacts other than Chain Veil.

EDIT: Realized a forgot a couple. Will do them tomorrow.
Hi emerald,

I've committed the 8 artifacts.
I also added you to the group of committers of the XMage project, so you can commit the next classes by yourself.

Re: M15

PostPosted: 08 Jul 2014, 14:14
by emerald3x0
LevelX wrote:
emerald3x0 wrote:Sent a patch via PM to LevelX containing the M15 artifacts other than Chain Veil.

EDIT: Realized a forgot a couple. Will do them tomorrow.
Hi emerald,

I've committed the 8 artifacts.
I also added you to the group of committers of the XMage project, so you can commit the next classes by yourself.
I noticed you added a couple of effect.setText() to some abilities. For which abilities do you have to add it?

Also, do you have to restart the Mage Server every time you make a change to a card? Because mine takes about 5 minutes to start and it takes forever to make small changes.

Re: M15

PostPosted: 08 Jul 2014, 15:55
by LevelX
emerald3x0 wrote:I noticed you added a couple of effect.setText() to some abilities. For which abilities do you have to add it?
Only if the text of a card combines more than one effect and modifies therefore the effect text. To get the correct text to the tooltip the best way is to use the effect.setText() method to change the standard effect text.

emerald3x0 wrote: Also, do you have to restart the Mage Server every time you make a change to a card? Because mine takes about 5 minutes to start and it takes forever to make small changes.
If you want to have the change active yes. But normally it doesn't need so much time. On Windows 7 64 bit the server restart needs about 15 seconds.
Which os and version do you use?

Re: M15

PostPosted: 08 Jul 2014, 16:08
by emerald3x0
LevelX wrote:If you want to have the change active yes. But normally it doesn't need so much time. On Windows 7 64 bit the server restart needs about 15 seconds.
Which os and version do you use?
I'm running Windows 7 32-bit on a couple of years old laptop.