Yeah, I see your point, the code could not actually function the way game supposed to.
Since declaring to play a card consider the future (player's abilities to pay the cost) that no code could predict.
Only make sense to us Human.
I have dived into the RRG 1.6 and found something that might work. (I don't know how to code at all. I am just good at logical thinking)
in RRG 1.6 page 23 under INITIATING ABILITIES section
When a player wishes to play a card or initiate a triggered ability, that player first declares their intent. Then, the player checks the following conditions in order:
1. Check play restrictions: can the card be played, or the ability initiated, at this time?
» » If the card or ability specifies one or more targets, check that it has at least one valid target. If the card or ability does not have at least one valid target, it cannot be played or initiated.
2. Determine the cost (or costs) to play the card or initiate the ability and the player’s ability to pay them, taking modifiers into account.
If both conditions are met, follow these steps in order:
3. If playing a card, the player places that card faceup on the table in front of them. (This card is not in play.)
4. Apply any modifiers to the cost(s).
5. Pay the cost(s). If this step is reached and the cost(s) cannot be paid, abort this process without paying any costs.
6. The card commences being played, or the effects of the ability attempt to initiate.
7. The card is played or the ability (if not canceled in the previous step) resolves. The card enters play or, if it is an event card, its effects resolve and it is then placed in its owner’s discard pile.
• If any of the above steps would make the triggering condition of an interrupt ability true, that ability may be initiated just before that triggering condition becomes true.
• If any of the above steps would make the triggering condition of a response ability true, that ability may be initiated immediately after that triggering condition becomes true
The number 2 suggests that players must review themselves that they can actually pay the cost.
The cost paying step is actually number 5 that allows players to generate resources (using Gauntlet Gun for War Machine, or Clarity of Purpose for Spider-Ham in your example)
or the hard way I suggest that you could write a code to detect Gauntlet Gun for War Machine Card and detect CoP for Spider-Ham. The CON is that when the new card is released, it would be hell to keep adding card that it should detect.
or another way is that, add a little extra 6.5 in between, "If all cost is not paid, abort the process and rewind to before card selection"