Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/main/java/lol/client/ai/RandomAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public Turn championSelect() {
String championName;
switch(teamID) {
case Nexus.BLUE: championName = "Warrior"; break;
case Nexus.RED: championName = "Archer"; break;
case Nexus.RED: championName = "Scientist"; break;
default: throw new RuntimeException("Unknown team color.");
}
turn.registerAction(new ChampionSelect(teamID, championName));
Expand All @@ -30,22 +30,22 @@ public Turn turn() {
Turn turn = new Turn();
// Try to attack the Nexus first.
arena.teamOf(teamID).forEachChampion((champion, id) ->
battlefield.visitAdjacent(champion.x(), champion.y(), champion.attackRange(), new TileVisitor(){
public void visitNexus(Nexus nexus) {
if(nexus.teamOfNexus() != teamID) {
turn.registerAction(new Attack(teamID, id, nexus.x(), nexus.y()));
}
}
}));
battlefield.visitAdjacent(champion.x(), champion.y(), champion.attackRange(), new TileVisitor(){
public void visitNexus(Nexus nexus) {
if(nexus.teamOfNexus() != teamID) {
turn.registerAction(new Attack(teamID, id, nexus.x(), nexus.y()));
}
}
}));
// Add a move action in case we could not attack the Nexus.
arena.teamOf(teamID).forEachChampion((champion, id) ->
battlefield.visitAdjacent(champion.x(), champion.y(), champion.walkSpeed(), new TileVisitor(){
public void visitGrass(int x, int y) {
if(random.nextInt() % 3 == 0) {
turn.registerAction(new Move(teamID, id, x, y));
}
}
}));
battlefield.visitAdjacent(champion.x(), champion.y(), champion.walkSpeed(), new TileVisitor(){
public void visitGrass(int x, int y) {
if(random.nextInt() % 3 == 0) {
turn.registerAction(new Move(teamID, id, x, y));
}
}
}));
return turn;
}
}
2 changes: 1 addition & 1 deletion src/main/java/lol/game/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void visitChampionSelect(int teamID, String championName) {
}
else {
System.out.println("Champion selection action outside of the champion selection phase (teamID = "
+ teamID + ", championName = " + championName + ".");
+ teamID + ", championName = " + championName + ".");
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/lol/game/Champion.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ public static Champion makeWarrior() {
return new Champion("Warrior", 15, 1, 3, 2);
}

public static Champion makeScientist() { return new Champion("Scientist", 3, 2, 15, 2);}

public static Champion make(String name) {
switch(name) {
case "Archer": return makeArcher();
case "Warrior": return makeWarrior();
case "Scientist" : return makeScientist();
default: throw new RuntimeException("The champion " + name + " does not exist.");
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/lol/ui/BattlefieldView.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ ImageView groundView(Battlefield.GroundTile tile) {
switch(tile) {
case GRASS: return sprites.grass();
default: throw new UnsupportedOperationException(
"Displaying ground tile `" + tile.name() + "` is not yet supported.");
"Displaying ground tile `" + tile.name() + "` is not yet supported.");
}
}

ImageView championView(Champion champion) {
String name = champion.name();
if(name.equals("Archer")) { return sprites.archer(); }
else if (name.equals("Warrior")) { return sprites.warrior(); }
else if (name.equals("Scientist")) { return sprites.scientist();}
else {
throw new UnsupportedOperationException(
"Displaying Champion tile `" + name + "` is not yet supported.");
"Displaying Champion tile `" + name + "` is not yet supported.");
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/lol/ui/Sprites.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ public class Sprites {
private Image grassImage;
private Image archerImage;
private Image warriorImage;
private Image scientistImage;
private Image blueNexusImage;
private Image redNexusImage;

public Sprites() {
grassImage = new Image("sprites/grass-tile.png");
archerImage = new Image("sprites/archer.png");
warriorImage = new Image("sprites/warrior.png");
scientistImage = new Image("sprites/scientist.png");
blueNexusImage = new Image("sprites/blue-nexus.png");
redNexusImage = new Image("sprites/red-nexus.png");
}
Expand All @@ -36,6 +38,8 @@ public ImageView warrior() {
return makeView(warriorImage);
}

public ImageView scientist() {return makeView(scientistImage);}

public ImageView blueNexus() {
return makeView(blueNexusImage);
}
Expand Down
Binary file added src/main/resources/sprites/scientist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.