Transfer verb: drop the redundant pre-check, let range, step length and quantity edges show in tests
TryStore already takes all of a part or none, so the pre-check in TryTransferItem changed nothing observable. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bb38036e51
commit
70aa1ed037
3 changed files with 62 additions and 12 deletions
|
|
@ -94,7 +94,7 @@ public static class CargoTransfer
|
|||
order.Budget -= 1;
|
||||
order.Remaining--;
|
||||
}
|
||||
if (giver.Giving == order && order.Remaining == 0) End(giver, GiveEnd.Done);
|
||||
if (order.Remaining == 0) End(giver, GiveEnd.Done);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2664,17 +2664,13 @@ public class EquippedCargoBay : EquippedItem
|
|||
return false;
|
||||
}
|
||||
|
||||
// Whole or nothing: the target must be able to take the part before it leaves the stack.
|
||||
var part = new SimpleCommodity { Data = item.Data, Quantity = min(quantity, item.Quantity), Rotation = item.Rotation };
|
||||
if (!target.TryFindSpace(part, out _)) return false;
|
||||
|
||||
var oldPos = Cargo[item];
|
||||
var newItem = Remove(item, quantity);
|
||||
|
||||
// The part removed goes across, never the stack left behind.
|
||||
if (target.TryStore(newItem)) return true;
|
||||
|
||||
// The target refused after all: put the part back where it came from.
|
||||
// Whole or nothing: TryStore takes all of the part or none of it, so a refusal puts the part back where it came from.
|
||||
TryStore(newItem, oldPos);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue