Hi Torsten,

A Stack is a GamePiece, so the documenation is not incorrect. Pretty much all 
pieces on a board are in Stacks, even when on their own, so you will always see 
this.

To get to all individual pieces, you need to iterate through the array of 
GamePieces and if the GamePiece is a Stack, then iterate through the units in 
the Stack. 

See GlobalCommand.java for a way to do this with a PieceVisitor (preferred 
method).

Alternatively, you can do something quick and nasty like:

    GamePiece pieces[] = map.getPieces();
    for (int i = 0; i < pieces.length; i++) {
      doSomething(pieces[i]);
    }

  protected void doSomething(GamePiece piece) {
    if (piece instanceof Stack) {
      Stack s = (Stack) piece;
      for (int i = 0; i < s.getPieceCount(); i++) {
        doSomething(s.getPieceAt(i));
      }
    }
    else {
      /* Do Something here
    }
  }

Have added this to the programming FAQ.

Cheers,
Brent.

*********** REPLY SEPARATOR ***********

On 30/11/2005 at 8:31 PM Torsten Spindler wrote:
Hello,

the doc for that method states that an array of all GamePieces on the
map is returned. Seems this is not the case when stacks are in use, as a
hierarchical structure is returned (array of stacks, containing
gamepieces). I'm not sure if the use of Game Piece Layers is causing
this.

Bye,
Torsten



[Non-text portions of this message have been removed]




YAHOO! GROUPS LINKS 

 Visit your group "vassalengine" on the web.
  
 To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
  
 Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
____________________________________________________________
Brent Easton                       
Analyst/Programmer                               
University of Western Sydney                                   
Email: [EMAIL PROTECTED]



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page
http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/IMSolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/vassalengine/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to