Skip to content

Commit

Permalink
removing multiple-item production in crafting, maybe i'll add it late…
Browse files Browse the repository at this point in the history
…r; also a few various fixes
  • Loading branch information
fabio-t committed Nov 12, 2017
1 parent 3e56611 commit 2cb4483
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
1 change: 0 additions & 1 deletion data/crafting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sharp-stone:
small-sharp-stone:
sources: sharp-stone
tools: stone
n: 2

stone-hammer:
sources: [stone, branch, vine]
Expand Down
16 changes: 8 additions & 8 deletions data/items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,14 +88,18 @@ void drawHeader(final AsciiPanel terminal)

void drawList(final AsciiPanel terminal, final List<String> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand All @@ -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) + '}';
}
}
}

0 comments on commit 2cb4483

Please sign in to comment.