Back to project page ubisoldiers.
The source code is released under:
MIT License
If you think the Android project ubisoldiers listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.gobbisanches.ubisoldiers.mechanics; /*www . j av a 2 s. c om*/ import java.io.Serializable; /** * Created by sanches on 7/4/14. */ public class BattleUnit implements Serializable { private static final long serialVersionUID = 1L; private Unit unit; private int hp; public BattleUnit(Unit unit) { this.unit = unit; this.hp = calculateHitPointsForUnit(); } public Unit getUnit() { return unit; } public int getHp() { return hp; } public void takeDamage(int damage) { hp = Math.max(hp - damage, 0); } public boolean isAlive() { return hp > 0; } public boolean isDead() { return !isAlive(); } private int calculateHitPointsForUnit() { return PolicyManager.getRules().calculateHitPointsForUnit(unit); } // helper method - a shortcut to avoid feature envy public String getSoldierName() { return getUnit().getSoldier().getName(); } }