feat: Adding items taken from chest to inventory

This commit is contained in:
2026-01-01 14:50:13 +01:00
parent 59803e46f5
commit 6373c7694f
2 changed files with 7 additions and 1 deletions

View File

@@ -1,11 +1,14 @@
package cz.jzitnik.game;
import cz.jzitnik.game.items.GameItem;
import cz.jzitnik.game.utils.RoomCords;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -16,6 +19,7 @@ import java.util.concurrent.TimeUnit;
public class Player {
private final RoomCords playerCords;
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private final List<GameItem> inventory = new CopyOnWriteArrayList<>();
private boolean swinging = false;
@Setter

View File

@@ -285,7 +285,9 @@ public final class Chest extends GameObject implements UIClickHandler {
return;
}
items.remove(part);
var item = items.get(part);
gameState.getPlayer().getInventory().add(item);
items.remove(item);
if (items.isEmpty()) {
uiClickHandlerRepository.removeHandlerForCurrentRoom(listenerHashCode, this);