Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- the Enemies abstract class:
- package Graph.Interactables.Enemies;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Random;
- import java.util.random.*;
- public abstract class Enemies {
- String name;
- int health;
- String[] attack;
- String[] defend;
- String[] counter;
- String[] special;
- String[] moves;
- Map<String, String> AttackToDefend;
- Map<String, String> AttackToCounter;
- Map<String, Integer> MapDamage;
- Map<String ,Integer> keyPress;
- String EnemyType;
- public int turns = 0;
- public int pattern;
- int CounterConstant;
- private int PressConstant;
- public Enemies(String name, String type, int health, String[] attack, String[] block, String[] counter, String[] special){
- setName(name);
- setMoveSets(attack, block, counter, special);
- AttackToDefend = new HashMap<String, String>();
- AttackToCounter = new HashMap<String, String>();
- MapDamage = new HashMap<String, Integer>();
- keyPress = new HashMap<String, Integer>();
- // works
- }
- public void setName(String name){
- this.name = name;
- }
- public void setMoveSets(String[] attack, String[] defend, String[] counter, String[] special){
- if (attack.length > 0){
- this.attack = attack;
- }
- if (defend.length > 0){
- this.defend = defend;
- }
- if (counter.length > 0){
- this.counter = counter;
- }
- if (special.length > 0){
- this.special = special;
- }
- // works
- }
- // nothing wrong
- public String getName(){
- return this.name;
- }
- public void AttackToDefendMap(String attack,String defend){ // works
- AttackToDefend.put(attack, defend);
- }
- public void AttackToCounterMap(String attack, String counter){ // works
- AttackToCounter.put(attack, counter);
- }
- public void MapDamages(String action, Integer DAM){ // works
- MapDamage.put(action, DAM);
- }
- public void MapKeys(String action, Integer key){ // works
- keyPress.put(action, key);
- }
- public int getDamage(String action){ // works
- return MapDamage.get(action);
- }
- public int getCombos(String action){ // works
- return keyPress.get(action);
- }
- public String getDefend(String attack){ // works
- return AttackToDefend.get(attack);
- }
- public String getCounter(String attack){ // works
- return AttackToCounter.get(attack);
- }
- public Integer getKeyPressNeeded(String attack){
- return keyPress.get(attack);
- }
- public void setPatterns(){ // works
- Random random = new Random();
- for (int i = 0; i < moves.length; i++){
- int index = random.nextInt(attack.length + special.length);
- if (index < attack.length){
- moves[i] = attack[index];
- }
- else{
- index = index - attack.length;
- moves[i] = special[index];
- }
- }
- }
- public int[] setCounters(int size) {
- int[] arr = new int[getCounterConstant()];
- Random rand = new Random();
- for (int i = 0; i < size; i++) {
- arr[i] = (rand.nextInt(size));
- }
- return arr;
- }
- public void setDiffuculty(String diff){
- switch (diff) {
- case "common":
- this.pattern = 5;
- break;
- case "un_common":
- this.pattern = 4;
- break;
- case "rare":
- this.pattern = 3;
- break;
- case "BOSS":
- this.pattern = 2;
- break;
- default:
- System.err.println("Incorrect enemy type");
- break;
- }
- }
- public void setHealth(int k){
- this.health = k;
- }
- public void getHealthDamage(int k){
- this.health -= k;
- }
- public int getHealth(){
- return health;
- }
- public void setMoves(String[] arr){ // works
- this.moves = arr;
- }
- public void setCounterConstant(int k){
- this.CounterConstant = k;
- }
- public int getCounterConstant(){
- return this.CounterConstant;
- }
- public void setPressConstant(int k ){ // works
- this.PressConstant = k;
- }
- public int getPressConstant(){ // works
- return this.PressConstant;
- }
- public String[] getMoves(){ // works
- return this.moves;
- }
- public void printAllHashMaps() {
- System.out.println("AttackToDefend:");
- for (String key : AttackToDefend.keySet()) {
- System.out.println(key + " : " + AttackToDefend.get(key));
- }
- System.out.println();
- System.out.println("AttackToCounter:");
- for (String key : AttackToCounter.keySet()) {
- System.out.println(key + " : " + AttackToCounter.get(key));
- }
- System.out.println();
- System.out.println("MapDamage:");
- for (String key : MapDamage.keySet()) {
- System.out.println(key + " : " + MapDamage.get(key));
- }
- System.out.println();
- System.out.println("keyPress:");
- for (String key : keyPress.keySet()) {
- System.out.println(key + " : " + keyPress.get(key));
- }
- }
- public String printKeyPress(){
- System.out.println("keyPress:");
- String text = "";
- for (String key : keyPress.keySet()) {
- String in = String.valueOf(keyPress.get(key));
- text = text + "\n" + key + ": " + in + '\n';
- }
- return text;
- }
- public void printMoveSets() {
- StringBuilder output = new StringBuilder();
- // Append attack moves
- output.append("Attack Moves: ");
- for (String arr : attack) {
- output.append(arr).append(" ");
- }
- // Append defend moves
- output.append("\nDefend Moves: ");
- for (String arr : defend) {
- output.append(arr).append(" ");
- }
- // Append counter moves
- output.append("\nCounter Moves: ");
- for (String arr : counter) {
- output.append(arr).append(" ");
- }
- output.append("\nSpecial Moves: ");
- for (String arr : special) {
- output.append(arr).append(" ");
- }
- // Print the complete output on one line
- System.out.println(output.toString());
- }
- public abstract void setAnimations();
- public abstract void setDamage();
- public abstract void setMovesSet();
- public abstract void BattleEvents();
- public abstract void Key();
- }
- The implementation of it:
- package Graph.Interactables.Enemies.BOSSES.BodyBlitzCP;
- import Graph.Interactables.Enemies.Enemies;
- public class BodyBlitzCP extends Enemies{
- static String[] attack = {"right_punch", "left_punch", "right_kick", "left_kick"};
- static String[] defend = {"block", "block_left_kick", "block_right_kick"};
- static String[] counter = {"right_punch_then_leftUpperCut", "holdleg_byWaist_then_makehimfall_thenkick"};
- static String[] special = {"BlackFlash_right_hand", "blackFlash_leftHand", "BlackFlash_upperCut"};
- public String[] moves = {"right_punch", "left_punch", "BlackFlash_right_hand", "left_kick"};
- int k;
- public BodyBlitzCP() {
- super("DISCGUSTING MUSCULAR CURSED SPIRIT", "BOSS", 150, attack, defend, counter, special);
- setMoves(moves);
- setMovesSet();
- setDamage();
- setDiffuculty("BOSS");
- setPressConstant(2);
- setCounterConstant(3);
- k = getPressConstant();
- Key();
- //TODO Auto-generated constructor stub
- }
- @Override
- public void setAnimations() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'setAnimations'");
- }
- @Override
- public void setDamage() { // works
- // TODO Auto-generated method stub
- MapDamages(attack[0], 10);
- MapDamages(attack[1], 10);
- MapDamages(attack[2], 5);
- MapDamages(attack[3], 5);
- /*
- * static int[] DAMattack = {10, 10, 5, 5};
- static int[] DAMdefend = {5,5,5};
- static int[] DAMcounter = {15, 15};
- */
- MapDamages(defend[0], 5);
- MapDamages(defend[1], 5);
- MapDamages(defend[2], 5);
- MapDamages(counter[0], 15);
- MapDamages(counter[1], 15);
- MapDamages(special[0], 25);
- MapDamages(special[1], 25);
- MapDamages(special[2], 25);
- }
- @Override
- public void setMovesSet() { // works
- // TODO Auto-generated method stub
- AttackToDefendMap(attack[0], defend[0]);
- AttackToDefendMap(attack[1], defend[0]);
- AttackToDefendMap(attack[3], defend[1]);
- AttackToDefendMap(attack[2], defend[2]);
- AttackToDefendMap(special[0], defend[0]);
- AttackToDefendMap(special[1], defend[0]);
- AttackToDefendMap(special[2], defend[0]);
- AttackToCounterMap(attack[0], counter[0]);
- AttackToCounterMap(attack[1], counter[0]);
- AttackToCounterMap(attack[2], counter[1]);
- AttackToCounterMap(attack[3], counter[1]);
- }
- @Override
- public void BattleEvents() {
- // TODO Auto-generated method stub
- }
- @Override
- public void Key() { // works
- // TODO Auto-generated method stub
- for (int i = 0; i < attack.length; i++){
- switch (i){
- case 0:
- MapKeys(attack[i], 3 + k );
- break;
- case 1:
- MapKeys(attack[i], 3 + k);
- break;
- case 2:
- MapKeys(attack[i], 2 + k);
- break;
- case 3:
- MapKeys(attack[i], 2 + k);
- break;
- case 4:
- MapKeys(attack[i], 3 + k );
- break;
- case 5:
- MapKeys(attack[i], 3 + k);
- break;
- case 6:
- MapKeys(attack[i], 2 + k);
- break;
- default:
- break;
- }
- }
- for (String in : special){
- MapKeys(in, 10);
- }
- }
Add Comment
Please, Sign In to add comment