feat: Faza 1 Gameplay Loop - Kista, Sekanje, Gradnja, Kmetovanje, Dnevnik, Zombiji
- Starter Chest (Kista): Nov sprite asset (chest_closed.png), zamenjal rectangles z dejansko sliko, dodal axe reward ob odprtju - Sekanje dreves: Zahteva Sekiro v rokah, padec drevesa odvrze 3 kose lesa (pickup sistem), unlock dnevniska vnosa - Gradnja Barikad [B]: Nov wooden_fence.png asset, BuildingSystem posodobljen z leseno barikado (cena: 2 les), ghost preview z grid snappingom, deductItem() API - Farming zanka: Popravljen seed property v InventorySystem, unlock ob prvem sajenju in zetvi - Kaijev Dnevnik [J]: Novi JournalSystem.js s 6 vnosi, gotski UI z zlatimi okviri, animirano odpiranje, odklepanje ob napredku - Zombie nochni napadi: Stopnjevano po nochih (max 8, hitrost do 65px/s, krajsi spawn delay), unlock dnevnika ob prvi nochi - InventorySystem: Popravljen bug kjer tools niso bili dodani v hotbar, dodan axe in wood v ITEM_DEFS, nova deductItem() funkcija - Pomoznna remove_bg.py skripta za odstranjevanje belega ozadja assetov
This commit is contained in:
@@ -29,17 +29,17 @@ export default class InventorySystem {
|
||||
this.items = {};
|
||||
// Format: { 'wheat_seed': { name, icon, count, type, tool/seed } }
|
||||
|
||||
// Hotbar = 7 slotov, vsak kaže na item key ali null
|
||||
// Hotbar = 7 slotov, vsak kaže na item key ali null (začenjamo prazni!)
|
||||
this.hotbar = [
|
||||
'hoe',
|
||||
'watering_can',
|
||||
'wheat_seed',
|
||||
'carrot_seed',
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
];
|
||||
this.activeSlot = 0; // Slot 1 = Motika
|
||||
this.activeSlot = 0; // Slot 1
|
||||
|
||||
// Item definicije
|
||||
this.ITEM_DEFS = {
|
||||
@@ -61,6 +61,15 @@ export default class InventorySystem {
|
||||
count: 1,
|
||||
desc: '[E] Zalij rastlino',
|
||||
},
|
||||
axe: {
|
||||
name: 'Sekira',
|
||||
icon: '🪓',
|
||||
type: 'tool',
|
||||
tool: 'axe',
|
||||
stackable: false,
|
||||
count: 1,
|
||||
desc: '[M1] Podri drevo',
|
||||
},
|
||||
wheat_seed: {
|
||||
name: 'Pšenica',
|
||||
icon: '🌾',
|
||||
@@ -88,8 +97,9 @@ export default class InventorySystem {
|
||||
seed: 'cannabis',
|
||||
stackable: true,
|
||||
count: 0,
|
||||
desc: '7 dni • 200g/harvest',
|
||||
desc: '[E] Posadi na preorano',
|
||||
color: '#88cc44',
|
||||
value: 50,
|
||||
},
|
||||
// Harvested items
|
||||
wheat: {
|
||||
@@ -116,6 +126,14 @@ export default class InventorySystem {
|
||||
count: 0,
|
||||
value: 200,
|
||||
},
|
||||
wood: {
|
||||
name: 'Les',
|
||||
icon: '🪵',
|
||||
type: 'resource',
|
||||
stackable: true,
|
||||
count: 0,
|
||||
value: 10,
|
||||
},
|
||||
};
|
||||
|
||||
// Inicializiraj items iz ITEM_DEFS (samo tiste s count > 0)
|
||||
@@ -169,9 +187,9 @@ export default class InventorySystem {
|
||||
}
|
||||
this.items[key].count += count;
|
||||
|
||||
// Dodaj v hotbar če je prazen slot + seme/resource
|
||||
// Dodaj v hotbar če je prazen slot in item še ni v hotbaru
|
||||
const def = this.ITEM_DEFS[key];
|
||||
if (def && def.stackable && !this.hotbar.includes(key)) {
|
||||
if (def && !this.hotbar.includes(key)) {
|
||||
const emptySlot = this.hotbar.findIndex(s => s === null);
|
||||
if (emptySlot !== -1) this.hotbar[emptySlot] = key;
|
||||
}
|
||||
@@ -186,6 +204,23 @@ export default class InventorySystem {
|
||||
console.log(`💰 +${amount}g (skupaj: ${this.gold}g)`);
|
||||
}
|
||||
|
||||
deductItem(key, amount) {
|
||||
if (!this.items[key] || this.items[key].count < amount) return false;
|
||||
|
||||
this.items[key].count -= amount;
|
||||
|
||||
// Če je stackable in gre na 0, odstrani tudi iz hotbara
|
||||
if (this.items[key].count <= 0 && this.items[key].stackable) {
|
||||
const index = this.hotbar.indexOf(key);
|
||||
if (index !== -1) {
|
||||
this.hotbar[index] = null;
|
||||
}
|
||||
}
|
||||
|
||||
this._notifyUI();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// PORABI ITEM (semena pri sajenju)
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user