Whether I do that or do it the way I'm doing it, it would still require that
I set revert to true or false depending on whether or not the move is legal.
So I'd have to set revert programatically. I know it can be done, but I
don't know how to do it.

It shouldn't matter whether I use ajax to verify the move or store the legal
moves locally. The ajax verification happens pretty instantaneously. The
issue becomes making it either stay at revert=true or revert=false depending
on whether or not the move is legal. Because no matter what, I need the
piece to stay there for a sec or so while the verification function checks
to see if the move is legal regardless of whether or not it's checking
locally or using ajax.

So I need it to basically go to revert=false (and center itself in the
square, which is a div) if the move is legal and revert if the move is
false. I'm not even sure if this is possible, unless I come up with
something custom.

Thanks for the response.

On 7/5/07, Jon Trelfa <[EMAIL PROTECTED]> wrote:
>
>
> On 7/5/07, Red <[EMAIL PROTECTED]> wrote:
> > I can't figure out an intelligent way to do this. If I set revert to
> true,
> > it will snap back to it's original position when I want it to stay at
> the
> > square while checking to see if the move is legit. If I set revert to
> false
> > and the move is illegal, it's not going to know where to snap back to.
> >
> > Anybody have any ideas how to go about this? Thanks in advance.
> >
>
> How about pre-fetching your legal moves for the piece using the XHR call?
> Then you can validate the move against a local set of data.  For example:
>
> In a grid where the rows are numbered and the columns are lettered,
> we'll say a pawn is in square 4A
> The pre-fetch for that piece says that it can only legally move to
> square 5A (if there were an opponent's piece in 5B, that square would
> also be returned)
> The user moves the piece forward 1 square (legally) to square 5A (If
> they tried 6A, the event would return false and snap the piece back.)
> If the ondrop event says it's "OK" for that piece, you fire off an XHR
> to get the next list of legal moves for that piece
>
> I'm sure it will get more complicated with regards to taking another
> person's piece, etc - but using Ajax before the person actually has to
> make the move would be more sensible rather than making the person
> wait for the response for each move.
>
> You could then maintain an object with 32 (16 black, 16 white)
> elements with arrays of "legal" moves.
>
> My two cents :)
>
> Jon
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to