comments
This commit is contained in:
+39
-14
@@ -158,33 +158,40 @@ public class Room
|
|||||||
switch (readData[0])
|
switch (readData[0])
|
||||||
{
|
{
|
||||||
|
|
||||||
//spieler hat gewürfelt
|
/**
|
||||||
//1 x, x = zahl
|
* //spieler hat gewürfelt
|
||||||
|
*/
|
||||||
case 3:
|
case 3:
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
//sync to all OTHER players
|
//sync to all OTHER players
|
||||||
if (i != player)
|
if (i != player)
|
||||||
{
|
{
|
||||||
|
//!!data processing!!
|
||||||
|
//----------------------------action---player-------rolled number----free space--------
|
||||||
players[i].output.write(new byte[]{3, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{3, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//pfeil wurde ausgewählt
|
/**
|
||||||
//1 x, x = idx
|
* //pfeil wurde ausgewählt
|
||||||
|
*/
|
||||||
case 4:
|
case 4:
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
|
//!!data processing!!
|
||||||
//sync to all OTHER players
|
//sync to all OTHER players
|
||||||
if (i != player)
|
if (i != player)
|
||||||
{
|
{
|
||||||
|
//-------------------------------action----player-----arrow index--------free space-----
|
||||||
players[i].output.write(new byte[]{4, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{4, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Spieler ist fertig mit seinem Zug
|
/**
|
||||||
//1 x, x = next player
|
* //Spieler ist fertig mit seinem Zug
|
||||||
|
*/
|
||||||
case 5:
|
case 5:
|
||||||
//calculate the next player
|
//calculate the next player
|
||||||
currentPlayer++;
|
currentPlayer++;
|
||||||
@@ -195,58 +202,76 @@ public class Room
|
|||||||
//sync the activation of the current player to ALL clients
|
//sync the activation of the current player to ALL clients
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
|
//!!data processing!!
|
||||||
|
//----------------------------action--------the next player-----------free space------
|
||||||
players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Es wurde auf ein CoinField getreten (Rot oder Blau)
|
/**
|
||||||
//1 x, x = player; 2 y, y = Loose or Get
|
* //Es wurde auf ein CoinField getreten (Rot oder Blau)
|
||||||
|
*/
|
||||||
case 6:
|
case 6:
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
//sync to OTHER players
|
//sync to OTHER players
|
||||||
if (i != player)
|
if (i != player)
|
||||||
{
|
{
|
||||||
|
//!!data processing!!
|
||||||
|
//-----------------------------action--player-------losse or get------------free space--
|
||||||
players[i].output.write(new byte[]{6, (byte)player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{6, (byte)player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Eventstop (ItemShop, BuyStar, ...) ist fertig
|
/**
|
||||||
//1 x, x = player
|
* //Eventstop (ItemShop, BuyStar, ...) ist fertig
|
||||||
|
*/
|
||||||
case 7:
|
case 7:
|
||||||
//sync to ALL players
|
//sync to ALL players
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
|
//!!simple sync!!
|
||||||
|
//------------------------------action---player---------free space--------
|
||||||
players[i].output.write(new byte[]{7, (byte)player, 0, 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{7, (byte)player, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//Spieler hat einen Stern gekauft
|
/**
|
||||||
|
* //Spieler hat einen Stern gekauft
|
||||||
|
*/
|
||||||
case 8:
|
case 8:
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
|
//!!simple sync!!
|
||||||
//sync to OTHER players
|
//sync to OTHER players
|
||||||
if (i != player)
|
if (i != player)
|
||||||
{
|
{
|
||||||
|
//-----------------------------action----player----------free space------
|
||||||
players[i].output.write(new byte[]{8, (byte)player, 0, 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{8, (byte)player, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Spieler hat ein Item Gekauft
|
/**
|
||||||
//1 x, x = player; 2 y, y = Item.Type (byte)
|
* //Spieler hat ein Item Gekauft
|
||||||
|
*/
|
||||||
case 9:
|
case 9:
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
//Sync to OTHER players
|
//Sync to OTHER players
|
||||||
if (i != player)
|
if (i != player)
|
||||||
{
|
{
|
||||||
|
//!!data processing!!
|
||||||
|
//------------------------------action---player-------item ID--------free space--------
|
||||||
players[i].output.write(new byte[]{9, (byte)player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
players[i].output.write(new byte[]{9, (byte)player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//the timeout check action
|
/**
|
||||||
|
* //the timeout check action
|
||||||
|
*/
|
||||||
case 126:
|
case 126:
|
||||||
|
//!!server action!!
|
||||||
players[player].lastTimeSendTimeOutCheck = System.currentTimeMillis();
|
players[player].lastTimeSendTimeOutCheck = System.currentTimeMillis();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -84,6 +84,9 @@ public class Server
|
|||||||
byte[] readData = new byte[10];
|
byte[] readData = new byte[10];
|
||||||
|
|
||||||
//read incoming data into the buffer
|
//read incoming data into the buffer
|
||||||
|
/**
|
||||||
|
* INPUT FORMAT: [action, free space]
|
||||||
|
*/
|
||||||
input.read(readData);
|
input.read(readData);
|
||||||
|
|
||||||
//check for the incoming actions
|
//check for the incoming actions
|
||||||
@@ -107,13 +110,19 @@ public class Server
|
|||||||
//in this case a player wants to join an existing room (even the room creator will join via this method)
|
//in this case a player wants to join an existing room (even the room creator will join via this method)
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
//fill the buffer with the incoming data (second data send after inital data transfer)
|
//fill the buffer with the incoming data (second data send after inital data transfer, no server response except TCP..)
|
||||||
|
/**
|
||||||
|
* INPUT FORMAT: [roomcode]
|
||||||
|
*/
|
||||||
input.read(readData);
|
input.read(readData);
|
||||||
|
|
||||||
//deocde the roomcode to a string (ascii -> string)
|
//deocde the roomcode to a string (ascii -> string)
|
||||||
String roomCode = new String(readData, StandardCharsets.US_ASCII);
|
String roomCode = new String(readData, StandardCharsets.US_ASCII);
|
||||||
|
|
||||||
//read the third message
|
//read the third message
|
||||||
|
/**
|
||||||
|
* INPUT FORMAT: [name]
|
||||||
|
*/
|
||||||
input.read(readData);
|
input.read(readData);
|
||||||
|
|
||||||
//deocde the players name
|
//deocde the players name
|
||||||
|
|||||||
Reference in New Issue
Block a user