Medieval Netwars By: Josh Allman, David Keegan jra1315

Preview:

Citation preview

Medieval Netwars

By: Josh Allman, David Keegan

www.cs.rit.edu/~jra1315

The Plan

• The Game• Design

o pattern o client (uml)o server (uml)

•  Protocolo message encodingo messageso sequence

• Demoo 2 playero 4 player (2 in each session)

• Questions

The game

 

The Game (for real)• Medieval assault recreated on (pseudo)graph paper• Troops

o Men -- Mobile utility unito Catapult -- Good against fortso Fort -- Good defensive structure

• Actionso Moveo Rest -- Regain HPo Forage -- Search for new men, fort or catapulto Attack

• Wino Kill all enemy units

Client Server Design pattern• All game logic handled on server

o prevents malicious clients • 'Thin' client; only responsible for updating the display• Standard interface-proxy-session design pattern•  Server broadcasts game state updates to all session

clients  

Client Design

 

Server Design

 

Protocol Encoding & Transmission

Serialized message objects passed via TCP

MessagesTo Client:

• turn(...)o tells whose turn it is

• win(...)o tells who won

• lose(...)o tells who lost

• set(...)o updates/adds/removes a unit

• forage(...)o tells clients that a spot has

been foraged •  message(...)

o user interaction message• close()

o closes the client

To Server:• forage(...)

o tries to find new units • move(...)

o tries to move a unit to a new

spot • attack(...)

o tries to attack a spot with a unit• rest(...)

o increases the HP of a unit• join(...)

o adds a client to the game• close(...)

o closes the connection with the client

Message Sequence: Join

client1->server    join(this,"client1","session1")client2->server     join(this,"client2","session1") server->clients in session1    set("client1",Men(1,5,20))    set("client2",Men(6,36,20))    turn("client1")

Message Sequence: Move

client->server   move("client1", Men(1, 2, 20),  3,  4) server->clients    set("client1", Men(1, 2, 0))    set("client1", Men(1, 2, 20))    turn("client2") alternate (move too far, already occupied)      message("Invalid move.")    turn("client1")

Message Sequence: Attack

client->server    attack("client1",Men(1,5,20),7,6) server->clients    set("client2",Men(7,6,0))    set("client1",Men(1,5,3))    turn("client2")

alternate (if (7,6) is empty, too far, etc)    message("Invalid attack")    turn("client1")

Message Sequence: Rest

client->server    rest("client1", Men(1, 2, 1)) server-> clients    set("client1", Men(1, 2, 20))    turn("client2")

Message Sequence: Forage

client->server   forage("client1", Men(1, 2), Catapult(3, 4)) server->clients    forage(3, 4)    set("client1", Catapult(3, 4))    turn("client2") alternate (if distance is too far, etc)   message("Invalid forage.")   turn("client1")

Demo

 

Questions?