#S0017. 游戏内物品交易
游戏内物品交易
1. Description & Background
🎮 In-Game Item Trading
In games like Animal Crossing, players exchange items. The system must:
- Verify both players have the required items
- Update inventories after successful trades
🛠️ Task
Implement a trading system with commands:
add player itemtrade from_player to_player give_item request_itemendto finish
Rules:
- Trade fails if items are missing (output
[Failed] Conditions not met) - Output
[Success] Trade detailson success
2. Input & Output
Input:
- Multiple commands ending with
end
Output:
- Immediate result for each trade attempt
- Final inventories sorted by player name
Example
# Input:
add Alice apple
add Alice apple
add Bob wood
trade Alice Bob apple wood
trade Bob Alice wood stone
end
# Process Output:
[Success] Alice traded apple for Bob's wood
[Failed] Conditions not met
# Final Output:
Alice: wood, apple
Bob: apple