Standard output or nothing IMO
But using a gui framework to draw simple ascii characters makes me cry a little.Look at all of those imports, there is something fun to me about making a game using the bare minimum.
Tiwa is genius.
import java.util.HashMap;public class NarutoNinja {protected String name;protected HashMap<String,NinjaBodyPart>body=new HashMap<String,NinjaBodyPart>();protected HashMap<String,Jutsu>jutsus=new HashMap<String,Jutsu>();//These are a Ninjas Attacks, in this case "Left Punch","Left Kick", etcpublic NarutoNinja(String n){name=n;}//c}//class
import java.util.ArrayList;public class NinjaBodyPart{protected String name;protected int health;protected int MAX_HEALTH;protected final ArrayListparts=new ArrayList();public NinjaBodyPart(String n,int h){name=n;health=h;MAX_HEALTH=h;}//cpublic String toString(){return name;}public String getLabel(){return String.format("%s: %d",name,health);}
protected final HashMaplblBody=new HashMap();
HashMapbody=kakashi.getBody();Object[]keys=body.keySet().toArray();for(int i=0;iString key=keys[i].toString();//one key now can access both HashMapsJLabel lbl=new JLabel(body.get(key).getLabel());//makes text for the JLabellbl.setOpaque(true);//otherwise the background colour doesnt come throughlbl.setBackground(Color.green);//a nice healthy limblblBody.put(key,lbl);}//for i
protected String processAttack(NarutoNinja ninja1,NarutoNinja ninja2,Jutsu attack){NinjaBodyPart part=processPart(ninja2,attack);Color col=Color.yellow;String line=String.format("%s %ss %s in his %s for %d damage (%d Health)\n",ninja1.getName(),attack.getName(),ninja2.getName(),part.getName(),attack.getDamage(),part.getHealth());int phealth=part.getHealth();String damage="";part.setHealth(phealth-attack.getDamage());if(part.getHealth()damage="bruised";}if(part.getHealth()<0){damage="dismembered";col=Color.red;destroyBodyParts(part,part.getHealth());String[]dead={"Head","UpperTorso","LowerTorso"};for(int i=0;iif(part.getName().equals(dead[i])){sndKick.stop();sndPunch.stop();sndWin.play();JOptionPane.showMessageDialog( this, "Congratulations! You Win!", "Crombat Great Success", JOptionPane.PLAIN_MESSAGE,new ImageIcon("gaithumbsup.jpg"));}//fi}//4 ireturn line+=String.format("Kakashis %s is %s (%d Health)",part.getName(),damage,part.getHealth());}//if part.getHealth()<0if(part.getHealth()==0){sndCrack.play();damage="critically injured";col=Color.WHITE;//gray doesnt show up properly here}if(part.getHealth()>=part.getMaxHealth()/2){damage="damaged";}line+=String.format("Kakashis %s is %s (%d Health)",part.getName(),damage,part.getHealth());lblBody.get(part.getName()).setText(part.getLabel());if(col!=null){lblBody.get(part.getName()).setBackground(col);}return line;}//me
protected void destroyBodyParts(NinjaBodyPart part,int h){part.setHealth(h);lblBody.get(part.getName()).setText(part.getLabel());lblBody.get(part.getName()).setBackground(Color.red);if(part.getParts().isEmpty())return;for(int i=0;idestroyBodyParts(part.getParts().get(i),h);}}//me
protected final String[]btnLabels={"Left Punch","Right Punch","Left Kick","Right Kick","Combo","Instructions"};protected void createButtons(JPanel btnPanel){for(int i=0;iJButton btn=new JButton(btnLabels[i]);btn.setMargin(new Insets(0,0,0,0));btn.setActionCommand(String.format("%s%s","btn",Library.removeSpaces(btnLabels[i])));btn.addActionListener(this);btnPanel.add(btn);}//4}public void actionPerformed(ActionEvent ae){try{getClass().getDeclaredMethod(ae.getActionCommand()).invoke(this);}//catchcatch(Exception e){Library.getHelp(e.toString(),ae.getActionCommand());}//catch}//me action performed
protected void reset(){HashMapbody=ninjas.get(0).getBody();for(Map.Entryentry:body.entrySet()){NinjaBodyPart part=entry.getValue();//get the iterated body part from the Mappart.setHealth(part.getMaxHealth());//MAX_HEALTH is saved in the class from the initial healthJLabel lbl=lblBody.get(part.getName());//get the label associated with the body partlbl.setText(part.getLabel());//reset the text of the labellbl.setBackground(Color.GREEN);//nice healthy limb}//4 iterate map of body parts}//reset
protected void reset(){for(Map.Entryentry:ninjas.get(0).getBody().entrySet()){entry.getValue().setHealth(entry.getValue().getMaxHealth());lblBody.get(entry.getValue().getName()).setText(entry.getValue().getLabel());lblBody.get(entry.getValue().getName()).setBackground(Color.GREEN);}
protected final String[]PARTS_BODY={"Head","UpperTorso","LowerTorso"};
What's up with these bots selling stuff?No one wants your iApples and HTC Galaxies.
I heard the next version of Ninja Attack will been released this week.If you have a previous install, you have to uninstall if first, format your hard drive, then buy a new computer before reinstalling.