[CODE] If Erepublik Else Nothing

Day 3,801, 01:01 Published in Iran Iran by Akane Kawahara
Today 17th of April 2018
Day 3801
In the name of the most beautiful eyes.
This is 2nd part of my tutorial on Erepublik automation coding. in previous article, we went through basics of javascript and as promised in this article we will cover:

• Conditional Sentences
• Conditional Sentence Code in Erepublik
This tutorial is going to be a little hard but read it carefully so you will be able to understand how it works properly.
Conditionals
First of all we need to know about two concepts in programming:
True and False
in conditions and loops true and false concepts play the base role.
Operands
==
== represents "is it equal?"
so 3 == 3 means is 3 equal to 3?
so the result of 3 == 3 is "true".
The same happens when we use math:
1 + 2 == 3 is true again.
1 + 2 == 4 is false.
remember variables we talked about in previous article? let us check it with variables too.
var energy = 600;
result = energy == 600
so it would change to:
result = true
< or > and =
it's the same with < and > operands:
energy < 500 : is energy less than 500?
energy > 200 : is energy more than 200?
so what about less than or equal
and more than or equal?
we can use = for this purpose.
example:
energy = 300 : is energy more than or equal 300?
!=
!= means it is not equal?
so 2 != 3: 2 is not equal to 3? is true.
How to make it work?
well remember the shoot function we talked about in the first article?
now we are gonna define your current energy and see how does if function work?
Here is a little bit of code using one of erepublik object. and object is like a box. When you open that box there might be a lot of variables inside it.
Don't get into what object is but for now we are going to use one.


var energy = erepublik.citizen.energy;
if ( energy < 600 ) {
if ( erepublik.citizen.energyFromFoodRemaining > 50 ){
energy.eatFood();
}
}

The code in both {} works only if the question in () is right.
this question is called condition in programming.
There are two conditions here:
1- energy < 600 : is energy more than 600? ( erepublik.citizen.energy is your current energy.)
2- erepublik.citizen.energyFromFoodRemaining > 50 : is remaining food recovery more than 50?
if both conditions are true then your code will automaticaly eat food.
Here is the complete syntax of using conditionals:

if ( condition ){
code
}
else if ( condition ){
code
}
else {
code
}

We use else if to check for another condition if the first one fails. and if none of them true javascript will go through else block and do the code in else block.
For more you can watch this youtube if you want to know more. except switch statements which are not nessesary for your need.
I will promise to cover loop conditions in the next tutorial and also I will translate it to Farsi as soon as I have time, also if anyone wants to translate this articles to other language direct message me in Erepublik.
Yet I will try to make PDF version of this so the code segments will look alive and with style.
Thank you for spending your time reading my article, Endorsments are appericiated and please vote and subscribe for more, and please leave comments if any question and also my mission.
Thank you again.