falyptus

Faith - Mob StBallotin/Halouwine

Jun 9th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.09 KB | None | 0 0
  1. /**
  2. *
  3. *@author Keal
  4. */
  5.  
  6. //Dans Ancestra.java
  7. public static int DAY = 0;
  8. public static int MONTH = 0;
  9.  
  10. //dans la méthode main()
  11. Date actDate = new Date();
  12. DateFormat dateFormat = new SimpleDateFormat("dd");
  13. String jour = dateFormat.format(actDate);
  14. dateFormat = new SimpleDateFormat("MM");
  15. String mois = dateFormat.format(actDate);
  16.  
  17. Faith.DAY = Integer.parseInt(jour);
  18. Faith.MONTH = Integer.parseInt(mois);
  19.  
  20. //Dans GameServer.java
  21. private Timer updateDateTimer;
  22.  
  23. //Dans le constructeur GameServer:
  24. updateDateTimer = new Timer();
  25. updateDateTimer.schedule(new TimerTask()
  26. {
  27.     @Override
  28.         public void run()
  29.     {
  30.         Thread t = new Thread(new UpdateDateThread());
  31.         t.start();
  32.         }
  33. }, 86400000, 86400000);
  34.  
  35. //Toujours dans GameServer
  36.  
  37. public static class UpdateDateThread implements Runnable
  38. {
  39.     @Override
  40.     public void run()
  41.     {
  42.         Date actDate = new Date();
  43.         DateFormat dateFormat = new SimpleDateFormat("dd");
  44.         String jour = dateFormat.format(actDate);
  45.         dateFormat = new SimpleDateFormat("MM");
  46.         String mois = dateFormat.format(actDate);
  47.        
  48.         Faith.DAY = Integer.parseInt(jour);
  49.         Faith.MONTH = Integer.parseInt(mois);
  50.        
  51.         if(Faith.MONTH == 2 && (Faith.DAY == 14 || Faith.DAY == 15) &&
  52.         (Faith.MONTH == 10 && Faith.DAY == 31 || Faith.MONTH == 1 && Faith.DAY == 1))//On altère seulement le jour spécial et le lendemain
  53.         {
  54.             synchronized(World.getCartes())
  55.             {
  56.                 for(Carte map : World.getCartes())
  57.                 {
  58.                     ArrayList<MobGrade> list = new ArrayList<MobGrade>();
  59.                     for(MobGrade mob : map.getMobPossibles())
  60.                     {
  61.                         int id = mob.getTemplate().getID();
  62.                         if(Faith.MONTH == 2 && Faith.DAY == 14)
  63.                         {
  64.                             if(id == 101) id = 1232;
  65.                         }else if(Faith.MONTH == 10 && Faith.DAY == 31)
  66.                         {
  67.                             if(id == 793) id = 101;
  68.                             if(id == 794) id = 98;
  69.                         }else
  70.                         {
  71.                             if(id == 793) id = 101;
  72.                             if(id == 794) id = 98;
  73.                             if(id == 1232) id = 101;
  74.                         }
  75.                         list.add(World.getMonstre(id).getGradeByLevel(mob.getLevel()));
  76.                        
  77.                         map.setMobPossibles(list);
  78.                     }
  79.                 }
  80.             }
  81.         }
  82.     }
  83. }
  84.  
  85. //Dans Carte.java
  86.  
  87. //Dans le constructeur Carte il suffit de remplacer la boucle for (for(String mob : monsters.split("\\|"))) par:
  88.  
  89. for(String mob : monsters.split("\\|"))
  90. {
  91.     if(mob.equals(""))continue;
  92.     int id = 0;
  93.     int lvl = 0;
  94.        
  95.     try
  96.     {
  97.         id = Integer.parseInt(mob.split(",")[0]);
  98.         lvl = Integer.parseInt(mob.split(",")[1]);
  99.     }catch(NumberFormatException e){continue;};
  100.     if(Faith.MONTH == 2 && Faith.DAY == 14)
  101.     {
  102.         if(id == 101) id = 1232;
  103.     }else if(Faith.MONTH == 10 && Faith.DAY == 31)
  104.     {
  105.         if(id == 793) id = 101;
  106.         if(id == 794) id = 98;
  107.     }else
  108.     {
  109.         if(id == 793) id = 101;
  110.         if(id == 794) id = 98;
  111.         if(id == 1232) id = 101;
  112.     }
  113.     if(id == 0 || lvl == 0)continue;
  114.     if(World.getMonstre(id) == null)continue;
  115.     if(World.getMonstre(id).getGradeByLevel(lvl) == null)continue;
  116.     _mobPossibles.add(World.getMonstre(id).getGradeByLevel(lvl));
  117. }
  118.  
  119. public ArrayList<MobGrade> getMobPossibles()
  120. {
  121.     return _mobPossibles;
  122. }
  123.    
  124. public void setMobPossibles(ArrayList<MobGrade> list)
  125. {
  126.     _mobPossibles = list;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment