Skip to content

Commit

Permalink
[entity] Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
5pilow committed May 19, 2023
1 parent 9146fd9 commit b4e9c3b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/leekwars/generator/fight/Fight.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void startFight(boolean drawCheckLife) throws Exception {
// Build AI after the fight is ready (static init)
var ai = EntityAI.build(this.generator, (AIFile) entity.getAIFile(), entity);
entity.setAI(ai);
((EntityAI) ai).setFight(this);
((EntityAI) ai).init();
((EntityAI) ai).getRandom().seed(state.getSeed());

Expand Down Expand Up @@ -267,14 +268,14 @@ public void startTurn() throws Exception {
state.getActions().log(new ActionEntityTurn(current));
Log.i(TAG, "Start turn of " + current.getName());

current.applyCoolDown();
current.startTurn();

if (!current.isDead()) {

var ai = (EntityAI) current.getAI();
if (ai != null) {
if (ai.isValid()) {
// System.out.println("Run " + current.getName() + " ai...");
long startTime = System.nanoTime();
ai.runTurn(state.getOrder().getTurn());
long endTime = System.nanoTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static EntityAI build(Generator generator, AIFile file, Entity entity) {
return new EntityAI(entity, (LeekLog) entity.getLogs());
}

Log.i(TAG, "Compile AI " + file.getPath() + "...");
Log.i(TAG, "Compile AI " + file.getPath() + " (id " + file.getId() + ")...");
try {
file.setJavaClass("AI_" + file.getId());
file.setRootClass("com.leekwars.generator.fight.entity.EntityAI");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public Entity createEntity(Generator generator, Scenario scenario, Fight fight)
entity.setId(id);
entity.setName(name);
entity.setLevel(level);
entity.setTotalLife(life);
entity.setLife(life);
entity.setStrength(strength);
entity.setAgility(agility);
Expand Down

0 comments on commit b4e9c3b

Please sign in to comment.