Tohle je můj bash script, který ti z wowheadu vytáhne talenty pro jednotlivé classy a zapíše do souborů talents_(class).php
#!/bin/bash
function parser(){
cat $1 | grep "new Listview" | sed 's:}:\n:g'| sed "s:new Listview({template\: 'spell', id\: 'spells', visibleCols\: \['level', 'school'\], hiddenCols\: \['reagents'\], \_noTalents\: 1, data\: \[:,:" | sed "s:rank\:'\(.*\)': \(\1\):g" | sed "s:,reagents\:\[\[.[0-9,]*\]\]::g" | cut -f2,8 -d: | cut -f1,3 -d, | sed "s:{id\:::g" | sed "s:[,;]::g" | sed "s:Rank ::" | sed "s:\([a-zA-Z]\)::g" | sed "s:\([0-9]\)$:\1 \(1\):" | sed "s:()$:\(1\):" | sed "s:)$::" | sed "s:]::" | sed "s: (: => ':" | sed "s:\([0-9]\)$:\1',:" | sed '/^$/d' > $2
}
a=1
b=1
while [ "$b" -le 11 ]; do
case "$b" in
1 )
url[1]='http://www.wowhead.com/?spells=-2.1.26'
url[2]='http://www.wowhead.com/?spells=-2.1.256'
url[3]='http://www.wowhead.com/?spells=-2.1.257'
;;
2 )
url[1]='http://www.wowhead.com/?spells=-2.2.594'
url[2]='http://www.wowhead.com/?spells=-2.2.267'
url[3]='http://www.wowhead.com/?spells=-2.2.184'
;;
3 )
url[1]='http://www.wowhead.com/?spells=-2.3.50'
url[2]='http://www.wowhead.com/?spells=-2.3.163'
url[3]='http://www.wowhead.com/?spells=-2.3.51'
;;
4 )
url[1]='http://www.wowhead.com/?spells=-2.4.253'
url[2]='http://www.wowhead.com/?spells=-2.4.38'
url[3]='http://www.wowhead.com/?spells=-2.4.39'
;;
5 )
url[1]='http://www.wowhead.com/?spells=-2.5.613'
url[2]='http://www.wowhead.com/?spells=-2.5.56'
url[3]='http://www.wowhead.com/?spells=-2.5.78'
;;
6 )
url[1]='http://www.wowhead.com/?spells=-2.6.770'
url[2]='http://www.wowhead.com/?spells=-2.6.771'
url[3]='http://www.wowhead.com/?spells=-2.6.772'
;;
7 )
url[1]='http://www.wowhead.com/?spells=-2.7.375'
url[2]='http://www.wowhead.com/?spells=-2.7.373'
url[3]='http://www.wowhead.com/?spells=-2.7.374'
;;
8 )
url[1]='http://www.wowhead.com/?spells=-2.8.237'
url[2]='http://www.wowhead.com/?spells=-2.8.8'
url[3]='http://www.wowhead.com/?spells=-2.8.6'
;;
9 )
url[1]='http://www.wowhead.com/?spells=-2.9.355'
url[2]='http://www.wowhead.com/?spells=-2.9.354'
url[3]='http://www.wowhead.com/?spells=-2.9.593'
;;
11 )
url[1]='http://www.wowhead.com/?spells=-2.11.574'
url[2]='http://www.wowhead.com/?spells=-2.11.134'
url[3]='http://www.wowhead.com/?spells=-2.11.573'
;;
* )
exit 0
;;
esac
while [ $a -le 3 ]; do
file=$(echo ${url[$a]} | sed 's:http\:\/\/www\.wowhead\.com\/:index\.html:')
wget ${url[$a]} && parser $file $a.tmp
echo "$b/$a"
rm $file
let a=a+1
done
a=1
c=1
while [ $c -le 3 ]; do
POSLEDNI=$(cat $c.tmp | tail -1)
SOUBOR=$(cat $c.tmp | sed '$d')
echo $SOUBOR > $c.tmp
echo $POSLEDNI | sed 's:,,:' >> $c.tmp
SOUBOR=$(echo "$c => array ("; cat $c.tmp)
echo $SOUBOR | sed 's:,:,\n:g' | sed '/^$/d' > $c.tmp
let c=c+1
done
c=1
SOUBOR=$(cat 3.tmp | sed 's:),); ?>:')
echo $SOUBOR | sed "s:,:,\n:" > 3.tmp
echo $(echo '<? $talent_id = array('; cat 1.tmp 2.tmp 3.tmp) > talents_$b.tmp
cat talents_$b.tmp | sed 's:,:,\n:g' > talents_$b.php
rm 1.tmp 2.tmp 3.tmp talents_$b.tmp
let b=b+1
if [ "$b" == "10" ]; then
b=11
fi
done
Takhle pak vypadá hotový talents_1.php. Stačí podle id spellu přičíst jeho rank.
<? $talent_id = array( 1 => array ( 12296 => '1',
46924 => '1',
29836 => '1',
29859 => '2',
12834 => '1',
12849 => '2',
12867 => '3',
16462 => '1',
16463 => '2',
16464 => '3',
16465 => '4',
16466 => '5',
29623 => '1',
16493 => '1',
16494 => '2',
12285 => '1',
12697 => '2',
12289 => '1',
12668 => '2',
23695 => '3',
12282 => '1',
12663 => '2',
12664 => '3',
35446 => '1',
35448 => '2',
35449 => '3',
12290 => '1',
12963 => '2',
12286 => '1',
12658 => '2',
12300 => '1',
12959 => '2',
12960 => '3',
64976 => '1',
12284 => '1',
12701 => '2',
12702 => '3',
12703 => '4',
12704 => '5',
12294 => '1',
12700 => '1',
12781 => '2',
12783 => '3',
12784 => '4',
12785 => '5',
29834 => '1',
29838 => '2',
46865 => '1',
46866 => '2',
29723 => '1',
29725 => '2',
29724 => '3',
12328 => '1',
12281 => '1',
12812 => '2',
12813 => '3',
12814 => '4',
12815 => '5',
12295 => '1',
12676 => '2',
12677 => '3',
56636 => '1',
56637 => '2',
56638 => '3',
46854 => '1',
46855 => '2',
12163 => '1',
12711 => '2',
12712 => '3',
46859 => '1',
46860 => '2',
20504 => '1',
20505 => '2',
46867 => '1',
56611 => '2',
56612 => '3',
56613 => '4',
56614 => '5'),
2 => array ( 61216 => '1',
61221 => '2',
61222 => '3',
16487 => '1',
16489 => '2',
16492 => '3',
46913 => '1',
46914 => '2',
46915 => '3',
23881 => '1',
12321 => '1',
12835 => '2',
12318 => '1',
12857 => '2',
12858 => '3',
12860 => '4',
12861 => '5',
12320 => '1',
12852 => '2',
12853 => '3',
12855 => '4',
12856 => '5',
12292 => '1',
23584 => '1',
23585 => '2',
23586 => '3',
23587 => '4',
23588 => '5',
12317 => '1',
13045 => '2',
13046 => '3',
13047 => '4',
13048 => '5',
12319 => '1',
12971 => '2',
12972 => '3',
12973 => '4',
12974 => '5',
46910 => '1',
46911 => '2',
60970 => '1',
20500 => '1',
20501 => '2',
29759 => '1',
29760 => '2',
29761 => '3',
29762 => '4',
29763 => '5',
12329 => '1',
12950 => '2',
20496 => '3',
12324 => '1',
12876 => '2',
12877 => '3',
12878 => '4',
12879 => '5',
20502 => '1',
20503 => '2',
29888 => '1',
29889 => '2',
12862 => '1',
12330 => '2',
29721 => '1',
29776 => '2',
46908 => '1',
46909 => '2',
56924 => '3',
12323 => '1',
29590 => '1',
29591 => '2',
29592 => '3',
29801 => '1',
46917 => '1',
12322 => '1',
12999 => '2',
13000 => '3',
13001 => '4',
13002 => '5',
56927 => '1',
56929 => '2',
56930 => '3',
56931 => '4',
56932 => '5'),
3 => array ( 12297 => '1',
12750 => '2',
12751 => '3',
12752 => '4',
12753 => '5',
12809 => '1',
47294 => '1',
47295 => '2',
47296 => '3',
58872 => '1',
58874 => '2',
20243 => '1',
29787 => '1',
29790 => '2',
29792 => '3',
12311 => '1',
12958 => '2',
12301 => '1',
12818 => '2',
29593 => '1',
29594 => '2',
12313 => '1',
12804 => '2',
12312 => '1',
12803 => '2',
12797 => '1',
12799 => '2',
59088 => '1',
59089 => '2',
12287 => '1',
12665 => '2',
12666 => '3',
50685 => '1',
50686 => '2',
50687 => '3',
12975 => '1',
16538 => '1',
16539 => '2',
16540 => '3',
16541 => '4',
16542 => '5',
12308 => '1',
12810 => '2',
12811 => '3',
46945 => '1',
46949 => '2',
29598 => '1',
29599 => '2',
12298 => '1',
12724 => '2',
12725 => '3',
12726 => '4',
12727 => '5',
46968 => '1',
46951 => '1',
46952 => '2',
46953 => '3',
12299 => '1',
12761 => '2',
12762 => '3',
12763 => '4',
12764 => '5',
50720 => '1',
29140 => '1',
29143 => '2',
29144 => '3',
57499 => '1')); ?>
Dělám to takto:
include ('../include/talents_'.$class.'.php');
$spells_q = @mysql_query("SELECT `spell` FROM `character_spell` WHERE `guid`='".$guid."' AND `active`='1'");
while ($spells_r = @mysql_fetch_array($spells_q)){
if ($talent_id[1][$spells_r[0]] > "0") $talent_c1 += $talent_id[1][$spells_r[0]];
if ($talent_id[2][$spells_r[0]] > "0") $talent_c2 += $talent_id[2][$spells_r[0]];
if ($talent_id[3][$spells_r[0]] > "0") $talent_c3 += $talent_id[3][$spells_r[0]];
}
//příklad
echo "talenty ".$talent_c1."/".$talent_c2."/".$talent_c3;
Nemám to 100% otestované pro všechny možné buildy, každopádně pár pokusů co jsem udělal dopadlo dobře.