oEtG Forum

General Category => Game Bugs => Fixed Bugs => Topic started by: timpa on December 02, 2014, 08:30:16 pm

Title: Autoconvert
Post by: timpa on December 02, 2014, 08:30:16 pm
Sometimes the button works, sometimes it doesn't work at all.
Title: Re: Autoconvert
Post by: kirbylover314 on December 03, 2014, 01:09:14 am
It doesn't autoconvert account bound cards, iirc
Title: Re: Autoconvert
Post by: timpa on December 05, 2014, 12:27:01 pm
Well, that would make no sense at all, since I can manually convert them.
Title: Re: Autoconvert
Post by: serprex on December 05, 2014, 01:25:58 pm
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
Title: Re: Autoconvert
Post by: timpa on January 14, 2015, 01:55:12 pm
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
Title: Re: Autoconvert
Post by: serprex on January 17, 2015, 10:55:16 pm
Overhauled algorithm (https://github.com/serprex/openEtG/commit/e06df17887896e71539f33e13026ac3a946fb02c)

It'll now downgrade cards, as it's output is predetermined by the effective number of unupped copies one owns
Title: Re: Autoconvert
Post by: timpa on January 18, 2015, 12:38:33 am
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'