Welcome Guest!
 editEverything
 Previous Message All Messages Next Message 
rewrote chess display engine in custom tags!  Tom Ritchford
 May 28, 2001 02:38 PDT 
<http://www.solvechess.com/boardTest.jsp?name=0/1/2>

compare this with the servlet:

<http://www.solvechess.com/chess>


I stuck to my original plan and it came out well.


There was a little random logic, which I hope to hide
in the <chess:represent> tag that I ran out of energy
to write tonight/this morning.

Here's the source to the page... it's very short.
The custom tags are pretty easy too...

----------------
boardTest.jsp


<%@ taglib uri="/editEverything" prefix="ee" %>
<%@ taglib uri="/chess" prefix="chess" %>

<%@ page import="com.editev.chess.*" %>

<html>
<head>
   <title>The complete game of chess.</title>
   <link rel="stylesheet" type="text/css" href="chess.css">
</head>

<body>

<ee:parameter   id="positionName" name="name">

   <% Move move = new Move(); %>

   <chess:position id="position"     name="positionName">

     <!-- now we make a format-independent table. -->
     <ee:table pad="4">
       <ee:for id="row" count="8">

         <ee:row>
           <ee:for id="column" count="8">
             <%
               move.row              = (byte) row.intValue();
               move.column           = (byte) column.intValue();
               byte   pieceIndex     = position.getPieceIndex( move );
               String piece          = GameHTML.PIECE_HTML[ pieceIndex ];

               boolean pieceIsWhite = Chess.White.is( pieceIndex );
               boolean squareIsWhite = (move.row + move.column)%2 == 0;

               String style = (pieceIsWhite ? "white" : "black") +
"On" + (squareIsWhite ? "White" : "Black");
             %>

             <ee:entry class="<%= style %>">
               <%= piece %>
             </ee:entry>

           </ee:for>
         </ee:row>

       </ee:for>
     </ee:table>

   </chess:position>

</ee:parameter>

</body>


off to a well-deserved sleep, I think!

/t

...electronic a cappella madness <http://volectrix.com>.........
...extreme internet radio        <http://extremeNY.com/radio>...
	
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Developers
 Food & Drink
 Health & Fitness
 Internet
 Music
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Software
 Sports
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.