Stock component - getSelecteItems output array

Game development with Board Game Arena Studio
Post Reply
emanueles
Posts: 13
Joined: 06 November 2011, 17:09

Stock component - getSelecteItems output array

Post 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
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: Stock component - getSelecteItems output array

Post 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...
emanueles
Posts: 13
Joined: 06 November 2011, 17:09

Re: Stock component - getSelecteItems output array

Post 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.
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: Stock component - getSelecteItems output array

Post 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,
Post Reply

Return to “Developers”