Advertisement
Guest User

initialstat

a guest
Dec 1st, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.51 KB | None | 0 0
  1. package com.GearGrinder.Networking;
  2.  
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.util.ArrayList;
  6. import java.util.List;
  7.  
  8. import com.GearGrinder.Game;
  9. import com.GearGrinder.entity.Entity;
  10.  
  11. public class InitialStat {
  12.  
  13.     //PLAYER STATS
  14.         public static String PSprite = null;
  15.         public static String PSpriteDir = null;
  16.         public static int gold = 1;
  17.         public static int health = 1;
  18.         public static double currenthealth = health;
  19.         public static double maxhealth = health;
  20.         public static double healthpercent = currenthealth / maxhealth * 100;
  21.         public static int magic = 1;
  22.         public static double currentmagic = magic;
  23.         public static double maxmagic = magic;
  24.         public static double magicpercent = currentmagic / maxmagic * 100;
  25.         public static int stamina = 1;
  26.         public static double currentstamina = stamina;
  27.         public static double maxstamina = stamina;
  28.         public static double staminapercent = currentstamina / maxstamina * 100;
  29.         public static int strength = 1;
  30.         public static int defense = 1;
  31.         public static int vitality = 1;
  32.         public static int agility = 1;
  33.         public static int intelligence = 1;
  34.         public static int dexterity = 1;
  35.         public static int luck = 1;
  36.         public static int PlayerLevel = 1;
  37.         public static int XP = 1;
  38.         public static double leveltotalxp = 11;
  39.         public static double XP2lvl = 1;
  40.         public static double XPpercent = 725 / leveltotalxp * XP;
  41.         public static String DB_Zone = null;
  42.         public static int Onlineint = 1;
  43.         public static int questcount = -1;
  44.        
  45.         //dummy values for the quest data
  46.         private static String Started;
  47.         private static String Complete;
  48.         private static String Title;
  49.         private static String MinLevel;
  50.         private static String MaxLevel;
  51.         private static String Solo;
  52.         private static String Timer;
  53.         private static String TimeLeft;
  54.         private static String MobName;
  55.         private static String MobAmount;
  56.         private static String MobKilled;
  57.         private static String Collect1;
  58.         private static String Collect2;
  59.         private static String Collect3;
  60.         private static String Collect4;
  61.         private static String Collect5;
  62.         private static String Collect6;
  63.         private static String Amount1;
  64.         private static String Amount2;
  65.         private static String Amount3;
  66.         private static String Amount4;
  67.         private static String Amount5;
  68.         private static String Amount6;
  69.         private static String Left1;
  70.         private static String Left2;
  71.         private static String Left3;
  72.         private static String Left4;
  73.         private static String Left5;
  74.         private static String Left6;
  75.         private static String Item1;
  76.         private static String Item2;
  77.         private static String Item3;
  78.         private static String Item4;
  79.         private static String Item5;
  80.         private static String Item6;
  81.         private static String QXP;
  82.         private static String QGold;
  83.         private static int Startedint;
  84.         private static int Completeint;
  85.         private static int Soloint;
  86.         private static int MinLevelint;
  87.         private static int MaxLevelint;
  88.         private static int QXPint;
  89.         private static int QGoldint;
  90.         private static int Timerint;
  91.         private static int TimeLeftint;
  92.         private static int MobAmountint;
  93.         private static int MobKilledint;
  94.         private static int Amount1int;
  95.         private static int Amount2int;
  96.         private static int Amount3int;
  97.         private static int Amount4int;
  98.         private static int Amount5int;
  99.         private static int Amount6int;
  100.         private static int Left1int;
  101.         private static int Left2int;
  102.         private static int Left3int;
  103.         private static int Left4int;
  104.         private static int Left5int;
  105.         private static int Left6int;
  106.        
  107.         public static ArrayList<ArrayList<String>> listofquests = new ArrayList<ArrayList<String>>();
  108.         public static ArrayList<String> questbloat = new ArrayList<String>();
  109.        
  110.         private static String test = "qweqweqwe";
  111.    
  112.     public static void InitialStat(){
  113.         ResultSet rs = null;
  114.         // initial player stat load
  115.         try{
  116.             Class.forName("com.mysql.jdbc.Driver");
  117.            
  118.             System.out.println("Loading Player Stats ...");
  119.            
  120.                 rs = UserVerify.stmt.executeQuery("SELECT Sprite, SpriteDirection, PlayerName, Zone, Xloc, Yloc, Level, XP, Health, Magic, Stamina, Strength, Defense, Vitality, Agility, Intelligence, Dexterity, Luck, Gold FROM accounts WHERE AccountID = " + UserVerify.clientID);
  121.                 while(rs.next()){
  122.                     PSprite = rs.getString("Sprite");
  123.                     PSpriteDir = rs.getString("SpriteDirection");
  124.                     Game.Playername = rs.getString("PlayerName");
  125.                     DB_Zone = rs.getString("Zone");
  126.                     Game.PlayerSpawnX = rs.getInt("Xloc");
  127.                     Game.PlayerSpawnY = rs.getInt("Yloc");
  128.                     XP = rs.getInt("XP");
  129.                     PlayerLevel = rs.getInt("Level");
  130.                     health = rs.getInt("Health");
  131.                     magic = rs.getInt("Magic");
  132.                     stamina = rs.getInt("Stamina");
  133.                     strength = rs.getInt("Strength");
  134.                     defense = rs.getInt("Defense");
  135.                     vitality = rs.getInt("Vitality");
  136.                     agility = rs.getInt("Agility");
  137.                     intelligence = rs.getInt("Intelligence");
  138.                     dexterity = rs.getInt("Dexterity");
  139.                     luck = rs.getInt("Luck");
  140.                     gold = rs.getInt("Gold");      
  141.                    
  142.                     currenthealth = health;
  143.                     maxhealth = health;
  144.                     healthpercent = currenthealth / maxhealth * 100;
  145.                     currentmagic = magic;
  146.                     maxmagic = magic;
  147.                     magicpercent = currentmagic / maxmagic * 100;
  148.                     currentstamina = stamina;
  149.                     maxstamina = stamina;
  150.                     staminapercent = currentstamina / maxstamina * 100;
  151.                     XPpercent = 725 / leveltotalxp * XP;                   
  152.                 }          
  153.         }catch(SQLException se){
  154.             // Handle errors for JDBC
  155.             se.printStackTrace();
  156.         }catch(Exception e){
  157.             e.printStackTrace();
  158.         }
  159.        
  160.         rs = null;
  161.        
  162.         try {
  163.           rs = UserVerify.stmt.executeQuery("SELECT COUNT(*) FROM Quests_" + Game.Playername);
  164.           // get the number of rows from the result set
  165.           rs.next();
  166.           questcount = rs.getInt(1);
  167.         }catch(SQLException se){
  168.             // Handle errors for JDBC
  169.             se.printStackTrace();
  170.         }catch(Exception e){
  171.             e.printStackTrace();
  172.         }
  173.  
  174.        
  175.         rs = null;
  176.        
  177.         // quest loader
  178.         for(int j = 0; j < 37; j++){
  179.             questbloat.add(" ");
  180.         }
  181.        
  182.       for(int i = 0; i< questcount; i++){
  183.             listofquests.add(questbloat);
  184.       }
  185.        
  186.         try{
  187.             Class.forName("com.mysql.jdbc.Driver");
  188.            
  189.             System.out.println("Loading Quest Data ...");
  190.            
  191.             for(int i = 0; i < questcount ; i++){
  192.                 rs = UserVerify.stmt.executeQuery("SELECT Started, Complete, Title, MinLevel, MaxLevel, Solo, Timer, TimeLeft, MobName, MobAmount, MobKilled, Collect1, Amount1, Left1, Collect2, Amount2, Left2, Collect3, Amount3, Left3, Collect4, Amount4, Left4, Collect5, Amount5, Left5, Collect6, Amount6, Left6, Gold, XP, Item1, Item2, Item3, Item4, Item5, Item6 FROM Quests_" + Game.Playername + " WHERE QuestID = " + i);
  193.                
  194.                 while(rs.next()){
  195.                     Startedint = rs.getInt("Started");
  196.                     Completeint = rs.getInt("Complete");
  197.                     Title = rs.getString("Title");
  198.                     MinLevelint = rs.getInt("MinLevel");//
  199.                     MaxLevelint = rs.getInt("MaxLevel");//
  200.                     Soloint = rs.getInt("Solo");//
  201.                     Timerint = rs.getInt("Timer");//
  202.                     TimeLeftint = rs.getInt("TimeLeft");//
  203.                     MobName = rs.getString("MobName");
  204.                     MobAmountint = rs.getInt("MobAmount");//
  205.                     MobKilledint = rs.getInt("MobKilled");//
  206.                     Collect1 = rs.getString("Collect1");
  207.                     Amount1int = rs.getInt("Amount1");//
  208.                     Left1int = rs.getInt("Left1");//
  209.                     Collect2 = rs.getString("Collect2");
  210.                     Amount2int = rs.getInt("Amount2");//
  211.                     Left2int = rs.getInt("Left2");//
  212.                     Collect3 = rs.getString("Collect3");
  213.                     Amount3int = rs.getInt("Amount3");//
  214.                     Left3int = rs.getInt("Left3");//
  215.                     Collect4 = rs.getString("Collect4");
  216.                     Amount4int = rs.getInt("Amount4");//
  217.                     Left4int = rs.getInt("Left4");//
  218.                     Collect5 = rs.getString("Collect5");
  219.                     Amount5int = rs.getInt("Amount5");//
  220.                     Left5int = rs.getInt("Left5");//
  221.                     Collect6 = rs.getString("Collect6");
  222.                     Amount6int = rs.getInt("Amount6");//
  223.                     Left6int = rs.getInt("Left6");//
  224.                     QGoldint = rs.getInt("Gold");//
  225.                     QXPint = rs.getInt("XP");//
  226.                     Item1 = rs.getString("Item1");
  227.                     Item2= rs.getString("Item2");
  228.                     Item3= rs.getString("Item3");
  229.                     Item4= rs.getString("Item4");
  230.                     Item5= rs.getString("Item5");
  231.                     Item6= rs.getString("Item6");
  232.                    
  233.                    
  234.                     //convert the ints to strings
  235.                     Started = Integer.toString(Startedint);
  236.                     Complete = Integer.toString(Completeint);
  237.                     MinLevel = Integer.toString(MinLevelint);
  238.                     MaxLevel = Integer.toString(MaxLevelint);
  239.                     Solo = Integer.toString(Soloint);
  240.                     Timer = Integer.toString(Timerint);
  241.                     TimeLeft = Integer.toString(TimeLeftint);
  242.                     MobAmount = Integer.toString(MobAmountint);
  243.                     MobKilled = Integer.toString(MobKilledint);
  244.                     Amount1 = Integer.toString(Amount1int);
  245.                     Left1 = Integer.toString(Left1int);
  246.                     Amount2 = Integer.toString(Amount2int);
  247.                     Left2 = Integer.toString(Left2int);
  248.                     Amount3 = Integer.toString(Amount3int);
  249.                     Left3 = Integer.toString(Left3int);
  250.                     Amount4 = Integer.toString(Amount4int);
  251.                     Left4 = Integer.toString(Left4int);
  252.                     Amount5 = Integer.toString(Amount5int);
  253.                     Left5 = Integer.toString(Left5int);
  254.                     Amount6 = Integer.toString(Amount6int);
  255.                     Left6 = Integer.toString(Left6int);
  256.                     QGold = Integer.toString(QGoldint);
  257.                     QXP = Integer.toString(QXPint);
  258.                    
  259.                    
  260.                     // Load the quest data into an array list
  261.                     System.out.println("loading data in ...");
  262.                     listofquests.get(i).set(0, Started);
  263.                     listofquests.get(i).set(1,  Complete);
  264.                     listofquests.get(i).set(2, Title);
  265.                     listofquests.get(i).set(3, MinLevel);
  266.                     listofquests.get(i).set(4, MaxLevel);
  267.                     listofquests.get(i).set(5, Solo);
  268.                     listofquests.get(i).set(6, Timer);
  269.                     listofquests.get(i).set(7, TimeLeft);
  270.                     listofquests.get(i).set(8, MobName);
  271.                     listofquests.get(i).set(9, MobAmount);
  272.                     listofquests.get(i).set(10, MobKilled);
  273.                     listofquests.get(i).set(11, Collect1);
  274.                     listofquests.get(i).set(12, Amount1);
  275.                     listofquests.get(i).set(13, Left1);
  276.                     listofquests.get(i).set(14, Collect2);
  277.                     listofquests.get(i).set(15, Amount2);
  278.                     listofquests.get(i).set(16, Left2);
  279.                     listofquests.get(i).set(17, Collect3);
  280.                     listofquests.get(i).set(18, Amount3);
  281.                     listofquests.get(i).set(19, Left3);
  282.                     listofquests.get(i).set(20, Collect4);
  283.                     listofquests.get(i).set(21, Amount4);
  284.                     listofquests.get(i).set(22, Left4);
  285.                     listofquests.get(i).set(23, Collect5);
  286.                     listofquests.get(i).set(24, Amount5);
  287.                     listofquests.get(i).set(25, Left5);
  288.                     listofquests.get(i).set(26, Collect6);
  289.                     listofquests.get(i).set(27, Amount6);
  290.                     listofquests.get(i).set(28, Left6);
  291.                     listofquests.get(i).set(29, QGold);
  292.                     listofquests.get(i).set(30, QXP);
  293.                     listofquests.get(i).set(31, Item1);
  294.                     listofquests.get(i).set(32, Item2);
  295.                     listofquests.get(i).set(33, Item3);
  296.                     listofquests.get(i).set(34, Item4);
  297.                     listofquests.get(i).set(35, Item5);
  298.                     listofquests.get(i).set(36, Item6);
  299.                    
  300.                    
  301.                    
  302.                       Started = null;
  303.                       Complete = null;
  304.                       Title = null;
  305.                       MinLevel = null;
  306.                       MaxLevel = null;
  307.                       Solo = null;
  308.                       Timer = null;
  309.                       TimeLeft = null;
  310.                       MobName = null;
  311.                       MobAmount = null;
  312.                       MobKilled = null;
  313.                       Collect1 = null;
  314.                       Collect2 = null;
  315.                       Collect3 = null;
  316.                       Collect4 = null;
  317.                       Collect5 = null;
  318.                       Collect6 = null;
  319.                       Amount1 = null;
  320.                       Amount2 = null;
  321.                       Amount3 = null;
  322.                       Amount4 = null;
  323.                       Amount5 = null;
  324.                       Amount6 = null;
  325.                       Left1 = null;
  326.                       Left2 = null;
  327.                       Left3 = null;
  328.                       Left4 = null;
  329.                       Left5 = null;
  330.                       Left6 = null;
  331.                       Item1 = null;
  332.                       Item2 = null;
  333.                       Item3 = null;
  334.                       Item4 = null;
  335.                       Item5 = null;
  336.                       Item6 = null;
  337.                       QXP = null;
  338.                       QGold = null;
  339.                      Startedint = 0;
  340.                      Completeint = 0;
  341.                      Soloint = 0;
  342.                      MinLevelint = 0;
  343.                      MaxLevelint = 0;
  344.                      QXPint = 0;
  345.                      QGoldint = 0;
  346.                      Timerint = 0;
  347.                      TimeLeftint = 0;
  348.                      MobAmountint = 0;
  349.                      MobKilledint = 0;
  350.                      Amount1int = 0;
  351.                      Amount2int = 0;
  352.                      Amount3int = 0;
  353.                      Amount4int = 0;
  354.                      Amount5int = 0;
  355.                      Amount6int = 0;
  356.                      Left1int = 0;
  357.                      Left2int = 0;
  358.                      Left3int = 0;
  359.                      Left4int = 0;
  360.                      Left5int = 0;
  361.                      Left6int = 0;
  362.                 }              
  363.             }
  364.         }catch(SQLException se){
  365.             // Handle errors for JDBC
  366.             se.printStackTrace();
  367.         }catch(Exception e){
  368.             e.printStackTrace();
  369.         }
  370.         System.out.println(listofquests);
  371.         System.out.println("Loaded " + questcount + " Quests ...");
  372.         System.out.println("Loading World ...");
  373.         Game.launch();
  374.     }
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement