10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

were reviewed, we’d like to focus on a more general key OOP concept for the Symmetric<br />

Proxy design pattern—flexibility.<br />

Because the Symmetric Proxy design focuses on interaction over the Internet, we<br />

need to look at two different kinds of flexibility. First, we need to look at <strong>com</strong>munication<br />

flexibility. That is, can the model be used with different <strong>com</strong>munication technologies<br />

over the Internet? Second, we must consider game flexibility. To what<br />

extent can different games be employed with the design?<br />

Communication Flexibility<br />

The first question to address is whether or not any trans-Internet <strong>com</strong>munication can<br />

work with the Symmetric Proxy pattern. Because of its ease of use and built-in features<br />

like remote shared objects, using an application such as Flash Media Server 2<br />

has a built-in disadvantage as a <strong>com</strong>munication testing and development platform<br />

for a general <strong>com</strong>munication design pattern. The server-side script automatically<br />

informs all players of the current game state in the form of one or both players having<br />

moved. Once both players have moved, the referee determines who has won and<br />

resets the game for another round.<br />

In the original model of the Symmetric Proxy and the Androgynous variation, as long<br />

as the proxy player makes the same move as the original player, whether FMS,<br />

another open socket technology, or middleware such as PHP, C#, Perl, ColdFusion,<br />

or VB.NET, is not important. The move for the proxy is the only state that really<br />

needs to be sent over the Internet. The proxy plays the move, and the referee takes<br />

care of deciding whether the proxy or its player opponent wins, displaying the out<strong>com</strong>e<br />

and resetting the variables for a new game. So any <strong>com</strong>munication system that<br />

can send the player’s state to its proxy is acceptable, meeting the criteria of <strong>com</strong>munication<br />

flexibility.<br />

Game Flexibility<br />

In the implementation you will see in this chapter, the referee’s not quite as active as<br />

the one envisioned by Heliotis and Schreiner. The primary difference is that the referee<br />

only inspects the moves after both moves have been made in a game. Because<br />

each round in a game of RPS is a <strong>com</strong>plete game, each game is over as soon as both<br />

players have moved. At this point, the referee kicks in with its template method,<br />

decides who won, displays the out<strong>com</strong>e, and resets the values to the start states.<br />

One way of reducing the referee’s work is in the UI. Players can only enter one of<br />

three different moves displayed on the buttons. The real player blocks any attempt to<br />

make any other move, such as one where the player has not made a move selection.<br />

In a more <strong>com</strong>plexgame with a wider selection of moves, either more responsibilities<br />

would be delegated to the referee or the UI would take care of allowing a wider<br />

but still limited move set.<br />

476 | Chapter 13: Symmetric Proxy Pattern

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!