public synchronized void removeItem(int guid, int qua, int pguid) { int i = 0; if (perso1.get_GUID() == pguid) i = 1; else if (perso2.get_GUID() == pguid) i = 2; ok1 = false; ok2 = false; SocketManager.GAME_SEND_EXCHANGE_OK( perso1.get_compte().getGameThread().get_out(), ok1, perso1.get_GUID()); SocketManager.GAME_SEND_EXCHANGE_OK( perso2.get_compte().getGameThread().get_out(), ok1, perso1.get_GUID()); SocketManager.GAME_SEND_EXCHANGE_OK( perso1.get_compte().getGameThread().get_out(), ok2, perso2.get_GUID()); SocketManager.GAME_SEND_EXCHANGE_OK( perso2.get_compte().getGameThread().get_out(), ok2, perso2.get_GUID()); Objet obj = World.getObjet(guid); if (obj == null) return; String add = "|" + obj.getTemplate().getID() + "|" + obj.parseStatsString(); if (i == 1) { Couple<Integer, Integer> couple = getCoupleInList(items1, guid); int newQua = couple.second - qua; if (newQua < 1) // Si il n'y a pu d'item { items1.remove(couple); SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso1, 'O', "-", "" + guid); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso2.get_compte().getGameThread().get_out(), 'O', "-", "" + guid); } else { couple.second = newQua; SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso1, 'O', "+", "" + guid + "|" + newQua); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso2.get_compte().getGameThread().get_out(), 'O', "+", "" + guid + "|" + newQua + add); } } else if (i == 2) { Couple<Integer, Integer> couple = getCoupleInList(items2, guid); int newQua = couple.second - qua; if (newQua < 1) // Si il n'y a pu d'item { items2.remove(couple); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso1.get_compte().getGameThread().get_out(), 'O', "-", "" + guid); SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso2, 'O', "-", "" + guid); } else { couple.second = newQua; SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso1.get_compte().getGameThread().get_out(), 'O', "+", "" + guid + "|" + newQua + add); SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso2, 'O', "+", "" + guid + "|" + newQua); } } }
public synchronized void addItem(int guid, int qua, int pguid) { ok1 = false; ok2 = false; Objet obj = World.getObjet(guid); int i = 0; if (perso1.get_GUID() == pguid) i = 1; if (perso2.get_GUID() == pguid) i = 2; if (qua == 1) qua = 1; String str = guid + "|" + qua; if (obj == null) return; String add = "|" + obj.getTemplate().getID() + "|" + obj.parseStatsString(); SocketManager.GAME_SEND_EXCHANGE_OK( perso1.get_compte().getGameThread().get_out(), ok1, perso1.get_GUID()); SocketManager.GAME_SEND_EXCHANGE_OK( perso2.get_compte().getGameThread().get_out(), ok1, perso1.get_GUID()); SocketManager.GAME_SEND_EXCHANGE_OK( perso1.get_compte().getGameThread().get_out(), ok2, perso2.get_GUID()); SocketManager.GAME_SEND_EXCHANGE_OK( perso2.get_compte().getGameThread().get_out(), ok2, perso2.get_GUID()); if (i == 1) { Couple<Integer, Integer> couple = getCoupleInList(items1, guid); if (couple != null) { couple.second += qua; SocketManager.GAME_SEND_EXCHANGE_MOVE_OK( perso1, 'O', "+", "" + guid + "|" + couple.second); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso2.get_compte().getGameThread().get_out(), 'O', "+", "" + guid + "|" + couple.second + add); return; } SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso1, 'O', "+", str); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso2.get_compte().getGameThread().get_out(), 'O', "+", str + add); items1.add(new Couple<Integer, Integer>(guid, qua)); } else if (i == 2) { Couple<Integer, Integer> couple = getCoupleInList(items2, guid); if (couple != null) { couple.second += qua; SocketManager.GAME_SEND_EXCHANGE_MOVE_OK( perso2, 'O', "+", "" + guid + "|" + couple.second); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso1.get_compte().getGameThread().get_out(), 'O', "+", "" + guid + "|" + couple.second + add); return; } SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso2, 'O', "+", str); SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK( perso1.get_compte().getGameThread().get_out(), 'O', "+", str + add); items2.add(new Couple<Integer, Integer>(guid, qua)); } }