feat: Adding items taken from chest to inventory
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
package cz.jzitnik.game;
|
package cz.jzitnik.game;
|
||||||
|
|
||||||
|
import cz.jzitnik.game.items.GameItem;
|
||||||
import cz.jzitnik.game.utils.RoomCords;
|
import cz.jzitnik.game.utils.RoomCords;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -16,6 +19,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class Player {
|
public class Player {
|
||||||
private final RoomCords playerCords;
|
private final RoomCords playerCords;
|
||||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||||
|
private final List<GameItem> inventory = new CopyOnWriteArrayList<>();
|
||||||
private boolean swinging = false;
|
private boolean swinging = false;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
|
|||||||
@@ -285,7 +285,9 @@ public final class Chest extends GameObject implements UIClickHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.remove(part);
|
var item = items.get(part);
|
||||||
|
gameState.getPlayer().getInventory().add(item);
|
||||||
|
items.remove(item);
|
||||||
|
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
uiClickHandlerRepository.removeHandlerForCurrentRoom(listenerHashCode, this);
|
uiClickHandlerRepository.removeHandlerForCurrentRoom(listenerHashCode, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user