Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The Weapons abstract class:
- package Graph.Interactables.InteractablesCommonObjs.Weapons;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- public abstract class WeaponsMech {
- String name;
- //ArrayList<ArrayList<String>> moveSets;
- String[] attack;
- String[] defend;
- String[] counter;
- String[] special;
- Map<String, String> AttackToDefend;
- Map<String, String> AttackToCounter;
- Map<String, Integer> MapDamage;
- ArrayList<String>moves;
- public WeaponsMech(String name, 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>();
- } // works
- public void setName(String name){
- this.name = name;
- }
- public void setMoveSets(String[] attack, String[] defend, String[] counter, String[] special){ // nothng wrong
- 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
- }
- 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 String getName(){
- return this.name;
- }
- public String[] getAttack(){
- return this.attack;
- }
- public String[] getDefend(){
- return this.defend;
- }
- public String[] getCounter(){
- return this.counter;
- }
- public String[] getSpecial(){
- return this.special;
- }
- 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 int getDamage(String action){ // works
- return MapDamage.get(action);
- }
- public String getDefend(String attack){ // works
- return AttackToDefend.get(attack);
- }
- public String getCounter(String attack){ // works
- return AttackToCounter.get(attack);
- }
- 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();
- }
- public abstract void setAnimations();
- public abstract void setDamage();
- public abstract void setMovesSet();
- }
- the implementation of it
- package Graph.Interactables.InteractablesCommonObjs.Weapons.Fists;
- import java.util.ArrayList;
- import java.util.Map;
- import Graph.Interactables.InteractablesCommonObjs.Weapons.WeaponsMech;
- public class Fists extends WeaponsMech{
- static String name = "Fists";
- static String[] attack = {"rightpunch", "leftpunch", "rightkick", "leftkick"};
- 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 Fists() { // works
- super(name, attack, defend, counter, special);
- setMovesSet();
- setDamage();
- //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[0], 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]);
- }
- }
Add Comment
Please, Sign In to add comment