Compare commits
3 Commits
develop-to
...
develop
Author | SHA1 | Date | |
---|---|---|---|
edf26785a3 | |||
4d90f5fc28 | |||
343decb05a |
@ -2,7 +2,6 @@ package eu.mhsl.minenet.minigames.handler.global;
|
||||
|
||||
import eu.mhsl.minenet.minigames.Main;
|
||||
import eu.mhsl.minenet.minigames.api.QueuedPlayerRooms;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.TowerdefenseFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||
import eu.mhsl.minenet.minigames.instance.transfer.Transfer;
|
||||
import eu.mhsl.minenet.minigames.skin.SkinCache;
|
||||
@ -49,15 +48,7 @@ public class PlayerLoginHandler implements EventListener<AsyncPlayerConfiguratio
|
||||
if(pushQueue != null) {
|
||||
Room.setRoom(p, Room.getRoom(pushQueue).orElseThrow());
|
||||
} else {
|
||||
if(p.getUsername().equals("28Pupsi28")) {
|
||||
try {
|
||||
MoveInstance.move(p, new TowerdefenseFactory().manufacture(Room.createRoom(p)));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
MoveInstance.move(p, Hub.INSTANCE);
|
||||
}
|
||||
MoveInstance.move(p, Hub.INSTANCE);
|
||||
}
|
||||
},
|
||||
TaskSchedule.seconds(1),
|
||||
|
@ -28,7 +28,7 @@ class Tetris extends StatelessGame {
|
||||
public Tetris(int nextTetrominoesCount, boolean isFast, boolean hasCombat) {
|
||||
super(Dimension.THE_END.key, "Tetris", new PointsWinScore());
|
||||
|
||||
eventNode()
|
||||
this.eventNode()
|
||||
.addListener(PlayerUseItemEvent.class, this::onPlayerInteract)
|
||||
.addListener(PlayerHandAnimationEvent.class, this::onPlayerAttack)
|
||||
.addListener(PlayerTickEvent.class, this::onPlayerTick);
|
||||
@ -58,7 +58,7 @@ class Tetris extends StatelessGame {
|
||||
protected void onStop() {
|
||||
this.tetrisGames.forEach((player, tetrisGame) -> {
|
||||
tetrisGame.loose();
|
||||
getScore().insertResult(player, tetrisGame.getScore());
|
||||
this.getScore().insertResult(player, tetrisGame.getScore());
|
||||
tetrisGame.sidebar.removeViewer(player);
|
||||
});
|
||||
}
|
||||
@ -106,7 +106,7 @@ class Tetris extends StatelessGame {
|
||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
||||
if(tetrisGame == null) return;
|
||||
if(tetrisGame.lost && player.getGameMode() != GameMode.SPECTATOR) {
|
||||
letPlayerLoose(player);
|
||||
this.letPlayerLoose(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,15 +114,15 @@ class Tetris extends StatelessGame {
|
||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.setInvisible(true);
|
||||
getScore().insertResult(player, tetrisGame.getScore());
|
||||
this.getScore().insertResult(player, tetrisGame.getScore());
|
||||
|
||||
boolean allGamesLost = this.tetrisGames.values().stream()
|
||||
.filter(game -> !game.lost)
|
||||
.toList()
|
||||
.isEmpty();
|
||||
if(!setTimeLimit && !allGamesLost) {
|
||||
if(!this.setTimeLimit && !allGamesLost) {
|
||||
this.setTimeLimit(90);
|
||||
setTimeLimit = true;
|
||||
this.setTimeLimit = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ class Tetris extends StatelessGame {
|
||||
if(this.tetrisGames.get(p) == null) {
|
||||
this.tetrisGames.put(p, new TetrisGame(
|
||||
this,
|
||||
getSpawn().sub(6, 8, 15).add(this.tetrisGames.size()*30, 0, 0),
|
||||
this.getSpawn().sub(6, 8, 15).add(this.tetrisGames.size()*30, 0, 0),
|
||||
Tetromino.Shape.J,
|
||||
this.nextTetrominoesCount,
|
||||
this.isFast,
|
||||
|
@ -74,10 +74,10 @@ public class Playfield {
|
||||
}
|
||||
}
|
||||
|
||||
batch.setBlock(getPlayerSpawnPosition().sub(0, 1, 0), Block.STONE);
|
||||
batch.setBlock(getPlayerSpawnPosition().sub(1, 1, 0), Block.STONE);
|
||||
batch.setBlock(getPlayerSpawnPosition().sub(1, 1, 1), Block.STONE);
|
||||
batch.setBlock(getPlayerSpawnPosition().sub(0, 1, 1), Block.STONE);
|
||||
batch.setBlock(this.getPlayerSpawnPosition().sub(0, 1, 0), Block.STONE);
|
||||
batch.setBlock(this.getPlayerSpawnPosition().sub(1, 1, 0), Block.STONE);
|
||||
batch.setBlock(this.getPlayerSpawnPosition().sub(1, 1, 1), Block.STONE);
|
||||
batch.setBlock(this.getPlayerSpawnPosition().sub(0, 1, 1), Block.STONE);
|
||||
|
||||
BatchUtil.loadAndApplyBatch(batch, this.instance, () -> {});
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class Playfield {
|
||||
if(this.instance.getBlock(this.lowerLeftCorner.add(x, y, 1)) == Block.AIR) isFullLine = false;
|
||||
}
|
||||
if(isFullLine) {
|
||||
removeFullLine(y);
|
||||
this.removeFullLine(y);
|
||||
removedLinesCounter += 1;
|
||||
y -= 1;
|
||||
}
|
||||
@ -99,10 +99,10 @@ public class Playfield {
|
||||
}
|
||||
|
||||
public void addLines(int lines) {
|
||||
int xPosMissing = random.nextInt(1, 10);
|
||||
int xPosMissing = this.random.nextInt(1, 10);
|
||||
|
||||
for (int i = 0; i < lines; i++) {
|
||||
moveAllLinesUp();
|
||||
this.moveAllLinesUp();
|
||||
for (int x = 1; x < 11; x++) {
|
||||
if(x != xPosMissing) {
|
||||
this.instance.setBlock(this.lowerLeftCorner.add(x, 1, 1), Block.LIGHT_GRAY_CONCRETE);
|
||||
|
@ -121,8 +121,8 @@ public class TetrisGame {
|
||||
|
||||
public void tick() {
|
||||
if(this.lost || this.paused) return;
|
||||
if(!currentTetromino.moveDown()) {
|
||||
setActiveTetrominoDown();
|
||||
if(!this.currentTetromino.moveDown()) {
|
||||
this.setActiveTetrominoDown();
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class TetrisGame {
|
||||
}
|
||||
|
||||
private boolean switchHold() {
|
||||
if(!holdPossible) return false;
|
||||
if(!this.holdPossible) return false;
|
||||
|
||||
Tetromino newCurrentTetromino;
|
||||
if(this.holdTetromino == null) {
|
||||
@ -194,7 +194,7 @@ public class TetrisGame {
|
||||
|
||||
this.currentTetromino.setPosition(this.tetrominoSpawnPosition);
|
||||
this.currentTetromino.draw();
|
||||
if(!this.currentTetromino.moveDown()) loose();
|
||||
if(!this.currentTetromino.moveDown()) this.loose();
|
||||
|
||||
double xChange = this.holdTetromino.getXChange();
|
||||
this.holdTetromino.setPosition(this.holdPosition.add(xChange, 0, 0));
|
||||
@ -312,7 +312,7 @@ public class TetrisGame {
|
||||
this.currentTetromino.setPosition(this.tetrominoSpawnPosition);
|
||||
this.currentTetromino.draw();
|
||||
if(!this.currentTetromino.moveDown()) {
|
||||
loose();
|
||||
this.loose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ public class Tetromino {
|
||||
this.uuid = UUID.randomUUID();
|
||||
|
||||
switch (this.shape) {
|
||||
case I -> shapeArray = new int[][]{{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||
case J -> shapeArray = new int[][]{{1,0,0}, {1,1,1}, {0,0,0}};
|
||||
case L -> shapeArray = new int[][]{{0,0,1}, {1,1,1}, {0,0,0}};
|
||||
case O -> shapeArray = new int[][]{{1,1}, {1,1}};
|
||||
case S -> shapeArray = new int[][]{{0,1,1}, {1,1,0}, {0,0,0}};
|
||||
case T -> shapeArray = new int[][]{{0,1,0}, {1,1,1}, {0,0,0}};
|
||||
case Z -> shapeArray = new int[][]{{1,1,0}, {0,1,1}, {0,0,0}};
|
||||
case I -> this.shapeArray = new int[][]{{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||
case J -> this.shapeArray = new int[][]{{1,0,0}, {1,1,1}, {0,0,0}};
|
||||
case L -> this.shapeArray = new int[][]{{0,0,1}, {1,1,1}, {0,0,0}};
|
||||
case O -> this.shapeArray = new int[][]{{1,1}, {1,1}};
|
||||
case S -> this.shapeArray = new int[][]{{0,1,1}, {1,1,0}, {0,0,0}};
|
||||
case T -> this.shapeArray = new int[][]{{0,1,0}, {1,1,1}, {0,0,0}};
|
||||
case Z -> this.shapeArray = new int[][]{{1,1,0}, {0,1,1}, {0,0,0}};
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,22 +58,22 @@ public class Tetromino {
|
||||
|
||||
public boolean rotate(boolean clockwise) {
|
||||
int[][] newShapeArray = this.getTurnedShapeArray(clockwise);
|
||||
return checkCollisionAndMove(this.position, newShapeArray);
|
||||
return this.checkCollisionAndMove(this.position, newShapeArray);
|
||||
}
|
||||
|
||||
public boolean moveDown() {
|
||||
Pos newPosition = this.position.sub(0, 1, 0);
|
||||
return checkCollisionAndMove(newPosition, this.shapeArray);
|
||||
return this.checkCollisionAndMove(newPosition, this.shapeArray);
|
||||
}
|
||||
|
||||
public boolean moveLeft() {
|
||||
Pos newPosition = this.position.sub(1, 0, 0);
|
||||
return checkCollisionAndMove(newPosition, this.shapeArray);
|
||||
return this.checkCollisionAndMove(newPosition, this.shapeArray);
|
||||
}
|
||||
|
||||
public boolean moveRight() {
|
||||
Pos newPosition = this.position.add(1, 0, 0);
|
||||
return checkCollisionAndMove(newPosition, this.shapeArray);
|
||||
return this.checkCollisionAndMove(newPosition, this.shapeArray);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
@ -83,11 +83,11 @@ public class Tetromino {
|
||||
public void draw(boolean withGhost) {
|
||||
if(withGhost) {
|
||||
Pos ghostPos = this.position;
|
||||
while (!checkCollision(ghostPos.sub(0, 1, 0), this.shapeArray)) {
|
||||
while (!this.checkCollision(ghostPos.sub(0, 1, 0), this.shapeArray)) {
|
||||
ghostPos = ghostPos.sub(0, 1, 0);
|
||||
}
|
||||
Pos positionChange = this.position.sub(ghostPos);
|
||||
getBlockPositions().forEach(pos -> {
|
||||
this.getBlockPositions().forEach(pos -> {
|
||||
Entity ghostBlock = new Entity(ghostEntityType);
|
||||
((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getGhostBlock());
|
||||
ghostBlock.setNoGravity(true);
|
||||
@ -97,11 +97,11 @@ public class Tetromino {
|
||||
});
|
||||
}
|
||||
|
||||
getBlockPositions().forEach(pos -> this.instance.setBlock(pos, this.getColoredBlock()));
|
||||
this.getBlockPositions().forEach(pos -> this.instance.setBlock(pos, this.getColoredBlock()));
|
||||
}
|
||||
|
||||
public void drawAsEntities() {
|
||||
getBlockPositions().forEach(pos -> {
|
||||
this.getBlockPositions().forEach(pos -> {
|
||||
Entity ghostBlock = new Entity(ghostEntityType);
|
||||
((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getColoredBlock());
|
||||
ghostBlock.setNoGravity(true);
|
||||
@ -222,10 +222,10 @@ public class Tetromino {
|
||||
}
|
||||
|
||||
private boolean checkCollision(Pos newPosition, int[][] newShapeArray) {
|
||||
List<Pos> newBlockPositions = getBlockPositions(newPosition, newShapeArray);
|
||||
List<Pos> newBlockPositions = this.getBlockPositions(newPosition, newShapeArray);
|
||||
|
||||
for(Pos pos : newBlockPositions) {
|
||||
if(isPartOfTetromino(pos)) continue;
|
||||
if(this.isPartOfTetromino(pos)) continue;
|
||||
if(this.instance.getBlock(pos) == this.getGhostBlock()) continue;
|
||||
if(this.instance.getBlock(pos) != Block.AIR) return true;
|
||||
}
|
||||
@ -234,7 +234,7 @@ public class Tetromino {
|
||||
}
|
||||
|
||||
private boolean checkCollisionAndMove(Pos newPosition, int[][] newShapeArray) {
|
||||
if(!checkCollision(newPosition, newShapeArray)) {
|
||||
if(!this.checkCollision(newPosition, newShapeArray)) {
|
||||
this.remove();
|
||||
this.shapeArray = Arrays.stream(newShapeArray).map(int[]::clone).toArray(int[][]::new);
|
||||
this.setPosition(newPosition);
|
||||
|
@ -44,7 +44,7 @@ public class Towerdefense extends StatelessGame {
|
||||
long rightLeftDifference = previousDirections.stream().filter(integer -> integer == 0).count() - previousDirections.stream().filter(integer -> integer == 2).count();
|
||||
if(rightLeftDifference >= 2 || direction == 2) origin = 1;
|
||||
if(rightLeftDifference <= -2 || direction == 0) bound = 2;
|
||||
direction = random.nextInt(origin, bound);
|
||||
direction = this.random.nextInt(origin, bound);
|
||||
previousDirections.add(direction);
|
||||
}
|
||||
this.addMazePosition(position, Block.WHITE_WOOL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user