Page 1 of 1

Stock component - getSelecteItems output array

Posted: 26 March 2013, 22:03
by emanueles
Hello everybody,

getSelectedItems method of Stock object doesn't return items' weights. It's useful for me having the weight of selected items because I have to order them and to check if they are in sequence. I'm using the same items structure present in Hearts, but in my game the ace comes before the 2 and not after the king.
Can getSelectItems return also the weights? Is it possible to add this feature?

Another question: I see that, when Play button is clicked in Hearts, controls are done in the server side instead of do them in client side. What's the best way? Should I do controls in client or server side?

Bye
Emanuele

Re: Stock component - getSelecteItems output array

Posted: 27 March 2013, 12:52
by Rudolf
For first question I don't know (pehraps with dojo.query().length?) , but maybe for second, the philosophy is to let in server side all the things that aren't concerning display... all the controls should (i think) be made in server side, 'cause if not, you've got possibility to unsynchronise things and probably cheat on the game. ...
hope it's an answer to your question...

Re: Stock component - getSelecteItems output array

Posted: 27 March 2013, 23:53
by emanueles
Thanks for your reply, Rudolf.
I'll try to make controls on the server side, so the problem I had with cards' weights maybe will disappear.
Thank you anyway.

Re: Stock component - getSelecteItems output array

Posted: 28 March 2013, 16:46
by sourisdudesert
Hello emanueles,

I confirm what Rudolf just said: the best thing is to create your button on server side. This is more simple as this is just a piece of HTML code to put into your template. If you want to make the button appear/disappear, you can do it with javascript (and optionally CSS).

Concerning weights: the only purpose of weight is for display purpose, so it's not relevant to add them into the "getSelectedItems". What you can do is to use the "type id" of your items as weight, so you can check that they are in sequence.

Another remark: for a "complex" thing like "check if there are in sequence", don't hesitate to check nothing on client side, and check it on server side. PHP is way more practical for this kind of stuff :)

Cheers,