/*
** j###t ########## #### ####
** j###t ########## #### ####
** j###T "###L J###"
** ######P' ########## #########
** ######k, ########## T######T
** ####~###L ####
** #### q###L ########## .#####
** #### \###L ########## #####"
**
** $Id$
**
** Class History
**
** Date Name Description
** ---------|------------|-----------------------------------------------
** 19Aug98 subtle start of recorded history
**
*/
package key;
import key.primitive.DateTime;
import java.util.StringTokenizer;
import java.io.*;
/**
* Some sort of note
*/
public class Letter extends Material
{
public static final AtomicElement[] ELEMENTS =
{
AtomicElement.construct( Letter.class, Paragraph.class,
"contents",
AtomicElement.PUBLIC_FIELD,
"the main text of the letter" ),
AtomicElement.construct( Letter.class, String.class,
"description",
AtomicElement.PUBLIC_FIELD,
"the subject or description of the letter" ),
AtomicElement.construct( Letter.class, String.class,
"from",
AtomicElement.PUBLIC_FIELD,
"the sender of the letter" ),
AtomicElement.construct( Letter.class, DateTime.class,
"when",
AtomicElement.PUBLIC_FIELD,
"the date the letter was sent" ),
AtomicElement.construct( Letter.class, Integer.TYPE,
"readCount",
AtomicElement.PUBLIC_FIELD,
"the number of times this letter has been read" )
};
public static final AtomicStructure STRUCTURE = new AtomicStructure( Atom.STRUCTURE, ELEMENTS );
public Paragraph contents;
public String description;
public String from;
public DateTime when;
public int readCount;
public static final int MAX_SUBJECT = 50;
public Letter()
{
contents = null;
description = "<no subject>";
from = "";
when = null;
readCount = 0;
setKey( new Integer( 0 ) );
}
public void read( Player p, StringTokenizer args, InteractiveConnection ic, Flags flags, Atom item )
{
readCount++;
ic.sendLine();
ic.send( " From: " + from );
ic.send( " Date: " + when.toString( p ) );
ic.send( " Subj: " + description );
ic.blankLine();
ic.send( contents );
ic.sendLine();
}
public AtomicStructure getDeclaredStructure()
{
return( STRUCTURE );
}
public String getFullPortrait( Player p )
{ return( "letter from " + from ); }
}