Post by Fox. on Sept 21, 2012 9:32:00 GMT -8
So, I've been learning Java, and I have noticed that even if I make something in it, it (to me) will obviously not work on something like the headers & footers here. This is plain Java and not Javascript (I got into BIG trouble for accidently saying it wrong lol) btw. The big question here for me is if I plan to use what I've been learning in Java what should the next language should I be learning, or next step should I be taking, to use these same effects into something like this for Proboards? I'm semi-familiar with PHP thanks to a different coder and that seems like the best route after I finish Java. Or another way, what language should I be learning other than HTML for more website based interactions?
Just in case anyone wants to discuss the Java Code currently in question. Here it is:
P.S: I do realize there are probably much much easier ways to do this same code with arrays and so on, but I'm still learning, so you'll have to cut me a bit of slack with it lol (Glad to hear any suggestions for it too).
Edit: I am currently working on this code still to improve it.
Just in case anyone wants to discuss the Java Code currently in question. Here it is:
import java.util.Scanner;
public class theBattle
{
//Made by Tabitha Henry aka JabberJay's pet Fox.
public static void main(String[] args)
{
//Variables & other Variable like things
int hitmiss = 0;
String attack = "0";
int damage = 0;
String weaponc = "0";
String atktype = "0";
int districtAdv = 0;
String districtAdv2 = "0";
Scanner input = new Scanner(System.in);
//Method Call 1 | calls the districtCheck
districtAdv = districtCheck(input, districtAdv);
//Method Call 1.1 | calls step 2 of districtCheck
districtAdv2 = districtCheck2(input, districtAdv2, districtAdv);
//Method call 2 | weapon choice
weaponc = weaponchoice(weaponc);
//Inserts blank line
System.out.println(" ");
//Method call 2.1 | damage checker
damage = damageCheck(damage, districtAdv, weaponc);
//Method call 2.2 | attack type
atktype = giveatktype(atktype, damage);
//Method call 3 | hit or miss attack
hitmiss = hitmiss(hitmiss);
//Method call 3.1 | string hit or miss
attack = hitmissattack(attack, hitmiss);
//Check sequence lines
System.out.println(attack);
System.out.println(damage);
System.out.println(atktype);
System.out.println(" ");
System.out.println(districtAdv2);
}
public static int damageCheck(int damage, int districtAdv, String weaponc)
{
//Variables & other Variable like things
int smdamage = (1 + (int)(Math.random() * 75));;
int meddamage = (1 + (int)(Math.random() * 150));;
int ldamage = (1 + (int)(Math.random() * 225));;
//If statement | tells the damage checker what equals what.
if(weaponc.equals("dagger"))
{
damage = smdamage;
if(districtAdv == 1)
{
damage = smdamage + 10;
}
}
else if(weaponc.equals("bow"))
{
damage = meddamage;
if(districtAdv == 1)
{
damage = meddamage + 10;
}
}
else if(weaponc.equals("axe"))
{
damage = ldamage;
if(districtAdv == 1)
{
damage = ldamage + 10;
}
}
else
{
damage = (1 + (int)(Math.random() * 50));;
if(districtAdv == 1 || districtAdv == 2)
{
damage = (1 + (int)(Math.random() * 50 + 10));;
}
}
//Returns the damage dealt
return damage;
}
public static int hitmiss(int hitmiss)
{
//Variables & other Variable like things
//Variables go here
//Randomize int on a max of 12
hitmiss = (1 + (int)(Math.random() * 12));
//Return if it was a hit or miss
return hitmiss;
}
@SuppressWarnings("resource")
public static String weaponchoice(String weaponc)
{
//Variables & other variable like things
Scanner inputDevice = new Scanner(System.in);
//Choose your weapon dialog
System.out.println("Weapon choice?");
weaponc = inputDevice.nextLine();
weaponc = weaponc.toLowerCase();
//Weapon Cases
switch (weaponc)
{
case "dagger":
damageCheck(0, 0, weaponc);
break;
case "bow":
damageCheck(0, 0, weaponc);
break;
case "axe":
damageCheck(0, 0, weaponc);
break;
case "hand to hand":
damageCheck(0, 0, weaponc);
break;
default:
System.out.println("You've chosen an invalid weapon or spelt it worng.");
break;
}
//Return weapon type
return weaponc;
}
public static String giveatktype(String atktype, int damage)
{
//Variables & Other Variable like things
//Enter variables here
//If statement | tells the attack type
if(damage == 1 || damage == 2 || damage == 3 || damage == 4 || damage == 5 || damage == 6 || damage == 7 || damage == 8 ||
damage == 9 || damage == 10)
{
atktype = "Wound 1";
}
else if (damage == 11 || damage == 12 || damage == 13 || damage == 14 || damage == 15 || damage == 16 || damage == 17 ||
damage == 18 || damage == 19 || damage == 20)
{
atktype = "Wound 2";
}
else if (damage == 21 || damage == 22 || damage == 23 || damage == 24 || damage == 25 || damage == 26 || damage == 27 ||
damage == 28 || damage == 29 || damage == 30)
{
atktype = "Wound 3";
}
else if (damage == 31 || damage == 32 || damage == 33 || damage == 34 || damage == 35 || damage == 36 || damage == 37 ||
damage == 38 || damage == 39 || damage == 40)
{
atktype = "Wound 4";
}
else if (damage == 41 || damage == 42 || damage == 43 || damage == 44 || damage == 45 || damage == 46 || damage == 47 ||
damage == 48 || damage == 49 || damage == 50)
{
atktype = "Wound 5";
}
else if (damage == 51 || damage == 52 || damage == 53 || damage == 54 || damage == 55 || damage == 56 || damage == 57 ||
damage == 58 || damage == 59 || damage == 60)
{
atktype = "Wound 6";
}
else if (damage == 61 || damage == 62 || damage == 63 || damage == 64 || damage == 65 || damage == 66 || damage == 67 ||
damage == 68 || damage == 69 || damage == 70)
{
atktype = "Wound 7";
}
else if (damage == 71 || damage == 72 || damage == 73 || damage == 74 || damage == 75 || damage == 76 || damage == 77 ||
damage == 78 || damage == 79 || damage == 80)
{
atktype = "Wound 8";
}
else if (damage == 81 || damage == 82 || damage == 83 || damage == 84 || damage == 85 || damage == 86 || damage == 87 ||
damage == 88 || damage == 89 || damage == 90)
{
atktype = "Wound 9";
}
else if (damage == 91 || damage == 92 || damage == 93 || damage == 94 || damage == 95 || damage == 96 || damage == 97 ||
damage == 98 || damage == 99 || damage == 100)
{
atktype = "Wound 10";
}
else if (damage == 101 || damage == 102 || damage == 103 || damage == 104 || damage == 105 || damage == 106 || damage == 107 ||
damage == 108 || damage == 109 || damage == 110)
{
atktype = "Wound 11";
}
else if (damage == 111 || damage == 112 || damage == 113 || damage == 114 || damage == 115 || damage == 116 || damage == 117 ||
damage == 118 || damage == 119 || damage == 120)
{
atktype = "Wound 12";
}
else if (damage == 121 || damage == 122 || damage == 123 || damage == 124 || damage == 125 || damage == 126 || damage == 127 ||
damage == 128 || damage == 129 || damage == 130)
{
atktype = "Wound 13";
}
else if (damage == 131 || damage == 132 || damage == 133 || damage == 134 || damage == 135 || damage == 136 || damage == 137 ||
damage == 138 || damage == 139 || damage == 140)
{
atktype = "Wound 14";
}
else if (damage == 141 || damage == 142 || damage == 143 || damage == 144 || damage == 145 || damage == 146 || damage == 147 ||
damage == 148 || damage == 149 || damage == 150)
{
atktype = "Wound 15";
}
else if (damage == 151 || damage == 152 || damage == 153 || damage == 154 || damage == 155 || damage == 156 || damage == 157 ||
damage == 158 || damage == 159 || damage == 160)
{
atktype = "Wound 16";
}
else if (damage == 161 || damage == 162 || damage == 163 || damage == 164 || damage == 165 || damage == 166 || damage == 167 ||
damage == 168 || damage == 169 || damage == 170)
{
atktype = "Wound 17";
}
else if (damage == 171 || damage == 172 || damage == 173 || damage == 174 || damage == 175 || damage == 176 || damage == 177 ||
damage == 178 || damage == 179 || damage == 180)
{
atktype = "Wound 18";
}
else if (damage == 181 || damage == 182 || damage == 183 || damage == 184 || damage == 185 || damage == 186 || damage == 187 ||
damage == 188 || damage == 189 || damage == 190)
{
atktype = "Wound 19";
}
else if (damage == 191 || damage == 192 || damage == 193 || damage == 194 || damage == 195 || damage == 196 || damage == 197 ||
damage == 198 || damage == 199 || damage == 200)
{
atktype = "Wound 20";
}
else if (damage == 201 || damage == 202 || damage == 203 || damage == 204 || damage == 205 || damage == 206 || damage == 207 ||
damage == 208 || damage == 209 || damage == 210)
{
atktype = "Wound 21";
}
else if(damage == 211 || damage == 212 || damage == 213 || damage == 214 || damage == 215 || damage == 216 || damage == 217 ||
damage == 218 || damage == 219 || damage == 220)
{
atktype = "Wound 22";
}
else
{
atktype = "Wound 23";
}
//Return attack type
return atktype;
}
public static String hitmissattack(String attack, int hitmiss)
{
//If statement 1 | tells if the character if their attack missed or hit
if(hitmiss == 2 || hitmiss == 4 || hitmiss == 6 || hitmiss == 8 || hitmiss == 10 || hitmiss == 12)
{
attack = "Success.";
}
else
{
attack = "Miss.";
}
//Return attack
return attack;
}
public static int districtCheck(Scanner input, int districtAdv)
{
//Variables & Other things
//Variables go here
//Dialog | Chose your district
System.out.println("Enter your district number.");
districtAdv = input.nextInt();
System.out.println(" ");
//Return districtAdv
return districtAdv;
}
public static String districtCheck2(Scanner input, String districtAdv2, int districtAdv)
{
//Variables & Other things
//Variables go here
//If statement to settle what the district advantage really is
if(districtAdv == 1)
{
districtAdv2 = "You are a Career and get +10 damage to any weapon and + 10 more if you're hunting at night." +
"\nYou also get another +10 damage to any weapon you use specialy. (Meaning, your weapon of choice.)";
}
else if(districtAdv == 2)
{
districtAdv2 = "You are a Career and get +10 to any weapon and + 10 more if you're hunting at night." +
"\nYou also get +10 to all your hand to hand combat hits.";
}
else if(districtAdv == 3)
{
districtAdv2 = "You are a problem solver and are very ingenutive.";
}
else if(districtAdv == 4)
{
districtAdv2 = "You are a Career and get +10 to any weapon and +10 more if you're hunting at night." +
"\nYou also have a bonus to Spear/Trident throwing (+10).";
}
else if(districtAdv == 5)
{
districtAdv2 = "You have bonuses to your knot tying and trap setting. You also get a sneak peak at the map.";
}
else if(districtAdv == 6)
{
districtAdv2 = "You have more strength than most tributes - only rivaled by the Careers and District 8 tributes." +
"\nYou also have a bonus to your hammer usage (+10).";
}
else if(districtAdv == 7)
{
districtAdv2 = "You have a bonus to your axe weapon usage (+10)" +
"\nYou are also very good at camouflage.";
}
else if(districtAdv == 8)
{
districtAdv2 = "You have more strength than most ributes - only rivaled by the Careers and District 6 tributes." +
"\nYou are able to use first aid rather well.";
}
else if(districtAdv == 9)
{
districtAdv2 = "You are stealthy and able to sneak around many things to avoid trouble." +
"\nYou have a bonus to using a Sythe (+10)";
}
else if(districtAdv == 10)
{
districtAdv2 = "You have a bonus to your Mahcete weapons usage (+10)." +
"\nYou have a chance to tame animals.";
}
else if(districtAdv == 11)
{
districtAdv2 = "You are able to tell which plants are edible to keep yourself full if you find them." +
"\nYou have a bonus to resist starving (+50 hunger points).";
}
else if(districtAdv == 12)
{
districtAdv2 = "You are able to start fires rather easily since you are gifted in that talent." +
"\nYou have a bonus to resist starving (+50 hunger points).";
}
//Returns districtAdv2
return districtAdv2;
}
}
P.S: I do realize there are probably much much easier ways to do this same code with arrays and so on, but I'm still learning, so you'll have to cut me a bit of slack with it lol (Glad to hear any suggestions for it too).
Edit: I am currently working on this code still to improve it.