deez

Ancestrar.beginningChallenges

Jul 13th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.91 KB | None | 0 0
  1. // Créer une nouvelle classe Challenge
  2.  
  3. package objects;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.List;
  7.  
  8. import common.SocketManager;
  9.  
  10. import objects.Fight.Fighter;
  11.  
  12. public class Challenge
  13. {
  14.     /*
  15.      * challengeOK = Réussi (Packet OK)
  16.      * challengeKO = Perdu (Packet KO)
  17.      */
  18.     private int type;
  19.     private int xpWin;
  20.     private int dropWin;
  21.     private boolean challengeKO = false;
  22.     private boolean challengeOK = false;
  23.     private Fight fight;
  24.     private Fighter fighter;
  25.     private List<Fight.Fighter> gameList = new ArrayList<Fighter>();
  26.     Personnage perso;
  27.    
  28.     public Challenge(Fight fight, int type, int xp, int drop)
  29.     {
  30.         this.challengeKO = true;
  31.         this.fight = fight;
  32.         this.type = type;
  33.         this.xpWin = xp;
  34.         this.dropWin = drop;
  35.        
  36.         gameList.clear();
  37.         gameList.addAll(fight.get_ordreJeu());
  38.     }
  39.    
  40.     public int getXp() { return xpWin; }
  41.     public int getDrop() { return dropWin; }
  42.     public boolean getWin() { return challengeOK; }
  43.     public boolean getLose() { return challengeKO; }
  44.    
  45.     public void challengeOK(){
  46.         challengeOK = true;
  47.         challengeKO = false;
  48.         SocketManager.GAME_SEND_CHALLENGE_FIGHT(fight, 7, "GdOK" + type);
  49.     }
  50.    
  51.     public void challengeKO(Fighter fighter){
  52.         String name = fighter.getPersonnage().get_name();
  53.         challengeKO = false;
  54.         SocketManager.GAME_SEND_CHALLENGE_FIGHT(fight, 7, "GdKO" + type);
  55.         SocketManager.GAME_SEND_CHALLENGE_FIGHT(fight, 7, "Im0188;" + name);
  56.     }
  57.    
  58.     public void showFightPerso() {
  59.         if (!challengeKO || fighter == null || fighter.get_fightCell() == null || perso == null) return;
  60.         StringBuilder packet = new StringBuilder();
  61.         packet.append("Gf").append(fighter.getGUID()).append("|").append(fighter.get_fightCell().getID());
  62.         SocketManager.send(perso, packet.toString());
  63.     }
  64.    
  65.     public void showFighter() {
  66.         if (!challengeKO || fighter == null || fighter.get_fightCell() == null) return;
  67.         StringBuilder packet = new StringBuilder();
  68.         packet.append("Gf").append(fighter.getGUID()).append("|").append(fighter.get_fightCell().getID());
  69.         SocketManager.GAME_SEND_CHALLENGE_FIGHT(fight, 7, packet.toString());
  70.     }
  71.    
  72.     public void fightStart() {
  73.         if (!challengeKO) return;
  74.       switch (type)
  75.       {
  76.  
  77.       }
  78.     }
  79.    
  80.     public void fightEnd() {
  81.         if (!challengeKO) return;
  82.         switch(type){
  83.        
  84.         }
  85.         challengeOK();
  86.     }
  87.     public void fighterDie(Fighter fighter) {
  88.         if(!challengeKO) return;
  89.         switch (type) {
  90.  
  91.         }
  92.     }
  93.    
  94.     public void fightAttack() {
  95.         if (!challengeKO) return;
  96.         switch(type) {
  97.        
  98.         }
  99.     }
  100.    
  101.     public void monsterDie(){
  102.         if(!challengeKO) return;
  103.         switch(type) {
  104.        
  105.         }
  106.     }
  107.  
  108.     public void persoMove(){
  109.         if(!challengeKO) return;
  110.         switch(type) {
  111.        
  112.         }
  113.     }
  114.    
  115.     public void persoAction(){
  116.         if(!challengeKO || fighter.getTeam() == 1)
  117.             return;
  118.         switch(type) {
  119.  
  120.         }
  121.         return;
  122.     }
  123.    
  124.     public void persoCac(){
  125.         if(!challengeKO) return;
  126.        
  127.         switch(type){
  128.        
  129.         }
  130.     }
  131.    
  132.     public void persoSpell(){
  133.         if(!challengeKO) return;
  134.        
  135.         switch(type){
  136.        
  137.         }
  138.     }
  139.    
  140.     public void fightStartTurn(){
  141.         if(!challengeKO) return;
  142.        
  143.         switch(type){
  144.        
  145.         }
  146.     }
  147.    
  148.     public void fightEndTurn(){
  149.         if(!challengeKO) return;
  150.        
  151.         switch(type){
  152.        
  153.         }
  154.     }
  155.    
  156. }
  157.  
  158. // SocketManager
  159.     public static void GAME_SEND_CHALLENGE_FIGHT(Fight fight, int challenge, String packet) {
  160.         for(Fighter fighter : fight.getFighters(challenge))
  161.         {
  162.             if(fighter.hasLeft())continue;
  163.             if(fighter.getPersonnage() == null || ! fighter.getPersonnage().isOnline())continue;
  164.             send(fighter.getPersonnage(),packet);
  165.         }
  166.     }
  167.  
  168. // Carte
  169.     public boolean hasEndFightAction(int actionId) {
  170.         return _endFightAction.containsKey(actionId);
  171.     }
  172.  
  173. // Formulas
  174.     public static int getRandomChallenge(Personnage _perso)
  175.     {
  176.        int challenge = 0;
  177.        if(_perso.get_lvl() < 6) {
  178.            return 0;
  179.        } else{
  180.           challenge++;
  181.        }
  182.        if(_perso.get_curCarte().hasEndFightAction( 0 ))
  183.        {
  184.           challenge++;
  185.        }
  186.        return challenge;
  187.     }
Advertisement
Add Comment
Please, Sign In to add comment