Page 1 of 1

Store...

Posted: Fri Feb 06, 2009 3:18 pm
by Right2Wrong2000
I don't know if its not so much a bug as it is a pain in the bum, but whenever entering commas into the price of one's store, it causes the item to be placed in the store at minimum price. Not really a problem as of now, but when we get bigger... I could see it being a pain.

Re: Store...

Posted: Fri Feb 06, 2009 4:35 pm
by invisible
yea thats a strange one R2.. Im not one to normally use commas in my prices but did try it and that would be a pain one day...

Re: Store...

Posted: Sat Feb 07, 2009 10:23 am
by Grokly
Just a note on this one....

Different countries use different punctuation within currency amounts (prices). Some use commas, some use decimal points. Considering this, I suspect we will probably continue to not use commas to separate values of thousands.

However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.

Re: Store...

Posted: Sat Feb 07, 2009 3:15 pm
by Right2Wrong2000
Okay.. I just ended minimum pricing some stuff the other day and was like ahh!

Re: Store...

Posted: Sat Feb 07, 2009 3:38 pm
by Gobberwart
It's always a good idea to have the option "Auto-Activate on Add New Item" disabled to protect you against exactly that kind of thing.

Re: Store...

Posted: Sat Feb 07, 2009 4:29 pm
by Right2Wrong2000
Ohh! Good idea! Gobb... Your so smart...

Re: Store...

Posted: Thu Feb 12, 2009 3:53 pm
by McFeisty
It doesn't just happen in the store, when I'm trying to withdraw from stash, it takes the numbers before the comma, and that's all. I was copying and pasting a number that was displayed on the page - with commas - and it didn't take it properly (I selected 34,987 and pasted it in the box, when I had 1,234,987 as displayed in stash). Whether you want the system to work without or with commas, it ought to jive with how the game displays it, so it seems to me.

Perhaps, instead of just taking the numbers before the comma as the total amount, it could generate an error, like it does for other incorrect numbers (too large, etc.) if it encounters a comma. Would it be feasible to have the commas parsed out or something? I know, it's really just a minor annoyance, but it does happen.

Re: Store...

Posted: Thu Feb 12, 2009 5:07 pm
by Gobberwart
If only PHP understood that 1,234,567 was the same thing as 1234567, we'd be sweet, but it doesn't do that natively. PHP things a number with comma-separators is a string value, not a number, so I need to write a function to strip the commas out.

It's on the to-do list.

Re: Store...

Posted: Thu Feb 12, 2009 5:21 pm
by Gobberwart
Ok, so I just wrote the function (all 4 lines of it). Now I just have to go through ALL 700,000 or so lines of code to find everywhere that a number gets posted by a form and make it use the function. That might take a while :)

Re: Store...

Posted: Thu Feb 12, 2009 10:44 pm
by Grokly
Grokly wrote:... However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.
Looks like I spoke to soon.

See what you people do? There's more content not being created. :D

Re: Store...

Posted: Thu Feb 12, 2009 11:06 pm
by Gobberwart
Heh, it's not gonna happen tomorrow that's for sure. There's... something else I'm gonna be working on then if I hope to have it out by intermission tomorrow. And if I don't, it's kinda pointless doing at all.

At some point I WILL add the validation code in wherever it's needed. Just... not right now.

Re: Store...

Posted: Fri Feb 13, 2009 6:19 am
by Right2Wrong2000
I love the inconspicuous "something else" mentioned here. Whatever could that be!? Hehe But I appreciate you taking the time to fix that little quirk. And good luck with your "something else." Im stoked to see it!

Re: Store...

Posted: Fri Feb 13, 2009 7:07 pm
by Gobberwart
Just out of interest, I've discovered that PHP's "round" function rounds 1,234 down to 1 because, regardless of local convention, it treats both '.' and ',' the same. Which is going to make things a fraction harder than I'd like.

And you don't want to KNOW what it does to a number like "1,234,567.89"

Re: Store...

Posted: Fri Feb 13, 2009 8:11 pm
by Elusis
I want to KNOW.

Re: Store...

Posted: Sat Feb 14, 2009 2:33 pm
by Right2Wrong2000
It destroys the game. Deathstar style.

Re: Store...

Posted: Sat Feb 14, 2009 2:52 pm
by Gobberwart
I'd tell you, but the universe would probably implode.

Re: Store...

Posted: Sat Feb 14, 2009 3:43 pm
by heliosa10
It would convert it into 1,234,567,89. Or over one billion.

Re: Store...

Posted: Sat Feb 14, 2009 6:53 pm
by jimmyBUFFET
unless it only considers them interchangeable within a like group, all periods or all commas. mixing and matching is best left to Maxis games and out of coding, methinks.

-jB

Re: Store...

Posted: Sun Feb 15, 2009 11:46 am
by Gobberwart
heliosa10 wrote:It would convert it into 1,234,567,89. Or over one billion.
Actually, no. PHP's inbuild "round", "floor" and "ceil" functions consider both commas and periods to be separators, so all three round 1,234,567.89 to....

1

No, really, it just discards everything after the first separator. Crap, huh?

To do this properly, then, extra code is needed to first strip out the thousand separators and THEN round the number to an integer, ie. "1,234,567.89" -> "1234567.89" -> "1234568" (or "1234567" if we're flooring the final result).

That's great, provided that commas are thousand separators and periods decimal points. If it's the other way around for whoever enters the values, results will be VERY different.

Leave it with me.

Re: Store...

Posted: Sun Feb 15, 2009 12:08 pm
by Gobberwart
Ackkk, apparently there's more inconsistency in these separators than I originally thought. For example, the number 1234567.89, formatted correctly would be:

Australia/UK/US: 1,234,567.89
France: 1 234 567,89
Germany: 1.234.567,89

So what IS consistent? Well, in all cases, the final separator is the decimal separator, so it should be a matter of finding out what this character is, splitting the string at that point, removing all non-numeric characters from the string on the left, joining it all back together in the local format, then rounding it up or down as required.

Of course, that assumes that, in some countries, thousand separators aren't also used AFTER the decimal point (eg. 1.234.567,891.23...

Alternatively, I could just strip out everything that's not a number, since the game only accepts integers, not decimals. That would mean that "1,234,567.89", "1 234 567,89" and "1.234.567,89" would all just end up as "123456789".

See what happens when I start thinking people are actually interested in all this geekiness? I start telling you about it :)

Re: Store...

Posted: Sun Feb 15, 2009 12:16 pm
by Gobberwart
After realising yet another complication with trying to identify thousand and decimal separators based on input, I've decided that the function will treat commas as thousand separators and periods as decimal separators and that's as far as it's going to go. When I finally get around to doing it.

Re: Store...

Posted: Sun Feb 15, 2009 2:14 pm
by jimmyBUFFET
/me holds up some pom-poms because there's no way he gets all this math this early in his day.

-jB

Re: Store...

Posted: Sun Feb 15, 2009 3:27 pm
by Gobberwart
OK, SOME pages will now let you input comma-separated values. Some won't. Oh, and I found an infinite-moolah bug and fixed it so I guess I get a bugzapper.

Re: Store...

Posted: Sun Feb 15, 2009 4:04 pm
by Right2Wrong2000
You can credit that to me Gobb... Seeing as I started this thread. Haha