Guest User

Untitled

a guest
Sep 26th, 2024
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.63 KB | Source Code | 0 0
  1. The Weapons abstract class:
  2.  
  3. package Graph.Interactables.InteractablesCommonObjs.Weapons;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8.  
  9. public abstract class WeaponsMech {
  10.     String name;
  11.     //ArrayList<ArrayList<String>> moveSets;
  12.     String[] attack;
  13.     String[] defend;
  14.     String[] counter;
  15.     String[] special;
  16.    
  17.     Map<String, String> AttackToDefend;
  18.     Map<String, String> AttackToCounter;
  19.     Map<String, Integer> MapDamage;
  20.    
  21.     ArrayList<String>moves;
  22.    
  23.    
  24.  
  25.     public WeaponsMech(String name, String[] attack, String[] block, String[] counter, String[] special){
  26.         setName(name);
  27.         setMoveSets(attack, block, counter, special);
  28.         AttackToDefend = new HashMap<String, String>();
  29.         AttackToCounter = new HashMap<String, String>();
  30.         MapDamage = new HashMap<String, Integer>();
  31.  
  32.     } // works
  33.  
  34.  
  35.     public void setName(String name){
  36.         this.name = name;
  37.  
  38.     }
  39.  
  40.  
  41.  
  42.     public void setMoveSets(String[] attack, String[] defend, String[] counter, String[] special){ // nothng wrong
  43.        
  44.         if (attack.length > 0){
  45.            this.attack = attack;
  46.  
  47.         }
  48.         if (defend.length > 0){
  49.             this.defend = defend;
  50.         }
  51.         if (counter.length > 0){
  52.             this.counter = counter;
  53.  
  54.         }
  55.         if (special.length > 0){
  56.            this.special = special;
  57.         }
  58. // works
  59.  
  60.  
  61.     }
  62.  
  63.     public void printMoveSets() {
  64.         StringBuilder output = new StringBuilder();
  65.    
  66.         // Append attack moves
  67.         output.append("Attack Moves: ");
  68.         for (String arr : attack) {
  69.             output.append(arr).append(" ");
  70.         }
  71.    
  72.         // Append defend moves
  73.         output.append("\nDefend Moves: ");
  74.         for (String arr : defend) {
  75.             output.append(arr).append(" ");
  76.         }
  77.    
  78.         // Append counter moves
  79.         output.append("\nCounter Moves: ");
  80.         for (String arr : counter) {
  81.             output.append(arr).append(" ");
  82.         }
  83.  
  84.         output.append("\nSpecial Moves: ");
  85.         for (String arr : special) {
  86.             output.append(arr).append(" ");
  87.         }
  88.    
  89.         // Print the complete output on one line
  90.         System.out.println(output.toString());
  91.     }
  92.    
  93.  
  94.  
  95.  
  96.    
  97.  
  98.  
  99.    
  100.     public String getName(){
  101.         return this.name;
  102.     }
  103.  
  104.     public String[] getAttack(){
  105.         return this.attack;
  106.     }
  107.     public String[] getDefend(){
  108.         return this.defend;
  109.     }
  110.     public String[] getCounter(){
  111.         return this.counter;
  112.     }
  113.     public String[] getSpecial(){
  114.         return this.special;
  115.     }
  116.    
  117.  
  118.  
  119.     public void AttackToDefendMap(String attack,String defend){ // works
  120.         AttackToDefend.put(attack, defend);
  121.  
  122.     }
  123.     public void AttackToCounterMap(String attack, String counter){ // works
  124.         AttackToCounter.put(attack, counter);
  125.     }
  126.     public void MapDamages(String action, Integer DAM){ // works
  127.         MapDamage.put(action, DAM);
  128.     }
  129.  
  130.  
  131.  
  132.     public int getDamage(String action){ // works
  133.         return MapDamage.get(action);
  134.     }
  135.  
  136.    
  137.  
  138.     public String getDefend(String attack){ // works
  139.         return AttackToDefend.get(attack);
  140.     }
  141.  
  142.     public String getCounter(String attack){ // works
  143.         return AttackToCounter.get(attack);
  144.        
  145.     }
  146.  
  147.  
  148.  
  149.     public void printAllHashMaps() {
  150.         System.out.println("AttackToDefend:");
  151.         for (String key : AttackToDefend.keySet()) {
  152.             System.out.println(key + " : " + AttackToDefend.get(key));
  153.         }
  154.         System.out.println();
  155.  
  156.         System.out.println("AttackToCounter:");
  157.         for (String key : AttackToCounter.keySet()) {
  158.             System.out.println(key + " : " + AttackToCounter.get(key));
  159.         }
  160.         System.out.println();
  161.  
  162.         System.out.println("MapDamage:");
  163.         for (String key : MapDamage.keySet()) {
  164.             System.out.println(key + " : " + MapDamage.get(key));
  165.         }
  166.         System.out.println();
  167.  
  168.        
  169.     }
  170.  
  171.  
  172.  
  173.    
  174.    
  175.  
  176.  
  177.    
  178.  
  179.  
  180.  
  181.  
  182.  
  183.     public abstract void setAnimations();
  184.     public abstract void setDamage();
  185.     public abstract void setMovesSet();
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. }
  196.  
  197.  
  198.  
  199.  
  200.  
  201. the implementation of it
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208. package Graph.Interactables.InteractablesCommonObjs.Weapons.Fists;
  209.  
  210. import java.util.ArrayList;
  211. import java.util.Map;
  212.  
  213. import Graph.Interactables.InteractablesCommonObjs.Weapons.WeaponsMech;
  214.  
  215. public class Fists extends WeaponsMech{
  216.     static String name = "Fists";
  217.     static String[] attack = {"rightpunch", "leftpunch", "rightkick", "leftkick"};
  218.     static String[] defend = {"block", "block_left_kick", "block_right_kick"};
  219.     static String[] counter = {"right_punch_then_leftUpperCut", "holdleg_byWaist_then_makehimfall_thenkick"};
  220.     static String[] special = {"BlackFlash_right_hand", "blackFlash_leftHand", "BlackFlash_upperCut"};
  221.    
  222.    
  223.  
  224.  
  225.  
  226.     public Fists() { // works
  227.         super(name, attack, defend, counter, special);
  228.         setMovesSet();
  229.         setDamage();
  230.  
  231.         //TODO Auto-generated constructor stub
  232.     }
  233.  
  234.     @Override
  235.     public void setAnimations() {
  236.         // TODO Auto-generated method stub
  237.         throw new UnsupportedOperationException("Unimplemented method 'setAnimations'");
  238.     }
  239.  
  240.     @Override
  241.     public void setDamage() { // works
  242.         // TODO Auto-generated method stub
  243.      MapDamages(attack[0], 10);
  244.      MapDamages(attack[1], 10);
  245.      MapDamages(attack[2], 5);
  246.      MapDamages(attack[3], 5);
  247.  
  248.  
  249.  
  250.          /*
  251.      * static int[] DAMattack = {10, 10, 5, 5};
  252.     static int[] DAMdefend = {5,5,5};
  253.     static int[] DAMcounter = {15, 15};
  254.    
  255.      */
  256.  
  257.     MapDamages(defend[0], 5);
  258.     MapDamages(defend[1], 5);
  259.     MapDamages(defend[2], 5);
  260.  
  261.  
  262.     MapDamages(counter[0], 15);
  263.     MapDamages(counter[0], 15);
  264.  
  265.     MapDamages(special[0], 25);
  266.     MapDamages(special[1], 25);
  267.     MapDamages(special[2], 25);
  268.  
  269.  
  270.  
  271.  
  272.        
  273.  
  274.     }
  275.  
  276.     @Override
  277.     public void setMovesSet() { // works
  278.         // TODO Auto-generated method stub
  279.  
  280.         AttackToDefendMap(attack[0], defend[0]);
  281.         AttackToDefendMap(attack[1], defend[0]);
  282.         AttackToDefendMap(attack[3], defend[1]);
  283.         AttackToDefendMap(attack[2], defend[2]);
  284.  
  285.  
  286.         AttackToDefendMap(special[0], defend[0]);
  287.         AttackToDefendMap(special[1], defend[0]);
  288.         AttackToDefendMap(special[2], defend[0]);
  289.  
  290.  
  291.         AttackToCounterMap(attack[0], counter[0]);
  292.         AttackToCounterMap(attack[1], counter[0]);
  293.         AttackToCounterMap(attack[2], counter[1]);
  294.         AttackToCounterMap(attack[3], counter[1]);
  295.  
  296.     }
  297.  
  298. }
  299.  
  300.  
Add Comment
Please, Sign In to add comment