use of coderoyale2.units.Unit in project warlords-duel by Warlord56x.
the class Buy method doCommand.
@Override
protected void doCommand(ArrayList<Object> args) throws CommandException {
String msg = "noerror";
CommandException temp = new CommandException(msg);
boolean ok = true;
int amount = (int) args.get(2);
String stat = (String) args.get(1);
try {
int price = getCurrentHero().incStat(stat, amount);
getCurrentHero().setStat("gold", getCurrentHero().getStat("gold") - price);
println("Current gold: " + getCurrentHero().getStat("gold"));
} catch (HeroException e) {
temp = new CommandException(e.getMessage());
msg = e.getMessage();
} finally {
if (msg == "noerror") {
println(msg);
return;
}
String unitID = (String) args.get(1);
if (!unitIDs.contains(unitID)) {
ok = false;
temp = new CommandException("No unit or stat called: " + unitID + " exists!");
}
if (!ok) {
throw temp;
}
for (Unit unit : getCurrentUnitList()) {
if (unit.getId().equals(unitID)) {
try {
getCurrentUnitList().add(getCurrentHero().buyUnits(unitID, unit.getSize() + amount));
getCurrentUnitList().remove(unit);
println("Current gold: " + getCurrentHero().getStat("gold"));
} catch (HeroException e) {
throw new CommandException(e.getMessage());
}
}
}
try {
getCurrentUnitList().add(getCurrentHero().buyUnits(unitID, amount));
} catch (HeroException e) {
throw new CommandException(e.getMessage());
}
println("Current gold: " + getCurrentHero().getStat("gold"));
}
}
use of coderoyale2.units.Unit in project warlords-duel by Warlord56x.
the class Units method doCommand.
@Override
protected void doCommand(ArrayList<Object> args) throws CommandException {
String str = "\n";
for (Unit unit : units) {
str += unit.getName() + "\n";
}
println(str);
}
use of coderoyale2.units.Unit in project warlords-duel by Warlord56x.
the class EnemyUnits method doCommand.
@Override
protected void doCommand(ArrayList<Object> args) throws CommandException {
String str = "";
Boolean e = false;
if (getEnemyHeroUnitList() != null) {
if (getEnemyHeroUnitList().isEmpty()) {
e = true;
}
} else {
e = true;
}
if (e) {
throw new CommandException("Hero doesn't have any units!");
}
for (Unit unit : getEnemyHeroUnitList()) {
str += "Name: " + unit.getName() + " size: " + unit.getSize() + "\n";
}
println(str);
}
use of coderoyale2.units.Unit in project sample by keepinmindsh.
the class SaveFiles method createUnitForSave.
private List<Unit> createUnitForSave(List<Unit> unitList) {
List<Unit> returnUnitList = new ArrayList<>();
unitList.forEach(unit -> {
Marine.Builder maringBuilder = new Marine.Builder(40).setAttackGuage(6).setMarineName("마린 1");
maringBuilder.setUnitState(unit.getUnitStatus());
Marine marine = maringBuilder.build();
returnUnitList.add(marine);
});
return returnUnitList;
}
use of coderoyale2.units.Unit in project sample by keepinmindsh.
the class SampleFiles method main.
public static void main(String[] args) throws Exception {
Unit marine1 = new Marine.Builder(40).setAttackGuage(6).setMarineName("마린 1").setShield(0).build();
Unit zealot1 = new Zealot.Builder(100).setAttackGuage(16).setZealotName("질럿 1").setShield(60).build();
SaveFiles saveFiles = new SaveFiles();
saveFiles.setSavePoint(Arrays.asList(marine1));
marine1.damaged(zealot1.attack());
Arrays.asList(marine1).stream().forEach(unit -> {
unit.checkHealthStatus();
});
saveFiles.setSavePoint(Arrays.asList(marine1));
List<Unit> list = saveFiles.getUnitFromSavePoint(0);
for (Unit unit : list) {
if (unit instanceof Marine) {
marine1 = unit;
}
}
Arrays.asList(marine1).stream().forEach(unit -> {
unit.checkHealthStatus();
});
List<Unit> list2 = saveFiles.getUnitFromSavePoint(1);
for (Unit unit : list2) {
if (unit instanceof Marine) {
marine1 = unit;
}
}
Arrays.asList(marine1).stream().forEach(unit -> {
unit.checkHealthStatus();
});
}
Aggregations