Bug - Fixed Moving exactly two kinds of item from inventory to stash does not update inventory

Cait

Member
If I take something out of my Clan Stash, Mafia notes it as gaining that item; however, it is no longer noting the related loss of an item when I return it to the Stash.

I don't know what the last version I used that handled it correctly was, since this is my first real stint in aftercore since the Valhalla thing, but I'm using r9401 at the moment.
 

slyz

Developer
Code:
> inv asshat

asshat

> stash put 1 asshat

Dropping items into stash...

> inv asshat
It seems to work for me. Maybe the response was lost in lag?
 

Cait

Member
Hm. It's working for me now... I guess it must've been a spot of whitescreening. Apologies for the false report, then.
 

Veracity

Developer
Staff member
I've seen this myself. I have the following note on my personal to-do list: "Dropping multiple items in clan stash does not detect transfer correctly". So, perhaps it only happens when you select more than one thing in the Item Manager and drop them in the stash. Or, perhaps, only when you select more than one of one thing - a plurals, issue.
I'm going to reopen this.
 

Cait

Member
Ah. Yeah, I was multi-dropping when it failed to work. Didn't think to consider that as a problem vector.
 

Veracity

Developer
Staff member
Well...I multi-dropped 5 items at a time and saw no problems. I only dropped one of each item, so plurals were not involved.

I'd like a repeatable case: "I dropped in 2 of item x and 1 of item y from the item manager, and KoLmafia did not remove item x from my inventory but did remove item y", for example.

That's why this is marked "Waiting for Info": if you see a problem, look in your session log and find the line that reports what was happening:

add to stash: 1 xxx, 1 yyy, 1, zzz

...for example, and report it here. That line is printed before you submit the URL. The actual updating of inventory comes after the request is submitted and we can look at the result text to see what KoL said actually happened.
 

Nifft

Member
Attempt was 2 stars and 2 lines from the Item Manager. Item Manager did not refresh either item's amount. Session log shows:

add to stash: 2 line, 2 star
 

Veracity

Developer
Staff member
This command:

stash put 5 line, 5 star

logs as this:

add to stash: 5 line, 5 star

submits this URL:

clan_stash.php?action=addgoodies&item1=655&qty1=5&item2=654&qty2=5

which results in this text from KoLmafia:

You add 5 stars and 5 lines to the Goodies Hoard.

ClanStashRequest uses this pattern to match that string

"You add (.*?) to the Goodies Hoard"

and get

5 stars and 5 lines

TransferItemRequest.getItemList( String, Pattern) uses this pattern to extract the items from that:

"(\\d+) ([^,]*)"

...and fails.

Doing the same thing for 5 line, 5 star, 5 star chart submits this:

clan_stash.php?action=addgoodies&item1=654&qty1=5&item2=655&qty2=5&item3=656&qty3=5

and results in this:

You add 5 stars, 5 lines, and 5 star charts to the Goodies Hoard.

And that works.

In other words, it works fine for "1 a, 2 b, and 3 c" but when you have exactly two items, there is no comma and we screw up.

I now know what needs to be done. It's just a Simple Matter of Coding to make it so. :)
 

Veracity

Developer
Staff member
Or not so easy. I'm looking for a regular expression which will match this:

1 Rock and Roll Legend

once and return groups like this:

group(1) = 1
group(2) = Rock and Roll Legend

Match this:

1 Rock and Roll Legend and 1 5-alarm saucepan

twice and return groups like this:

group(1) = 1
group(2) = Rock and Roll Legend
group(1) = 1
group(2) = 5-alarm saucepan

Match this:

1 Rock and Roll Legend, 1 5-alarm saucepan, and 1 gin and tonic

thrice and return groups like this:

group(1) = 1
group(2) = Rock and Roll Legend
group(1) = 1
group(2) = 5-alarm saucepan
group(1) = 1
group(2) = gin and tonic

No joy, so far.
 

Bale

Minion
When you consider 1337 7r0uZ0RZ and 1.21 jigawatts I consider that the solution might actually be impossible.
 

Veracity

Developer
Staff member
Maybe, maybe not. There will ALWAYS be a "count" there. That example will appear as "1 1337 7r0uZ0RZ".
 

Bale

Minion
Maybe, maybe not. There will ALWAYS be a "count" there. That example will appear as "1 1337 7r0uZ0RZ".

Ah. I take it back. So, if you find an "and" followed by a number, then you know it is a second item. Hard, but not impossible. At least until Jick implements an item called "mother hen and 2 chickens". :)

Edit:Yay for slyz! The "mother hen and 2 chickens" will still break it, but that's a problem for a possible future that may not occur.
 
Last edited:

Veracity

Developer
Staff member
Oh, sweet. I've never even tried (?=X) before. I don't understand it. :)

Use my own test program:

$ java RegexTestHarness

Enter your regex: (\d+) (.+?)(?:, (?=\d)|, and|and (?=\d)|$)
Enter input string to search: 5 stars and 5 lines
I found the text "5 stars and " starting at index 0 and ending at index 12.
group(1) = 5
group(2) = stars
I found the text "5 lines" starting at index 12 and ending at index 19.
group(1) = 5
group(2) = lines

Enter your regex: (\d+) (.+?)(?:, (?=\d)|, and|and (?=\d)|$)
Enter input string to search: 5 stars, 5 lines, and 5 star charts
I found the text "5 stars, " starting at index 0 and ending at index 9.
group(1) = 5
group(2) = stars
I found the text "5 lines, and" starting at index 9 and ending at index 21.
group(1) = 5
group(2) = lines
I found the text "5 star charts" starting at index 22 and ending at index 35.
group(1) = 5
group(2) = star charts

Enter your regex: (\d+) (.+?)(?:, (?=\d)|, and|and (?=\d)|$)
Enter input string to search: 1 Rock and Roll Legend and 1 1337 7r0uZ0RZ
I found the text "1 Rock and Roll Legend and " starting at index 0 and ending at index 27.
group(1) = 1
group(2) = Rock and Roll Legend
I found the text "1 1337 7r0uZ0RZ" starting at index 27 and ending at index 42.
group(1) = 1
group(2) = 1337 7r0uZ0RZ

Enter your regex: (\d+) (.+?)(?:, (?=\d)|, and|and (?=\d)|$)
Enter input string to search: 1 heart of rock and roll, 1 Rock and Roll Legend, and 1 1337 7r0uZ0RZ
I found the text "1 heart of rock and roll, " starting at index 0 and ending at index 27.
group(1) = 1
group(2) = heart of rock and roll
I found the text "1 Rock and Roll Legend, and" starting at index 27 and ending at index 54.
group(1) = 1
group(2) = Rock and Roll Legend
I found the text "1 1337 7r0uZ0RZ" starting at index 55 and ending at index 70.
group(1) = 1
group(2) = 1337 7r0uZ0RZ

Oooh! I'll try it in situ.
 

slyz

Developer
Good new is:
Code:
You add 1111 meat stacks to the Goodies Hoard
So no need to worry about commas in the quantity.
 

Veracity

Developer
Staff member
I had to add a space to the pattern.
Code:
(\d+) (.+?)(?:, (?=\d)|, and|and (?=\d)|$)
became
Code:
(\d+) (.+?)(?:, (?=\d)|, and| and (?=\d)|$)
...And now it works like a charm. Thanks!

Revision 9428
 
Top