oEtG Forum

Autoconvert

timpa · 7 · 8370

timpa

  • Member
  • **
    • Posts: 462
  • New to Elements
Sometimes the button works, sometimes it doesn't work at all.
« Last Edit: January 17, 2015, 10:55:25 pm by serprex »
:chroma :gravity :time


kirbylover314

  • The Meta of Christmas Past
  • Member
  • **
    • Posts: 381
It doesn't autoconvert account bound cards, iirc


timpa

  • Member
  • **
    • Posts: 462
  • New to Elements
Well, that would make no sense at all, since I can manually convert them.
:chroma :gravity :time


serprex

  • Global Moderator
  • *****
    • Posts: 1543
It doesn't consider accountbound cards, so if you have 1 accountbound & 11 non accountbound, it'll not upgrade

It's a little sloppy, but useful for doing things mostly right


timpa

  • Member
  • **
    • Posts: 462
  • New to Elements
I suggest this change to upshall

Code: [Select]
exports.upshall = function(data, user) {
var pool = etgutil.deck2pool(user.pool);
for(var code in pool){
var card = Cards.Codes[code];
if (!card || pool[code] < 12 || card.rarity == 5 || card.rarity < 1 || (card.upped && card.shiny)) continue;
var upcode = etgutil.asUpped(code, true);
if (upcode != code){
if (!(upcode in pool)) pool[upcode] = 0;
while (pool[upcode] < 6 && pool[code] >= 12){
pool[upcode]++;
pool[code] -= 6;
}
}
upcode = etgutil.asShiny(code, true);
if (upcode != code){
if (!(upcode in pool)) pool[upcode] = 0;
while (pool[code] >= 12){
pool[upcode]++;
pool[code] -= 6;
}
}
code = upcode
upcode = etgutil.asUpped(code, true);
if (upcode != code){
if (!(upcode in pool)) pool[upcode] = 0;
while (pool[code] >= 12){
pool[upcode]++;
pool[code] -= 6;
}
}
}
var newpool = "";
for(var code in pool){
if (pool[code]) newpool = etgutil.addcard(newpool, code, pool[code]);
}
user.pool = newpool;
}

since keeping the conversion only if the target has less than 6 cards ends up accumulating the cards as unshiny and unnupped (rendering the button useless). This change should accumulate any excess as shiny upped. I had to open the loop though to make this.

DISCLAIMER:

I don't really know js and this was done entirelly assuming things are similar to python and C (whatever looked closer in each line), so double check my logic. For example, I don't know if those etgutil[] are needed or if that's a way to use a namespace or something like that, or if the line 'code = upcode' works as I think it does.

serpedit Improved etgutil member referencing
« Last Edit: January 14, 2015, 02:58:22 pm by serprex »
:chroma :gravity :time


serprex

  • Global Moderator
  • *****
    • Posts: 1543
Overhauled algorithm

It'll now downgrade cards, as it's output is predetermined by the effective number of unupped copies one owns


timpa

  • Member
  • **
    • Posts: 462
  • New to Elements
I'm having trouble understanding why the second loop over pool is safe, but if you tested it and it works I'll trust you.

nevermind, spotted the 'card.upped || card.shiny'
« Last Edit: January 18, 2015, 12:44:55 am by timpa »
:chroma :gravity :time