feat: End

This commit is contained in:
2026-02-22 20:24:31 +01:00
parent 32f8521951
commit f7d878f430
5 changed files with 69 additions and 3 deletions

View File

@@ -71,6 +71,11 @@ public class RoomChangeEventHandler extends AbstractEventHandler<RoomChangeEvent
eventManager.emitEvent(new SendSocketMessageEvent(new MovePlayerRoom(newRoom.getId(), oldCords, playerCords)));
gameState.setCurrentRoom(newRoom);
if (newRoom.isEnd()) {
cz.jzitnik.client.game.setup.scenes.WinScene winScene = new cz.jzitnik.client.game.setup.scenes.WinScene();
gameState.setScreen(winScene);
winScene.fullRender();
}
scheduler.schedule(() -> roomTaskScheduler.setupNewSchedulers(newRoom), 200, TimeUnit.MILLISECONDS);
}
}

View File

@@ -37,6 +37,9 @@ public class GameRoom {
@JsonProperty("requirement")
private Requirement requirement;
@JsonProperty("end")
private boolean end;
private GameRoom left;
private GameRoom right;
private GameRoom up;

View File

@@ -0,0 +1,11 @@
package cz.jzitnik.client.game.setup.scenes;
import cz.jzitnik.client.screens.WinScreen;
import cz.jzitnik.client.screens.Screen;
import cz.jzitnik.client.screens.scenes.Scene;
public class WinScene extends Scene {
public WinScene() {
super(new Screen[]{new WinScreen()}, new OnEndAction.Repeat());
}
}

View File

@@ -0,0 +1,46 @@
package cz.jzitnik.client.screens;
import com.googlecode.lanterna.SGR;
import com.googlecode.lanterna.TextColor;
import com.googlecode.lanterna.graphics.TextGraphics;
import com.googlecode.lanterna.screen.TerminalScreen;
import cz.jzitnik.client.annotations.injectors.InjectState;
import cz.jzitnik.client.events.KeyboardPressEvent;
import cz.jzitnik.client.events.MouseAction;
import cz.jzitnik.client.states.TerminalState;
import java.io.IOException;
public class WinScreen extends Screen {
@InjectState
private TerminalState terminalState;
@Override
public void fullRender() {
TerminalScreen screen = terminalState.getTerminalScreen();
screen.clear();
TextGraphics tg = terminalState.getTextGraphics();
int termWidth = screen.getTerminalSize().getColumns();
int termHeight = screen.getTerminalSize().getRows();
String message = "YOU WON!";
tg.setForegroundColor(TextColor.ANSI.GREEN);
tg.enableModifiers(SGR.BOLD);
tg.putString((termWidth - message.length()) / 2, termHeight / 2, message);
try {
screen.refresh(com.googlecode.lanterna.screen.Screen.RefreshType.COMPLETE);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public void handleMouseAction(MouseAction event) {
}
@Override
public void handleKeyboardAction(KeyboardPressEvent event) {
}
}

View File

@@ -138,6 +138,7 @@
texture: "ROOM6"
requirement:
item: "quest_item_final_key"
end: true
#objects:
# - objectType: "exit"
# cords: { x: 140, y: 40 }
@@ -171,7 +172,7 @@
updateRateMs: 700
west: "filler_2"
east: "spawn"
north: null
north: "empty_c"
south: "filler_deadend_1"
@@ -200,7 +201,7 @@
west: "filler_c_west"
east: null
north: "boss"
south: null
south: "empty_a"
@@ -243,7 +244,7 @@
- id: "filler_1b"
texture: "ROOM1"
west: "filler_7"
west: "filler_1"
east: null
north: null
south: null