function [ dust ] = calcdust( cards, golden, dustgoldens, dustnongolden)
value = [40,100,400,1600 ; 400,800,1600,3200];
disenchant = [5,20,100,400 ; 50,100,400,1600];
ncards = [1, 50, 86, 113, 133];%bins for each rarity
totalcards = 132;
nongoldcards = cards(find(1-(golden-1)));
goldcards = cards(find(golden-1));
dust = 0;
counts = histcounts(nongoldcards, 1:totalcards+1);
for i = 1:length(counts)
r = discretize(i, ncards);
if dustnongolden
dust = dust + (counts(i) * disenchant(1,r));
else
dust = dust + min(counts(i),2) * value(1,r); %at most 2 full value
dust = dust + max(counts(i)-2, 0) * disenchant(1,r); %rest is disenchanted
end
end
counts = histcounts(goldcards, 1:totalcards+1);
for i = 1:length(counts)
r = discretize(i, ncards);
if dustgoldens
dust = dust + counts(i) * disenchant(2,r);
else
dust = dust + min(counts(i),2) * value(2,r); %at most 2 full value
dust = dust + max(counts(i)-2, 0) * disenchant(2,r); %rest is disenchanted
end
end
end
%UNTITLED Counts all the dust in a list of cards you opened
%All duplicates (>2, or >1 for legendary) are counted as disenchanted
%The rest is counted as full dust value (40 for common, etc)
%if dustgoldens is 1, then all goldens are disenchanted no matter what
%All duplicates (>2, or >1 for legendary) are counted as disenchanted
%The rest is counted as full dust value (40 for common, etc)
%if dustgoldens is 1, then all goldens are disenchanted no matter what
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.