View Javadoc

1   /*
2   @See License.txt@
3    */
4   
5   package spellcast.game;
6   
7   import java.util.*;
8   import spellcast.beings.*;
9   
10  /***
11   * The game log contains a transcript of the spellcast game.
12   *
13   * @author Barrie Treloar
14   */
15  public class GameLog
16  {
17      private StringBuffer transcript = new StringBuffer( 1024 );
18  
19      public GameLog()
20      {
21          transcript.append( "Spellcast Game Transcript\n\n" );
22      }
23  
24      public void log( String message )
25      {
26          transcript.append( message );
27      }
28  
29      public void logRoundHeader( Game theGame )
30      {
31          String turnTypeString = "";
32          if ( theGame.getTurn().isTimeStop() ) 
33          {
34              turnTypeString = " (Time Stop)";
35          }
36          else if ( theGame.getTurn().isHaste() )
37          {
38              turnTypeString = " (Haste)";
39          }
40  
41          log( "\n\tTurn " + theGame.getTurn().getNumber() + turnTypeString + ":\n" );
42  
43          Iterator wizardIterator = theGame.getWizards().iterator();
44          while ( wizardIterator.hasNext() )
45          {
46              Wizard wiz = (Wizard)wizardIterator.next();
47              if ( wiz.isAlive() ) 
48              {
49                  if ( wiz.isActive() ) 
50                  {
51                      log( wiz.getName() + " (" + wiz.getHitPoints() + "): " + "LEFT HAND" + " " + "RIGHTHAND" + "\n" );
52                  }
53                  else 
54                  {
55                      log( wiz.getName() + " (" + wiz.getHitPoints() + "): " + "[no gestures]\n" );
56                  }
57              }
58          }
59  
60          Iterator monsterIterator = theGame.getMonsters().iterator();
61          while ( monsterIterator.hasNext() )
62          {
63              Monster monster = (Monster)monsterIterator.next();
64              if ( monster.isAlive() ) 
65              {
66                  log( monster.getName() + " (" + monster.getHitPoints() + ")\n" );
67              }
68          }
69          log( "\n" );
70      }
71  }
72