I tried your suggested algorithm and got the following error on localPut when i call the smart contract for second player (Bob):
logic eval error: invalid Account reference
Here’s the code (I wrote a comment where I received the error):
scratchWaitinglayer.store(App.globalGet(Bytes("waitingPlayer"))),
If(scratchWaitinglayer.load() == Bytes(""), # no player in Queue
Seq([
App.globalPut(Bytes("waitingPlayer"), Txn.sender()),
])
, # a player is in Queue
Seq([
App.localPut(Int(0), Bytes("partner"), scratchWaitinglayer.load()), #Got error here
App.localPut(scratchWaitinglayer.load(),Bytes("partner"),Txn.sender()),
App.globalPut(Bytes("waitingPlayer"), Bytes("")),
])
),