public static void PriestRequest(Personnage perso, Carte carte, int IdPretre) { Personnage Homme = Married.get(0); Personnage Femme = Married.get(1); if (Homme.getWife() != 0) { SocketManager.GAME_SEND_MESSAGE_TO_MAP( carte, Homme.get_name() + " est deja marier!", Ancestra.CONFIG_MOTD_COLOR); return; } if (Femme.getWife() != 0) { SocketManager.GAME_SEND_MESSAGE_TO_MAP( carte, Femme.get_name() + " est deja marier!", Ancestra.CONFIG_MOTD_COLOR); return; } SocketManager.GAME_SEND_cMK_PACKET_TO_MAP( perso.get_curCarte(), "", -1, "Prêtre", perso.get_name() + " acceptez-vous d'épouser " + getMarried((perso.get_sexe() == 1 ? 0 : 1)).get_name() + " ?"); SocketManager.GAME_SEND_WEDDING( carte, 617, (Homme == perso ? Homme.get_GUID() : Femme.get_GUID()), (Homme == perso ? Femme.get_GUID() : Homme.get_GUID()), IdPretre); }
public synchronized long getKamas(int guid) { int i = 0; if (perso1.get_GUID() == guid) i = 1; else if (perso2.get_GUID() == guid) i = 2; if (i == 1) return kamas1; else if (i == 2) return kamas2; return 0; }
public static void addSeller(Personnage p) { if (Seller.get(p.get_curCarte().get_id()) == null) { ArrayList<Integer> PersoID = new ArrayList<Integer>(); PersoID.add(p.get_GUID()); Seller.put(p.get_curCarte().get_id(), PersoID); } else { ArrayList<Integer> PersoID = new ArrayList<Integer>(); PersoID.addAll(Seller.get(p.get_curCarte().get_id())); PersoID.add(p.get_GUID()); Seller.remove(p.get_curCarte().get_id()); Seller.put(p.get_curCarte().get_id(), PersoID); } }
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 }
public static void AddMarried(int ordre, Personnage perso) { Personnage Perso = Married.get(ordre); if (Perso != null) { if (perso.get_GUID() == Perso.get_GUID()) // Si c'est le meme joueur... return; if (Perso.isOnline()) // Si perso en ligne... { Married.remove(ordre); Married.put(ordre, perso); return; } return; } else { Married.put(ordre, perso); return; } }
public synchronized void toogleOK(int guid) { int i = 0; if (perso1.get_GUID() == guid) i = 1; else if (perso2.get_GUID() == guid) i = 2; if (i == 1) { ok1 = !ok1; SocketManager.GAME_SEND_EXCHANGE_OK( perso1.get_compte().getGameThread().get_out(), ok1, guid); SocketManager.GAME_SEND_EXCHANGE_OK( perso2.get_compte().getGameThread().get_out(), ok1, guid); } else if (i == 2) { ok2 = !ok2; SocketManager.GAME_SEND_EXCHANGE_OK( perso1.get_compte().getGameThread().get_out(), ok2, guid); SocketManager.GAME_SEND_EXCHANGE_OK( perso2.get_compte().getGameThread().get_out(), ok2, guid); } else return; if (ok1 && ok2) apply(); }
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 + ""); } }
public synchronized int getQuaItem(int itemID, int playerGuid) { ArrayList<Couple<Integer, Integer>> items; if (perso1.get_GUID() == playerGuid) items = items1; else items = items2; for (Couple<Integer, Integer> curCoupl : items) { if (curCoupl.first == itemID) { return curCoupl.second; } } return 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); } } }
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)); } }
public static void addPersonnage(Personnage perso) { Persos.put(perso.get_GUID(), perso); }