For each player, choose friend or foe. Each friend searches their library for a land card, puts it onto the battlefield tapped, then shuffles their library. Each foe sacrifices an artifact or enchantment they control.
You may call a player a friend or a foe even if that player will be instructed to perform an impossible action. For example, for Regnaâ€™s Sanction, a foe may control no untapped creatures.
You make this choice for yourself as well as each other player. In some rare cases, you may wish to call yourself (or your teammate in a Two-Headed Giant game) a foe. You can do that.
When Pirâ€™s Whim resolves and your friends perform their actions, first the next friend in turn order (or, if itâ€™s a friendâ€™s turn, that friend) searches their library for a land without revealing the card they choose, then each other friend in turn order does the same. Then all the lands are put onto the battlefield at the same time.
When Pirâ€™s Whim resolves and your foes perform their actions, first the next foe in turn order (or, if itâ€™s a foeâ€™s turn, that foe) chooses an artifact or enchantment they control, then each other foe in turn order does the same, then all chosen permanents are sacrificed at the same time. Foes will know choices made by earlier players when making their choices.
The designation of friend or foe is only relevant to the spell that asks you to choose. A player you call your friend doesnâ€™t become your teammate, and the next â€œfriend or foeâ€ spell you cast could name that player your foe.
Players canâ€™t take actions in between the time that friends perform their actions and the time that foes perform theirs. If any abilities trigger from friends performing actions, those triggers wonâ€™t be put onto the stack until the foes perform their actions and the spell finishes resolving.
Friends perform their specified actions before foes. This means that a friendâ€™s action may cause a triggered ability of a foeâ€™s permanent to trigger before that foeâ€™s action causes that permanent to leave the battlefield.