Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/zazof/jteg/ProtocolFiveBuilder.java


1   /**
2     *  This class builds a Chain Of Responsability for protocol version 5 of TEG
3     *  This is the protocol used by teg servers 0.9.x
4     *
5     *  @author Yves Vandewoude
6     *  @date December 2001
7     */
8   package org.zazof.jteg;
9   
10  public class ProtocolFiveBuilder extends MessageChainBuilder
11  {
12    public ProtocolFiveBuilder()
13      {
14      if (DEBUG) System.out.println("Protocol 5: Building messagechain");
15      // The chain is roughly build so that messages that occur often are at the beginning of the chain.
16      // The chain is built from back to front
17  
18      Message gbm = new GameBusyMessage(null);    
19      Message plc = new PlayerColorMessage(gbm);
20      Message cpm = new ClientPlayerMessage(plc);
21      Message startm = new StartMessageProt5(cpm);
22      Message wm = new WinnerMessage(startm);
23      Message mission = new MissionMessage(wm);
24      Message npm = new NewPlayerMessageProt4(mission);
25      Message lm = new LoserMessage(npm);
26      Message errorm = new ErrorMessage(lm);
27      Message ecm = new ExchangeCardMessage(errorm);
28      Message rgam = new RegroupArmiesMessage(ecm);
29      Message tm = new TurnMessage(rgam);
30      Message rcm = new ReceiveCardMessage(tm);
31      Message raam = new RegroupAfterAttackMessage(rcm);
32      Message psm = new PlayerStatusMessage(raam);
33      Message sm = new StatusMessageProt5(psm);
34      Message cm = new CountryMessage(sm);
35      Message pnam = new PlaceArmiesMessage(cm);
36      Message am = new AttaqueMessage(pnam);
37      Message chatm = new ChatMessage(am);  
38      Message dm = new DiceMessage(chatm);
39      
40      $entryPoint = dm;      
41      }
42    
43    /**
44      *  Returns the first Message of the MessageChain that needs to be used as entrypoint
45      *
46      */
47    public Message returnEntryPoint()
48      {
49        return $entryPoint;
50      }
51      
52    Message $entryPoint;
53    private final static boolean DEBUG = false;  
54  }  
55