Player-Proxy Classes | 493
In addition to using theRefereeto show the winner and tidy ready the game for a
new round, one of the methods,displayResults( ), is used to show each player the
other’s move. So, in addition to the using the template method, it uses one of the
methods that make up the template method separately.
Player 2 Changes
The second player class also implements theISymPlayerinterface, but it’s slightly dif-
ferent, and a few parameter values have changed. All you need to do is make a few
changes inSymPlayer1. Begin by saving theSymPlayer1.asfile asSymPlayer2.as,and
then make the changes in bold in the following segments:
public class SymPlayer2 extends Sprite implements ISymPlayer
....
public function SymPlayer2( )
....
//
//makeMove: Make Move
//
public function makeMove(event:Event):void
....
moveVal=event.currentTarget.name;
if (!monitor[1] && mcheck)
....
var m:String=showText.getMove( );
if (m != "ready" && m != "Error!")
{
//Proxy 2 move
doMove(m);
//Player 2 move
localMove(m);
}
....
//
//localMove Player Move
//
public function localMove(locMove:String):void
{
playerText.setMove("player2");
if (!monitor[1])
{
p2move=locMove;
monitor[1]=true;
}
....
//
//onProxyMove: Info from server
//
public function onProxyMove(proxMove:String):void
{
playerNow=proxMove.substring(proxMove.indexOf("~")+1);