public class Skill {
private int level, xp, xpborder;
public Skill() {
level = 1;
xp = 0;
xpborder = 100;
}
public int getLevel(){
return level;
}
/** *
* @return
* true if the added XP changed the level
*/
public boolean addXP(int amount){
xp += amount;
if(xp > xpborder)
{
++level;
xp -= xpborder;
xpborder *= 2;
return true;
}
return false;
}
}
public final class CharacterStats {
public final String firstName;
public final String lastName;
public final Zodiac zodiac;
public final Date birtdate;
public final Skill bravery, willpower, agility, intelligence, comprehension;
public CharacterStats(String firstName, String lastName, Zodiac zodiac, Date birtdate) {
this.firstName = firstName;
this.lastName = lastName;
this.zodiac = zodiac;
this.birtdate = birtdate;
bravery = new Skill();
willpower = new Skill();
agility = new Skill();
intelligence = new Skill();
comprehension = new Skill();
}
}
public class Character {
private final CharacterStats stats;
private Weapon weapon;
private int life;
...
public Character(...) {
...
}
public Damage getAttack();
public void defendAttack(Damage dmg);
public void grantWinOver(Character char);
public int getLife()
{
return life;
}
}
public class Game {
public enum TimeOfDay {
MORNING, MIDDAY, EVENING, NIGHT;
}
private final Date date;
private final Character player, enemy;
public Game() {
date = new Date(21, 12, 2012);
...
fight(player, enemy);
}
public void fight(Character a, Character b)
{
while(a.getLife() > 0 && b.getLife() > 0)
{
a.defendAttack(b.getAttack());
b.defendAttack(a.getAttack());
}
if(a.getLife() > 0)
a.grantWinOver(b);
else if(b.getLife() > 0)
b.grantWinOver(a);
}
public TimeOfDay getTimeOfDay() {
int h = date.getHours();
if (h >= 4 && h < 10) {
return TimeOfDay.MORNING;
} else if (h >= 10 && h < 16) {
return TimeOfDay.MIDDAY;
} else if (h >= 16 && h < 22) {
return TimeOfDay.EVENING;
} else {
return TimeOfDay.NIGHT;
}
}
}