My text game is a survival text game where you try to survive, and you can do a certain number of actions per day, and you can attack other tribes, etc. I wanted to include a weather system, where the
Weather I want to implement
Drought - Decreases Water Supply Double by 3. (Water supply cannot go negative)
5%
Sunny - Does nothing
20%
Cloudy - Does nothing
20%
Flood - Adds 10 to water supply, Lowers Housing Integer by 2 (cannot go negative)
5%
Very windy - Lowers Housing integer by 1.
10%
Rain - Increases food supply by 5.
30%
Rainbow - Increases Moral by 1 and Increases Karma
10%
I know how to do most of this. But theirs 1 major thing I am clueless on how to do.
I want the weather to be shown on the main menu,
System.out.println("Today's Weather is"+weather);
and the variable weather would show the weather. How would I do this?
Oh, and this is the code of the game just in-case you want to see it, it's pretty long.
import java.util.Random;
import java.util.Scanner;
public class TRIBALSURVIVAL {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner (System.in);
Random generator = new Random();
double food;
double water;
double housing;
double tech;
double pop;
double atk;
double def;
double karma;
double farmlevel;
double moral;
double ap;
int apache;
int watersor;
int watersor1;
int chance;
int choice;
int choice1;
int choice2;
int choice3;
int input;
int x;
int tribe;
int action;
int crow;
int cherokee;
int chickasaw;
int kiowa;
double foodintake;
boolean fact = true;
//OTHER TRIBE STATS
apache=60;
cherokee=50;
chickasaw=30;
crow=20;
kiowa=10;
moral=1;
watersor1=0;
x=-1;
watersor=0;
karma=0;
food=3;
water=3;
housing=1;
tech=1;
pop=6;
ap=pop*(.5);
farmlevel=1;
x=generator.nextInt(4)+1;
atk=pop*tech*moral;
def=(pop*housing)+tech;
foodintake=pop*1/2;
chance=generator.nextInt(100)+1;
System.out.println("This is the Tribe Surival Game!");
System.out.println("Your tribe will take up food and water every day! You should try to farm a get water sources quicky!");
System.out.println("If their isnt enough food or water, Tribe Members will die!");
System.out.println("You can also attack Tribes with a defence stat that is lower then your Tribes attack stat!");
String tribename;
System.out.print("Enter your tribe's name: ");
tribename = in.nextLine();
System.out.println("__________________");
System.out.println("You are the leader of the "+tribename+" Tribe");
choice3=1;
choice=1;
while (fact==true)
{//WHILE MAIN
while(choice>0)
{//while1
atk=pop*tech*moral;
def=(pop*housing)+tech;
if(pop<=0)
{//if
System.out.println("All your Tribe Member's dead");
System.out.println("GAME OVER");
}//if
else
{//else
System.out.println("__________________");
System.out.println("Enter 1 to see your Tribe's Status");
System.out.println("Enter 2 to use action points");
System.out.println("Enter 3 to sleep");
System.out.println("Enter 4 to see Other Tribes");
choice = in.nextInt();
switch(choice)
{//switch
case 1:
{//case1
System.out.println("__________________");
System.out.println("Your Tribes Stats");
System.out.println("__________________");
System.out.println("Population ("+pop+")");
System.out.println("Water Supply ("+water+")");
System.out.println("Water Source ("+watersor+")");
System.out.println("Housing Level ("+housing+")");
System.out.println("Technological Level ("+tech+")");
System.out.println("Food Supply ("+food+")");
System.out.println("Farm Level ("+farmlevel+")");
System.out.println("Population Food Intake Per Day ("+foodintake+")");
System.out.println("Action Points ("+ap+")");
System.out.println("Karma level ("+karma+")");
System.out.println("Attack Stat ("+atk+")");
System.out.println("Defensce Stat ("+def+")");
System.out.println("People's Moral ("+moral+")");
System.out.println("__________________");
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
break;
}//case1
case 2:
{//case2 MAIN
System.out.println("__________________");
System.out.println("Spend your action Points");
System.out.println("Current Amount Of ("+ap+")");
System.out.println("__________________");
System.out.println("Enter 1 to Look for a water source(Costs 1 ap)");
System.out.println("Enter 2 to Connect to the water source (Costs 3 ap)");
System.out.println("Enter 3 to Hunt for food (Costs 2 ap)");
System.out.println("Enter 4 to Upgrade Housing (Costs 3 ap)");
System.out.println("Enter 5 to Research New Technology (Costs 4 ap)");
System.out.println("Enter 6 to Upgrade Farm (Costs 5 ap)");
System.out.println("Enter 7 to Do some good deeds (Costs 2 ap)");
System.out.println("Enter 8 to Do some malicious things (Costs 2 ap)");
System.out.println("Enter 9 to Speak a speech and increase moral(costs 6 ap)");
System.out.println("Enter 10 to Populate(costs 2 ap and 6 food)");
System.out.println("__________________");
input = in.nextInt();
switch(input)
{//SUB SWITCH
case 1:
{//SUB SWITCH CASE 1
System.out.println("You chose to look for a water source!");
ap=ap-1;
if (ap<0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}// if
else
{//else
chance=generator.nextInt(100)+1;
if(chance>0&&chance<60)
{//IF CHANCE
System.out.println("You found a water source!");
watersor++;
watersor++;
}//IF CHANCE
else
{//ELSE
chance=generator.nextInt(100)+1;
System.out.println("You found no water source!");
}// ELSE
//Don't forget to break at each case
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//else
break;
}//SUB SWITCH CASE 1
case 2:
{//SUB SWITCH CASE 2
ap=ap-3;
if (ap<0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}// if
else
{//else
System.out.println("You connected to the water source !");
watersor=watersor+watersor1;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//else
break;
}//SUB SWITHC CASE 2
case 3:
{//SUB SWITCH CASE 3
ap=ap-2;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//if
else
{//else 2
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}// if
else
{//else
chance=generator.nextInt(100)+1;
System.out.println("The hunters went to the forest!");
if (chance>25&&chance<50);
{//ELSE IF
System.out.println("The hunters came back with a deer!");
System.out.println("You got 6 food!");
food=food+5;
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//ELSE IF
}//else
}//else 2
break;
}//SUB SWITCH CASE 3
case 4:
{//SUB SWITCH CASE 4
ap=ap-3;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}// if
else
{//else
System.out.println("You upgraded the tribes housing!");
System.out.println("You used 3 ap!");
System.out.println("Housing level increased by 1!");
housing=housing+1;
System.out.println("Your new housing level is "+housing);
System.out.println("Your new defence is "+def);
}//else
break;
}//SUB SWITCH CASE 4
case 5:
{// SUB SWITCH CASE 5
ap=ap-5;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}// if
else
{//else
System.out.println("You researched new technology!");
System.out.println("You used 4 ap!");
System.out.println("Technology increased by 1!");
tech=tech+1;
System.out.println("Your new Technology level is "+tech);
}//else
break;
}//SUB SWITCH CASE 5
case 6:
{//sub switch CASE 6
ap=ap-5;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//if
else
{//else
ap=ap-4;
System.out.println("You upgraded your farm!");
System.out.println("You used 5 ap!");
System.out.println("Farm level increased by 1!");
farmlevel=farmlevel+1;
System.out.println("Your new Farm level is "+farmlevel);
System.out.println("Your new attack is "+farmlevel);
}//else
break;
}//sub switch case 6
case 7:
{// SUB SWITCH CASE 7
ap=ap-2;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//if
else
{//else
System.out.println("You have decided to do some good deeds!");
System.out.println("Your karma increased by 2!");
karma=karma+2;
}//else
break;
}//SUB SWITCH CASE 7
case 8:
{// SUB SWITCH CASE 8
ap=ap-2;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//if
else
{//else
System.out.println("You have decided to do some malicious deeds!");
System.out.println("Your karma decreased by 2!");
karma=karma-2;
}//else
break;
}//SUB SWITCH CASE 8
case 9:
{// SUB SWITCH CASE 9
ap=ap-6;
if (ap<=0)
{// if
ap=0;
System.out.println("You do not have enough ap for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//if
else
{//else
System.out.println("You have decided to do a great speech!");
System.out.println("The tribes moral decreased by 2!");
moral=moral+5;
}//else
break;
}//SUB SWITCH CASE 9
case 10:
{// SUB SWITCH CASE 10
ap=ap-2;
food=food-3;
if (ap<=0||food<=3)
{// if
ap=0;
food=0;
System.out.println("You do not have enough ap or food for this");
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//if
else
{//else
System.out.println("Tribe members have populated!");
pop=pop+4;
}//else
break;
}//SUB SWITCH CASE 10
}//SUB SWITCH
break;
}//case 2 MAIN
case 3:
{//case3
System.out.println("____________________________________");
food=food-(pop*1/2);
System.out.println("You lost -"+pop*1/2+" food from eating");
if(food<0)
{//if food
pop=pop-1;
food=food+(food*x);
System.out.println("1 Tribe Member Died From Starvation!");
}//if food
food=farmlevel+food;
System.out.println("You gained "+farmlevel+" food from farming");
water=water-(pop*1/4);
if(water<0)
{//if water
pop=pop-1;
water=water+(water*x);
System.out.println("1 Tribe Member Died From dehydration!");
}//if water
water=watersor1+water;
ap=0;
ap=pop*1/2;
System.out.println("A long day has passed");
System.out.println("____________________________________");
break;
}//case3
case 4:
{//case 4
System.out.println("The status of other tribes");
System.out.println("Apache tribe (VERY STRONG)");
System.out.println("Type 2 to see info on or take action on Apache");
System.out.println("Cherokee tribe(STRONG)");
System.out.println("Type 3 to see info on or take action on Cherokee");
System.out.println("Chickasaw tribe(MEDIUM)");
System.out.println("Type 4 to see info on or take action on Chickasaw");
System.out.println("Crow tribe(MEDIUM-WEAK)");
System.out.println("Type 5 to see info on or take action on Crow");
System.out.println("Kiowa tribe(WEAK)");
System.out.println("Type 6 to see info on or take action on Kiowa");
tribe=in.nextInt();
switch(tribe)
{//SUB SWITCH WITHIN MAIN CASE 4
case 2:
{//CASE 2
System.out.println("Apache tribe (STRONG)");
System.out.println("Apache Tribe has 50 ATK");
System.out.println("Apache Tribe has 60 DEF");
System.out.println("Apache Tribe has Negative Karma");
System.out.println("Enter 2 to Attack the Apache Tribe(Costs 6 ap)");
action = in.nextInt();
if (action==2)
{//IF
if (atk == apache){
System.out.println("The Apache and "+tribename+" were equally powerful. They both retreated in suprised and no casulties has happened.");
}//if2
else if(atk>apache){
System.out.println("The great "+tribename+" tribe was able to defeat the Apache tribe's defences.");
System.out.println("Enter 1 if you want to pillage the Tribe? (-Karma)");
System.out.println("Enter 2 if you want to convert the Tribe into your group? (+Karma)");
action = in.nextInt();
if (action==1)
{//if3
food=food+30;
pop=pop-2;
karma=karma-10;
tech=tech+5;
housing=housing+5;
moral=moral+5;
System.out.println("You gained 30 food!");
System.out.println("You lost 2 pop from revolts!");
System.out.println("You 10 karma from evil!");
System.out.println("You gained 10 technology from the enemy!");
System.out.println("You gained 5 housing technology from the enemy!");
System.out.println("You gained 5 moral from Nationaism!");
}//if3
else if (action==2)
{//ELSE IF
farmlevel=farmlevel+10;
karma=karma+5;
pop=pop+10;
moral=moral-2;
if (moral<=0)
{
moral=0;
}
System.out.println("You gained 10 farmlevels from civilian farmers!");
System.out.println("You gained 5 karma for giving pityness!");
System.out.println("You gained 10 population for converting!");
System.out.println("You lost 2 moral because of Nationalism!");
}//ELSE IF
}//if 2
else if (apache>atk)
System.out.println("Our army is not powerful enough to take on their defences. Prepare more.");
}//IF
break;
}//CASE 2
case 3:
{//CASE 3
System.out.println("Cherokee tribe (VERY STRONG)");
System.out.println("Cherokee Tribe has 40 ATK");
System.out.println("Cherokee Tribe has 50 DEF");
System.out.println("Cherokee Tribe has Positive Karma");
System.out.println("Enter 2 to Attack the Cherokee Tribe(Costs 6 ap)");
action = in.nextInt();
if (action==2)
{//IF
if (atk == cherokee){
System.out.println("The Chrokee and "+tribename+" were equally powerful. They both retreated in suprised and no casulties has happened.");
}//if2
else if(atk>cherokee){
System.out.println("The great "+tribename+" tribe was able to defeat the Cherokee tribe's defences.");
System.out.println("Enter 1 if you want to pillage the Tribe? (-Karma)");
System.out.println("Enter 2 if you want to convert the Tribe into your group? (+Karma)");
action = in.nextInt();
if (action==1)
{//if3
food=food+20;
pop=pop-2;
karma=karma-15;
tech=tech+7;
housing=housing+3;
moral=moral+3;
System.out.println("You gained 20 food!");
System.out.println("You lost 2 pop from revolts!");
System.out.println("You 15 karma from evil!");
System.out.println("You gained 7 technology from the enemy!");
System.out.println("You gained 3 housing technology from the enemy!");
System.out.println("You gained 3 moral from Nationaism!");
}//if3
else if (action==2)
{//ELSE IF
farmlevel=farmlevel+10;
karma=karma+5;
pop=pop+10;
moral=moral-2;
if (moral<=0)
{
moral=0;
}
System.out.println("You gained 10 farmlevels from civilian farmers!");
System.out.println("You gained 5 karma for giving pityness!");
System.out.println("You gained 10 population for converting!");
System.out.println("You lost 2 moral because of Nationalism!");
}//ELSE IF
}//if 2
else if (cherokee>atk)
System.out.println("Our army is not powerful enough to take on their defences. Prepare more.");
}//IF
break;
}//CASE 3
case 4:
{//CASE 4
System.out.println("Chickasaw tribe (MEDIUM)");
System.out.println("Chickasaw Tribe has 20 ATK");
System.out.println("Chickasaw Tribe has 30 DEF");
System.out.println("Chickasaw Tribe has Positive Karma");
System.out.println("Enter 2 to Attack the Chickasaq Tribe(Costs 6 ap)");
action = in.nextInt();
if (action==2)
{//IF
if (atk == chickasaw){
System.out.println("The Chickasaw and "+tribename+" were equally powerful. They both retreated in suprised and no casulties has happened.");
}//if2
else if(atk>chickasaw){
System.out.println("The great "+tribename+" tribe was able to defeat the Chickasaw tribe's defences.");
System.out.println("Enter 1 if you want to pillage the Tribe? (-Karma)");
System.out.println("Enter 2 if you want to convert the Tribe into your group? (+Karma)");
action = in.nextInt();
if (action==1)
{//if3
food=food+13;
pop=pop-2;
karma=karma-10;
tech=tech+4;
housing=housing+1;
moral=moral+3;
System.out.println("You gained 13 food!");
System.out.println("You lost 2 pop from revolts!");
System.out.println("You Lost 10 karma from evil!");
System.out.println("You gained 4 technology from the enemy!");
System.out.println("You gained 1 housing technology from the enemy!");
System.out.println("You gained 3 moral from Nationaism!");
}//if3
else if (action==2)
{//ELSE IF
farmlevel=farmlevel+5;
karma=karma+5;
pop=pop+5;
moral=moral-2;
if (moral<=0)
{
moral=0;
}
System.out.println("You gained 5 farmlevels from civilian farmers!");
System.out.println("You gained 5 karma for giving pityness!");
System.out.println("You gained 5 population for converting!");
System.out.println("You lost 2 moral because of Nationalism!");
}//ELSE IF
}//if 2
else if (cherokee>atk)
System.out.println("Our army is not powerful enough to take on their defences. Prepare more.");
}//IF
break;
}//CASE 4
case 5:
{//CASE 5
System.out.println("Crow tribe (MEDIUM-WEAK)");
System.out.println("Crow Tribe has 10 ATK");
System.out.println("Crow Tribe has 20 DEF");
System.out.println("Crow Tribe has Negative Karma");
System.out.println("Enter 2 to Attack the Crow Tribe(Costs 6 ap)");
action = in.nextInt();
if (action==2)
{//IF
if (atk == crow){
System.out.println("The Crow and "+tribename+" were equally powerful. They both retreated in suprised and no casulties has happened.");
}//if2
else if(atk>crow){
System.out.println("The great "+tribename+" tribe was able to defeat the Crow tribe's defences.");
System.out.println("Enter 1 if you want to pillage the Tribe? (-Karma)");
System.out.println("Enter 2 if you want to convert the Tribe into your group? (+Karma)");
action = in.nextInt();
if (action==1)
{//if3
food=food+7;
pop=pop-2;
karma=karma-5;
tech=tech+2;
moral=moral+2;
System.out.println("You gained 7 food!");
System.out.println("You lost 2 pop from revolts!");
System.out.println("You Lost 5 karma from evil!");
System.out.println("You gained 2 technology from the enemy!");
System.out.println("You gained 2 moral from Nationaism!");
}//if3
else if (action==2)
{//ELSE IF
farmlevel=farmlevel+2;
karma=karma+5;
pop=pop+3;
moral=moral-2;
if (moral<=0)
{
moral=0;
}
System.out.println("You gained 2 farmlevels from civilian farmers!");
System.out.println("You gained 5 karma for giving pityness!");
System.out.println("You gained 3 population for converting!");
System.out.println("You lost 2 moral because of Nationalism!");
}//ELSE IF
}//if 2
else if (crow>atk)
System.out.println("Our army is not powerful enough to take on their defences. Prepare more.");
}//IF
break;
}//CASE 5
case 6:
{//CASE 6
System.out.println("Kiowa tribe (MEDIUM-WEAK)");
System.out.println("Kiowa Tribe has 5 ATK");
System.out.println("Kiowa Tribe has 10 DEF");
System.out.println("Kiowa Tribe has Negative Karma");
System.out.println("Enter 2 to Attack the Kiowa Tribe(Costs 6 ap)");
action = in.nextInt();
if (action==2)
{//IF
if (atk == kiowa){
System.out.println("The Kiowa and "+tribename+" were equally powerful. They both retreated in suprised and no casulties has happened.");
}//if2
else if(atk>kiowa){
System.out.println("The great "+tribename+" tribe was able to defeat the Kiowa tribe's defences.");
System.out.println("Enter 1 if you want to pillage the Tribe? (-Karma)");
System.out.println("Enter 2 if you want to convert the Tribe into your group? (+Karma)");
action = in.nextInt();
if (action==1)
{//if3
food=food+4;
pop=pop-1;
karma=karma-3;
tech=tech+1;
moral=moral+1;
System.out.println("You gained 4 food!");
System.out.println("You lost 1 pop from revolts!");
System.out.println("You Lost 3 karma from evil!");
System.out.println("You gained 1 technology from the enemy!");
System.out.println("You gained 1 moral from Nationaism!");
}//if3
else if (action==2)
{//ELSE IF
farmlevel=farmlevel+1;
karma=karma+3;
pop=pop+2;
moral=moral-1;
if (moral<=0)
{
moral=0;
}
System.out.println("You gained 1 farmlevels from civilian farmers!");
System.out.println("You gained 3 karma for giving pityness!");
System.out.println("You gained 2 population for converting!");
System.out.println("You lost 1 moral because of Nationalism!");
}//ELSE IF
}//if 2
else if (kiowa>atk)
System.out.println("Our army is not powerful enough to take on their defences. Prepare more.");
}//IF
break;
}//CASE 6
default:fact = true;
}// SUB SWITCH WITHIN MAIN CASE 4
choice--;
System.out.println("Press 1 to return to the main menu");
choice1 = in.nextInt();
}//case 4
default:fact = true;
}//switch
}//while1
}//else
}//while MAIN
}//main method
}