diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java index fc3e54c..617e5c6 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java @@ -27,31 +27,33 @@ public void duel(View vw) boolean blnSecondBCWins = false; BattleCreature bcOne; - BattleCreature bcTwo; + AnimeRobot arTwo; // Thanks to Mr Hardman for checking the original numbers! These ones work better. bcOne = new BattleCreature("Mondoise", 200, 10, 33); - bcTwo = new BattleCreature("Tuesachu", 200, 25, 15); + arTwo = new AnimeRobot("Gun Dam", 500, 25, 15, 100); bcOne.restore(); - bcTwo.restore(); + arTwo.restore(); txtvwBattleOutput.setText(""); while(blnNoWinner) { // Thanks to Mr Hardman for the logic assist! - if((bcTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) + if ((arTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) { - bcOne.attack(bcTwo); - txtvwBattleOutput.append(bcTwo.getLastAction()); + bcOne.attack(arTwo); + txtvwBattleOutput.append(bcOne.getLastAction()); + txtvwBattleOutput.append(arTwo.getLastAction()); blnFirstBCWins = bcOne.hasWon(); } - if((bcOne.isDefeated() == false) && (bcTwo.isDefeated() == false)) + if((bcOne.isDefeated() == false) && (arTwo.isDefeated() == false)) { - bcTwo.attack(bcOne); + arTwo.AnimeLaserAttack(bcOne); + txtvwBattleOutput.append(arTwo.getLastAction()); txtvwBattleOutput.append(bcOne.getLastAction()); - blnSecondBCWins = bcTwo.hasWon(); + blnSecondBCWins = arTwo.hasWon(); } blnNoWinner = !blnFirstBCWins && !blnSecondBCWins; diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java new file mode 100644 index 0000000..0cd8250 --- /dev/null +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java @@ -0,0 +1,44 @@ +package com.example.mrb.amazingbattlecreatures; + +/** + * Created by student on 11/03/2016. + */ +public class AnimeRobot extends BattleCreature +{ + + private int intAnimeLaserAttackAmount; + private int intAnimeShieldAmount; + + public AnimeRobot (String strName_PARAM, + int intHitPoints_PARAM, + int intDefenceRating_PARAM, + int intOffenceRating_PARAM, + int intAnimeLaserAttackAmount_PARAM) + + { + super(strName_PARAM, intHitPoints_PARAM, intDefenceRating_PARAM, intOffenceRating_PARAM); + + this.intAnimeLaserAttackAmount = intAnimeLaserAttackAmount_PARAM; + + } + + public void AnimeLaserAttack(BattleCreature battlecreatOpponent_PARAM) + {if(!battlecreatOpponent_PARAM.isDefeated()) + { + battlecreatOpponent_PARAM.defend(intAnimeLaserAttackAmount); + strLastAction = strName + " has exacted " + intAnimeLaserAttackAmount + " of laser damage! \n"; + } + + if(battlecreatOpponent_PARAM.isDefeated()) + { + blnHasWon = true; + } + else + { + blnHasWon = false; + }} + +} + + + diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java index fe328cf..37e60d9 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java @@ -5,14 +5,14 @@ */ public class BattleCreature { - private String strName; + protected String strName; private int intHitPointsMaster; private int intHitPoints; // Or perhaps it should be intHealthPoints? private int intDefenceRating; private int intOffenceRating; private boolean blnIsDefeated; - private boolean blnHasWon; - private String strLastAction; + protected boolean blnHasWon; + protected String strLastAction; public BattleCreature(String strName_PARAM, int intHitPoints_PARAM, @@ -45,6 +45,7 @@ public void attack(BattleCreature battcreatOpponent_PARAM) if (!battcreatOpponent_PARAM.isDefeated()) { battcreatOpponent_PARAM.defend(intOffenceRating); + strLastAction = strName + " has delivered a " + intOffenceRating + " point attack!\n"; } if(battcreatOpponent_PARAM.isDefeated()) @@ -66,12 +67,12 @@ public void defend(int intOffenceAmount_PARAM) intHitPoints = 0; blnIsDefeated = true; blnHasWon = false; - strLastAction = strName + " is defeated."; + strLastAction = strName + " is defeated.\n"; } else if (intNetDamage > 0) { intHitPoints = intHitPoints - intNetDamage; - strLastAction = strName + " has taken " + intNetDamage + " damage."; + strLastAction = strName + " has taken " + intNetDamage + " damage.\n"; } } diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java new file mode 100644 index 0000000..1e62f1b --- /dev/null +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java @@ -0,0 +1,46 @@ +package com.example.mrb.amazingbattlecreatures; + +/** + * Created by PBuskell on 08/03/2016. + */ +public class CyberBattleCreature extends BattleCreature +{ + private int intCyberAttackAmount; + + public CyberBattleCreature(String strName_PARAM, + int intHitPoints_PARAM, + int intDefenceRating_PARAM, + int intOffenceRating_PARAM, + int intCyberAttackAmount_PARAM) + { + // Call the Constructor of the parent class using the keyword "super". This will set the + // values for most of the variables (except intCyberAttackAmount) + super(strName_PARAM, intHitPoints_PARAM, intDefenceRating_PARAM, intOffenceRating_PARAM); + + // We need to set the new data variable here, since the parent class constructor can't + // handle it. + this.intCyberAttackAmount = intCyberAttackAmount_PARAM; + } + + public void cyberAttack(BattleCreature battcreatOpponent_PARAM) + { + if (!battcreatOpponent_PARAM.isDefeated()) + { + // We attack the opponent with our new intCyberAttackAmount! + battcreatOpponent_PARAM.defend(intCyberAttackAmount); + strLastAction = strName + " has delivered a " + intCyberAttackAmount + + "-point cyber attack!\n"; + } + + if(battcreatOpponent_PARAM.isDefeated()) + { + // We call the blnHasWon() method on our opponent using the "super" keyword + blnHasWon = true; + } + else + { + blnHasWon = false; + } + } + +}