From 0ce427fafb53a8e168ba39b4b4779183f22c0de2 Mon Sep 17 00:00:00 2001 From: EliottBICS Date: Sun, 9 May 2021 16:17:55 +0200 Subject: [PATCH 1/2] Scientist class created --- src/main/java/lol/client/ai/RandomAI.java | 30 +++++++++++----------- src/main/java/lol/game/Arena.java | 2 +- src/main/java/lol/game/Champion.java | 3 +++ src/main/resources/sprites/scientist.png | Bin 0 -> 921 bytes 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 src/main/resources/sprites/scientist.png diff --git a/src/main/java/lol/client/ai/RandomAI.java b/src/main/java/lol/client/ai/RandomAI.java index f60584d..85e21ad 100644 --- a/src/main/java/lol/client/ai/RandomAI.java +++ b/src/main/java/lol/client/ai/RandomAI.java @@ -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)); @@ -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; } } diff --git a/src/main/java/lol/game/Arena.java b/src/main/java/lol/game/Arena.java index a0b1e0d..36be3fa 100644 --- a/src/main/java/lol/game/Arena.java +++ b/src/main/java/lol/game/Arena.java @@ -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 + "."); } } } diff --git a/src/main/java/lol/game/Champion.java b/src/main/java/lol/game/Champion.java index 26f7198..8b17972 100644 --- a/src/main/java/lol/game/Champion.java +++ b/src/main/java/lol/game/Champion.java @@ -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."); } } diff --git a/src/main/resources/sprites/scientist.png b/src/main/resources/sprites/scientist.png new file mode 100644 index 0000000000000000000000000000000000000000..ed3c6131c7645b3867819c0896da79a3191b71e5 GIT binary patch literal 921 zcmV;K17`e*P)j^ZdHL`8@09gt{`>iXjWD4|E9xR$4g=nw@W5+Vg1Qlu1j z2vJZWaoW?Yy?c|rU3;?DjGcJhB(c|?{r~1;$94)e@U0lQew6{_2pBkloB{(6fLsJ~ z3J9lwuCdpNGo*|f;riFpsQ%*4Cwok4PR5>uF}?c!M2+rUBL!OpLSkMb0E~Fpr~r&t z%4iUQz-c5&yvqY22w9;_Xg=U{?na9{|KPNB#%^@xHj_?Ltj{U$z4w0Cr3jA=?SSU-z+hF@#tI zz?k#rH`rGLF1o?BKNRAAbF@=6Ahh;VR{^PhfHeX(ZGik%QKBK@0$@sj-vWc6y88hP zKteosfeChkR0z8Oz(s+d3VxxB6hhAEbipQJWTSfmDbI`Cd!J4YUB|PxJW;kLoIQT% zJaG5x5A)sb+gqMUI7KD`0Klym&y2A@A3i#xb|2mk`(O+Sz-*z_!F~w}fA^OW!f#gE z7=WD%i1YzqNF)GOIDA?V1hJtZtN_5E4}k!HwmO05dk(-%@N{x$JdRT!JiELSTv9*^sTdbTK!AMDd2CUP~-6wn|9L>EP2M1=sr zF|99ekKy-xK3CJ}G&p559v+;0dvC;74^fhJB%esAIkf<+@DKpFHUNXohX&&nc)#?# z-I8@ApV$_Fn|UAt8m~QDsJGW&xnalu-XyOEeFYGo*KDD&c%ZO#0C3nxQXmWK=3t&c62zSeCm!Qrw1@O#0gJ3N51 zb16{a2KTyxSm&i(1Aw)z0kHY*r^Fxtpkn6$Sr9`4fUBO)0IDZKIRfhL1XI>H!a1CM zK(Gh~ygZB)2sp#S_y0dEtP8#iODFC$DbTBFd v=m2`JOy&sal{-3^OpbsKp!dq;;3MDy#Ja~&U`3J000000NkvXXu0mjfaABAW literal 0 HcmV?d00001 From bd6bb8934ae66db966e3c0e68f6c2d6d8a1dc382 Mon Sep 17 00:00:00 2001 From: EliottBICS Date: Sun, 9 May 2021 16:33:35 +0200 Subject: [PATCH 2/2] Scientist class created --- src/main/java/lol/ui/BattlefieldView.java | 5 +++-- src/main/java/lol/ui/Sprites.java | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/lol/ui/BattlefieldView.java b/src/main/java/lol/ui/BattlefieldView.java index 4029a71..6e7ca7d 100644 --- a/src/main/java/lol/ui/BattlefieldView.java +++ b/src/main/java/lol/ui/BattlefieldView.java @@ -49,7 +49,7 @@ 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."); } } @@ -57,9 +57,10 @@ 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."); } } diff --git a/src/main/java/lol/ui/Sprites.java b/src/main/java/lol/ui/Sprites.java index a3eae85..7b1ee04 100644 --- a/src/main/java/lol/ui/Sprites.java +++ b/src/main/java/lol/ui/Sprites.java @@ -7,6 +7,7 @@ public class Sprites { private Image grassImage; private Image archerImage; private Image warriorImage; + private Image scientistImage; private Image blueNexusImage; private Image redNexusImage; @@ -14,6 +15,7 @@ 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"); } @@ -36,6 +38,8 @@ public ImageView warrior() { return makeView(warriorImage); } + public ImageView scientist() {return makeView(scientistImage);} + public ImageView blueNexus() { return makeView(blueNexusImage); }