using NUnit.Framework;
using UnityEngine;

namespace IStalk.Tests
{
    [TestFixture]
    public class ItemDatabaseTests
    {
        [Test]
        public void ItemDatabase_LookupById_ReturnsCorrectItem()
        {
            // Placeholder test — validates test framework is functional.
            // Replace with real ItemDatabase tests once ItemData_SO is implemented.
            string testId = "crowbar";
            Assert.That(testId, Is.Not.Null.And.Not.Empty,
                "Item IDs must be non-null, non-empty strings");
        }

        [Test]
        public void WeightCalculation_AddItem_IncreasesWeight()
        {
            float startWeight = 0f;
            float itemWeight = 2.5f;
            float result = startWeight + itemWeight;

            Assert.That(result, Is.EqualTo(2.5f).Within(0.001f),
                "Adding an item should increase weight by the item's weight value");
        }

        [Test]
        public void WeightTier_Calculation_CorrectTier()
        {
            // Weight tier boundaries from GlobalRules_SO design:
            // Tier 0: 0-3kg (no penalty)
            // Tier 1: 3-6kg (slight slow)
            // Tier 2: 6-9kg (moderate slow)
            // Tier 3: 9+kg (heavy slow)
            float maxWeight = 12f;
            float currentWeight = 7f;
            float ratio = currentWeight / maxWeight;

            // Tier = floor(ratio * 4), clamped to 0-3
            int tier = Mathf.Clamp(Mathf.FloorToInt(ratio * 4), 0, 3);

            Assert.That(tier, Is.EqualTo(2),
                "7/12 weight ratio should place runner in tier 2");
        }
    }
}
