From 857924ccf2bfca4e85647ad5492808379ab28e3d Mon Sep 17 00:00:00 2001 From: Tom Rijnbeek Date: Mon, 2 Oct 2023 22:49:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=AB=97=20Add=2010=20points=20for=20each?= =?UTF-8?q?=20empty=20slot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/inventory/Inventory.cs | 1 + scenes/main/Main.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scenes/inventory/Inventory.cs b/scenes/inventory/Inventory.cs index 62e99fc..817f68d 100644 --- a/scenes/inventory/Inventory.cs +++ b/scenes/inventory/Inventory.cs @@ -38,6 +38,7 @@ public int Height private readonly List heldItems = new(); public IReadOnlyList HeldItems => heldItems.AsReadOnly(); + public int EmptySlotCount => itemGrid.Count(i => i is null); public Item? this[Coord coord] { diff --git a/scenes/main/Main.cs b/scenes/main/Main.cs index bf68457..1792435 100644 --- a/scenes/main/Main.cs +++ b/scenes/main/Main.cs @@ -78,7 +78,9 @@ private void onPlayerDied() private void addLootScore() { - score += GetNode("Inventory").HeldItems.Sum(i => i.Type.Score()); + var inventory = GetNode("Inventory"); + score += inventory.HeldItems.Sum(i => i.Type.Score()); + score += inventory.EmptySlotCount * 10; } private void doGameOver()