Guest User

Untitled

a guest
Sep 26th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.21 KB | Source Code | 0 0
  1. the Enemies abstract class:
  2. package Graph.Interactables.Enemies;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.util.Random;
  7. import java.util.random.*;
  8.  
  9.  
  10.  
  11. public abstract class Enemies {
  12.     String name;
  13.     int health;
  14.  
  15.     String[] attack;
  16.     String[] defend;
  17.     String[] counter;
  18.     String[] special;
  19.     String[] moves;
  20.    
  21.    
  22.     Map<String, String> AttackToDefend;
  23.     Map<String, String> AttackToCounter;
  24.     Map<String, Integer> MapDamage;
  25.     Map<String ,Integer> keyPress;
  26.  
  27.    
  28.  
  29.     String EnemyType;
  30.  
  31.     public int turns = 0;
  32.    public  int pattern;
  33.     int CounterConstant;
  34.     private int PressConstant;
  35.  
  36.    
  37.    
  38.  
  39.     public Enemies(String name, String type, int health,  String[] attack, String[] block, String[] counter, String[] special){
  40.         setName(name);
  41.         setMoveSets(attack, block, counter, special);
  42.        
  43.         AttackToDefend = new HashMap<String, String>();
  44.         AttackToCounter = new HashMap<String, String>();
  45.         MapDamage = new HashMap<String, Integer>();
  46.         keyPress = new HashMap<String, Integer>();
  47.  
  48.         // works
  49.  
  50.        
  51.  
  52.     }
  53.  
  54.  
  55.     public void setName(String name){
  56.         this.name = name;
  57.  
  58.     }
  59.  
  60.  
  61.  
  62.     public void setMoveSets(String[] attack, String[] defend, String[] counter, String[] special){
  63.        
  64.         if (attack.length > 0){
  65.            this.attack = attack;
  66.  
  67.         }
  68.         if (defend.length > 0){
  69.             this.defend = defend;
  70.         }
  71.         if (counter.length > 0){
  72.             this.counter = counter;
  73.  
  74.         }
  75.         if (special.length > 0){
  76.            this.special = special;
  77.         }
  78.        // works
  79.  
  80.  
  81.     }
  82.     // nothing wrong
  83.  
  84.  
  85.  
  86.    
  87.  
  88.  
  89.    
  90.     public String getName(){
  91.         return this.name;
  92.     }
  93.  
  94.    
  95.  
  96.  
  97.     public void AttackToDefendMap(String attack,String defend){ // works
  98.         AttackToDefend.put(attack, defend);
  99.  
  100.     }
  101.     public void AttackToCounterMap(String attack, String counter){ // works
  102.         AttackToCounter.put(attack, counter);
  103.     }
  104.  
  105.     public void MapDamages(String action, Integer DAM){ // works
  106.         MapDamage.put(action, DAM);
  107.     }
  108.     public void MapKeys(String action, Integer key){ // works
  109.         keyPress.put(action, key);
  110.     }
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.     public int getDamage(String action){ // works
  123.         return MapDamage.get(action);
  124.     }
  125.  
  126.     public int getCombos(String action){ // works
  127.         return keyPress.get(action);
  128.     }
  129.  
  130.     public String getDefend(String attack){  // works
  131.         return AttackToDefend.get(attack);
  132.     }
  133.  
  134.     public String getCounter(String attack){  // works
  135.         return AttackToCounter.get(attack);
  136.        
  137.     }
  138.     public Integer getKeyPressNeeded(String attack){
  139.         return keyPress.get(attack);
  140.     }
  141.  
  142.  
  143.     public void setPatterns(){ // works
  144.         Random random = new Random();
  145.         for (int i = 0; i < moves.length; i++){
  146.             int index = random.nextInt(attack.length + special.length);
  147.             if (index < attack.length){
  148.                 moves[i] = attack[index];
  149.             }
  150.             else{
  151.                 index = index - attack.length;
  152.                 moves[i] = special[index];
  153.  
  154.             }
  155.  
  156.         }
  157.        
  158.     }
  159.  
  160.     public int[] setCounters(int size) {
  161.         int[] arr = new int[getCounterConstant()];
  162.         Random rand = new Random();
  163.         for (int i = 0; i < size; i++) {
  164.             arr[i] = (rand.nextInt(size));
  165.         }
  166.         return arr;
  167.     }
  168.  
  169.  
  170.     public void setDiffuculty(String diff){
  171.         switch (diff) {
  172.             case "common":
  173.                 this.pattern = 5;
  174.                
  175.                 break;
  176.             case "un_common":
  177.                 this.pattern  =  4;
  178.                
  179.                 break;
  180.             case "rare":
  181.                 this.pattern = 3;
  182.  
  183.                 break;
  184.  
  185.             case "BOSS":
  186.                 this.pattern = 2;
  187.  
  188.                 break;
  189.                
  190.                
  191.        
  192.             default:
  193.                 System.err.println("Incorrect enemy type");
  194.                 break;
  195.         }
  196.     }
  197.  
  198.     public void setHealth(int k){
  199.         this.health = k;
  200.     }
  201.     public void getHealthDamage(int k){
  202.         this.health -= k;
  203.     }
  204.     public int getHealth(){
  205.         return health;
  206.     }
  207.     public void setMoves(String[] arr){ // works
  208.         this.moves = arr;
  209.     }
  210.  
  211.  
  212.     public void setCounterConstant(int k){
  213.         this.CounterConstant = k;
  214.     }
  215.  
  216.     public int getCounterConstant(){
  217.         return this.CounterConstant;
  218.     }
  219.    
  220.  
  221.     public void setPressConstant(int k ){ // works
  222.         this.PressConstant = k;
  223.     }
  224.     public int getPressConstant(){ // works
  225.         return this.PressConstant;
  226.     }
  227.  
  228.  
  229.  
  230.     public String[] getMoves(){ // works
  231.         return this.moves;
  232.     }
  233.  
  234.  
  235.     public void printAllHashMaps() {
  236.         System.out.println("AttackToDefend:");
  237.         for (String key : AttackToDefend.keySet()) {
  238.             System.out.println(key + " : " + AttackToDefend.get(key));
  239.         }
  240.         System.out.println();
  241.  
  242.         System.out.println("AttackToCounter:");
  243.         for (String key : AttackToCounter.keySet()) {
  244.             System.out.println(key + " : " + AttackToCounter.get(key));
  245.         }
  246.         System.out.println();
  247.  
  248.         System.out.println("MapDamage:");
  249.         for (String key : MapDamage.keySet()) {
  250.             System.out.println(key + " : " + MapDamage.get(key));
  251.         }
  252.         System.out.println();
  253.  
  254.         System.out.println("keyPress:");
  255.         for (String key : keyPress.keySet()) {
  256.             System.out.println(key + " : " + keyPress.get(key));
  257.         }
  258.     }
  259.  
  260.     public String printKeyPress(){
  261.         System.out.println("keyPress:");
  262.         String text = "";
  263.         for (String key : keyPress.keySet()) {
  264.             String in = String.valueOf(keyPress.get(key));
  265.             text = text + "\n"  + key + ": " + in + '\n';
  266.            
  267.         }
  268.         return text;
  269.     }
  270.  
  271.  
  272.  
  273.  
  274.  
  275.     public void printMoveSets() {
  276.         StringBuilder output = new StringBuilder();
  277.    
  278.         // Append attack moves
  279.         output.append("Attack Moves: ");
  280.         for (String arr : attack) {
  281.             output.append(arr).append(" ");
  282.         }
  283.    
  284.         // Append defend moves
  285.         output.append("\nDefend Moves: ");
  286.         for (String arr : defend) {
  287.             output.append(arr).append(" ");
  288.         }
  289.    
  290.         // Append counter moves
  291.         output.append("\nCounter Moves: ");
  292.         for (String arr : counter) {
  293.             output.append(arr).append(" ");
  294.         }
  295.  
  296.         output.append("\nSpecial Moves: ");
  297.         for (String arr : special) {
  298.             output.append(arr).append(" ");
  299.         }
  300.  
  301.  
  302.    
  303.         // Print the complete output on one line
  304.         System.out.println(output.toString());
  305.     }
  306.    
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.    
  317.     public abstract void setAnimations();
  318.     public abstract void setDamage();
  319.     public abstract void setMovesSet();
  320.     public abstract void BattleEvents();
  321.     public abstract void Key();
  322.  
  323.  
  324. }
  325.    
  326.  
  327.  
  328.    
  329. The implementation of it:
  330.  
  331.  
  332. package Graph.Interactables.Enemies.BOSSES.BodyBlitzCP;
  333.  
  334. import Graph.Interactables.Enemies.Enemies;
  335.  
  336. public class BodyBlitzCP extends Enemies{
  337.     static String[] attack = {"right_punch", "left_punch", "right_kick", "left_kick"};
  338.     static String[] defend = {"block", "block_left_kick", "block_right_kick"};
  339.     static String[] counter = {"right_punch_then_leftUpperCut", "holdleg_byWaist_then_makehimfall_thenkick"};
  340.     static String[] special = {"BlackFlash_right_hand", "blackFlash_leftHand", "BlackFlash_upperCut"};
  341.     public String[] moves = {"right_punch", "left_punch", "BlackFlash_right_hand", "left_kick"};
  342.     int k;
  343.  
  344.    
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.    
  352.     public BodyBlitzCP() {
  353.         super("DISCGUSTING MUSCULAR CURSED SPIRIT", "BOSS", 150, attack, defend, counter, special);
  354.         setMoves(moves);
  355.         setMovesSet();
  356.         setDamage();
  357.         setDiffuculty("BOSS");
  358.         setPressConstant(2);
  359.         setCounterConstant(3);
  360.         k = getPressConstant();
  361.         Key();
  362.         //TODO Auto-generated constructor stub
  363.     }
  364.  
  365.  
  366.  
  367.    
  368.    
  369.  
  370.  
  371.    
  372.  
  373.  
  374.  
  375.    
  376.  
  377.     @Override
  378.     public void setAnimations() {
  379.         // TODO Auto-generated method stub
  380.         throw new UnsupportedOperationException("Unimplemented method 'setAnimations'");
  381.     }
  382.  
  383.  
  384.  
  385.     @Override
  386.     public void setDamage() { // works
  387.         // TODO Auto-generated method stub
  388.         MapDamages(attack[0], 10);
  389.         MapDamages(attack[1], 10);
  390.         MapDamages(attack[2], 5);
  391.         MapDamages(attack[3], 5);
  392.    
  393.    
  394.    
  395.             /*
  396.         * static int[] DAMattack = {10, 10, 5, 5};
  397.        static int[] DAMdefend = {5,5,5};
  398.        static int[] DAMcounter = {15, 15};
  399.        
  400.         */
  401.    
  402.        MapDamages(defend[0], 5);
  403.        MapDamages(defend[1], 5);
  404.        MapDamages(defend[2], 5);
  405.    
  406.    
  407.        MapDamages(counter[0], 15);
  408.        MapDamages(counter[1], 15);
  409.    
  410.        MapDamages(special[0], 25);
  411.        MapDamages(special[1], 25);
  412.        MapDamages(special[2], 25);
  413.    
  414.    
  415.    
  416.    
  417.            
  418.     }
  419.  
  420.  
  421.  
  422.     @Override
  423.     public void setMovesSet() { // works
  424.         // TODO Auto-generated method stub
  425.         AttackToDefendMap(attack[0], defend[0]);
  426.         AttackToDefendMap(attack[1], defend[0]);
  427.         AttackToDefendMap(attack[3], defend[1]);
  428.         AttackToDefendMap(attack[2], defend[2]);
  429.  
  430.  
  431.         AttackToDefendMap(special[0], defend[0]);
  432.         AttackToDefendMap(special[1], defend[0]);
  433.         AttackToDefendMap(special[2], defend[0]);
  434.  
  435.  
  436.         AttackToCounterMap(attack[0], counter[0]);
  437.         AttackToCounterMap(attack[1], counter[0]);
  438.         AttackToCounterMap(attack[2], counter[1]);
  439.         AttackToCounterMap(attack[3], counter[1]);
  440.  
  441.        
  442.     }
  443.  
  444.  
  445.  
  446.     @Override
  447.     public void BattleEvents() {
  448.         // TODO Auto-generated method stub
  449.        
  450.     }
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.     @Override
  465.     public void Key() { // works
  466.         // TODO Auto-generated method stub
  467.         for (int i = 0; i < attack.length; i++){
  468.             switch (i){
  469.                 case 0:
  470.                     MapKeys(attack[i], 3 + k );
  471.                    
  472.                    
  473.                     break;
  474.                 case 1:
  475.                     MapKeys(attack[i], 3 + k);
  476.  
  477.                     break;
  478.                 case 2:
  479.                     MapKeys(attack[i], 2 + k);
  480.  
  481.                     break;
  482.  
  483.                 case 3:
  484.                     MapKeys(attack[i], 2 + k);
  485.  
  486.                     break;
  487.                 case 4:
  488.                     MapKeys(attack[i], 3 + k );
  489.                    
  490.                    
  491.                     break;
  492.                 case 5:
  493.                     MapKeys(attack[i], 3 + k);
  494.  
  495.                     break;
  496.                 case 6:
  497.                     MapKeys(attack[i], 2 + k);
  498.  
  499.                     break;
  500.  
  501.            
  502.                 default:
  503.                     break;
  504.             }
  505.         }
  506.  
  507.  
  508.         for (String in : special){
  509.             MapKeys(in, 10);
  510.         }
  511.        
  512.    
  513.            
  514.        
  515.     }
  516.  
  517.  
  518.    
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.    
  533.  
  534.  
Add Comment
Please, Sign In to add comment