Refactored extends and implements
This commit is contained in:
parent
559c590b52
commit
f5b26810b8
12
server/src/main/java/fr/lnl/game/server/ServerMain.java
Normal file
12
server/src/main/java/fr/lnl/game/server/ServerMain.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package fr.lnl.game.server;
|
||||||
|
|
||||||
|
import fr.lnl.game.server.games.grid.Grid;
|
||||||
|
|
||||||
|
public class ServerMain {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Grid grid = new Grid(10,10);
|
||||||
|
grid.initGrid();
|
||||||
|
grid.printGrid();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
|
public abstract class AbstractAction implements Action {
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
public class DeployShield implements Action{
|
public class DeployShield extends AbstractAction {
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
public class DropObject implements Action{
|
public abstract class DropObject extends AbstractAction {
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
public class Move implements Action{
|
public class Move extends AbstractAction {
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
public class Nothing implements Action {
|
public class Nothing extends AbstractAction {
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
public class Shot implements Action{
|
public class Shot extends AbstractAction {
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fr.lnl.game.server.games.grid;
|
package fr.lnl.game.server.games.grid;
|
||||||
|
|
||||||
public class Explosive implements Box{
|
public abstract class Explosive implements Box{
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,11 @@ public class Grid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: 18/10/2021
|
||||||
|
public void placePlayers() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void printGrid() {
|
public void printGrid() {
|
||||||
for (int i = 0; i < x; i++) {
|
for (int i = 0; i < x; i++) {
|
||||||
System.out.print("\n");
|
System.out.print("\n");
|
||||||
@ -77,10 +82,4 @@ public class Grid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Grid grid = new Grid(10,10);
|
|
||||||
grid.initGrid();
|
|
||||||
grid.printGrid();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package fr.lnl.game.server.games.player;
|
|||||||
import fr.lnl.game.server.games.weapon.Weapon;
|
import fr.lnl.game.server.games.weapon.Weapon;
|
||||||
import fr.lnl.game.server.utils.Point;
|
import fr.lnl.game.server.utils.Point;
|
||||||
|
|
||||||
public abstract class AbstractPlayer {
|
public abstract class AbstractPlayer implements Player {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private Point position;
|
private Point position;
|
||||||
|
@ -3,7 +3,8 @@ package fr.lnl.game.server.games.player;
|
|||||||
import fr.lnl.game.server.games.weapon.Weapon;
|
import fr.lnl.game.server.games.weapon.Weapon;
|
||||||
import fr.lnl.game.server.utils.Point;
|
import fr.lnl.game.server.utils.Point;
|
||||||
|
|
||||||
public class ComputerPlayer extends AbstractPlayer implements Player{
|
public class ComputerPlayer extends AbstractPlayer{
|
||||||
|
|
||||||
public ComputerPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
|
public ComputerPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
|
||||||
super(id, position, energy, weapon, shieldDeploy);
|
super(id, position, energy, weapon, shieldDeploy);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package fr.lnl.game.server.games.player;
|
|||||||
import fr.lnl.game.server.games.weapon.Weapon;
|
import fr.lnl.game.server.games.weapon.Weapon;
|
||||||
import fr.lnl.game.server.utils.Point;
|
import fr.lnl.game.server.utils.Point;
|
||||||
|
|
||||||
public class HumanPlayer extends AbstractPlayer implements Player{
|
public class HumanPlayer extends AbstractPlayer {
|
||||||
public HumanPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
|
public HumanPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
|
||||||
super(id, position, energy, weapon, shieldDeploy);
|
super(id, position, energy, weapon, shieldDeploy);
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,13 @@ package fr.lnl.game.server.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractModelListening implements ModelListener {
|
public abstract class AbstractModelListening implements ModelListener {
|
||||||
|
|
||||||
List<ModelListener> listeners;
|
List<ModelListener> listeners;
|
||||||
|
|
||||||
public abstract void addListener(ModelListener e);
|
public abstract void addListener(ModelListener e);
|
||||||
|
|
||||||
public abstract void removalListener(ModelListener e);
|
public abstract void removalListener(ModelListener e);
|
||||||
|
|
||||||
public void fireChange(){
|
public void fireChange(){
|
||||||
for(ModelListener e : listeners){
|
for(ModelListener e : listeners){
|
||||||
e.updateModel(this);
|
e.updateModel(this);
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package fr.lnl.game.server.utils;
|
package fr.lnl.game.server.utils;
|
||||||
|
|
||||||
public enum Cardinal {
|
public enum Cardinal {
|
||||||
NORTH,SOUTH,EAST,WEST,NORTH_EAST,NORTH_WEST,SOUTH_EAST,SOUTH_WEST
|
NORTH,
|
||||||
|
SOUTH,
|
||||||
|
EAST,
|
||||||
|
WEST,
|
||||||
|
NORTH_EAST,
|
||||||
|
NORTH_WEST,
|
||||||
|
SOUTH_EAST,
|
||||||
|
SOUTH_WEST
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user