Thread: help please
View Single Post
  #1 (permalink)  
Old 06-05-2008, 11:51 PM
f_the_cook's Avatar
f_the_cook f_the_cook is offline
Member
 
Join Date: May 2008
Posts: 18
f_the_cook is on a distinguished road
help please
ok so i am having a problem with my while loop. it does let me go again it stop a a ceratin point. help would be appreciated.

import cs1.Keyboard;
public class combat
{


public static void main(String args[])
{


String again="yes";
String again2="yes";
String again3="yes";
String Equip;

int playerHP=30;
int playerItem=1;
int playerItem2=1;
int playerXP=0;
int level=1;
int atk=1;
int def=1;
int basicAttack=15;
int spiralAttack=20;
int omegaStrike=25;
int whirlWind=20;



while (again3.equalsIgnoreCase("yes"))
{
int enemyHP=30;
int enemyAttack=10;
int choice;
System.out.println("1.would you like to head north to duweldenvarden\n2.head east to murgenville\n3.head south to ruby island\n4.head west to city of the great");
choice=Keyboard.readInt();
switch(choice)
{
case 1:
System.out.println("As you are walking you are attacked by a goblin!\n");
break;
case 2:
System.out.println("you smell a foul smell in the air...its a wild boar!\n");
break;
case 3:
System.out.println("As you are walking you are attacked by a zombie!\n");
break;
case 4:
System.out.println("As you are walking you are attacked by a baby dragon!\n");
break;
}
while(again.equalsIgnoreCase("yes"))
{
System.out.println("1.fight\n2.item\n3.flee ");
choice=Keyboard.readInt();
switch(choice)
{


case 1:
System.out.println("1.basic attack\n2.spiral attack\n3.omega strike\n4.whrilwind");
choice=Keyboard.readInt();
switch(choice)
{
case 1:
if (choice==1)
{
enemyHP=enemyHP-basicAttack;
System.out.println("the enemy's health is "+enemyHP);
}
case 2:
if (choice==2)
{
enemyHP=enemyHP-spiralAttack;
System.out.println("the enemy's health is "+enemyHP);
}
case 3:
if (choice==3)
{
enemyHP=enemyHP-omegaStrike;
System.out.println("the enemy's health is "+enemyHP);
}
case 4:
if (choice==4)
{
enemyHP=enemyHP-whirlWind;
System.out.println("the enemy's health is "+enemyHP);
}
}
break;
case 2:
System.out.println("1.potion\n2.super potion");
choice=Keyboard.readInt();
switch(choice)
{
case 1:
if (choice==1)
{

if (playerItem<1)
{
System.out.println("you have no more potions!");
}
else
playerHP=playerHP+15;
playerItem=playerItem-1;
}
case 2:
if (choice==2)
{

if (playerItem2<1)
{
System.out.println("you have no more super potions!");
}
else
playerHP=playerHP+35;
playerItem2=playerItem2-1;
}
}
case 3:
if(choice==3)
{
System.out.println("You ran like a little girl! ");
}
break;

}


if (choice==1)
{
System.out.println("the enemy has attacked you! ");
playerHP=playerHP-enemyAttack;
System.out.println("your health is "+playerHP);
}
else if (choice==2)
{
System.out.println("the enemy has attacked you! ");
playerHP=playerHP-enemyAttack;
System.out.println("your health is "+playerHP);
}
else if (choice==3)
{
System.out.println("the enemy has attacked you! ");
playerHP=playerHP-enemyAttack;
System.out.println("your health is "+playerHP);
}
else if (choice==4)
{
System.out.println("the enemy has attacked you! ");
playerHP=playerHP-enemyAttack;
System.out.println("your health is "+playerHP);

}

if (enemyHP<=0)
{

System.out.println("You win! ");
playerXP=playerXP+100;

if (playerXP==100)
{
level=level+1;
System.out.println("you went up one level!!! you are now level "+level);
if (level>1)
{
atk=atk+1;
def=def+1;
playerHP=playerHP+15;
basicAttack=basicAttack+5;
spiralAttack=spiralAttack+5;
omegaStrike=omegaStrike+5;
whirlWind=whirlWind+5;
enemyAttack=enemyAttack--;
enemyHP=enemyHP+10;
}

}


Claymore weapon=new Claymore();

System.out.println("you get a sword with "+weapon.getClaymoreAtk());


System.out.println("would you like to equip the "+weapon.getClaymoreName()+"?");
Equip=Keyboard.readString();
if (Equip.equalsIgnoreCase("yes"))
{
atk=atk+weapon.getClaymoreAtk();
System.out.println("your atk is now "+atk);
basicAttack=basicAttack+10;
spiralAttack=spiralAttack+10;
omegaStrike=omegaStrike+10;
whirlWind=whirlWind+10;
}

}


System.out.print("Would you like to continue fighting or run yes/no : ");
again=Keyboard.readString();


if (again.equalsIgnoreCase("no"))
{
while(again2.equalsIgnoreCase("yes"))
{


System.out.println("welcome to the town! what would you like to do?\n1.go to the inn?\n2.go to the store\n3.leave");
choice=Keyboard.readInt();
switch(choice)
{
case 1:
playerHP=playerHP+playerHP;
System.out.println("you are fully healed");
break;
case 2:
System.out.println("Welcome to the store! what would you like?");

System.out.println("\n1.potion\n2.super potion\n3.weapons\n4.leave");
choice=Keyboard.readInt();
switch(choice)
{
case 1:
playerItem=playerItem+1;
case 2:
playerItem2=playerItem2+1;

case 3:
System.out.println("what weapon would you like to buy?");
System.out.println("\n1.claymore\n2.sword\n3.katan a");
choice=Keyboard.readInt();
switch(choice)
{

case 1:
Claymore weapon=new Claymore();
System.out.println("would you like to equip the "+weapon.getClaymoreName()+"?");
Equip=Keyboard.readString();
if (Equip.equalsIgnoreCase("yes"))
{
atk=atk+weapon.getClaymoreAtk();
System.out.println("your atk is now "+atk);
basicAttack=basicAttack+10;
spiralAttack=spiralAttack+10;
omegaStrike=omegaStrike+10;
whirlWind=whirlWind+10;

}
break;
case 2:

break;
case 3:
katana weapon3=new katana();
System.out.println("would you like to equip the "+weapon3.getKatanaName()+"?");
Equip=Keyboard.readString();
if (Equip.equalsIgnoreCase("yes"))
{
atk=atk+weapon3.getKatanaAtk();
System.out.println("your atk is now "+atk);
basicAttack=basicAttack+10;
spiralAttack=spiralAttack+10;
omegaStrike=omegaStrike+10;
whirlWind=whirlWind+10;

}
break;
}
}







}
System.out.println("is the anything else you would do today?");
again2=Keyboard.readString();
}


}





}
}
System.out.println("is the anything else you would do today?");
again3=Keyboard.readString();
}
}






thank you!
Reply With Quote
Sponsored Links