| Home >> All >> com >> adorphuye >> othello >> [ player Javadoc ] |
Source code: com/adorphuye/othello/player/PlayerDecorator.java
1 /* 2 * PlayerDecorator.java 3 * 4 * Created on 16 February 2002, 12:59 5 */ 6 7 package com.adorphuye.othello.player; 8 9 import com.adorphuye.othello.gui.board.*; 10 import com.adorphuye.othello.*; 11 import java.awt.*; 12 import java.awt.event.*; 13 import java.util.*; 14 import java.io.*; 15 16 /** 17 * 18 * @author root 19 */ 20 public class PlayerDecorator extends Player implements MouseListener 21 { 22 private Player decoratedPlayer = null; 23 24 public PlayerDecorator() 25 { 26 } 27 28 /** Creates a new instance of PlayerDecorator 29 * @param p 30 * @param num */ 31 public PlayerDecorator(Player p, int num) 32 { 33 super(p.getModel(),num); 34 setPlayer(p); 35 } 36 37 /** 38 * @param p */ 39 public void setPlayer(Player p) 40 { 41 if(p!=null) 42 { 43 decoratedPlayer = null; 44 System.runFinalization(); 45 decoratedPlayer = p; 46 } 47 else 48 { 49 throw new IllegalArgumentException("Cannot decorate a NULL Player"); 50 } 51 } 52 53 public void play() 54 { 55 if(decoratedPlayer!=null) 56 { 57 decoratedPlayer.play(); 58 } 59 else 60 { 61 throw new IllegalArgumentException("Cannot play a NULL Player"); 62 } 63 } 64 65 /** 66 * @return */ 67 public Player getPlayer() 68 { 69 return decoratedPlayer; 70 } 71 72 /** 73 * @param mouseEvent */ 74 public void mousePressed(java.awt.event.MouseEvent mouseEvent) 75 { 76 } 77 78 /** 79 * @param mouseEvent */ 80 public void mouseEntered(java.awt.event.MouseEvent mouseEvent) 81 { 82 } 83 84 /** 85 * @param mouseEvent */ 86 public void mouseClicked(java.awt.event.MouseEvent mouseEvent) 87 { 88 if(getPlayer() instanceof HumanPlayer) 89 { 90 ((HumanPlayer)getPlayer()).mouseClicked(mouseEvent); 91 } 92 } 93 94 /** 95 * @param mouseEvent */ 96 public void mouseReleased(java.awt.event.MouseEvent mouseEvent) 97 { 98 } 99 100 /** 101 * @param mouseEvent */ 102 public void mouseExited(java.awt.event.MouseEvent mouseEvent) 103 { 104 } 105 106 /** 107 * @return */ 108 public int getIndex() 109 { 110 int retValue; 111 112 retValue = getPlayer().getIndex(); 113 return retValue; 114 } 115 116 /** 117 * @return */ 118 public BoardDataModel getModel() 119 { 120 BoardDataModel retValue; 121 122 retValue = getPlayer().getModel(); 123 return retValue; 124 } 125 126 /** 127 * @param evt */ 128 public void boardChanged(BoardEvent evt) 129 { 130 getPlayer().boardChanged(evt); 131 } 132 133 /** 134 * @return */ 135 public int getSide() 136 { 137 int retValue; 138 139 retValue = getPlayer().getSide(); 140 return retValue; 141 } 142 143 /** 144 * @return */ 145 public String toString() 146 { 147 String retValue; 148 149 retValue = getPlayer().toString(); 150 return retValue; 151 } 152 153 /** 154 * @param mod */ 155 public void setModel(BoardDataModel mod) 156 { 157 getPlayer().setModel(mod); 158 } 159 160 public void reset() 161 { 162 getPlayer().reset(); 163 } 164 165 }