コード例 #1
0
 public static void deletePerso(Personnage perso) {
   if (perso.get_guild() != null) {
     if (perso.get_guild().getMembers().size()
         <= 1) // Il est tout seul dans la guilde : Supression
     {
       World.removeGuild(perso.get_guild().get_id());
     } else if (perso.getGuildMember().getRank()
         == 1) // On passe les pouvoir a celui qui a le plus de droits si il est meneur
     {
       int curMaxRight = 0;
       Personnage Meneur = null;
       for (Personnage newMeneur : perso.get_guild().getMembers()) {
         if (newMeneur == perso) continue;
         if (newMeneur.getGuildMember().getRights() < curMaxRight) {
           Meneur = newMeneur;
         }
       }
       perso.get_guild().removeMember(perso);
       Meneur.getGuildMember().setRank(1);
     } else // Supression simple
     {
       perso.get_guild().removeMember(perso);
     }
   }
   perso.remove(); // Supression BDD Perso, items, monture.
   World.unloadPerso(perso.get_GUID()); // UnLoad du perso+item
 }
コード例 #2
0
  public static int getEncloCellIdByMapId(short i) {
    if (World.getCarte(i).getMountPark() != null) {
      if (World.getCarte(i).getMountPark().get_cellid() > 0) {
        return World.getCarte(i).getMountPark().get_cellid();
      }
    }

    return -1;
  }
コード例 #3
0
 public Area(int id, int superArea, String name) {
   _id = id;
   _name = name;
   _superArea = World.getSuperArea(superArea);
   // Si le continent n'est pas encore créer, on le créer et on l'ajoute au monde
   if (_superArea == null) {
     _superArea = new SuperArea(superArea);
     World.addSuperArea(_superArea);
   }
 }
コード例 #4
0
  public static Objet newObjet(int Guid, int template, int qua, int pos, String strStats) {
    if (World.getObjTemplate(template) == null) {
      System.out.println(
          "ItemTemplate " + template + " inexistant, GUID dans la table `items`:" + Guid);
      Ancestra.closeServers();
    }

    if (World.getObjTemplate(template).getType() == 85)
      return new PierreAme(Guid, qua, template, pos, strStats);
    else return new Objet(Guid, template, qua, pos, strStats);
  }
コード例 #5
0
    public ItemSet(int id, String items, String bonuses) {
      _id = id;
      // parse items String
      for (String str : items.split(",")) {
        try {
          ObjTemplate t = World.getObjTemplate(Integer.parseInt(str.trim()));
          if (t == null) continue;
          _itemTemplates.add(t);
        } catch (Exception e) {
        }
        ;
      }

      // on ajoute un bonus vide pour 1 item
      _bonuses.add(new Stats());
      // parse bonuses String
      for (String str : bonuses.split(";")) {
        Stats S = new Stats();
        // séparation des bonus pour un même nombre d'item
        for (String str2 : str.split(",")) {
          try {
            String[] infos = str2.split(":");
            int stat = Integer.parseInt(infos[0]);
            int value = Integer.parseInt(infos[1]);
            // on ajoute a la stat
            S.addOneStat(stat, value);
          } catch (Exception e) {
          }
          ;
        }
        // on ajoute la stat a la liste des bonus
        _bonuses.add(S);
      }
    }
コード例 #6
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);
        }
      }
    }
コード例 #7
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));
      }
    }
コード例 #8
0
 public static int getObjectByIngredientForJob(
     ArrayList<Integer> list, Map<Integer, Integer> ingredients) {
   if (list == null) return -1;
   for (int tID : list) {
     ArrayList<Couple<Integer, Integer>> craft = World.getCraft(tID);
     if (craft == null) {
       GameServer.addToLog("/!\\Recette pour l'objet " + tID + " non existante !");
       continue;
     }
     if (craft.size() != ingredients.size()) continue;
     boolean ok = true;
     for (Couple<Integer, Integer> c : craft) {
       // si ingredient non présent ou mauvaise quantité
       if (ingredients.get(c.first) != c.second) ok = false;
     }
     if (ok) return tID;
   }
   return -1;
 }
コード例 #9
0
  public static String parseMPtoGuild(int GuildID) {
    Guild G = World.getGuild(GuildID);
    byte enclosMax = (byte) Math.floor(G.get_lvl() / 10);
    StringBuilder packet = new StringBuilder();
    packet.append(enclosMax);

    for (Entry<Short, Carte.MountPark> mp : MountPark.entrySet()) {
      if (mp.getValue().get_guild() != null && mp.getValue().get_guild().get_id() == GuildID) {
        packet
            .append("|")
            .append(mp.getValue().get_map().get_id())
            .append(";")
            .append(mp.getValue().get_size())
            .append(";")
            .append(mp.getValue().getObjectNumb()); // Nombre d'objets pour le dernier
      } else {
        continue;
      }
    }
    return packet.toString();
  }
コード例 #10
0
 public synchronized void apply() {
   // Gestion des Kamas
   perso1.addKamas((-kamas1 + kamas2));
   perso2.addKamas((-kamas2 + kamas1));
   for (Couple<Integer, Integer> couple : items1) {
     if (couple.second == 0) continue;
     if (!perso1.hasItemGuid(
         couple.first)) // Si le perso n'a pas l'item (Ne devrait pas arriver)
     {
       couple.second = 0; // On met la quantité a 0 pour éviter les problemes
       continue;
     }
     Objet obj = World.getObjet(couple.first);
     if ((obj.getQuantity() - couple.second) < 1) // S'il ne reste plus d'item apres l'échange
     {
       perso1.removeItem(couple.first);
       couple.second = obj.getQuantity();
       SocketManager.GAME_SEND_REMOVE_ITEM_PACKET(perso1, couple.first);
       if (!perso2.addObjet(obj, true)) // Si le joueur avait un item similaire
       World.removeItem(couple.first); // On supprime l'item inutile
     } else {
       obj.setQuantity(obj.getQuantity() - couple.second);
       SocketManager.GAME_SEND_OBJECT_QUANTITY_PACKET(perso1, obj);
       Objet newObj = Objet.getCloneObjet(obj, couple.second);
       if (perso2.addObjet(newObj, true)) // Si le joueur n'avait pas d'item similaire
       World.addObjet(newObj, true); // On ajoute l'item au World
     }
   }
   for (Couple<Integer, Integer> couple : items2) {
     if (couple.second == 0) continue;
     if (!perso2.hasItemGuid(
         couple.first)) // Si le perso n'a pas l'item (Ne devrait pas arriver)
     {
       couple.second = 0; // On met la quantité a 0 pour éviter les problemes
       continue;
     }
     Objet obj = World.getObjet(couple.first);
     if ((obj.getQuantity() - couple.second) < 1) // S'il ne reste plus d'item apres l'échange
     {
       perso2.removeItem(couple.first);
       couple.second = obj.getQuantity();
       SocketManager.GAME_SEND_REMOVE_ITEM_PACKET(perso2, couple.first);
       if (!perso1.addObjet(obj, true)) // Si le joueur avait un item similaire
       World.removeItem(couple.first); // On supprime l'item inutile
     } else {
       obj.setQuantity(obj.getQuantity() - couple.second);
       SocketManager.GAME_SEND_OBJECT_QUANTITY_PACKET(perso2, obj);
       Objet newObj = Objet.getCloneObjet(obj, couple.second);
       if (perso1.addObjet(newObj, true)) // Si le joueur n'avait pas d'item similaire
       World.addObjet(newObj, true); // On ajoute l'item au World
     }
   }
   // Fin
   perso1.set_isTradingWith(0);
   perso2.set_isTradingWith(0);
   perso1.setCurExchange(null);
   perso2.setCurExchange(null);
   SocketManager.GAME_SEND_Ow_PACKET(perso1);
   SocketManager.GAME_SEND_Ow_PACKET(perso2);
   SocketManager.GAME_SEND_STATS_PACKET(perso1);
   SocketManager.GAME_SEND_STATS_PACKET(perso2);
   SocketManager.GAME_SEND_EXCHANGE_VALID(perso1.get_compte().getGameThread().get_out(), 'a');
   SocketManager.GAME_SEND_EXCHANGE_VALID(perso2.get_compte().getGameThread().get_out(), 'a');
   SQLManager.SAVE_PERSONNAGE(perso1, true);
   SQLManager.SAVE_PERSONNAGE(perso2, true);
 }
コード例 #11
0
 public SubArea(int id, int areaID, int alignement, String name) {
   _id = id;
   _name = name;
   _area = World.getArea(areaID);
   _alignement = alignement;
 }