Пример #1
0
    public synchronized void setKamas(int guid, long k) {
      ok1 = false;
      ok2 = false;

      int i = 0;
      if (perso1.get_GUID() == guid) i = 1;
      else if (perso2.get_GUID() == guid) i = 2;
      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) {
        kamas1 = k;
        SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso1, 'G', "", k + "");
        SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK(
            perso2.get_compte().getGameThread().get_out(), 'G', "", k + "");
      } else if (i == 2) {
        kamas2 = k;
        SocketManager.GAME_SEND_EXCHANGE_OTHER_MOVE_OK(
            perso1.get_compte().getGameThread().get_out(), 'G', "", k + "");
        SocketManager.GAME_SEND_EXCHANGE_MOVE_OK(perso2, 'G', "", k + "");
      }
    }
Пример #2
0
    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);
        }
      }
    }
Пример #3
0
    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));
      }
    }