refactor(slay-the-spire-like): use IRunContext in combat system
Update the combat system to use `IRunContext` instead of passing raw inventory objects. This provides a cleaner abstraction for accessing item data and managing consumed uses. - Update `canPlayCard` and `payCardCost` to use `IRunContext` - Pass `IRunContext` through the trigger registration chain - Fix logic in `canPlayCard` for "uses" cost validation - Update combat effect tests to use a mock `IRunContext`
This commit is contained in:
@@ -145,9 +145,9 @@ export function canPlayCard(
|
||||
if (costType === "uses") {
|
||||
const item = run.getItemData(itemId);
|
||||
if (!item) return false;
|
||||
const maxUses = item?.card.costType === "energy" ? item.card.costCount : 0;
|
||||
const maxUses = item?.card.costType === "uses" ? item.card.costCount : 0;
|
||||
const consumed = run.getConsumedUses(itemId);
|
||||
return consumed + costCount <= maxUses;
|
||||
return consumed < maxUses;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user