From 2cb44830c5d0824d677a2359e76d18a440386d6b Mon Sep 17 00:00:00 2001 From: Fabio Ticconi Date: Sun, 12 Nov 2017 23:05:12 +0100 Subject: [PATCH] removing multiple-item production in crafting, maybe i'll add it later; also a few various fixes --- data/crafting.yml | 1 - data/items.yml | 16 ++++++++-------- .../alone/screens/AbstractScreen.java | 9 +++++++-- .../alone/screens/CraftItemScreen.java | 5 ----- .../fabioticconi/alone/systems/CraftSystem.java | 7 +------ 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/data/crafting.yml b/data/crafting.yml index 344e80b..df53828 100644 --- a/data/crafting.yml +++ b/data/crafting.yml @@ -6,7 +6,6 @@ sharp-stone: small-sharp-stone: sources: sharp-stone tools: stone - n: 2 stone-hammer: sources: [stone, branch, vine] diff --git a/data/items.yml b/data/items.yml index 7555ba1..a8ef89e 100644 --- a/data/items.yml +++ b/data/items.yml @@ -21,8 +21,14 @@ branch: c: '/' col: 5987163 # change +vine: + name: a thin, flexible branch + sprite: + c: 239 + col: 5987163 # change + trunk: - name: a tree trunk + name: a fallen tree sprite: c: '-' # change col: 5987163 # change @@ -33,12 +39,6 @@ boulder: c: '#' col: 5987163 # change -vine: - name: a thin, flexible branch - sprite: - c: '>' # change - col: 5987163 # change - sharp-stone: name: a sharp stone wearable: @@ -48,7 +48,7 @@ sharp-stone: damage: 2 sprite: c: 'o' # change - col: 5987163 # using rgb as single int.. + col: 5987163 # change small-sharp-stone: name: a small, sharp stone diff --git a/src/main/java/com/github/fabioticconi/alone/screens/AbstractScreen.java b/src/main/java/com/github/fabioticconi/alone/screens/AbstractScreen.java index d646ff6..810baac 100644 --- a/src/main/java/com/github/fabioticconi/alone/screens/AbstractScreen.java +++ b/src/main/java/com/github/fabioticconi/alone/screens/AbstractScreen.java @@ -22,6 +22,7 @@ import com.artemis.managers.PlayerManager; import com.artemis.utils.BitVector; import com.github.fabioticconi.alone.components.Inventory; +import com.github.fabioticconi.alone.utils.Util; import net.mostlyoriginal.api.system.core.PassiveSystem; import java.util.Collections; @@ -87,14 +88,18 @@ void drawHeader(final AsciiPanel terminal) void drawList(final AsciiPanel terminal, final List list) { + if (list.isEmpty()) + return; + final int maxSize = AbstractScreen.Letter.values().length; final int size = Math.min(maxSize, list.size()); + final int space = Util.clamp(maxSize/size, 1, 4); - for (int i = 0, starty = terminal.getHeightInCharacters() / 2 - size / 2; i < size; i++) + for (int i = 0, starty = terminal.getHeightInCharacters() / 2 - (size*space / 2); i < size; i++) { final String entry = ALL[i] + " " + list.get(i); - terminal.writeCenter(entry, starty + (size < maxSize / 2 ? i * 2 : i)); + terminal.writeCenter(entry, starty + i*space); } } diff --git a/src/main/java/com/github/fabioticconi/alone/screens/CraftItemScreen.java b/src/main/java/com/github/fabioticconi/alone/screens/CraftItemScreen.java index 375a640..ccd95cd 100644 --- a/src/main/java/com/github/fabioticconi/alone/screens/CraftItemScreen.java +++ b/src/main/java/com/github/fabioticconi/alone/screens/CraftItemScreen.java @@ -92,11 +92,6 @@ public void display(final AsciiPanel terminal) terminal.writeCenter("Tools needed:", height); terminal.writeCenter(Arrays.toString(craftScreen.craftItem.tools), height+2); - height += 8; - - terminal.writeCenter("# items produced:", height); - terminal.writeCenter(String.valueOf(craftScreen.craftItem.n), height + 2); - terminal.writeCenter("[ type ENTER to confirm ]", terminal.getHeightInCharacters()-2); } } diff --git a/src/main/java/com/github/fabioticconi/alone/systems/CraftSystem.java b/src/main/java/com/github/fabioticconi/alone/systems/CraftSystem.java index 7705330..5daa6c9 100644 --- a/src/main/java/com/github/fabioticconi/alone/systems/CraftSystem.java +++ b/src/main/java/com/github/fabioticconi/alone/systems/CraftSystem.java @@ -185,8 +185,6 @@ public int craftItem(final int entityId, final CraftItem itemRecipe) if (tempSources.size() < itemRecipe.sources.length || tempTools.size() < itemRecipe.tools.length) return -1; - // FIXME it doesn't take "n" into account.. do we actually need that? - final int id = sItems.makeItem(itemRecipe.tag); if (id < 0) @@ -195,8 +193,6 @@ public int craftItem(final int entityId, final CraftItem itemRecipe) for (final int sourceId : tempSources.getData()) { // destroying source items - // TODO figure out how to rely on EntityLinkManager even though we are effectively in pause - // (the best option is to make CraftItem an Action, which is also preferable overall..) world.delete(sourceId); inv.items.removeValue(sourceId); } @@ -209,13 +205,12 @@ public static class CraftItem public String tag; public String[] sources; public String[] tools; - public int n = 1; @Override public String toString() { return "CraftItem{" + "tag='" + tag + '\'' + ", sources=" + Arrays.toString(sources) + ", tools=" + - Arrays.toString(tools) + ", n=" + n + '}'; + Arrays.toString(tools) + '}'; } } }