All pastes #620614 Raw Edit

genti

public java v1 · immutable
·published 2007-07-15 17:00 UTC
rendered paste body
public synchronized String shootAtHostSide(int x, int y)	{		String shipType;		if(guestMaximalShots > 0)		{			hostMaximalShots = maximalShots;			guestMaximalShots--;			if(hostSideGameField[x][y] == 1)			{				hostSideGameField[x][y] = 3;				for(String[] ships : hostShipsMap)				{					for(int l = 1; l < ships.length; l++) 					{						if(ships[l].startsWith((new Integer(x)).toString()) && ships[l].endsWith((new Integer(x)).toString()))						{							int count = 0;							String[] coordinates = new String[2];							StringTokenizer st = new StringTokenizer(ships[l], "x");							while(st.hasMoreTokens())							{								coordinates[count] = st.nextToken();								count++;							}							if(shipDestroyed(ships, "hostField", x, y)) 							{								destroyedHostShips++;								if(ships[0].equals("aircraft")) guestPoints += 2;								if(ships[0].equals("battleship")) guestPoints += 4;								if(ships[0].equals("destroyer")) guestPoints += 6;								if(ships[0].equals("submarine")) guestPoints += 8;								if(ships[0].equals("boat")) guestPoints += 8;								if(destroyedHostShips == totalHostShips) return "allShipsDestroyed host";								return ("destroyed host " + ships[0] + " " + determineAlignment(ships) + " " + coordinates[0] + " " + coordinates[1] + " " + new Integer(hostPoints).toString() + " " + new Integer(guestPoints).toString() + " " + new Integer(x).toString() + " " + new Integer(y).toString());							}							else return ("hit host "  + new Integer(x).toString() + " " + new Integer(y).toString());;						}					}				}			}			if(hostSideGameField[x][y] == 2) return ("alreadyHit host " + new Integer(x).toString() + " " + new Integer(y).toString());;			if(hostSideGameField[x][y] == 0) 			{				hostSideGameField[x][y] = 2;				return ("water host" + new Integer(x).toString() + " " + new Integer(y).toString());;			}		}		return "error";	}