road to 100k
This commit is contained in:
parent
d3f6fceb6a
commit
c294c61a85
4 changed files with 94 additions and 20 deletions
|
|
@ -6,10 +6,7 @@ import com.epita.creeps.given.vo.geometry.Point;
|
|||
import com.epita.creeps.given.vo.response.CommandResponse;
|
||||
import com.epita.creeps.given.vo.response.InitResponse;
|
||||
import com.epita.creeps.given.vo.response.StatisticsResponse;
|
||||
import com.epita.creeps.units.Building;
|
||||
import com.epita.creeps.units.Citizen;
|
||||
import com.epita.creeps.units.Turret;
|
||||
import com.epita.creeps.units.Unit;
|
||||
import com.epita.creeps.units.*;
|
||||
import kong.unirest.core.HttpResponse;
|
||||
import kong.unirest.core.JsonNode;
|
||||
import kong.unirest.core.Unirest;
|
||||
|
|
@ -79,21 +76,77 @@ public class Program {
|
|||
StatisticsResponse statistics = Basics.getStatistics();
|
||||
logger.debug(statistics.toString());
|
||||
|
||||
while (true) {
|
||||
for (var player : statistics.players) {
|
||||
if (player.name == login)
|
||||
continue;
|
||||
citizen1.sendMessage(player.name, "Nicole");
|
||||
citizen2.sendMessage(player.name,"Ouvre");
|
||||
citizen1.waitFinished();
|
||||
citizen2.waitFinished();
|
||||
citizen1.sendMessage(player.name, "Nicole");
|
||||
citizen2.sendMessage(player.name, "MAIS MOI JE VEUX FAIRE L'AMOUUUUR");
|
||||
citizen1.waitFinished();
|
||||
citizen2.waitFinished();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Gossip
|
||||
// while (true) {
|
||||
// for (var player : statistics.players) {
|
||||
// if (player.name == login)
|
||||
// continue;
|
||||
// citizen1.sendMessage(player.name, "Nicole");
|
||||
// citizen2.sendMessage(player.name,"Ouvre");
|
||||
// citizen1.sendMessage(player.name, "Nicole");
|
||||
// citizen2.sendMessage(player.name, "MAIS MOI JE VEUX FAIRE L'AMOUUUUR");
|
||||
// }
|
||||
// }
|
||||
|
||||
// timoutheou
|
||||
// while (true) {
|
||||
// for (var player : statistics.players) {
|
||||
// if (player.name == login || !player.name.contains("battefort"))
|
||||
// continue;
|
||||
// citizen1.sendMessage(player.name, "Nicole");
|
||||
// citizen2.sendMessage(player.name,"Ouvre");
|
||||
// citizen1.sendMessage(player.name, "Nicole");
|
||||
// citizen2.sendMessage(player.name, "MAIS MOI JE VEUX FAIRE L'AMOUUUUR");
|
||||
// citizen1.sendMessage(player.name, "<3");
|
||||
// citizen2.fetchMessages();
|
||||
// }
|
||||
// }
|
||||
|
||||
citizen2.sendMessage("Hector", "Nique ta mère Hector").waitFinished();
|
||||
|
||||
// Kaboom & epic fail
|
||||
citizen1.spawn("bomber-bot").waitFinished();
|
||||
List<Unit> bomberos = BomberBot.getBomberBotUnits();
|
||||
BomberBot bomberau = (BomberBot) bomberos.getFirst();
|
||||
|
||||
bomberau.upgrade();
|
||||
// bomberau.fire();
|
||||
|
||||
// =======================================================
|
||||
// Stormtrooper
|
||||
citizen1.spawn("turret").waitFinished();
|
||||
List<Unit> tourelles = Turret.getTurretUnits();
|
||||
Turret unerelle = (Turret) tourelles.getFirst();
|
||||
for (int i = 0; i < 101; i++) {
|
||||
unerelle.fire(unerelle.getPosition().plus(new Point(0, 1)));
|
||||
}
|
||||
|
||||
// Gather resources
|
||||
while (true) {
|
||||
citizen1.move(Direction.RIGHT);
|
||||
citizen2.move(Direction.LEFT);
|
||||
citizen1.gather();
|
||||
citizen2.gather();
|
||||
citizen1.move(Direction.UP);
|
||||
citizen2.move(Direction.DOWN);
|
||||
citizen1.gather();
|
||||
citizen2.gather();
|
||||
}
|
||||
|
||||
// Country roads
|
||||
// while (true) {
|
||||
// citizen1.move(Direction.RIGHT);
|
||||
// citizen2.move(Direction.LEFT);
|
||||
// citizen1.build(Building.ROAD);
|
||||
// citizen2.build(Building.ROAD);
|
||||
// citizen1.move(Direction.UP);
|
||||
// citizen2.move(Direction.DOWN);
|
||||
// citizen1.build(Building.ROAD);
|
||||
// citizen2.build(Building.ROAD);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.epita.creeps.given.json.Json;
|
|||
import com.epita.creeps.given.vo.report.*;
|
||||
import com.epita.creeps.given.vo.response.InitResponse;
|
||||
import com.epita.creeps.given.vo.response.StatisticsResponse;
|
||||
import com.epita.creeps.units.BomberBot;
|
||||
import com.epita.creeps.units.Turret;
|
||||
import com.epita.creeps.units.Unit;
|
||||
import kong.unirest.core.HttpResponse;
|
||||
|
|
@ -110,8 +111,8 @@ public class Basics {
|
|||
Unit.getUnits().add(turret);
|
||||
}
|
||||
else if (spawnReport.spawnedUnit.opcode.endsWith("bomber-bot")) {
|
||||
Turret turret = new Turret(Program.getLogin(), spawnReport.spawnedUnitId, spawnReport.spawnedUnit.position);
|
||||
Unit.getUnits().add(turret);
|
||||
BomberBot bombhero = new BomberBot(Program.getLogin(), spawnReport.spawnedUnitId, spawnReport.spawnedUnit.position);
|
||||
Unit.getUnits().add(bombhero);
|
||||
}
|
||||
else {
|
||||
logger.warn("Spawned unit is an unknown type. Ignored...");
|
||||
|
|
|
|||
|
|
@ -1,10 +1,26 @@
|
|||
package com.epita.creeps.units;
|
||||
|
||||
import com.epita.creeps.given.extra.Cartographer;
|
||||
import com.epita.creeps.given.json.Json;
|
||||
import com.epita.creeps.given.vo.geometry.Point;
|
||||
import com.epita.creeps.given.vo.parameter.FireParameter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BomberBot extends Unit {
|
||||
|
||||
public BomberBot(String login, String id, Point position) {
|
||||
super(login, id, position);
|
||||
}
|
||||
|
||||
// Retrieves all units that are turrets
|
||||
public static List<Unit> getBomberBotUnits() {
|
||||
return getUnits().stream().filter(unit -> unit.getClass() == BomberBot.class).toList();
|
||||
}
|
||||
|
||||
public BomberBot fire() {
|
||||
FireParameter fp = new FireParameter(this.position);
|
||||
sendActionWithBody("fire:bomber-bot", Json.serialize(fp), 2);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,11 @@ public abstract class Unit {
|
|||
// Sends a specific action to the server using it's HTTPS string representation
|
||||
// Sets pending action accordingly and asks for a report after `delay` ticks
|
||||
public void sendActionWithBody(String actionCode, String body, long delay) {
|
||||
// Move
|
||||
if (!idle) {
|
||||
// logger.warn("Unit is already busy, queuing action");
|
||||
this.waitFinished();
|
||||
}
|
||||
// Do
|
||||
idle = false;
|
||||
pendingAction = AsyncExec.asyncExec(() -> Unirest.post(command_uri + actionCode).body(body).asJson(), delay)
|
||||
.thenApplyAsync( x -> x );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue