-
Notifications
You must be signed in to change notification settings - Fork 26
Champion revive, attack and death. #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,12 @@ public boolean allNexusAlive() { | |
| return true; | ||
| } | ||
|
|
||
| public void removeChampion(Destructible d, int x, int y) { | ||
| if (d instanceof Champion && !d.isAlive()) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could generalize to |
||
| battlefield[y][x] = Optional.empty(); | ||
| } | ||
| } | ||
|
|
||
| // We can place something at (x, y) if: | ||
| // * The ground tile at (x, y) is walkable. | ||
| // * No other destructible is present at (x, y). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ public class Champion extends Destructible { | |
| private int rangeOfAttack; | ||
| private int damages; | ||
| private int speed; | ||
| private int deathTimer = 0; | ||
|
|
||
| private Champion(String name, int hp, int rangeOfAttack, int damages, int speed) { | ||
| super(hp); | ||
|
|
@@ -62,6 +63,18 @@ public boolean attack(Destructible d) { | |
| return false; | ||
| } | ||
|
|
||
| public void increaseTimer() { | ||
| deathTimer = deathTimer + 1; | ||
| } | ||
|
|
||
| public boolean reachedTimer() { | ||
| return deathTimer==3; | ||
| } | ||
|
|
||
| public void resetTimer() { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to override revive and reset the timer there? |
||
| deathTimer = 0; | ||
| } | ||
|
|
||
| @Override public String toString() { | ||
| return name(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package lol.game.action; | ||
|
|
||
| import lol.game.*; | ||
| import java.io.Serializable; | ||
|
|
||
| public class Revive extends ChampionAction implements Serializable { | ||
|
|
||
| public Revive(int teamID, int championID, int x, int y) { | ||
| super(teamID, championID, x, y); | ||
| } | ||
|
|
||
| public void accept(ActionVisitor visitor) { | ||
| visitor.visitRevive(teamID, championID, x, y); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be automatic on the server side, and the champion should spawn next to its nexus.
Also, because it is done on the client side, the client can choose to spawn just next to the opponent nexus.
Why do we need a revive action? Doesn't a Spawn action would be enough? (It would also allows to reuse most of the mechanics of a spawn action).