Guest User

Untitled

a guest
Mar 6th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 30.33 KB | None | 0 0
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. import javax.swing.JScrollPane;
  4. import javax.swing.JPanel;
  5. import javax.swing.JTextArea;
  6. import javax.swing.JTextField;
  7. import javax.swing.JTable;
  8. import javax.swing.BoxLayout;
  9. import javax.swing.table.DefaultTableModel;
  10. import javax.swing.table.TableModel;
  11.  
  12. import java.awt.BorderLayout;
  13. import java.awt.Color;
  14. import java.awt.Font;
  15. import java.awt.Dimension;
  16. import java.awt.event.KeyListener;
  17. import java.awt.event.KeyEvent;
  18.  
  19. /**
  20.  * This class acts as the main GUI, where everything is shown to the player.
  21.  * Information such as Attributes, class, experience and the likes will all
  22.  * be updated and shown here. These informations can also be collected from
  23.  * this class. All Game Text will also be sent to this GUI, and all input
  24.  * from the Player (in form of a String) will be collected here.
  25.  */
  26.  
  27. public class RPGWindow extends JFrame implements KeyListener{    
  28.     // Minimum and Maximum Physical Damage
  29.     private int dMin, dMax;
  30.    
  31.     // Minimum and Maximum Magical Damage
  32.     private int mMin, mMax;
  33.    
  34.     // Minimum and Maximum Health
  35.     private int hMin, hMax;
  36.    
  37.     // Minimum and Maximum Mana
  38.     private int maMin, maMax;
  39.    
  40.     // Dodge, Crit and Block
  41.     private float dod, cri, blo;
  42.    
  43.     // Strength, Agility, Intelligence, Dexterity, Stamina
  44.     private JLabel lStr;
  45.     private JLabel lAgi;
  46.     private JLabel lInt;
  47.     private JLabel lDex;
  48.     private JLabel lSta;
  49.    
  50.     // Attack Damage, Magic Damage, Dodge Chance, Critical Chance, Block Chance
  51.     private JLabel lDmg;
  52.     private JLabel mDmg;
  53.     private JLabel lDod;
  54.     private JLabel lCri;
  55.     private JLabel lBlo;
  56.    
  57.     // Class, Level, Health, Mana, Experience
  58.     private JLabel lCla;
  59.     private JLabel lLvl;
  60.     private JLabel lHel;
  61.     private JLabel lMan;
  62.     private JLabel lExp;
  63.    
  64.     // Main Hand, Off Hand, Head, Chest, Gloves, Legs, Boots, Neklace, Ring1, Ring2
  65.     private JLabel lMah;
  66.     private JLabel lOfh;
  67.     private JLabel lHea;
  68.     private JLabel lChe;
  69.     private JLabel lGlo;
  70.     private JLabel lLeg;
  71.     private JLabel lBts;
  72.     private JLabel lNec;
  73.     private JLabel lRi1;
  74.     private JLabel lRi2;
  75.    
  76.     // Fire, Poison, Water, Arcane, Lightning
  77.     private JLabel lFir;
  78.     private JLabel lPoi;
  79.     private JLabel lWat;
  80.     private JLabel lArc;
  81.     private JLabel lLig;
  82.    
  83.     private JTextArea gameBox;
  84.     private JTextArea descBox;
  85.     private JTextField input;
  86.    
  87.     private JTable table;
  88.     private DefaultTableModel model;
  89.    
  90.     private JTable table2;
  91.     private DefaultTableModel model2;
  92.    
  93.     /**
  94.      * Constructor for objects of class RPGWindow
  95.      */
  96.    
  97.     public RPGWindow() {
  98.         makeFrame();
  99.         lLvl.setText("Level: " + 1);
  100.         lExp.setText("Experience: " + 0);
  101.         dMin = 0; dMax = 0;
  102.         mMin = 0; mMax = 0;
  103.         hMin = 0; hMax = 0;
  104.         maMin = 0; maMax = 0;
  105.         dod = 0; cri = 0; blo = 0;
  106.         this.setVisible(true);
  107.     }
  108.    
  109.     private void makeFrame() {
  110.         // Setup Frame
  111.         setTitle("Dungeons and Dragons");
  112.         setSize(1100,600);
  113.         setResizable(false);
  114.         setDefaultCloseOperation(this.EXIT_ON_CLOSE);
  115.         setBackground(Color.BLACK);
  116.        
  117.         // Make a Custom font
  118.         Font font = new Font("Consolas", Font.PLAIN, 16);
  119.        
  120.         // Make the main JTextArea
  121.         gameBox = new JTextArea();
  122.         gameBox.setFont(font);
  123.         gameBox.setBackground(Color.black);
  124.         gameBox.setForeground(Color.green);
  125.         gameBox.setLineWrap(true);
  126.         gameBox.setWrapStyleWord(true);
  127.         gameBox.setEditable(false);
  128.        
  129.         // For visualization only. Comment out when done.
  130.         gameBox.setText("This is where the game text is gonna be so " +
  131.                         "here is a lot of filler crap to kind of demonstrate " +
  132.                         "word wrapping, etc. Please don't really pay attention " +
  133.                         "to this text as it is meaningless jabber!\n" +
  134.                         "But please do note how sexy it all looks.");
  135.        
  136.         // Make a panel to hold the main text area
  137.         JScrollPane gScroll = new JScrollPane(gameBox);
  138.         gScroll.setAutoscrolls(true);
  139.         gScroll.setPreferredSize(new Dimension(400,415));
  140.        
  141.         JPanel gbPanel = new JPanel(new BorderLayout(1,1));
  142.         gbPanel.setLayout(new BoxLayout(gbPanel, BoxLayout.Y_AXIS));
  143.         gbPanel.add(gScroll, BorderLayout.NORTH);
  144.        
  145.         // Make a field for input and add to the panel
  146.         input = new JTextField();
  147.         input.addKeyListener(this);
  148.         input.setPreferredSize(new Dimension(400,25));
  149.         input.setBackground(Color.black);
  150.         input.setForeground(Color.green);
  151.         input.setFont(font);
  152.         gbPanel.add(input, BorderLayout.CENTER);
  153.        
  154.         // Make panels for the southren end of the Game box panel
  155.         JPanel gbSouth = new JPanel(new BorderLayout(1,1));
  156.        
  157.         JPanel gbSouthWest = new JPanel(new BorderLayout(1,1));
  158.         gbSouthWest.setBackground(Color.black);
  159.         gbSouthWest.setLayout(new BoxLayout(gbSouthWest, BoxLayout.Y_AXIS));
  160.        
  161.         JPanel gbSouthCenter = new JPanel(new BorderLayout(1,1));
  162.         gbSouthCenter.setBackground(Color.black);
  163.        
  164.         JPanel gbSouthEast = new JPanel(new BorderLayout(1,1));
  165.         gbSouthEast.setBackground(Color.black);
  166.         gbSouthEast.setLayout(new BoxLayout(gbSouthEast, BoxLayout.Y_AXIS));
  167.        
  168.         // Make Labels
  169.         Font lFont = new Font("Consolas", Font.BOLD, 12);
  170.        
  171.         JLabel lAtt = new JLabel("Attributes");
  172.         lAtt.setFont(lFont);
  173.         lAtt.setForeground(Color.white);
  174.         lStr = new JLabel("Strength: ");
  175.         lStr.setFont(lFont);
  176.         lStr.setForeground(Color.red);
  177.         lAgi = new JLabel("Agility: ");
  178.         lAgi.setFont(lFont);
  179.         lAgi.setForeground(Color.orange);
  180.         lInt = new JLabel("Intelligence: ");
  181.         lInt.setFont(lFont);
  182.         lInt.setForeground(Color.cyan);
  183.         lDex = new JLabel("Dexterity: ");
  184.         lDex.setFont(lFont);
  185.         lDex.setForeground(Color.yellow);
  186.         lSta = new JLabel("Stamina: ");
  187.         lSta.setFont(lFont);
  188.         lSta.setForeground(Color.green);
  189.        
  190.         // Add Labels
  191.         gbSouthWest.add(lAtt);
  192.         gbSouthWest.add(lStr);
  193.         gbSouthWest.add(lAgi);
  194.         gbSouthWest.add(lInt);
  195.         gbSouthWest.add(lDex);
  196.         gbSouthWest.add(lSta);
  197.        
  198.         // Labels for the Center part of the south game box panel
  199.         JLabel lOaD = new JLabel("Offensive/Defensive");
  200.         lOaD.setFont(lFont);
  201.         lOaD.setForeground(Color.white);
  202.         lDmg = new JLabel("Attack Damage: ");
  203.         lDmg.setFont(lFont);
  204.         lDmg.setForeground(Color.white);
  205.         mDmg = new JLabel("Magic Damage: ");
  206.         mDmg.setFont(lFont);
  207.         mDmg.setForeground(Color.white);
  208.         lDod = new JLabel("Dodge Chance: ");
  209.         lDod.setFont(lFont);
  210.         lDod.setForeground(Color.white);
  211.         lCri = new JLabel("Critical Chance: ");
  212.         lCri.setFont(lFont);
  213.         lCri.setForeground(Color.white);
  214.         lBlo = new JLabel("Block Chance: ");
  215.         lBlo.setFont(lFont);
  216.         lBlo.setForeground(Color.white);
  217.        
  218.         // Resistances
  219.         JLabel lRes = new JLabel("Ressistances");
  220.         lRes.setFont(lFont);
  221.         lRes.setForeground(Color.white);
  222.         lFir = new JLabel("Fire: ");
  223.         lFir.setFont(lFont);
  224.         lFir.setForeground(Color.red);
  225.         lPoi = new JLabel("Poison: ");
  226.         lPoi.setFont(lFont);
  227.         lPoi.setForeground(Color.green);
  228.         lWat = new JLabel("Water: ");
  229.         lWat.setFont(lFont);
  230.         lWat.setForeground(Color.cyan);
  231.         lArc = new JLabel("Arcane: ");
  232.         lArc.setFont(lFont);
  233.         lArc.setForeground(Color.pink);
  234.         lLig = new JLabel("Lightning: ");
  235.         lLig.setFont(lFont);
  236.         lLig.setForeground(Color.yellow);
  237.        
  238.         JPanel gbSouthCenterWest = new JPanel(new BorderLayout(1,1));
  239.         gbSouthCenterWest.setLayout(new BoxLayout(gbSouthCenterWest, BoxLayout.Y_AXIS));
  240.         gbSouthCenterWest.setBackground(Color.black);
  241.        
  242.         gbSouthCenterWest.add(lOaD);
  243.         gbSouthCenterWest.add(lDmg);
  244.         gbSouthCenterWest.add(mDmg);
  245.         gbSouthCenterWest.add(lDod);
  246.         gbSouthCenterWest.add(lCri);
  247.         gbSouthCenterWest.add(lBlo);
  248.        
  249.         JPanel gbSouthCenterEast = new JPanel(new BorderLayout(1,1));
  250.         gbSouthCenterEast.setLayout(new BoxLayout(gbSouthCenterEast, BoxLayout.Y_AXIS));
  251.         gbSouthCenterEast.setBackground(Color.black);
  252.        
  253.         gbSouthCenterEast.add(lRes);
  254.         gbSouthCenterEast.add(lFir);
  255.         gbSouthCenterEast.add(lPoi);
  256.         gbSouthCenterEast.add(lWat);
  257.         gbSouthCenterEast.add(lArc);
  258.         gbSouthCenterEast.add(lLig);
  259.        
  260.         // Add Labels
  261.         gbSouthCenter.add(gbSouthCenterWest, BorderLayout.WEST);
  262.         gbSouthCenter.add(gbSouthCenterEast, BorderLayout.EAST);
  263.        
  264.        
  265.         // Labels for the East part of the south game box panel
  266.         JLabel lGen = new JLabel("General Information");
  267.         lGen.setFont(lFont);
  268.         lGen.setForeground(Color.white);
  269.         lCla = new JLabel("Class: ");
  270.         lCla.setFont(lFont);
  271.         lCla.setForeground(Color.white);
  272.         lLvl = new JLabel("Level: ");
  273.         lLvl.setFont(lFont);
  274.         lLvl.setForeground(Color.yellow);
  275.         lHel = new JLabel("Health: ");
  276.         lHel.setFont(lFont);
  277.         lHel.setForeground(Color.red);
  278.         lMan = new JLabel("Mana: ");
  279.         lMan.setFont(lFont);
  280.         lMan.setForeground(Color.cyan);
  281.         lExp = new JLabel("Experience: ");
  282.         lExp.setFont(lFont);
  283.         lExp.setForeground(Color.green);
  284.        
  285.         // Add Labels
  286.         gbSouthEast.add(lGen);
  287.         gbSouthEast.add(lCla);
  288.         gbSouthEast.add(lLvl);
  289.         gbSouthEast.add(lHel);
  290.         gbSouthEast.add(lMan);
  291.         gbSouthEast.add(lExp);
  292.        
  293.         gbSouth.add(gbSouthWest,BorderLayout.WEST);
  294.         gbSouth.add(gbSouthCenter,BorderLayout.CENTER);
  295.         gbSouth.add(gbSouthEast,BorderLayout.EAST);
  296.         gbPanel.add(gbSouth, BorderLayout.SOUTH);
  297.        
  298.         // Make the main content panel and 4 sub panels
  299.         // for each section of the JFrame
  300.         JPanel contentPane = (JPanel) getContentPane();
  301.         JPanel northPanel = new JPanel(new BorderLayout(1,1));
  302.         JPanel southPanel = new JPanel(new BorderLayout(1,1));
  303.         JPanel eastPanel = new JPanel(new BorderLayout(1,1));
  304.         JPanel westPanel = new JPanel(new BorderLayout(1,1));
  305.        
  306.         // Make a "skeleton" for the Backpack
  307.         model = new DefaultTableModel();
  308.        
  309.         // Make the JTable, and add columns
  310.         table = new JTable(model);
  311.         model.addColumn("Item");
  312.         model.addColumn("Amount");
  313.         model.insertRow(0, new Object []{"Some item", 1});
  314.        
  315.         // Configure the table
  316.         table.setEnabled(false);
  317.         table.setBackground(Color.black);
  318.         table.setForeground(Color.green);
  319.  
  320.         JScrollPane tScroll = new JScrollPane(table);
  321.         tScroll.setPreferredSize(new Dimension(300, 450));
  322.         westPanel.add(tScroll, BorderLayout.WEST);
  323.        
  324.         // Make a "skeleton" for the Ability Pane
  325.         model2 = new DefaultTableModel();
  326.        
  327.         // Make the JTable, and add Columns
  328.         table2 = new JTable(model2);
  329.         model2.addColumn("Name");
  330.         model2.addColumn("Level");
  331.         model2.addColumn("Mana Cost");
  332.         model2.insertRow(0, new Object [] {"Some Ability", 1, 123});
  333.        
  334.         // Configure the table
  335.         table2.setEnabled(false);
  336.         table2.setBackground(Color.black);
  337.         table2.setForeground(Color.green);
  338.        
  339.         JScrollPane tScroll2 = new JScrollPane(table2);
  340.         tScroll2.setPreferredSize(new Dimension(300, 450));
  341.         eastPanel.add(tScroll2, BorderLayout.EAST);
  342.        
  343.         // Make a Description Box
  344.         descBox = new JTextArea("Some Description");
  345.         descBox.setFont(font);
  346.         descBox.setBackground(Color.black);
  347.         descBox.setForeground(Color.green);
  348.         descBox.setLineWrap(true);
  349.         descBox.setWrapStyleWord(true);
  350.         descBox.setEditable(false);
  351.        
  352.         // Make a scroll pane for the Description box
  353.         JScrollPane dScroll = new JScrollPane(descBox);
  354.         dScroll.setPreferredSize(new Dimension(300,150));
  355.        
  356.         eastPanel.add(dScroll, BorderLayout.SOUTH);
  357.        
  358.         // Labels for Equipment
  359.         lMah = new JLabel("Main Hand:");
  360.         lMah.setFont(lFont);
  361.         lMah.setForeground(Color.white);
  362.         lOfh = new JLabel("Off Hand:");
  363.         lOfh.setFont(lFont);
  364.         lOfh.setForeground(Color.white);
  365.         lHea = new JLabel("Head:");
  366.         lHea.setFont(lFont);
  367.         lHea.setForeground(Color.white);
  368.         lChe = new JLabel("Chest:");
  369.         lChe.setFont(lFont);
  370.         lChe.setForeground(Color.white);
  371.         lGlo = new JLabel("Gloves:");
  372.         lGlo.setFont(lFont);
  373.         lGlo.setForeground(Color.white);
  374.         lLeg = new JLabel("Legs:");
  375.         lLeg.setFont(lFont);
  376.         lLeg.setForeground(Color.white);
  377.         lBts = new JLabel("Boots:");
  378.         lBts.setFont(lFont);
  379.         lBts.setForeground(Color.white);
  380.         lNec = new JLabel("Necklace:");
  381.         lNec.setFont(lFont);
  382.         lNec.setForeground(Color.white);
  383.         lRi1 = new JLabel("Ring 1:");
  384.         lRi1.setFont(lFont);
  385.         lRi1.setForeground(Color.white);
  386.         lRi2 = new JLabel("Ring 2:");
  387.         lRi2.setFont(lFont);
  388.         lRi2.setForeground(Color.white);
  389.        
  390.         // Equipment Panel
  391.         JPanel equipPanel = new JPanel(new BorderLayout(1,1));
  392.         equipPanel.setBackground(Color.black);
  393.         equipPanel.setLayout(new BoxLayout(equipPanel, BoxLayout.Y_AXIS));
  394.         equipPanel.add(lMah);
  395.         equipPanel.add(lOfh);
  396.         equipPanel.add(lHea);
  397.         equipPanel.add(lChe);
  398.         equipPanel.add(lGlo);
  399.         equipPanel.add(lLeg);
  400.         equipPanel.add(lBts);
  401.         equipPanel.add(lNec);
  402.         equipPanel.add(lRi1);
  403.         equipPanel.add(lRi2);
  404.        
  405.         westPanel.add(equipPanel, BorderLayout.SOUTH);
  406.        
  407.         // Add all panels to the main panel.
  408.         contentPane.add(northPanel, BorderLayout.NORTH);
  409.         contentPane.add(southPanel, BorderLayout.SOUTH);
  410.         contentPane.add(eastPanel, BorderLayout.EAST);
  411.         contentPane.add(westPanel, BorderLayout.WEST);
  412.         contentPane.add(gbPanel, BorderLayout.CENTER);
  413.     }
  414.    
  415.     /**
  416.      *
  417.      */
  418.    
  419.     public void keyPressed(KeyEvent ePressed) {
  420.         String text = getInput();
  421.         if(ePressed.getKeyCode() == KeyEvent.VK_ENTER) {
  422.             if(text.length() == 0) {
  423.                 // No command was entered
  424.             } else {
  425.                 gameBox.append("\n" + text);
  426.                 input.setText("");
  427.             }
  428.         }
  429.     }
  430.    
  431.     /**
  432.      * @return The JTextArea that contains the game text.
  433.      */
  434.    
  435.     public JTextArea getGameBox() {
  436.         return gameBox;
  437.     }
  438.    
  439.     /**
  440.      * @return The JTextArea that contains descriptions
  441.      */
  442.    
  443.     public JTextArea getDescBox() {
  444.         return descBox;
  445.     }
  446.    
  447.     /**
  448.      * @return The input from the JTextField as a String.
  449.      */
  450.    
  451.     public String getInput() {
  452.         return input.getText();
  453.     }
  454.    
  455.     /**
  456.      * This method will insert an item into the backpack (JTable)
  457.      *
  458.      * @param item The Item to be inserted
  459.      * @param amount How many of the item to insert
  460.      */
  461.    
  462.     public void insertItem(String item, int amount) {
  463.         if(model.getRowCount() == 0) {
  464.             model.insertRow(0, new Object[]{item, amount});
  465.         } else {
  466.             for(int i = 0; i < model.getRowCount(); i++) {
  467.                 if(model.getValueAt(i,0).equals(item)) {
  468.                     int am = (int) model.getValueAt(i,1);
  469.                     model.setValueAt(am + amount, i, 1);
  470.                     return;
  471.                 }
  472.             }
  473.             model.insertRow(model.getRowCount(), new Object[]{item, amount});
  474.         }
  475.     }
  476.    
  477.     /**
  478.      * This method will remove an item from the backpack (JTable)
  479.      *
  480.      * @param item The item to remove (also called "Use")
  481.      * @param amount How many of the item to use (Usually only 1)
  482.      */
  483.    
  484.     public void removeItem(String item, int amount) throws NoItemFoundException {
  485.         if(model.getRowCount() == 0) {
  486.             throw new NoItemFoundException(item);
  487.         } else {
  488.             for(int i = 0; i < model.getRowCount(); i++) {
  489.                 if(model.getValueAt(i,0).equals(item)) {
  490.                     int am = (int) model.getValueAt(i,1);
  491.                     if(am - amount <= 0) {
  492.                         model.removeRow(i);
  493.                         return;
  494.                     } else {
  495.                         model.setValueAt(am - amount, i, 1);
  496.                         return;
  497.                     }
  498.                 } else {
  499.                     throw new NoItemFoundException(item);
  500.                 }
  501.             }
  502.         }
  503.     }
  504.    
  505.     /**
  506.      * Insert a spell or ability into the spell book
  507.      *
  508.      * @param name Name of the Spell
  509.      * @param level The Level of the Spell
  510.      * @param manacost How much mana the spell should cost to use
  511.      */
  512.    
  513.     public void insertAbility(String name, int level, int manacost) throws DuplicateAbilityException {
  514.         if(model2.getRowCount() == 0) {
  515.             model2.insertRow(0, new Object[]{name, level, manacost});
  516.         } else {
  517.             for(int i = 0; i < model2.getRowCount(); i++) {
  518.                 if(model2.getValueAt(i,0).equals(name)) {
  519.                     throw new DuplicateAbilityException(name);
  520.                 }
  521.             }
  522.             model2.insertRow(model2.getRowCount(), new Object[]{name, level, manacost});
  523.         }
  524.     }
  525.    
  526.     /**
  527.      * Remove a spell or ability from the spell book.
  528.      *
  529.      * @param name The spell to look for.
  530.      */
  531.    
  532.     public void removeAbility(String name) throws NoAbilityFoundException {
  533.         if(model2.getRowCount() == 0) {
  534.             throw new NoAbilityFoundException(name);
  535.         } else {
  536.             for(int i = 0; i < model2.getRowCount(); i++) {
  537.                 if(model2.getValueAt(i,0).equals(name)) {
  538.                     model2.removeRow(i);
  539.                     return;
  540.                 } else {
  541.                     throw new NoAbilityFoundException(name);
  542.                 }
  543.             }
  544.         }
  545.     }
  546.    
  547.     /**
  548.      * Upgrade a spell or ability from the spell book.
  549.      *
  550.      * @param name The spell to upgrade
  551.      * @param manacost The new manacost for the ability, if any.
  552.      */
  553.    
  554.     public void upgradeAbility(String name, int manacost) throws NoAbilityFoundException {
  555.         if(model2.getRowCount() == 0) {
  556.             throw new NoAbilityFoundException(name);
  557.         } else {
  558.             for(int i = 0; i < model2.getRowCount(); i++) {
  559.                 if(model2.getValueAt(i,0).equals(name)) {
  560.                     int l = (int) model2.getValueAt(i,1);
  561.                     int m = (int) model2.getValueAt(i,2);
  562.                     model2.setValueAt(l + 1, i, 1);
  563.                     model2.setValueAt(m + manacost, i, 2);
  564.                     return;
  565.                 } else {
  566.                     throw new NoAbilityFoundException(name);
  567.                 }
  568.             }
  569.         }
  570.     }
  571.    
  572.     /**
  573.      * Will return the mana cost for specific spell or ability in the spell book
  574.      *
  575.      * @param name The spell to look for.
  576.      */
  577.    
  578.     public int getManaCost(String name) throws NoAbilityFoundException {
  579.         int cost = 0;
  580.         if(model2.getRowCount() == 0) {
  581.             throw new NoAbilityFoundException(name);
  582.         } else {
  583.             for(int i = 0; i < model2.getRowCount(); i++) {
  584.                 if(model2.getValueAt(i,0).equals(name)) {
  585.                     cost = (int) model2.getValueAt(i,2);
  586.                     break;
  587.                 } else {
  588.                     throw new NoAbilityFoundException(name);
  589.                 }
  590.             }
  591.         }
  592.         return cost;
  593.     }
  594.    
  595.     /**
  596.      * ATTRIBUTES
  597.      */
  598.    
  599.     /**
  600.      * @param val Set the Strength Attribute.
  601.      */
  602.    
  603.     public void setStr(int val) {
  604.         lStr.setText("Strength: " + val);
  605.     }
  606.    
  607.     public int getStr() {
  608.         return Integer.parseInt(lStr.getText().substring(10));
  609.     }
  610.    
  611.     /**
  612.      * @param val Set the Agility Attribute.
  613.      */
  614.    
  615.     public void setAgi(int val) {
  616.         lAgi.setText("Agility: " + val);
  617.     }
  618.    
  619.     public int getAgi() {
  620.         return Integer.parseInt(lAgi.getText().substring(9));
  621.     }
  622.    
  623.     /**
  624.      * @param val Set the Intelligence Attribute.
  625.      */
  626.    
  627.     public void setInt(int val) {
  628.         lInt.setText("Intelligence: " + val);
  629.     }
  630.    
  631.     public int getInt() {
  632.         return Integer.parseInt(lInt.getText().substring(14));
  633.     }
  634.    
  635.     /**
  636.      * @param val Set the Dexterity Attribute.
  637.      */
  638.    
  639.     public void setDex(int val) {
  640.         lDex.setText("Dexterity: " + val);
  641.     }
  642.    
  643.     public int getDex() {
  644.         return Integer.parseInt(lDex.getText().substring(11));
  645.     }
  646.    
  647.     /**
  648.      * @param val Set the Stamina Attribute.
  649.      */
  650.    
  651.     public void setSta(int val) {
  652.         lSta.setText("Stamina: " + val);
  653.     }
  654.    
  655.     public int getSta() {
  656.         return Integer.parseInt(lSta.getText().substring(9));
  657.     }
  658.    
  659.     /**
  660.      * @param dMin Minimum Damage before crit and block
  661.      * @param dMax Maximum Damage before crit and block
  662.      */
  663.    
  664.     public void setDamage(int dMin, int dMax) {
  665.         this.dMin = dMin;
  666.         this.dMax = dMax;
  667.         lDmg.setText("Attack Damage: " + this.dMin + "-" + this.dMax);
  668.     }
  669.    
  670.     public int getMinDmg() {
  671.         return dMin;
  672.     }
  673.    
  674.     public int getMaxDmg() {
  675.         return dMax;
  676.     }
  677.    
  678.     /**
  679.      * @param dMin Minimum Damage
  680.      * @param dMax Maximum Damage
  681.      */
  682.    
  683.     public void setMagicDamage(int mMin, int mMax) {
  684.         this.mMin = mMin;
  685.         this.mMax = mMax;
  686.         mDmg.setText("Magic Damage: " + this.dMin + "-" + this.dMax);
  687.     }
  688.    
  689.     public int getMinMagic() {
  690.         return mMin;
  691.     }
  692.    
  693.     public int getMaxMagic() {
  694.         return mMax;
  695.     }
  696.    
  697.     /**
  698.      * @param val Set the Dodge Attribute
  699.      */
  700.    
  701.     public void setDodge(float val) {
  702.         dod = val;
  703.         lDod.setText("Dodge Chance: " + dod + "%");
  704.     }
  705.    
  706.     public float getDodge() {
  707.         return dod;
  708.     }
  709.    
  710.     /**
  711.      * @param val Set the Critical Chance Attribute
  712.      */
  713.    
  714.     public void setCrit(float val) {
  715.         cri = val;
  716.         lCri.setText("Critical Chance: " + cri + "%");
  717.     }
  718.    
  719.     public float getCrit() {
  720.         return cri;
  721.     }
  722.    
  723.     /**
  724.      * @param val Set the Block Chance Attribute
  725.      */
  726.    
  727.     public void setBlock(float val) {
  728.         blo = val;
  729.         lBlo.setText("Block Chance: " + blo + "%");
  730.     }
  731.    
  732.     public float getBlock() {
  733.         return blo;
  734.     }
  735.    
  736.     /**
  737.      * GENERAL
  738.      */
  739.    
  740.     /**
  741.      * @param rll Set the Name of the Class.
  742.      */
  743.    
  744.     public void setRole(String rll) {
  745.         lCla.setText("Class: " + rll);
  746.     }
  747.    
  748.     public String getRole() {
  749.         return lCla.getText().substring(7);
  750.     }
  751.    
  752.     /**
  753.      * @param val The Level to be set.
  754.      */
  755.    
  756.     public void setLevel(int val) {
  757.         lLvl.setText("Level: " + val);
  758.     }
  759.    
  760.     public int getLevel() {
  761.         return Integer.parseInt(lLvl.getText().substring(7));
  762.     }
  763.    
  764.     /**
  765.      * @param hMin Minimum value of the Health Attribute
  766.      * @param hMax Maximum value of the Health Attribute
  767.      */
  768.    
  769.     public void setHealth(int hMin, int hMax) {
  770.         this.hMin = hMin;
  771.         this.hMax = hMax;
  772.         lHel.setText("Health: " + this.hMin + "/" + this.hMax);
  773.     }
  774.    
  775.     public int getMinHp() {
  776.         return hMin;
  777.     }
  778.    
  779.     public int getMaxHp() {
  780.         return hMax;
  781.     }
  782.    
  783.     /**
  784.      * @param mMin Minimum value of the Mana Attribute
  785.      * @param mMax Minimum value of the Mana Attribute
  786.      */
  787.    
  788.     public void setMana(int maMin, int maMax) {
  789.         this.maMin = maMin;
  790.         this.maMax = maMax;
  791.         lMan.setText("Mana: " + this.maMin + "/" + this.maMax);
  792.     }
  793.    
  794.     public int getMinMana() {
  795.         return maMin;
  796.     }
  797.    
  798.     public int getMaxMana() {
  799.         return maMax;
  800.     }
  801.    
  802.     /**
  803.      * @param val The Experience to be set.
  804.      */
  805.    
  806.     public void setExperience(int val) {
  807.         lExp.setText("Experience: " + val);
  808.     }
  809.    
  810.     public int getExperience() {
  811.         return Integer.parseInt(lExp.getText().substring(12));
  812.     }
  813.    
  814.     /**
  815.      * EQUIPIMENT
  816.      */
  817.    
  818.     /**
  819.      * @param item Set the Main Hand Weapon.
  820.      * @param clr Quality of the item expressed in a Color.
  821.      */
  822.    
  823.     public void setMainHand(String item, Color clr) {
  824.         lMah.setText("Main Hand: " + item);
  825.         lMah.setForeground(clr);
  826.     }
  827.    
  828.     public String getMainHand() {
  829.         return lMah.getText().substring(11);
  830.     }
  831.    
  832.     /**
  833.      * @param item Set the Off Hand Weapon.
  834.      * @param clr Quality of the item expressed in a Color.
  835.      */
  836.    
  837.     public void setOffHand(String item, Color clr) {
  838.         lOfh.setText("Off Hand: " + item);
  839.         lOfh.setForeground(clr);
  840.     }
  841.    
  842.     public String getOffHand() {
  843.         return lOfh.getText().substring(10);
  844.     }
  845.    
  846.     /**
  847.      * @param item Set the Head armor
  848.      * @param clr Quality of the item expressed in a Color.
  849.      */
  850.    
  851.     public void setHead(String item, Color clr) {
  852.         lHea.setText("Head: " + item);
  853.         lHea.setForeground(clr);
  854.     }
  855.    
  856.     public String getHead() {
  857.         return lHea.getText().substring(6);
  858.     }
  859.    
  860.     /**
  861.      * @param item Set the Chest armor
  862.      * @param clr Quality of the item expressed in a Color.
  863.      */
  864.    
  865.     public void setChest(String item, Color clr) {
  866.         lChe.setText("Chest: " + item);
  867.         lChe.setForeground(clr);
  868.     }
  869.    
  870.     public String getChest() {
  871.         return lChe.getText().substring(7);
  872.     }
  873.    
  874.     /**
  875.      * @param item Set the Gloves armor
  876.      * @param clr Quality of the item expressed in a Color.
  877.      */
  878.    
  879.     public void setGloves(String item, Color clr) {
  880.         lGlo.setText("Gloves: " + item);
  881.         lGlo.setForeground(clr);
  882.     }
  883.    
  884.     public String getGloves() {
  885.         return lGlo.getText().substring(8);
  886.     }
  887.    
  888.     /**
  889.      * @param item Set the Legs armor
  890.      * @param clr Quality of the item expressed in a Color.
  891.      */
  892.    
  893.     public void setLegs(String item, Color clr) {
  894.         lLeg.setText("Legs: " + item);
  895.         lLeg.setForeground(clr);
  896.     }
  897.    
  898.     public String getLegs() {
  899.         return lLeg.getText().substring(6);
  900.     }
  901.    
  902.     /**
  903.      * @param item Set the Boots armor
  904.      * @param clr Quality of the item expressed in a Color.
  905.      */
  906.    
  907.     public void setBoots(String item, Color clr) {
  908.         lBts.setText("Boots: " + item);
  909.         lBts.setForeground(clr);
  910.     }
  911.    
  912.     public String getBoots() {
  913.         return lBts.getText().substring(7);
  914.     }
  915.    
  916.     /**
  917.      * @param item Set the Neck item
  918.      * @param clr Quality of the item expressed in a Color.
  919.      */
  920.    
  921.     public void setNeck(String item, Color clr) {
  922.         lNec.setText("Necklace: " + item);
  923.         lNec.setForeground(clr);
  924.     }
  925.    
  926.     public String getNeck() {
  927.         return lNec.getText().substring(10);
  928.     }
  929.    
  930.     /**
  931.      * @param item Set the First Ring item
  932.      * @param clr Quality of the item expressed in a Color.
  933.      */
  934.    
  935.     public void setRing1(String item, Color clr) {
  936.         lRi1.setText("Ring 1: " + item);
  937.         lRi1.setForeground(clr);
  938.     }
  939.    
  940.     public String getRing1() {
  941.         return lRi1.getText().substring(8);
  942.     }
  943.    
  944.     /**
  945.      * @param item Set the Second Ring item
  946.      * @param clr Quality of the item expressed in a Color.
  947.      */
  948.    
  949.     public void setRing2(String item, Color clr) {
  950.         lRi2.setText("Ring 2: " + item);
  951.         lRi2.setForeground(clr);
  952.     }
  953.    
  954.     public String getRing2() {
  955.         return lRi2.getText().substring(8);
  956.     }
  957.    
  958.     /**
  959.      * RESISTANCES
  960.      */
  961.    
  962.     /**
  963.      * Sets the Fire ressistance
  964.      * @param val The value for the ressistance.
  965.      */
  966.    
  967.     public void setFireRess(int val) {
  968.         lFir.setText("Fire: " + val);
  969.     }
  970.    
  971.     public int getFireRess() {
  972.         return Integer.parseInt(lFir.getText().substring(6));
  973.     }
  974.    
  975.     /**
  976.      * Sets the Poison ressistance
  977.      * @param val The value for the ressistance.
  978.      */
  979.    
  980.     public void setPoisonRess(int val) {
  981.         lPoi.setText("Poison: " + val);
  982.     }
  983.    
  984.     public int getPoisonRess() {
  985.         return Integer.parseInt(lPoi.getText().substring(8));
  986.     }
  987.    
  988.     /**
  989.      * Sets the Water ressistance
  990.      * @param val The value for the ressistance.
  991.      */
  992.    
  993.     public void setWaterRess(int val) {
  994.         lWat.setText("Water: " + val);
  995.     }
  996.    
  997.     public int getWaterRess() {
  998.         return Integer.parseInt(lWat.getText().substring(7));
  999.     }
  1000.    
  1001.     /**
  1002.      * Sets the Arcane ressistance
  1003.      * @param val The value for the ressistance.
  1004.      */
  1005.    
  1006.     public void setArcaneRess(int val) {
  1007.         lArc.setText("Arcane: " + val);
  1008.     }
  1009.    
  1010.     public int getArcaneRess() {
  1011.         return Integer.parseInt(lArc.getText().substring(8));
  1012.     }
  1013.    
  1014.     /**
  1015.      * Sets the Lightning ressistance
  1016.      * @param val The value for the ressistance.
  1017.      */
  1018.  
  1019.     public void setLightningRess(int val) {
  1020.         lLig.setText("Lightning: " + val);
  1021.     }
  1022.    
  1023.     public int getLightningRess() {
  1024.         return Integer.parseInt(lLig.getText().substring(11));
  1025.     }
  1026.    
  1027.     /**
  1028.      * Unused Method implemented from KeyListener
  1029.      */
  1030.    
  1031.     public void keyReleased(KeyEvent eReleased) {}
  1032.    
  1033.     /**
  1034.      * Unused Method implemented from KeyListener
  1035.      */
  1036.    
  1037.     public void keyTyped(KeyEvent eTyped) {}
  1038. }
Add Comment
Please, Sign In to add comment