← Chess for Power Apps

Behaviour: Chess for Power Apps

73 behaviour formulas read into 478 steps: 200 write, 95 branch, 58 effect, 54 collection, 27 navigate, 15 scope, 15 data, 7 value, 4 context, 3 loop. 0 steps the translator could not express. 258 value expressions inside the steps were translated and reconciled like properties (229 reconciled).

Each formula is a Python handler in python/behaviour.py that applies the same steps to a Context: state is written, navigation is recorded, actions that leave the app are logged rather than performed. This is a specification for the host that replaces the app, not a claim that the actions were tested end to end.

State written by events

Target Kind Written by
colActions collection Actions Screen.OnVisible
colAdmins collection App.OnStart
colBoard collection App.OnStart
colCaptured collection Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
colCastling collection Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleResetGame.OnCheck
colGame collection Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMove.OnCheck, Game Screen/ToggleResetGame.OnCheck, Join Game Screen/ButtonJoin.OnSelect, New Game Screen/ButtonCreateGame.OnSelect
colIcons collection App.OnStart
colIntegers collection App.OnStart
colMessages collection Game Screen/ToggleMoveMessage.OnCheck, Game Screen/ToggleResetGame.OnCheck
colNewCastling collection App.OnStart
colNewGame collection App.OnStart
colPGN collection Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck, Join Game Screen/ButtonJoin.OnSelect, New Game Screen/ButtonCreateGame.OnSelect
colPGNTagPairs collection Game Screen/ToggleLoadGame.OnCheck
colPeople collection New Game Screen.OnVisible
colPeopleTemp collection New Game Screen.OnVisible
colPieces collection App.OnStart
colPlayerData collection App.OnStart, Join Game Screen/ButtonJoin.OnSelect, New Game Screen/ButtonCreateGame.OnSelect, Share Screen/ButtonPGNUpdate.OnSelect
colPlayers collection App.OnStart
colSVG collection App.OnStart
selectedPieces collection Game Screen/InputMove.OnChange, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
selectedPlayers collection New Game Screen.OnVisible, New Game Screen/galleryTemplate6.OnSelect
selectedSquares collection Game Screen/InputMove.OnChange, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
Join Game Screen/SortDescending1 context Join Game Screen.OnVisible, Join Game Screen/IconSortUpDown1.OnSelect
New Game Screen/locGetPeople context New Game Screen.OnVisible
GamePlayerData data New Game Screen/ButtonCreateGame.OnSelect
colCaptured data Game Screen/ToggleMove.OnCheck
colCastling data Game Screen/ToggleMove.OnCheck
colGame data Game Screen/ToggleMove.OnCheck
colPGN data Game Screen/ToggleMove.OnCheck
selectedPlayers data New Game Screen/galleryTemplate6.OnSelect
resetReplay write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/galleryTemplate3.OnSelect
selectedMatch write App.OnStart, Archive Dialog/ButtonArchiveConfirm.OnSelect, Forfeit Dialog/ButtonForfeitConfirm.OnSelect, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveValidation.OnCheck, Game Screen/ToggleSaveGame.OnCheck, Join Game Screen/ButtonJoin.OnSelect, New Game Screen/ButtonCreateGame.OnSelect
selectedMatchTemp write Game Screen/TimerRefresh.OnTimerEnd
selectedMove write Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSetup.OnCheck
selectedMoveMetadata write Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleMoveValidation.OnCheck
selectedMoveNumber write Game Screen/TimerRefresh.OnTimerEnd, Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleResetGame.OnCheck
selectedPGN write Game Screen/galleryTemplate5.OnSelect
selectedPiece write Game Screen/InputMove.OnChange, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
selectedPlayer write Game Screen/TimerRefresh.OnTimerEnd, Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleResetGame.OnCheck
selectedPlayerData write Game Screen/IconPlayerMenu.OnSelect
selectedSquare write Game Screen/InputMove.OnChange, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
selectedSquareTemp write Game Screen/galleryTemplate1.OnSelect
stringFEN write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveJump.OnCheck, Game Screen/ToggleSyncGame.OnCheck, Share Screen/ButtonPGNUpdate.OnSelect
stringPGN write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleSyncGame.OnCheck, Share Screen/ButtonPGNUpdate.OnSelect
triggerArchive write Archive Dialog/ButtonArchiveConfirm.OnSelect
triggerForfeit write Forfeit Dialog/ButtonForfeitConfirm.OnSelect
triggerLoadGame write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveJump.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/ToggleSyncGame.OnCheck
triggerMove write Game Screen/TimerMoveTransition.OnTimerEnd, Game Screen/ToggleMove.OnCheck, Game Screen/ToggleResetGame.OnCheck
triggerMoveEnd write Game Screen/ToggleMove.OnCheck, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleResetGame.OnCheck
triggerMoveJump write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/galleryTemplate5.OnSelect
triggerMoveLast write Game Screen/TimerRefresh.OnTimerEnd
triggerMoveMessage write Game Screen/InputMove.OnChange, Game Screen/ToggleMoveMessage.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
triggerMoveSelect write Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/galleryTemplate1.OnSelect
triggerMoveSetup write Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleMoveValidation.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/galleryTemplate3.OnSelect
triggerMoveTransition write Game Screen/ToggleMove.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
triggerMoveValidation write Game Screen/InputMove.OnChange, Game Screen/TimerRefresh.OnTimerEnd, Game Screen/ToggleMoveValidation.OnCheck, Game Screen/ToggleResetGame.OnCheck
triggerNewGame write Game Screen.OnVisible, New Game Screen/ButtonCreateGame.OnSelect
triggerResetGame write Game Screen.OnVisible, Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/galleryTemplate3.OnSelect
triggerRotation write Game Screen/TimerRotate.OnTimerEnd, Game Screen/galleryTemplate3.OnSelect
triggerSaveGame write Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleSaveGame.OnCheck
triggerSyncGame write Game Screen/InputMove.OnChange, Game Screen/TimerRefresh.OnTimerEnd, Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleSyncGame.OnCheck, Game Screen/galleryTemplate1.OnSelect, Game Screen/galleryTemplate3.OnSelect
varAppId write App.OnStart
varCanEnPassant write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
varCastlingMetadata write Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleMoveValidation.OnCheck
varDebug write Game Screen/galleryTemplate3.OnSelect
varDelimiter write App.OnStart
varDelimiterForData write App.OnStart
varEnPassantSquare write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
varEndReplay write Game Screen/ToggleMoveEnd.OnCheck, Game Screen/galleryTemplate3.OnSelect
varGoose write Home Screen/AudioGoose.OnEnd, Home Screen/ImageGoose.OnSelect
varIsAdmin write App.OnStart
varIsEnPassant write Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleResetGame.OnCheck
varIsGuest write App.OnStart
varIsNewGame write Join Game Screen/ButtonJoin.OnSelect, New Game Screen/ButtonCreateGame.OnSelect
varIsReplay write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveEnd.OnCheck, Game Screen/ToggleMoveSelect.OnCheck, Game Screen/ToggleResetGame.OnCheck, Game Screen/galleryTemplate3.OnSelect, Game Screen/galleryTemplate5.OnSelect
varLoadFEN write App.OnStart, Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveJump.OnCheck, Game Screen/ToggleSyncGame.OnCheck, Join Game Screen/ButtonJoin.OnSelect, Share Screen/ButtonPGNUpdate.OnSelect
varLoadPGN write App.OnStart, Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleSyncGame.OnCheck, Join Game Screen/ButtonJoin.OnSelect, Share Screen/ButtonPGNUpdate.OnSelect
varMatchId write App.OnStart
varMoveEntry write Game Screen/InputMove.OnChange, Game Screen/TimerRefresh.OnTimerEnd, Game Screen/ToggleMoveSetup.OnCheck, Game Screen/ToggleMoveValidation.OnCheck
varMoveEntryTemp write Game Screen/TimerRefresh.OnTimerEnd
varMoveMessage write Game Screen/ToggleMoveMessage.OnCheck
varMoveScan write Game Screen/InputMove.OnChange, Game Screen/ToggleMoveMessage.OnCheck, Game Screen/ToggleMoveSelect.OnCheck
varOverrideLoad write Game Screen/ToggleLoadGame.OnCheck, Game Screen/ToggleMoveJump.OnCheck, Game Screen/ToggleSyncGame.OnCheck, Join Game Screen/ButtonJoin.OnSelect, Share Screen/ButtonPGNUpdate.OnSelect
varRotation write Game Screen.OnVisible, Game Screen/TimerRotate.OnTimerEnd
varTenantId write App.OnStart
varTimeNow write Join Game Screen.OnVisible, Join Game Screen/IconRefresh1.OnSelect, Join Game Screen/TimerRefreshServer.OnTimerEnd
varUser write App.OnStart
varViewGame write App.OnStart, Home Screen/ButtonJoinGame.OnSelect, Home Screen/ButtonNewGame.OnSelect, Home Screen/ButtonViewGame.OnSelect

Screen flow

Event Goes to
App.OnStart Game Screen
Share Screen/IconBackPGN.OnSelect Game Screen
Share Screen/IconBackPGN.OnSelect Home Screen
Share Screen/ButtonPGNUpdate.OnSelect Game Screen
Checkmate Screen/ButtonCheckmate.OnSelect Home Screen
Settings Screen/IconBackSettings.OnSelect Game Screen
New Game Screen/IconBackNewGame.OnSelect Home Screen
New Game Screen/ButtonCreateGame.OnSelect Game Screen
Actions Screen/IconBackActions.OnSelect Game Screen
Actions Screen/ButtonActionForfeit.OnSelect Forfeit Dialog
Actions Screen/ButtonActionArchive.OnSelect Archive Dialog
Game Screen/galleryTemplate3.OnSelect Home Screen
Game Screen/galleryTemplate3.OnSelect Settings Screen
Game Screen/galleryTemplate3.OnSelect Share Screen
Game Screen/ToggleMoveValidation.OnCheck Checkmate Screen
Game Screen/ToggleMoveEnd.OnCheck Checkmate Screen
Game Screen/IconPlayerMenu.OnSelect Actions Screen
Forfeit Dialog/ButtonForfeitConfirm.OnSelect Checkmate Screen
Forfeit Dialog/ButtonForfeitCancel.OnSelect Actions Screen
Archive Dialog/ButtonArchiveConfirm.OnSelect Join Game Screen
Archive Dialog/ButtonArchiveCancel.OnSelect Actions Screen
Home Screen/ButtonNewGame.OnSelect New Game Screen
Home Screen/ButtonJoinGame.OnSelect Join Game Screen
Home Screen/ButtonViewGame.OnSelect Share Screen
Join Game Screen/IconHamburger.OnSelect Home Screen
Join Game Screen/IconNewItem1.OnSelect New Game Screen
Join Game Screen/ButtonJoin.OnSelect Game Screen

Actions that leave the app

Logged by the handlers, never performed; the host decides what each means.

Function Kind Calls
Notify UI or environment 24
Select UI or environment 19
Refresh UI or environment 7
Reset UI or environment 6
Trace UI or environment 1
PowerAppsNotification.SendPushNotification connector 1

Every event

App.OnStart

// Get the app id of this app. You need to include one if you want to send a link in the match invitation. Set(varAppId,LookUp(GameList,Title="Chess").AppId); /

Step Kind What it does Reason not translated
Set write sets variable varAppId to LookUp(GameList, (Title = "Chess")).AppId
Set write sets variable varTenantId to ""
Set write sets variable varDelimiter to ","
Set write sets variable varDelimiterForData to "||"
ClearCollect collection replaces the rows of colIntegers: AddColumns(RenameColumns(Sequence((255 + 1), 0), "Value", "n"), "Hex", Concat(Sort(RenameColumns(Sequence(2), "Value", "Power"), Power, Descending), With({Base: 16, String: "123456789ABCDEF"}, Coalesce(Mid(String, Mod(RoundDown((n / Power(Base, (Power - 1))), 0), Base), 1), "0"))))
ClearCollect collection replaces the rows of colBoard: AddColumns(AddColumns(Ungroup(AddColumns(RenameColumns(Sequence(8), "Value", "Y"), "ColumnTable", RenameColumns(Sequence(8), "Value", "X")), "ColumnTable"), "Rank", ((8 - Y) + 1), "File", Mid("abcdefgh", X, 1)), "Id", (((Y - 1) * 8) + X), "Square", (File & Rank))
ClearCollect collection replaces the rows of colPlayers: Table({Player: 1, Color: "White"}, {Player: 2, Color: "Black"})
ClearCollect collection replaces the rows of colPieces: Table({Piece: 1, Name: "King", Abbr: "K"}, {Piece: 2, Name: "Queen", Abbr: "Q"}, {Piece: 3, Name: "Rook", Abbr: "R"}, {Piece: 4, Name: "Bishop", Abbr: "B"}, {Piece: 5, Name: "Knight", Abbr: "N"}, {Piece: 6, Name: "Pawn", Abbr: Blank()})
ClearCollect collection replaces the rows of colIcons: Table({PlayerId: 1, PieceId: 1, Icon: "♔"}, {PlayerId: 2, PieceId: 1, Icon: "♚"}, {PlayerId: 1, PieceId: 2, Icon: "♕"}, {PlayerId: 2, PieceId: 2, Icon: "♛"}, {PlayerId: 1, PieceId: 3, Icon: "♖"}, {PlayerId: 2, PieceId: 3, Icon: "♜"}, {PlayerId: 1, PieceId: 4, Icon: "♗"}, {PlayerId: 2, PieceId: 4, Icon: "♝"}, {PlayerId: 1, PieceId: 5, Icon: "♘"}, {PlayerId: 2, PieceId: 5, Icon: "♞"}, {PlayerId: 1, PieceId: 6, Icon: "♙"}, {PlayerId: 2, PieceId: 6, Icon: "♟"})
ClearCollect collection replaces the rows of colNewGame: AddColumns(Ungroup(AddColumns(colPlayers, "PiecesTable", Ungroup(AddColumns(colPieces, "PlacementTable", Switch(Name, "King", Filter(colBoard, (Rank = Switch(Player, 1, 1, 2, 8)), (File = "e")), "Queen", Filter(colBoard, (Rank = Switch(Player, 1, 1, 2, 8)), (File = "d")), "Rook", Filter(colBoard, (Rank = Switch(Player, 1, 1, 2, 8)), Or((File = "a"), (File = "h"))), "Bishop", Filter(colBoard, (Rank = Switch(Player, 1, 1, 2, 8)), Or((File = "c"), (File = "f"))), "Knight", Filter(colBoard, (Rank = Switch(Player, 1, 1, 2, 8)), Or((File = "b"), (File = "g"))), "Pawn", Filter(colBoard, (Rank = Switch(Player, 1, 2, 2, 7)))), "Icon", LookUp(colIcons, And((PlayerId = Player), (PieceId = Piece))).Icon), "PlacementTable")), "PiecesTable"), "Guid", GUID())
ClearCollect collection replaces the rows of colNewCastling: AddColumns(RenameColumns(ShowColumns(AddColumns(Sort(Sort(Filter(colNewGame, (Name = "Rook")), Id, Descending), Player), "Side", If((File = "h"), Switch(Player, 1, "K", "k"), Switch(Player, 1, "Q", "q"))), "Id", "Player", "Side"), "Id", "RookId"), "CanCastle", true)
ClearCollect collection replaces the rows of colSVG: Table({Key: "linearGradient", Value: Trim((("" & "|table|") & ""))}, {Key: "radialGradient", Value: Trim((("" & "|table|") & ""))}, {Key: "dropShadow", Value: Trim(((("" & "<feOffset result='offOut' in='SourceGraphic'
dx='|dx|'
dy='|dy|'
/>") & "<feColorMatrix
result='matrixOut'
in='offOut'
type='matrix'
values='0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 |opacity| 0'
/>") & "<feGaussianBlur
result='blurOut'
in='matrixOut'
stdDeviation='|stdDeviation|'
/>
<feBlend
in='SourceGraphic'
in2='blurOut'
mode='normal'
/>
"))}, {Key: "rect", Value: Trim("<rect
x='|x|'
y='|y|'
width='|width|'
height='|height|'
rx='|rx|'
ry='|ry|'
stroke='|stroke|'
stroke-width='|stroke-width|'
fill='|fill|'
fill-opacity='|fill-opacity|'
filter='|filter|'
/>")}, {Key: "circle", Value: Trim(("<circle " & "cx='|cx|'
cy='|cy|'
r='|r|'
stroke='|stroke|'
stroke-width='|stroke-width|'
fill='|fill|'
fill-opacity='|fill-opacity|'
filter='|filter|'
/>"))}, {Key: "text", Value: Trim(((("<text " & "x='|x|'
y='|y|'
class='|class|'
font-family='|font-family|'
font-size='|font-size|'
font-weight='|font-weight|'
text-anchor='|text-anchor|'
alignment-baseline='|middle|'
stroke='|stroke|'
stroke-width='|stroke-width|'
fill='|fill|'
filter='|filter|'
>") & "|text|") & ""))}, {Key: "icon", Value: Trim("<path
transform='
translate(|translateX|,|translateY|)
scale(|scaleX|,|scaleY|)
rotate(|angle|,|rotateX|,|rotateY|)
'
fill='|fill|'
filter='|filter|'
d='|d|'
>
")}, {Key: "polygon", Value: Trim("<polygon
points='|points|'
fill='|fill|'
fill-opacity='|fill-opacity|'
stroke='|stroke|'
stroke-width='|stroke-width|'
/>")}, {Key: "gauge", Value: Concat(Table({angle: (Pi() / 4), value: 50, max: 100, center: 50%, radius: 30%, 'stroke-width': 5%}), ((((((((((((((((((((((("<path
fill='none'
style='
stroke-width:" & 'stroke-width') & ";
stroke:") & "white") & ";
stroke-linecap:") & "round") & ";
stroke-opacity:") & "0.5") & ";
'
d='") & "M ") & Text((center - (radius * Sin(angle))))) & " ") & Text((center + (radius * Cos(angle))))) & " A ") & radius) & " ") & radius) & " 0 1 1 ") & Text((center - (radius * Sin(((2 * Pi()) - angle)))))) & " ") & Text((center + (radius * Cos(((2 * Pi()) - angle)))))) & "'>") & "") & If((value > 0), (((((((((((((((((((((((("<path
fill='none'
style='
stroke-width:" & 'stroke-width') & ";
stroke:") & "rgb(54,175,76)") & ";
stroke-linecap:") & "round") & ";
stroke-opacity:") & "") & ";
'
d='") & "M ") & Text((center - (radius * Sin(angle))))) & " ") & Text((center + (radius * Cos(angle))))) & " A ") & radius) & " ") & radius) & " 0 ") & If(((value / max) > (Pi() / (2 * (Pi() - angle)))), "1", "0")) & " 1 ") & Text((center - (radius * Sin((angle + (((2 * (Pi() - angle)) * value) / max))))))) & " ") & Text((center + (radius * Cos((angle + (((2 * (Pi() - angle)) * value) / max))))))) & "'>") & ""))))})
Set write sets variable varUser to Coalesce(Office365Users.MyProfileV2(), {displayName: "", id: "", userPrincipalName: ""})
If branch if IsBlank(varUser.id)
Set write sets variable varIsGuest to true
Set write sets variable varUser to With({Guest: Lower(User().Email)}, With({recordGuest: LookUp(GamePlayerData, And((Title = Guest), (AppId = varAppId), (MatchId = 0)))}, Patch(varUser, {displayName: Last(FirstN(Split(recordGuest.PlayerData, varDelimiterForData), 1)).Result, id: recordGuest.PlayerId, userPrincipalName: Guest})))
Trace effect UI or environment action Trace(varUser.id, TraceSeverity.Information), logged not performed
ClearCollect collection replaces the rows of colAdmins: RenameColumns(["contact@mr-dang.com"], "Value", "Admin")
Set write sets variable varIsAdmin to (Lower(varUser.userPrincipalName) in colAdmins.Admin)
Set write sets variable varMatchId to Value(Param("matchid"))
If branch if (varMatchId > 0)
Set write sets variable selectedMatch to LookUp(GameServer, (ID = varMatchId))
If branch if !IsBlank(selectedMatch.ID)
Set write sets variable varViewGame to !(varUser.id in selectedMatch.Players)
ClearCollect collection replaces the rows of colPlayerData: Ungroup(AddColumns(colPlayers, "tablePlayerData", With({tablePlayers: AddColumns(AddColumns(RenameColumns(Split(selectedMatch.Players, varDelimiter), "Result", "PlayerData"), "DisplayName", First(Split(PlayerData, " <")).Result, "Id", Substitute(Match(PlayerData, "(?:\<).+?(?=>)").FullMatch, "<", "")), "UserPrincipalName", If(varIsGuest, Coalesce(LookUp(GamePlayerData, (PlayerId = Id)).Title, ""), With(Office365Users.UserProfileV2(Id), If(!("#EXT#" in userPrincipalName), userPrincipalName, Coalesce(With({stringUserPrincipalName: First(Split(userPrincipalName, "#EXT#")).Result}, Lower(Replace(stringUserPrincipalName, Last(MatchAll(stringUserPrincipalName, "_")).StartMatch, 1, "@"))), If(IsMatch(displayName, Match.Email), displayName, ""))))))}, If((Player = 1), FirstN(Filter(tablePlayers, (Id in selectedMatch.ActivePlayer)), 1), Coalesce(FirstN(Filter(tablePlayers, !(Id in selectedMatch.ActivePlayer)), 1), LastN(FirstN(tablePlayers, 2), 1))))), "tablePlayerData")
Set write sets variable varLoadFEN to true
Set write sets variable varLoadPGN to true
Navigate navigate navigates to Game Screen (Fade)

Share Screen/IconBackPGN.OnSelect

If( varViewGame, Navigate('Home Screen',Fade), Navigate('Game Screen', ScreenTransition.Fade) )

Step Kind What it does Reason not translated
If branch if varViewGame / else
Navigate navigate navigates to Home Screen (Fade)
Navigate navigate navigates to Game Screen (ScreenTransition.Fade)

Share Screen/InputFEN.OnSelect

false

Step Kind What it does Reason not translated
value value evaluates false and discards the result

Share Screen/InputDeepLink.OnSelect

false

Step Kind What it does Reason not translated
value value evaluates false and discards the result

Share Screen/ButtonPGNUpdate.OnSelect

Set(varOverrideLoad,true); With( { validFEN: And( !IsBlank(Trim(InputFEN.Text)), IsMatch(InputFEN.Text,"([KQRBNPkqrbnp1-8](\/)?){8,}\s[bw]\s[KQkq-]{1,}\s([a-h][

Step Kind What it does Reason not translated
Set write sets variable varOverrideLoad to true
With scope with {validFEN: And(!IsBlank(Trim(InputFEN.Text)), IsMatch(InputFEN.Text, "(KQRBNPkqrbnp1-8?){8,}\s[bw]\s[KQkq-]{1,}\s([a-h][1-8]|-)\s\d\s\d")), validPGN: And(!IsBlank(Trim(InputPGN.Text)), !IsEmpty(MatchAll(InputPGN.Text, "\d{1,}.{1,}\s?(([Oo0]-Oo0?|[KQRBN]?[a-h]?[1-8]?x?[a-h]1-8?[+#]?)(\s?{.+?})?(\s(1-0|0-1|1\/2-1\/2))?\s?){1,}")))}
If branch if validFEN
Set write sets variable varLoadFEN to true
Set write sets variable stringFEN to InputFEN.Text
If branch if validPGN
Set write sets variable varLoadPGN to true
Set write sets variable stringPGN to InputPGN.Text
If branch if And(!validFEN, !validPGN) / elif !validFEN / elif !validPGN
Notify effect UI or environment action Notify("Neither the FEN nor PGN could be imported because they did not match the expected syntax.", NotificationType.Warning, 2500), logged not performed
Notify effect UI or environment action Notify("The FEN could not be imported because it did not match the expected syntax.", NotificationType.Warning, 2500), logged not performed
Notify effect UI or environment action Notify("The PGN could not be imported because it did not match the expected syntax.", NotificationType.Warning, 2500), logged not performed
If branch if varViewGame
Clear collection empties colPlayerData
Collect collection adds to colPlayerData: colPlayers
If branch if Or(varLoadFEN, varLoadPGN)
Navigate navigate navigates to Game Screen (Fade)

Checkmate Screen/ButtonCheckmate.OnSelect

Navigate('Home Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to Home Screen (ScreenTransition.Fade)

Settings Screen/IconBackSettings.OnSelect

Navigate('Game Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to Game Screen (ScreenTransition.Fade)

New Game Screen.OnVisible

If( !varIsGuest, If( IsEmpty(colPeople), UpdateContext({locGetPeople: true}); // Get the logged in user's manager. // Add the manager to the collection of every

Step Kind What it does Reason not translated
If branch if !varIsGuest
If branch if IsEmpty(colPeople)
UpdateContext context sets context variable locGetPeople = true on New Game Screen
ClearCollect collection replaces the rows of colPeopleTemp: Office365Users.ManagerV2(varUser.id, {'$select': "id,displayName,jobTitle,mail,userPrincipalName"})
Collect collection adds to colPeopleTemp: Office365Users.DirectReportsV2(First(colPeopleTemp).id, {'$select': "id,displayName,jobTitle,mail,userPrincipalName"}).value
With scope with {tableRelevantPeople: ShowColumns(Office365Users.RelevantPeople(varUser.id).value, "id", "displayName", "jobTitle", "userPrincipalName", "scoredEmailAddresses", "imAddress")}
Collect collection adds to colPeopleTemp: RenameColumns(DropColumns(Filter(AddColumns(Filter(tableRelevantPeople, !(id exactin colPeopleTemp.id)), "helperDisplayName", If(IsMatch(displayName, Match.Email), First(Split(displayName, "@")).Result, displayName), "helperUserPrincipalName", Coalesce(userPrincipalName, First(scoredEmailAddresses).address, If(IsMatch(displayName, Match.Email), Lower(displayName)))), !IsBlank(helperUserPrincipalName), !And(IsMatch(id, "[A-f0-9]{8}-[A-f0-9]{4}-[A-f0-9]{4}-[A-f0-9]{4}-[A-f0-9]{12}"), IsBlank(imAddress))), "displayName", "userPrincipalName", "scoredEmailAddresses", "imAddress"), "helperDisplayName", "displayName", "helperUserPrincipalName", "userPrincipalName")
ClearCollect collection replaces the rows of colPeople: Filter(RenameColumns(colPeopleTemp, "id", "Id", "displayName", "DisplayName", "jobTitle", "JobTitle", "mail", "Mail", "userPrincipalName", "UserPrincipalName"), (Id <> varUser.id))
UpdateContext context sets context variable locGetPeople = false on New Game Screen
ClearCollect collection replaces the rows of selectedPlayers: {Id: varUser.id, DisplayName: varUser.displayName, UserPrincipalName: varUser.userPrincipalName, Photo: If(!varIsGuest, If(Office365Users.UserPhotoMetadata(varUser.id).HasPhoto, Office365Users.UserPhotoV2(varUser.id), "http://www.placekitten.com/100/100/"), Blank()), Background: ""}

New Game Screen/IconBackNewGame.OnSelect

Navigate('Home Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to Home Screen (ScreenTransition.Fade)

New Game Screen/galleryTemplate6.OnSelect

If( !triggerNewGame, If( // Deselect a player if there are already 2 players selected. CountRows(selectedPlayers)>=2, Remove(selectedPlayers,LastN(FirstN(select

Step Kind What it does Reason not translated
If branch if !triggerNewGame
If branch if (CountRows(selectedPlayers) >= 2)
Remove data removes from selectedPlayers: LastN(FirstN(selectedPlayers, CountRows(selectedPlayers)), (CountRows(selectedPlayers) - 1))
Collect collection adds to selectedPlayers: {Id: ThisItem.Id, DisplayName: ThisItem.DisplayName, UserPrincipalName: ThisItem.UserPrincipalName, Photo: Image1.Image, Background: ""}

New Game Screen/icoPeopleSelected.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryPeople (runs its OnSelect)

New Game Screen/Image1.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryPeople (runs its OnSelect)

New Game Screen/Title1.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryPeople (runs its OnSelect)

New Game Screen/ButtonCreateGame.OnSelect

If( CountRows(selectedPlayers)=2, ////////////////// // CREATE MATCH // ////////////////// Set(triggerNewGame,true); Set(selectedMatch, Patch(GameServer,Default

Step Kind What it does Reason not translated
If branch if (CountRows(selectedPlayers) = 2) / else
Set write sets variable triggerNewGame to true
Set write sets variable selectedMatch to Patch(GameServer, Defaults(GameServer), {Title: ("Chess match with " & If((First(selectedPlayers).Id = Last(selectedPlayers).Id), " yourself", Concat(selectedPlayers, (DisplayName & If((Id <> Last(selectedPlayers).Id), (varDelimiter & " ")))))), AppId: varAppId, Host: (((varUser.displayName & " <") & varUser.id) & ">"), Players: Concat(Sequence(2), ((((Last(FirstN(selectedPlayers, Value)).DisplayName & " <") & Last(FirstN(selectedPlayers, Value)).Id) & ">") & If((Value = 1), varDelimiter))), ActivePlayer: Concat(FirstN(Shuffle(selectedPlayers), 1), (((DisplayName & " <") & Id) & ">")), Active: 1, GameData: (("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" & varDelimiterForData) & Concat(Table({Key: "Date", Value: Text(selectedMatch.Created, "[$-en-US]yyyy.mm.dd")}, {Key: "White", Value: LookUp(colPlayerData, (Player = 1)).DisplayName}, {Key: "Black", Value: LookUp(colPlayerData, (Player = 2)).DisplayName}), ((((((("[" & Key) & " ") & Char(34)) & Value) & Char(34)) & "]") & If((Key <> "Black"), Char(10)))))})
With scope with {tableGuests: Filter(selectedPlayers, ("#EXT#" in UserPrincipalName))}
If branch if !IsEmpty(tableGuests)
ForAll loop for each row of tableGuests
With scope with {recordGuest: LookUp(GamePlayerData, And((AppId = varAppId), (MatchId = 0), (PlayerId = Id)))}
If branch if IsBlank(recordGuest.ID)
Patch data patches GamePlayerData: base Defaults(GamePlayerData), changes {Title: With({stringUserPrincipalName: First(Split(Last(selectedPlayers).UserPrincipalName, "#EXT#")).Result}, Lower(Replace(stringUserPrincipalName, Last(MatchAll(stringUserPrincipalName, "_")).StartMatch, 1, "@"))), AppId: varAppId, MatchId: 0, PlayerId: Id, PlayerData: (DisplayName & varDelimiterForData)}
Clear collection empties colGame
Clear collection empties colPGN
ClearCollect collection replaces the rows of colPlayerData: Ungroup(AddColumns(colPlayers, "tablePlayerData", With({tablePlayers: ShowColumns(selectedPlayers, "DisplayName", "Id", "UserPrincipalName")}, If((Player = 1), FirstN(Filter(tablePlayers, (Id in selectedMatch.ActivePlayer)), 1), Coalesce(FirstN(Filter(tablePlayers, !(Id in selectedMatch.ActivePlayer)), 1), LastN(FirstN(tablePlayers, 2), 1))))), "tablePlayerData")
Set write sets variable varIsNewGame to true
Navigate navigate navigates to Game Screen (Fade)
Notify effect UI or environment action Notify("Please select an opponent to start a game.", NotificationType.Information, 2500), logged not performed

Actions Screen.OnVisible

If( IsEmpty(colActions), ClearCollect(colActions, Table( {Id: 1, Action: "Forfeit"}, {Id: 2, Action: "Mute"} ) ) )

Step Kind What it does Reason not translated
If branch if IsEmpty(colActions)
ClearCollect collection replaces the rows of colActions: Table({Id: 1, Action: "Forfeit"}, {Id: 2, Action: "Mute"})

Actions Screen/IconBackActions.OnSelect

Navigate('Game Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to Game Screen (ScreenTransition.Fade)

Actions Screen/ButtonActionForfeit.OnSelect

If( IsEmpty(MatchAll(selectedMatch.GameData,"1-0|0-1,1\/2-1\/2")), Navigate('Forfeit Dialog', ScreenTransition.Fade), Notify("The outcome of this match has alre

Step Kind What it does Reason not translated
If branch if IsEmpty(MatchAll(selectedMatch.GameData, "1-0|0-1,1\/2-1\/2")) / else
Navigate navigate navigates to Forfeit Dialog (ScreenTransition.Fade)
Notify effect UI or environment action Notify("The outcome of this match has already been determined.", NotificationType.Information, 2500), logged not performed

Actions Screen/ButtonActionArchive.OnSelect

Navigate('Archive Dialog', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to Archive Dialog (ScreenTransition.Fade)

Game Screen.OnVisible

/* If( !triggerNewGame, // Get the user principal name for each player who does not already have one in the table. ForAll( Filter(RenameColumns(colPlayerData,"I

Step Kind What it does Reason not translated
Set write sets variable varRotation to If(Or(varViewGame, (varUser.id in selectedMatch.ActivePlayer)), 0, 180)
If branch if Or(triggerNewGame, varLoadFEN, varLoadPGN)
Set write sets variable triggerNewGame to false
Set write sets variable triggerResetGame to true

Game Screen/galleryTemplate3.OnSelect

Switch(ThisItem.Id, 1, Navigate('Home Screen',Fade), 2, If( And( varIsReplay, !varViewGame ), Set(varIsReplay,false); Set(triggerSyncGame,true) ); Navigate('Sha

Step Kind What it does Reason not translated
Switch branch switch on ThisItem.Id
Navigate navigate navigates to Home Screen (Fade)
If branch if And(varIsReplay, !varViewGame)
Set write sets variable varIsReplay to false
Set write sets variable triggerSyncGame to true
Navigate navigate navigates to Share Screen (Fade)
If branch if triggerRotation / elif !IsEmpty(colPGN)
Notify effect UI or environment action Notify("Please wait until the board is finished rotating before replaying moves.", NotificationType.Warning, 2500), logged not performed
If branch if varIsReplay / else
Set write sets variable varEndReplay to true
Set write sets variable varIsReplay to !varIsReplay
If branch if And(!varIsReplay, !varViewGame) / elif And(varIsReplay, !ToggleIsMoving.Value)
Notify effect UI or environment action Notify("You have paused the replay. The game is now returning to its saved state.", NotificationType.Information, 2500), logged not performed
Set write sets variable triggerSyncGame to true
If branch if And(varViewGame, !ToggleIsReplayComplete.Value) / else
Set write sets variable triggerMoveSetup to true
Set write sets variable resetReplay to true
Set write sets variable triggerResetGame to true
If branch if !ToggleIsMoving.Value / else
Set write sets variable triggerRotation to true
Notify effect UI or environment action Notify("Please pause the replay or wait until pieces are done moving to rotate the board.", NotificationType.Warning, 2500), logged not performed
Navigate navigate navigates to Settings Screen (Fade)
Set write sets variable varDebug to !varDebug

Game Screen/ImageMenu.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryMenu (runs its OnSelect)

Game Screen/LabelMenu.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryMenu (runs its OnSelect)

Game Screen/galleryTemplate1.OnSelect

If( // CASE: If the game is still in progress, but it has not completed its replay, resync the game. And( !varViewGame, !ToggleIsMoving.Value, !ToggleIsReplayCo

Step Kind What it does Reason not translated
If branch if And(!varViewGame, !ToggleIsMoving.Value, !ToggleIsReplayComplete.Value) / elif And(!varIsReplay, !triggerRotation, !ToggleIsMoving.Value)
Notify effect UI or environment action Notify("The replay was paused. The game will now return to its saved state so a move can be attempted.", NotificationType.Information, 2500), logged not performed
Set write sets variable triggerSyncGame to true
Set write sets variable selectedSquareTemp to ThisItem
Set write sets variable triggerMoveSelect to true

Game Screen/ButtonSelect.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GallerySelect (runs its OnSelect)

Game Screen/LabelRankLeft.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryRankLeft (runs its OnSelect)

Game Screen/LabelFileTop.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryFileTop (runs its OnSelect)

Game Screen/LabelRankRight.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryRankRight (runs its OnSelect)

Game Screen/LabelFileBottom.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryFileBottom (runs its OnSelect)

Game Screen/InputMove.OnChange

If( ////////////// // SCANNING // ////////////// // CASE: Return details about a square if it belongs to the player. And( // Check if the move entry is a square

Step Kind What it does Reason not translated
If branch if And((Len(Trim(InputMove.Text)) = 2), (Coalesce(Right(Match(Trim(InputMove.Text), "([KQRBN]?[a-h]?[1-8]?x?)[a-h][1-8]").FullMatch, 2), "") exactin Filter(colGame, (Player = selectedPlayer.Player)).Square)) / elif And(!varViewGame, !ToggleIsReplayComplete.Value) / elif And(!IsBlank(Trim(InputMove.Text)), !ToggleIsMoving.Value, ToggleIsYourTurn.Value) / elif !ToggleIsYourTurn.Value
Set write sets variable varMoveEntry to Coalesce(Right(Match(Trim(InputMove.Text), "([KQRBN]?[a-h]?[1-8]?x?)[a-h][1-8]").FullMatch, 2), "")
Set write sets variable selectedSquare to LookUp(colBoard, (Square = varMoveEntry))
ClearCollect collection replaces the rows of selectedSquares: selectedSquare
Set write sets variable selectedPiece to LookUp(colGame, (Square = varMoveEntry))
ClearCollect collection replaces the rows of selectedPieces: selectedPiece
Set write sets variable varMoveScan to true
Set write sets variable triggerMoveMessage to true
Notify effect UI or environment action Notify("The replay was paused. The game will now return to its saved state so a move can be attempted.", NotificationType.Information, 2500), logged not performed
Set write sets variable triggerSyncGame to true
Set write sets variable varMoveEntry to Trim(InputMove.Text)
Set write sets variable triggerMoveValidation to true
Notify effect UI or environment action Notify("It is not your turn to move.", NotificationType.Warning, 2500), logged not performed

Game Screen/TimerMoveTransition.OnTimerEnd

Reset(TimerMoveTransition); Set(triggerMove,true)

Step Kind What it does Reason not translated
Reset effect resets TimerMoveTransition to its defaults
Set write sets variable triggerMove to true

Game Screen/TimerRefresh.OnTimerEnd

If( And( IsBlank(selectedPiece.Square), !ToggleIsMoving.Value, !triggerSyncGame, !triggerResetGame, !triggerLoadGame, !triggerMoveLast ), Set(triggerMoveLast,tr

Step Kind What it does Reason not translated
If branch if And(IsBlank(selectedPiece.Square), !ToggleIsMoving.Value, !triggerSyncGame, !triggerResetGame, !triggerLoadGame, !triggerMoveLast)
Set write sets variable triggerMoveLast to true
Refresh effect UI or environment action Refresh(GameServer), logged not performed
Set write sets variable selectedMatchTemp to LookUp(GameServer, (ID = selectedMatch.ID))
Set write sets variable varMoveEntryTemp to Trim(Substitute(Last(FirstN(Split(selectedMatchTemp.GameData, varDelimiterForData), 2)).Result, Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 2)).Result, ""))
With scope with {FEN: Last(FirstN(Split(selectedMatchTemp.GameData, varDelimiterForData), 1)).Result, tableMoves: RenameColumns(MatchAll(varMoveEntryTemp, "[Oo0]-Oo0?|[KQRBN]?[a-h]?[1-8]?x?[a-h]1-8?[+#]?").FullMatch, "FullMatch", "Move")}
If branch if (CountRows(Filter(tableMoves, !IsBlank(Move))) = 1) / else
Set write sets variable selectedPlayer to LookUp(colPlayers, (Lower(Left(Color, 1)) <> Last(FirstN(Split(FEN, " "), 2)).Result))
Set write sets variable selectedMoveNumber to Max(1, (Value(Last(FirstN(Split(FEN, " "), 6)).Result) - If((selectedPlayer.Player = 2), 1)))
Set write sets variable varMoveEntry to First(tableMoves).Move
Set write sets variable triggerMoveValidation to true
Set write sets variable triggerSyncGame to true
Set write sets variable triggerMoveLast to false

Game Screen/TimerRotate.OnTimerEnd

Set(triggerRotation,false); Set(varRotation, Switch(varRotation, 0,90, 90,180, 180,-90, -90,0 ) ); Reset(TimerRotate)

Step Kind What it does Reason not translated
Set write sets variable triggerRotation to false
Set write sets variable varRotation to Switch(varRotation, 0, 90, 90, 180, 180, -90, -90, 0)
Reset effect resets TimerRotate to its defaults

Game Screen/ToggleResetGame.OnCheck

///////////////// // CLEAR PHASE // ///////////////// If( And( !resetReplay, !triggerSyncGame ), Set(varIsReplay,false); Clear(colPGN) ); Set(selectedSquare,Bla

Step Kind What it does Reason not translated
If branch if And(!resetReplay, !triggerSyncGame)
Set write sets variable varIsReplay to false
Clear collection empties colPGN
Set write sets variable selectedSquare to Blank()
Set write sets variable selectedPiece to Blank()
Clear collection empties selectedSquares
Clear collection empties selectedPieces
Clear collection empties colCaptured
Clear collection empties colMessages
Reset effect resets TimerMoveTransition to its defaults
Reset effect resets TimerRotate to its defaults
Set write sets variable triggerMoveValidation to false
Set write sets variable triggerMoveSelect to false
Set write sets variable triggerMoveSetup to false
Set write sets variable triggerMoveTransition to false
Set write sets variable triggerMove to false
Set write sets variable triggerMoveEnd to false
Set write sets variable triggerMoveMessage to false
Set write sets variable triggerMoveJump to false
If branch if !varLoadFEN
ClearCollect collection replaces the rows of colGame: colNewGame
ClearCollect collection replaces the rows of colCastling: colNewCastling
Set write sets variable varCanEnPassant to false
Set write sets variable varIsEnPassant to false
Set write sets variable varEnPassantSquare to Blank()
Set write sets variable selectedMoveNumber to 1
Set write sets variable selectedPlayer to First(colPlayers)
If branch if And(!varIsNewGame, !And(varViewGame, !varLoadFEN, !varLoadPGN))
Set write sets variable triggerLoadGame to true
If branch if varIsReplay
Set write sets variable resetReplay to false
Set write sets variable triggerMoveSetup to true
Set write sets variable triggerResetGame to false

Game Screen/ToggleLoadGame.OnCheck

// Determine whether to load FEN/PGN from an existing game or the overriding content. If( varOverrideLoad, // Clear the flag for overriding content to load. Set

Step Kind What it does Reason not translated
If branch if varOverrideLoad / else
Set write sets variable varOverrideLoad to false
If branch if varLoadFEN
Set write sets variable stringFEN to Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 1)).Result
If branch if varLoadPGN
Set write sets variable stringPGN to Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 2)).Result
If branch if varLoadFEN
With scope with {FENByRow: FirstN(Split(First(Split(stringFEN, " ")).Result, "/"), 8)}
With scope with {tableFEN: ShowColumns(AddColumns(AddColumns(Filter(AddColumns(Ungroup(AddColumns(AddColumns(AddColumns(RenameColumns(Sequence(8), "Value", "Rank_FEN"), "Y_FEN", ((8 - Rank_FEN) + 1)), "stringByRow", Last(FirstN(FENByRow, Y_FEN)).Result), "tableRow", RenameColumns(MatchAll(stringByRow, "[A-z1-8]"), "FullMatch", "Piece_FEN", "StartMatch", "StartMatch_Row")), "tableRow"), "Player_FEN", If(IsMatch(Piece_FEN, Match.Digit), 0, IsMatch(Piece_FEN, "[A-Z]"), 1, 2)), (Player_FEN > 0)), "X_FEN", ((CountRows(Filter(MatchAll(stringByRow, "[A-z]"), (StartMatch < StartMatch_Row))) + Sum(Filter(MatchAll(stringByRow, "[1-8]"), (StartMatch < StartMatch_Row)), Value(FullMatch))) + 1)), "File_FEN", Mid("abcdefgh", X_FEN, 1)), "Rank_FEN", "File_FEN", "Piece_FEN", "X_FEN", "Y_FEN", "Player_FEN")}
ClearCollect collection replaces the rows of colGame: AddColumns(DropColumns(AddColumns(Ungroup(AddColumns(Ungroup(AddColumns(Ungroup(AddColumns(tableFEN, "tableSquare", Filter(colBoard, (Square = (File_FEN & Rank_FEN)))), "tableSquare"), "tablePlayer", Filter(colPlayers, (Player = Player_FEN))), "tablePlayer"), "tablePiece", Filter(colPieces, If(Or((Piece_FEN = "p"), (Piece_FEN = "P")), (Name = "Pawn"), (Abbr = Upper(Piece_FEN)), true))), "tablePiece"), "Icon", LookUp(colIcons, And((PlayerId = Player), (PieceId = Piece))).Icon), "Rank_FEN", "File_FEN", "Piece_FEN", "X_FEN", "Y_FEN", "Player_FEN"), "Guid", GUID())
If branch if !triggerMoveJump
Clear collection empties colPGN
With scope with {tableFEN: Split(stringFEN, " ")}
Set write sets variable selectedPlayer to LookUp(colPlayers, (Upper(Last(FirstN(tableFEN, 2)).Result) in Color))
ClearCollect collection replaces the rows of colCastling: Filter(colNewCastling, (Side exactin Last(FirstN(tableFEN, 3)).Result))
If branch if IsMatch(Last(FirstN(tableFEN, 3)).Result, "[a-h][1-8]")
Set write sets variable varCanEnPassant to true
Set write sets variable varEnPassantSquare to LookUp(colBoard, (Square = Last(FirstN(tableFEN, 3)).Result))
Set write sets variable selectedMoveNumber to Value(Last(FirstN(tableFEN, 6)).Result)
If branch if varLoadPGN
ClearCollect collection replaces the rows of colPGNTagPairs: ShowColumns(AddColumns(RenameColumns(MatchAll(stringPGN, "[.+?]"), "FullMatch", "stringTagPair"), "Key", Substitute(First(Split(stringTagPair, (" " & Char(34)))).Result, "[", ""), "Value", Substitute(Last(Split(stringTagPair, (" " & Char(34)))).Result, (Char(34) & "]"), "")), "Key", "Value")
ClearCollect collection replaces the rows of colPGN: AddColumns(DropColumns(Ungroup(AddColumns(AddColumns(AddColumns(RenameColumns(MatchAll(Trim(Substitute(Substitute(stringPGN, Char(10), " "), Char(13), " ")), "\d{1,}.{1,}\s?(([Oo0]-Oo0?|[KQRBN]?[a-h]?[1-8]?x?[a-h]1-8?[+#]?)(\s?{.+?})?(\s(1-0|0-1|1\/2-1\/2))?\s?){1,}").FullMatch, "FullMatch", "MoveText"), "MoveNumber", Value(Match(MoveText, "\d{1,}(?=.)").FullMatch)), "tableMoves", DropColumns(AddColumns(AddColumns(AddColumns(MatchAll(MoveText, "(([Oo0]-Oo0?|[KQRBN]?[a-h]?[1-8]?x?[a-h]1-8?[+#]?)(\s?{.+?})?(\s(1-0|0-1|1\/2-1\/2))?)").FullMatch, "Comment", Match(FullMatch, "{.+?}").FullMatch), "Move", Trim(Substitute(FullMatch, Comment, ""))), "Piece", Match(Move, "KQRBN").FullMatch), "FullMatch")), "tablePlayers", Ungroup(AddColumns(Filter(colPlayers, If((CountRows(tableMoves) = 2), true, (CountRows(MatchAll(Match(MoveText, "\d{1,}.{1,}").FullMatch, ".")) > 1), (Player = 2), (Player = 1))), "tableMove", LastN(FirstN(tableMoves, Player))), "tableMove")), "tablePlayers"), "tableMoves", "MoveText"), "FEN", "")
If branch if !varLoadFEN
With scope with {lastMove: GroupBy(colPGN, "MoveNumber", "ByMoveNumber")}
With scope with {IsCompletedGame: !IsEmpty(Filter(Last(lastMove).ByMoveNumber, IsMatch(Move, "1-0|0-1|1/2-1/2")))}
If branch if IsCompletedGame / else
Set write sets variable selectedPlayer to LookUp(colPlayers, (Player = CountRows(Last(lastMove).ByMoveNumber)))
Set write sets variable selectedMoveNumber to Last(lastMove).MoveNumber
Set write sets variable selectedPlayer to LookUp(colPlayers, (Player <> CountRows(Last(lastMove).ByMoveNumber)))
Set write sets variable selectedMoveNumber to (Last(lastMove).MoveNumber + If((selectedPlayer.Player = 1), 1))
If branch if And(!triggerMoveJump, varViewGame, Or(varLoadFEN, varLoadPGN))
Set write sets variable varIsReplay to true
Set write sets variable resetReplay to true
Set write sets variable triggerResetGame to true
Set write sets variable varLoadFEN to false
Set write sets variable varLoadPGN to false
Set write sets variable triggerMoveJump to false
Set write sets variable triggerLoadGame to false
Set write sets variable triggerSyncGame to false

Game Screen/ToggleSyncGame.OnCheck

If( // Check if the game data is the same as what's currently in the app. Last(FirstN(Split(selectedMatch.GameData,varDelimiterForData),1)).Result<>InputFEN.Tex

Step Kind What it does Reason not translated
If branch if (Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 1)).Result <> InputFEN.Text) / else
If branch if And(!triggerResetGame, !triggerLoadGame)
Set write sets variable varOverrideLoad to true
Set write sets variable stringFEN to Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 1)).Result
Set write sets variable stringPGN to Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 2)).Result
Set write sets variable varLoadFEN to true
Set write sets variable varLoadPGN to true
Set write sets variable triggerLoadGame to true
Set write sets variable triggerSyncGame to false

Game Screen/ToggleIsMoving.OnCheck

false

Step Kind What it does Reason not translated
value value evaluates false and discards the result

Game Screen/ToggleSaveGame.OnCheck

// Save the match. If( And( !varIsReplay, !varViewGame ), Refresh(GameServer); Set(selectedMatch, Patch(GameServer, LookUp(GameServer,ID=selectedMatch.ID), { Ga

Step Kind What it does Reason not translated
If branch if And(!varIsReplay, !varViewGame)
Refresh effect UI or environment action Refresh(GameServer), logged not performed
Set write sets variable selectedMatch to Patch(GameServer, LookUp(GameServer, (ID = selectedMatch.ID)), {GameData: ((InputFEN.Text & varDelimiterForData) & InputPGN.Text)})
Set write sets variable triggerSaveGame to false

Game Screen/ToggleIsReplayComplete.OnCheck

false

Step Kind What it does Reason not translated
value value evaluates false and discards the result

Game Screen/ToggleIsYourTurn.OnCheck

false

Step Kind What it does Reason not translated
value value evaluates false and discards the result

Game Screen/ToggleMoveValidation.OnCheck

If( !IsBlank(varMoveEntry), // Get the metadata for a hypothetical move. Set(selectedMoveMetadata, { // IsCastling IsCastling: IsMatch(varMoveEntry,"[Oo0]-[Oo0]

Step Kind What it does Reason not translated
If branch if !IsBlank(varMoveEntry) / else
Set write sets variable selectedMoveMetadata to {IsCastling: IsMatch(varMoveEntry, "[Oo0]-Oo0?"), PieceType: Match(varMoveEntry, "KQRBN").FullMatch, Disambiguation: Match(varMoveEntry, "[a-h]?[1-8]?(?=x?[a-h][1-8])").FullMatch, IsCapture: !IsEmpty(MatchAll(varMoveEntry, "x")), Square_Move: Coalesce(Last(MatchAll(varMoveEntry, "[a-h][1-8]")).FullMatch, ""), PromotionPiece: Substitute(Match(varMoveEntry, "\=[QRBN]").FullMatch, "=", ""), IsCheck: !IsEmpty(MatchAll(varMoveEntry, "+")), IsCheckmate: !IsEmpty(MatchAll(varMoveEntry, "#")), Score: Match(varMoveEntry, "1-0|0-1|1\/2-1\/2").FullMatch}
If branch if CheckboxDebug.Value / elif !IsBlank(selectedMoveMetadata.Score) / elif selectedMoveMetadata.IsCastling / else
Set write sets variable triggerMoveSetup to true
If branch if Switch(selectedPlayer.Player, 1, IsMatch(varMoveEntry, "0-1"), 2, IsMatch(varMoveEntry, "1-0")) / else
If branch if !IsEmpty(Filter(colPGN, !IsEmpty(MatchAll(Move, "1-0|0-1|1\/2-1\/2")))) / else
Notify effect UI or environment action Notify("This match already has a score logged.", NotificationType.Information, 2500), logged not performed
Navigate navigate navigates to Checkmate Screen (Fade)
Set write sets variable selectedMatch to Patch(GameServer, LookUp(GameServer, (ID = selectedMatch.ID)), {GameData: ((((InputFEN.Text & varDelimiterForData) & InputPGN.Text) & " ") & varMoveEntry)})
Notify effect UI or environment action Notify("You can only forfeit the match with a score that is in favor of your opponent.", NotificationType.Information, 2500), logged not performed
Set write sets variable varMoveEntry to Blank()
Set write sets variable varCastlingMetadata to With({IsKingside: (CountRows(MatchAll(varMoveEntry, "[Oo0]")) = 2)}, {IsKingside: IsKingside, King: LookUp(colGame, And((Player = selectedPlayer.Player), (Name = "King"))), Rook: LookUp(colGame, And((Player = selectedPlayer.Player), (Name = "Rook"), If(IsKingside, (X = 8), (X = 1)))), KingSquare: LookUp(colBoard, And(If(IsKingside, (X = 7), (X = 3)), Switch(selectedPlayer.Player, 1, (Y = 8), (Y = 1)))), RookSquare: LookUp(colBoard, And(If(IsKingside, (X = 6), (X = 4)), Switch(selectedPlayer.Player, 1, (Y = 8), (Y = 1))))})
If branch if And(!IsEmpty(Filter(colCastling, (Player = selectedPlayer.Player), CanCastle, If(varCastlingMetadata.IsKingside, (Upper(Side) = "K"), (Upper(Side) = "Q")))), IsEmpty(Filter(colGame, (Y = varCastlingMetadata.King.Y), If(varCastlingMetadata.IsKingside, And((X > varCastlingMetadata.King.X), (X < varCastlingMetadata.Rook.X)), And((X < varCastlingMetadata.King.X), (X > varCastlingMetadata.Rook.X)))))) / else
Set write sets variable triggerMoveSetup to true
Notify effect UI or environment action Notify("You are not able to castle with the attempted move.", NotificationType.Information, 2500), logged not performed
Set write sets variable varMoveEntry to Blank()
If branch if !IsEmpty(Filter(GalleryMoves.AllItems, (Player_Origin = selectedPlayer.Player), (Abbr = selectedMoveMetadata.PieceType), (selectedMoveMetadata.Square_Move exactin MovesValid.Square_Destination), If(!selectedMoveMetadata.IsCapture, If((Name = "Pawn"), (File = Left(selectedMoveMetadata.Square_Move, 1)), IsEmpty(Filter(colGame, (Square = selectedMoveMetadata.Square_Move)))), And((Name = "Pawn"), varCanEnPassant, IsMatch(Trim(selectedMoveMetadata.Disambiguation), "[a-h][1-8]"), selectedMoveMetadata.IsCapture, (selectedMoveMetadata.Square_Move = varEnPassantSquare.Square)), IsEmpty(Filter(colGame, (Square = selectedMoveMetadata.Square_Move))), selectedMoveMetadata.IsCapture, (selectedMoveMetadata.Square_Move exactin MovesCapture.Square_Destination), IsEmpty(Filter(colGame, (Square = selectedMoveMetadata.Square_Move)))), If(IsBlank(selectedMoveMetadata.Disambiguation), true, If((Len(selectedMoveMetadata.Disambiguation) = 2), (Square_Origin = selectedMoveMetadata.Disambiguation), IsMatch(selectedMoveMetadata.Disambiguation, Match.Digit), (Rank = Value(selectedMoveMetadata.Disambiguation)), IsMatch(selectedMoveMetadata.Disambiguation, Match.Letter), (File = selectedMoveMetadata.Disambiguation), If(selectedMoveMetadata.IsCapture, (selectedMoveMetadata.Square_Move exactin MovesCapture.Square_Destination), (File = Left(selectedMoveMetadata.Square_Move, 1))))), If(IsBlank(selectedMoveMetadata.PromotionPiece), true, And(IsBlank(selectedMoveMetadata.PieceType), (Name = "Pawn"), (Value(Right(selectedMoveMetadata.Square_Move, 1)) = Switch(selectedPlayer.Player, 1, 8, 1)))))) / else
Set write sets variable triggerMoveSetup to true
Notify effect UI or environment action Notify("There is not a piece that can legally complete the attempted move.", NotificationType.Information, 2500), logged not performed
Set write sets variable varMoveEntry to Blank()
Set write sets variable varMoveEntry to Blank()
Notify effect UI or environment action Notify("The attempted move did not match a possible chess move.", NotificationType.Information, 2500), logged not performed
Set write sets variable triggerMoveValidation to false

Game Screen/ButtonNotify.OnSelect

false; With( { opponent: LookUp(colPlayerData,!(varUser.id in Id)) }, PowerAppsNotification.SendPushNotification( { recipients: RenameColumns(colPlayerData.User

Step Kind What it does Reason not translated
value value evaluates false and discards the result
With scope with {opponent: LookUp(colPlayerData, !(varUser.id in Id))}
PowerAppsNotification.SendPushNotification effect connector call PowerAppsNotification.SendPushNotification({recipients: RenameColumns(colPlayerData.UserPrincipalName, "UserPrincipalName", "Value"), openApp: true, params: Table({key: "matchid", value: Text(selectedMatch.ID)}, {key: "playerid", value: Text(opponent.Id)}), message: If(ToggleCheckmate.Value, (((("Checkmate! " & Last(colPGN).Color) & "wins in your chess match with ") & varUser.displayName) & "!"), ToggleCheck.Value, (("Check! It's your turn to move in your chess match with " & varUser.displayName) & "."), (If(selectedMoveMetadata.IsCastling, (((varUser.displayName & " castled ") & If(varCastlingMetadata.IsKingside, "kingside", "queenside")) & "."), (((((((varUser.displayName & " moved their ") & Lower(LookUp(colPieces, (Abbr = selectedMoveMetadata.PieceType)).Name)) & " to ") & selectedMoveMetadata.Square_Move) & If(selectedMoveMetadata.IsCapture, (" and captured your " & Lower(Last(colCaptured).Name)))) & ".") & If(!IsBlank(selectedMoveMetadata.PromotionPiece), ((" Their pawn has been promoted to a " & Lower(LookUp(colPieces, (Abbr = selectedMoveMetadata.PromotionPiece)).Name)) & ".")))) & " It's your turn to move."))}), logged not performed

Game Screen/ToggleMoveSelect.OnCheck

If( // CASE: Prevent movement when viewing a game. And( !CheckboxDebug.Value, varViewGame ), Set(selectedSquare,LookUp(colBoard,Square=selectedSquareTemp.Square

Step Kind What it does Reason not translated
If branch if And(!CheckboxDebug.Value, varViewGame) / else
Set write sets variable selectedSquare to LookUp(colBoard, (Square = selectedSquareTemp.Square))
ClearCollect collection replaces the rows of selectedSquares: selectedSquare
Set write sets variable selectedPiece to LookUp(colGame, (Square = selectedSquareTemp.Square))
ClearCollect collection replaces the rows of selectedPieces: selectedPiece
If branch if !IsEmpty(selectedPieces)
Set write sets variable varMoveScan to true
Set write sets variable triggerMoveMessage to true
Set write sets variable selectedSquare to selectedSquareTemp
ClearCollect collection replaces the rows of selectedSquares: selectedSquare
If branch if (selectedSquare.Square = selectedPiece.Square) / elif (selectedSquare.Square exactin Filter(colGame, (Player = selectedPlayer.Player)).Square) / elif And(!IsBlank(selectedPiece.Square), Or(CheckboxDebug.Value, And((selectedSquare.Square exactin LookUp(GalleryMoves.AllItems, (Square_Origin = selectedPiece.Square)).MovesValid.Square_Destination), IsEmpty(Filter(colPGN, IsMatch(Move, "1-0|0-1|1/2-1/2"))))))
Set write sets variable selectedSquare to Blank()
Set write sets variable selectedPiece to Blank()
Clear collection empties selectedPieces
If branch if !varViewGame
Refresh effect UI or environment action Refresh(GameServer), logged not performed
Set write sets variable selectedMatch to LookUp(GameServer, (ID = selectedMatch.ID))
If branch if And(!CheckboxDebug.Value, !varViewGame, (Value(Last(FirstN(Split(Last(FirstN(Split(selectedMatch.GameData, varDelimiterForData), 1)).Result, " "), 6)).Result) <> selectedMoveNumber)) / elif And(!CheckboxDebug.Value, !ToggleIsYourTurn.Value, !varViewGame) / else
Notify effect UI or environment action Notify("This app is out of sync with the game server. The game will now resync.", NotificationType.Information, 2500), logged not performed
Set write sets variable triggerSyncGame to true
Notify effect UI or environment action Notify("It is not your turn to move.", NotificationType.Warning, 2500), logged not performed
Set write sets variable triggerSyncGame to true
Set write sets variable selectedPiece to LookUp(colGame, (Square = selectedSquare.Square))
ClearCollect collection replaces the rows of selectedPieces: selectedPiece
Set write sets variable varMoveScan to true
Set write sets variable triggerMoveMessage to true
Set write sets variable varIsReplay to false
Set write sets variable triggerMoveSetup to true
Set write sets variable triggerMoveSelect to false

Game Screen/ToggleMoveSetup.OnCheck

If( Or( varIsReplay, !IsBlank(varMoveEntry) ), ///////////////// // REPLAY MODE // ///////////////// // Move > Metadata > Square > Piece Set(selectedMove,LookUp

Step Kind What it does Reason not translated
If branch if Or(varIsReplay, !IsBlank(varMoveEntry)) / else
Set write sets variable selectedMove to LookUp(colPGN, And((MoveNumber = selectedMoveNumber), (Player = selectedPlayer.Player)))
If branch if IsBlank(varMoveEntry)
Set write sets variable selectedMoveMetadata to {IsCastling: IsMatch(selectedMove.Move, "[Oo0]-Oo0?"), PieceType: Coalesce(selectedMove.Piece, ""), Disambiguation: Match(selectedMove.Move, "[a-h]?[1-8]?(?=x?[a-h][1-8])").FullMatch, IsCapture: !IsEmpty(MatchAll(selectedMove.Move, "x")), Square_Move: Coalesce(Last(MatchAll(selectedMove.Move, "[a-h][1-8]")).FullMatch, ""), PromotionPiece: Substitute(Match(selectedMove.Move, "\=[QRBN]").FullMatch, "=", ""), IsCheck: !IsEmpty(MatchAll(selectedMove.Move, "+")), IsCheckmate: !IsEmpty(MatchAll(selectedMove.Move, "#")), Score: Match(selectedMove.Move, "1-0|0-1|1\/2-1\/2").FullMatch}
If branch if !selectedMoveMetadata.IsCastling
Set write sets variable selectedSquare to LookUp(colBoard, (Square = selectedMoveMetadata.Square_Move))
ClearCollect collection replaces the rows of selectedSquares: selectedSquare
If branch if And(IsBlank(selectedMoveMetadata.Disambiguation)) / else
Set write sets variable selectedPiece to LookUp(colGame, (Square = LookUp(GalleryMoves.AllItems, And((Abbr = selectedMoveMetadata.PieceType), (Player_Origin = selectedPlayer.Player), (selectedMoveMetadata.Square_Move exactin MovesValid.Square_Destination))).Square_Origin))
Set write sets variable selectedPiece to LookUp(colGame, And((Player = selectedPlayer.Player), (Abbr = selectedMoveMetadata.PieceType), If((Len(selectedMoveMetadata.Disambiguation) = 2), (Square = selectedMoveMetadata.Disambiguation), IsMatch(selectedMoveMetadata.Disambiguation, Match.Digit), (Rank = Value(selectedMoveMetadata.Disambiguation)), IsMatch(selectedMoveMetadata.Disambiguation, Match.Letter), (File = selectedMoveMetadata.Disambiguation), If(selectedMoveMetadata.IsCapture, (selectedMoveMetadata.Square_Move exactin LookUp(GalleryMoves.AllItems, (Square_Origin = Square)).MovesCapture.Square_Destination), (File = Left(selectedMoveMetadata.Square_Move, 1))))))
ClearCollect collection replaces the rows of selectedPieces: selectedPiece
Set write sets variable varIsEnPassant to And(varCanEnPassant, (selectedPiece.Name = "Pawn"), (Abs((selectedPiece.X - selectedSquare.X)) = 1), (selectedSquare.Square = varEnPassantSquare.Square), IsEmpty(Filter(colGame, (Square = selectedSquare.Square))), !IsEmpty(Filter(colGame, (Player <> selectedPlayer.Player), (Name = "Pawn"), (Rank = (varEnPassantSquare.Rank + Switch(selectedPlayer.Player, 1, -1, 1))), (File = varEnPassantSquare.File))))
Set write sets variable varIsEnPassant to And(varCanEnPassant, (selectedPiece.Name = "Pawn"), (Abs((selectedPiece.X - selectedSquare.X)) = 1), (selectedSquare.Square = varEnPassantSquare.Square), IsEmpty(Filter(colGame, (Square = selectedSquare.Square))), !IsEmpty(Filter(colGame, (Player <> selectedPlayer.Player), (Name = "Pawn"), (Rank = (varEnPassantSquare.Rank + Switch(selectedPlayer.Player, 1, -1, 1))), (File = varEnPassantSquare.File))))
Set write sets variable selectedMoveMetadata to {IsCastling: And((selectedPiece.Name = "King"), (selectedPiece.Y = Switch(selectedPlayer.Player, 1, 8, 1)), (selectedPiece.X = 5), (selectedSquare.Y = selectedPiece.Y), (Abs((selectedPiece.X - selectedSquare.X)) = 2), LookUp(colCastling, And((Player = selectedPlayer.Player), (Upper(Side) = Switch(selectedSquare.X, 8, "K", "Q")))).CanCastle), PieceType: selectedPiece.Abbr, Disambiguation: With({tablePiecesValid: Filter(GalleryMoves.AllItems, (Player_Origin = selectedPlayer.Player), (Piece = selectedPiece.Piece), (selectedSquare.Square exactin MovesValid.Square_Destination))}, If(varIsEnPassant, selectedPiece.Square, (CountRows(tablePiecesValid) > 1), If((CountRows(GroupBy(tablePiecesValid, "File", "ByFile")) = CountRows(tablePiecesValid)), selectedPiece.File, (CountRows(GroupBy(tablePiecesValid, "Rank", "ByRank")) = CountRows(tablePiecesValid)), selectedPiece.Rank, selectedPiece.Square), Blank())), IsCapture: Or((selectedSquare.Square exactin LookUp(GalleryMoves.AllItems, (Square_Origin = selectedPiece.Square)).MovesCapture.Square_Destination), varIsEnPassant), Square_Move: selectedSquare.Square, PromotionPiece: If(And((selectedPiece.Name = "Pawn"), (selectedSquare.Rank = Switch(selectedPlayer.Player, 1, 8, 2, 1))), "Q"), IsCheck: false, IsCheckmate: false, Score: ""}
If branch if Or(!varIsReplay, !IsBlank(varMoveEntry))
Set write sets variable selectedMove to {FEN: "", Comment: "", Player: selectedPlayer.Player, Color: selectedPlayer.Color, Piece: selectedPiece.Abbr, MoveNumber: selectedMoveNumber, Move: If(selectedMoveMetadata.IsCastling, If((selectedSquare.X = 3), "O-O-O", "O-O"), Concatenate(selectedMoveMetadata.PieceType, selectedMoveMetadata.Disambiguation, If(selectedMoveMetadata.IsCapture, "x"), selectedMoveMetadata.Square_Move, If(!IsBlank(selectedMoveMetadata.PromotionPiece), ("=" & selectedMoveMetadata.PromotionPiece)), If(selectedMoveMetadata.IsCheck, "+", selectedMoveMetadata.IsCheckmate, "#")))}
Collect collection adds to colPGN: selectedMove
Set write sets variable varMoveEntry to Blank()
Set write sets variable varCanEnPassant to And((selectedPiece.Name = "Pawn"), (selectedPiece.Rank = Switch(selectedPlayer.Player, 1, 2, 7)), (Abs((selectedPiece.Y - selectedSquare.Y)) = 2))
If branch if varCanEnPassant
Set write sets variable varEnPassantSquare to LookUp(colBoard, And((Rank = (selectedSquare.Rank + Switch(selectedPlayer.Player, 1, -1, 1))), (File = selectedSquare.File)))
If branch if selectedMoveMetadata.IsCapture
With scope with {capturedPiece: If(varIsEnPassant, LookUp(colGame, And((Rank = (varEnPassantSquare.Rank + Switch(selectedPlayer.Player, 1, -1, 1))), (File = varEnPassantSquare.File))), LookUp(colGame, (Square = selectedSquare.Square)))}
Collect collection adds to colCaptured: capturedPiece
If branch if selectedMoveMetadata.IsCastling
Set write sets variable varCastlingMetadata to With({IsKingside: (CountRows(MatchAll(selectedMove.Move, "[Oo0]")) = 2)}, {IsKingside: IsKingside, King: LookUp(colGame, And((Player = selectedPlayer.Player), (Name = "King"))), Rook: LookUp(colGame, And((Player = selectedPlayer.Player), (Name = "Rook"), If(IsKingside, (X = 8), (X = 1)))), KingSquare: LookUp(colBoard, And(If(IsKingside, (X = 7), (X = 3)), Switch(selectedPlayer.Player, 1, (Y = 8), (Y = 1)))), RookSquare: LookUp(colBoard, And(If(IsKingside, (X = 6), (X = 4)), Switch(selectedPlayer.Player, 1, (Y = 8), (Y = 1))))})
Set write sets variable selectedPiece to varCastlingMetadata.King
ClearCollect collection replaces the rows of selectedPieces: varCastlingMetadata.King, varCastlingMetadata.Rook
Set write sets variable selectedSquare to varCastlingMetadata.KingSquare
ClearCollect collection replaces the rows of selectedSquares: varCastlingMetadata.KingSquare, varCastlingMetadata.RookSquare
If branch if CheckboxMoveEntry.Value
Set write sets variable triggerMoveMessage to true
Set write sets variable triggerMoveSetup to false
Set write sets variable triggerMoveTransition to true

Game Screen/ToggleMoveMessage.OnCheck

If( varMoveScan, ////////////////// // SCAN MESSAGE // ////////////////// Set(varMoveScan,false); Set(varMoveMessage, With( { recordPieceDetails: LookUp(Gallery

Step Kind What it does Reason not translated
If branch if varMoveScan / else
Set write sets variable varMoveScan to false
Set write sets variable varMoveMessage to With({recordPieceDetails: LookUp(GalleryMoves.AllItems, (Square_Origin = selectedPiece.Square)), tableThreat: Filter(GalleryMoves.AllItems, (selectedPiece.Square exactin MovesCapture.Square_Destination))}, ((((("You selected the " & Lower(selectedPiece.Name)) & " on ") & selectedPiece.Square) & ". ") & If(And(ToggleCheck.Value, (selectedPiece.Name = "King")), With({King: LookUp(colGame, And((Name = "King"), (Player = selectedPlayer.Player)))}, With({tableSafe: Filter(recordPieceDetails.MovesValid, IsEmpty(Filter(GalleryMoves.AllItems, (Player_Origin <> selectedPlayer.Player), (Square_Destination exactin MovesThreatActive.Square_Destination))), IsEmpty(Filter(GalleryMoves.AllItems, (Player_Origin <> selectedPlayer.Player), (Square_Destination exactin MovesThreatPassive.Square_Destination))))}, ((((((("Your king is in check by the " & Lower(First(tableThreat).Name)) & " on ") & First(tableThreat).Square_Origin) & ". ") & If(IsEmpty(tableSafe), "It cannot move itself to a safe square.", (("It can safely move to " & Concat(tableSafe, If((Square_Destination <> Last(tableSafe).Square_Destination), (Square_Destination & If((CountRows(tableSafe) >= 3), ", ", " ")), ("or " & Square_Destination)))) & If((CountRows(recordPieceDetails.MovesValid) <> CountRows(tableSafe)), With({tableUnsafe: Filter(recordPieceDetails.MovesValid, !(Square_Destination exactin tableSafe.Square_Destination))}, (", but " & Concat(tableUnsafe, If((Square_Destination <> Last(tableUnsafe).Square_Destination), (Square_Destination & If((CountRows(tableUnsafe) >= 3), ", ", " ")), If((CountRows(tableUnsafe) > 1), ((("and " & Square_Destination) & " are ") & " unsafe."), (Square_Destination & " is unsafe.")))))), ".")))) & With({tableCaptureThreat: Filter(GalleryMoves.AllItems, (First(tableThreat).Square_Origin exactin MovesCapture.Square_Destination))}, If(IsEmpty(tableCaptureThreat), " There are no pieces that can capture the threat.", (" The threat can be captured by " & Concat(tableCaptureThreat, If((Square_Origin <> Last(tableCaptureThreat).Square_Origin), (((("the " & Lower(Name)) & " on ") & Square_Origin) & If((CountRows(tableCaptureThreat) >= 3), ", ", " ")), (((((If((CountRows(tableCaptureThreat) > 1), "and ") & "the ") & Lower(Name)) & " on ") & Square_Origin) & "."))))))) & If(Or((First(tableThreat).Name = "Queen"), (First(tableThreat).Name = "Rook"), (First(tableThreat).Name = "Bishop")), With({tableBlock: Filter(GalleryMoves.AllItems, (Player_Origin = selectedPlayer.Player), (Name <> "King"), !IsEmpty(Filter(MovesValid, (Square_Destination <> First(tableThreat).Square_Origin), (Square_Destination exactin First(tableThreat).MovesThreatActive.Square_Destination))))}, If(IsEmpty(tableBlock), " There are no pieces that can block the path of the threat.", (Concat(tableBlock, If((Square_Origin <> Last(tableBlock).Square_Origin), ((((If((Square_Origin = First(tableBlock).Square_Origin), " The ", "the ") & Lower(Name)) & " on ") & Square_Origin) & If((CountRows(tableBlock) >= 3), ", ", " ")), ((((If((CountRows(tableBlock) > 1), "and ") & If((Square_Origin = First(tableBlock).Square_Origin), " The ", "the ")) & Lower(Name)) & " on ") & Square_Origin))) & " can block the path of the threat."))))))), ((If(!IsEmpty(recordPieceDetails.MovesValid), ("This piece is able to " & If(!IsEmpty(recordPieceDetails.MovesCapture), (" capture " & With({tableCapture: Filter(colGame, (Square exactin recordPieceDetails.MovesCapture.Square_Destination))}, (Concat(tableCapture, If((Square <> Last(tableCapture).Square), (((("the " & Lower(Name)) & " on ") & Square) & If((CountRows(tableCapture) >= 3), ", ", " ")), ((((If((CountRows(tableCapture) > 1), "or ") & "the ") & Lower(Name)) & " on ") & Square))) & With({tableNonCapture: Filter(recordPieceDetails.MovesValid, !(Square_Destination exactin recordPieceDetails.MovesCapture.Square_Destination))}, If(!IsEmpty(tableNonCapture), (", and it can also move to " & Concat(tableNonCapture, If((Square_Destination <> Last(tableNonCapture).Square_Destination), (Square_Destination & If((CountRows(tableNonCapture) >= 3), ", ", " ")), ((If((CountRows(tableNonCapture) > 1), "or ") & Square_Destination) & ".")))), "."))))), (" move to " & Concat(recordPieceDetails.MovesValid, If((Square_Destination <> Last(recordPieceDetails.MovesValid).Square_Destination), (Square_Destination & If((CountRows(recordPieceDetails.MovesValid) >= 3), ", ", " ")), ((If((CountRows(recordPieceDetails.MovesValid) > 1), "or ") & Square_Destination) & ".")))))), "This piece has no valid moves.") & If(!IsEmpty(recordPieceDetails.MovesDefend), (" It is defending " & With({tableDefend: Filter(colGame, (Name <> "King"), (Square exactin recordPieceDetails.MovesDefend.Square_Destination))}, Concat(tableDefend, If((Square <> Last(tableDefend).Square), (((("the " & Lower(Name)) & " on ") & Square) & If((CountRows(tableDefend) >= 3), ", ", " ")), (((((If((CountRows(tableDefend) > 1), "and ") & "the ") & Lower(Name)) & " on ") & Square) & "."))))))) & If(!IsEmpty(tableThreat), (((" Your " & Lower(selectedPiece.Name)) & " is in danger of being captured by ") & Concat(tableThreat, If((Square_Origin <> Last(tableThreat).Square_Origin), (((("the " & Lower(Name)) & " on ") & Square_Origin) & If((CountRows(tableThreat) >= 3), ", ", " ")), (((((If((CountRows(tableThreat) > 1), "and ") & "the ") & Lower(Name)) & " on ") & Square_Origin) & ".")))))))))
Set write sets variable varMoveMessage to If(selectedMoveMetadata.IsCastling, (((selectedPlayer.Color & " has castled ") & If(varCastlingMetadata.IsKingside, "kingside", "queenside")) & "."), ((((((selectedPlayer.Color & " ") & Lower(LookUp(colPieces, (Abbr = selectedMoveMetadata.PieceType)).Name)) & If(selectedMoveMetadata.IsCapture, ((" has captured the " & Lower(Last(colCaptured).Name)) & If(varIsEnPassant, ((" on " & Last(colCaptured).Square) & " by en passant."), ((" on " & selectedMoveMetadata.Square_Move) & "."))), ((" to " & selectedMoveMetadata.Square_Move) & "."))) & If(!IsBlank(selectedMoveMetadata.PromotionPiece), ((" The pawn has been promoted to a " & Lower(LookUp(colPieces, (Abbr = selectedMoveMetadata.PromotionPiece)).Name)) & "."))) & If(selectedMoveMetadata.IsCheckmate, " Checkmate!", selectedMoveMetadata.IsCheck, " Check!")) & If(!IsBlank(selectedMoveMetadata.Score), With({finalMove: LookUp(colPGN, !IsEmpty(MatchAll(Move, "1-0|0-1|1\/2-1\/2")))}, (" " & If(("1-0" in finalMove.Move), "White has won the match!", ("0-1" in finalMove.Move), "Black has won the match!", ("1/2-1/2" in finalMove.Move), "Draw game!"))))))
Collect collection adds to colMessages: {Id: GUID(), Timestamp: Now(), Player: selectedPlayer.Player, MoveNumber: selectedMoveNumber, Message: varMoveMessage}
If branch if And(CheckboxReadMove.Value, CheckboxMoveEntry.Value)
Notify effect UI or environment action Notify(varMoveMessage, NotificationType.Information, 5000), logged not performed
Set write sets variable triggerMoveMessage to false

Game Screen/ToggleMove.OnCheck

If( //////////////////// // CASTLING PHASE // //////////////////// selectedMoveMetadata.IsCastling, ForAll( RenameColumns(selectedPieces,"Square","Square_Castle

Step Kind What it does Reason not translated
If branch if selectedMoveMetadata.IsCastling / else
ForAll loop for each row of RenameColumns(selectedPieces, "Square", "Square_Castle")
Patch data patches colGame: base LookUp(colGame, (Square = Square_Castle)), changes First(Ungroup(AddColumns(DropColumns(Filter(colGame, (Square = Square_Castle)), "Id", "Square", "Rank", "File", "X", "Y"), "tableNewSquare", LastN(FirstN(selectedSquares, If((Name = "King"), 1, 2)), 1)), "tableNewSquare"))
UpdateIf data updates colCastling where (Player = selectedPlayer.Player): {CanCastle: false}
If branch if selectedMoveMetadata.IsCapture
With scope with {capturedPiece: Last(colCaptured)}
Remove data removes from colGame: capturedPiece
If branch if (capturedPiece.Id exactin colCastling.RookId)
Patch data patches colCastling: base LookUp(colCastling, (RookId = capturedPiece.Id)), changes {CanCastle: false}
Patch data patches colGame: base LookUp(colGame, (Square = selectedPiece.Square)), changes First(Ungroup(AddColumns(DropColumns(Filter(colGame, (Square = selectedPiece.Square)), "Id", "Square", "Rank", "File", "X", "Y"), "tableNewSquare", Filter(colBoard, (Square = selectedSquare.Square))), "tableNewSquare"))
If branch if (selectedPiece.Name = "King") / elif (selectedPiece.Id exactin colCastling.RookId)
UpdateIf data updates colCastling where (Player = selectedPlayer.Player): {CanCastle: false}
Patch data patches colCastling: base LookUp(colCastling, (RookId = selectedPiece.Id)), changes {CanCastle: false}
If branch if !IsBlank(selectedMoveMetadata.PromotionPiece)
Patch data patches colGame: base LookUp(colGame, (Square = selectedPiece.Square)), changes First(Ungroup(AddColumns(DropColumns(Filter(colGame, (Square = selectedPiece.Square)), "Abbr", "Icon", "Name", "Piece"), "tableNewPiece", AddColumns(Filter(colPieces, (Abbr = selectedMoveMetadata.PromotionPiece)), "Icon", LookUp(colIcons, (PieceId = Piece)).Icon)), "tableNewPiece"))
If branch if !IsEmpty(Filter(GalleryMoves.AllItems, (Player_Origin <> selectedPlayer.Player), !IsEmpty(MovesThreatActive))) / else
If branch if !IsBlank(selectedMoveMetadata.PromotionPiece)
Patch data patches colGame: base LookUp(colGame, (Square = selectedSquare.Square)), changes First(Ungroup(AddColumns(DropColumns(Filter(colGame, (Square = selectedSquare.Square)), "Abbr", "Icon", "Name", "Piece"), "tableNewPiece", AddColumns(Filter(colPieces, (Name = "Pawn")), "Icon", LookUp(colIcons, (PieceId = Piece)).Icon)), "tableNewPiece"))
ForAll loop for each row of RenameColumns(selectedSquares, "Square", "Square_Undo")
With scope with {record: LookUp(colGame, (Square = Square_Undo))}
Patch data patches colGame: base record, changes LookUp(selectedPieces, (Piece = record.Piece))
If branch if selectedMoveMetadata.IsCastling
UpdateIf data updates colCastling where And((Player = selectedPlayer.Player), If((CountRows(Filter(colGame, (Name = "Rook"), (Player = selectedPlayer.Player))) = 2), true, Switch(varCastlingMetadata.IsKingside, (Upper(Side) = "K"), (Upper(Side) = "Q")))): {CanCastle: true}
If branch if selectedMoveMetadata.IsCapture
Collect collection adds to colGame: Last(colCaptured)
Remove data removes from colCaptured: Last(colCaptured)
If branch if !varIsReplay
Remove data removes from colPGN: Last(colPGN)
Reset effect resets TimerMoveTransition to its defaults
Notify effect UI or environment action Notify("Your move could not be completed because the king is still in check.", NotificationType.Warning, 3000), logged not performed
Set write sets variable triggerMoveEnd to CheckboxReplayLoop.Value
Set write sets variable triggerMoveTransition to false
Set write sets variable triggerMove to false

Game Screen/ToggleMoveEnd.OnCheck

Set(selectedPiece,Blank()); Set(selectedSquare,Blank()); Clear(selectedPieces); Clear(selectedSquares); Reset(AudioMove); //////////////////////// // TAKING TUR

Step Kind What it does Reason not translated
Set write sets variable selectedPiece to Blank()
Set write sets variable selectedSquare to Blank()
Clear collection empties selectedPieces
Clear collection empties selectedSquares
Reset effect resets AudioMove to its defaults
With scope with {IsCompletedGame: !IsEmpty(Filter(colPGN, !IsEmpty(MatchAll(Move, "1-0|0-1|1\/2-1\/2")))), HasNextMove: !IsEmpty(Filter(colPGN, (MoveNumber = (selectedMoveNumber + If((selectedPlayer.Player = 2), 1))), (Player = LookUp(colPlayers, (Player <> selectedPlayer.Player)).Player)))}
If branch if Or(And(!IsCompletedGame, !IsEmpty(colPGN)), And(varIsReplay, HasNextMove)) / else
Set write sets variable selectedMoveNumber to (selectedMoveNumber + If((selectedPlayer.Player = 2), 1))
Set write sets variable selectedPlayer to LookUp(colPlayers, (Player <> selectedPlayer.Player))
If branch if And(!IsCompletedGame, !HasNextMove)
Set write sets variable varIsReplay to false
Set write sets variable varIsReplay to false
If branch if And(ToggleCheck.Value, !varIsReplay, IsEmpty(MatchAll(Last(colPGN).Move, "[+#]")))
Set write sets variable selectedMove to Patch(colPGN, Last(colPGN), {Move: (Last(colPGN).Move & If(ToggleCheckmate.Value, ("# " & Switch(Last(colPGN).Player, 1, "1-0", "0-1")), "+"))})
Set write sets variable selectedMove to Patch(colPGN, LookUp(colPGN, And((MoveNumber = (selectedMoveNumber - If((selectedPlayer.Player = 1), 1))), (Player = If((selectedPlayer.Player = 1), 2, 1)))), {FEN: InputFEN.Text})
If branch if And(!varIsReplay, !varViewGame, (selectedMatch.GameData <> Concatenate(InputFEN.Text, varDelimiterForData, InputPGN.Text)))
Set write sets variable triggerSaveGame to true
If branch if !IsEmpty(MatchAll(selectedMove.Move, "1-0|0-1|1\/2-1\/2"))
Set write sets variable varIsReplay to false
If branch if And(!varViewGame, ("#" in selectedMove.Move))
Notify effect UI or environment action Notify("Checkmate!", NotificationType.Information, 3000), logged not performed
Navigate navigate navigates to Checkmate Screen (Fade)
If branch if !ToggleCheckmate.Value
If branch if And(!varEndReplay, varIsReplay, !IsEmpty(Filter(colPGN, (MoveNumber = selectedMoveNumber), (Player = selectedPlayer.Player)))) / else
Set write sets variable triggerMoveSetup to true
Set write sets variable varIsReplay to false
Set write sets variable varEndReplay to false
Set write sets variable triggerMoveEnd to false

Game Screen/ToggleMoveJump.OnCheck

// Raise a flag to override the existing game's FEN. Set(varOverrideLoad,true); Set(stringFEN,selectedPGN.FEN); // Resync the match. Set(varLoadFEN,true); Set(t

Step Kind What it does Reason not translated
Set write sets variable varOverrideLoad to true
Set write sets variable stringFEN to selectedPGN.FEN
Set write sets variable varLoadFEN to true
Set write sets variable triggerLoadGame to true

Game Screen/SliderRotation.OnSelect

false

Step Kind What it does Reason not translated
value value evaluates false and discards the result

Game Screen/LabelKing.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryPlayers (runs its OnSelect)

Game Screen/LabelPlayer.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryPlayers (runs its OnSelect)

Game Screen/IconPlayerMenu.OnSelect

Select(Parent); Set(selectedPlayerData,ThisItem); Navigate('Actions Screen',Fade)

Step Kind What it does Reason not translated
Select effect selects GalleryPlayers (runs its OnSelect)
Set write sets variable selectedPlayerData to ThisItem
Navigate navigate navigates to Actions Screen (Fade)

Game Screen/LabelPGN.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryPGN (runs its OnSelect)

Game Screen/galleryTemplate5.OnSelect

If( And( varViewGame, !triggerMoveJump, !IsBlank(ThisItem.FEN), !ToggleIsMoving.Value ), Set(varIsReplay,false); Set(selectedPGN,ThisItem); Set(triggerMoveJump,

Step Kind What it does Reason not translated
If branch if And(varViewGame, !triggerMoveJump, !IsBlank(ThisItem.FEN), !ToggleIsMoving.Value)
Set write sets variable varIsReplay to false
Set write sets variable selectedPGN to ThisItem
Set write sets variable triggerMoveJump to true

Forfeit Dialog/ButtonForfeitConfirm.OnSelect

If( !triggerForfeit, Set(triggerForfeit,true); Refresh(GameServer); Set(selectedMatch,LookUp(GameServer,ID=selectedMatch.ID)); Set(selectedMatch, Patch( GameSer

Step Kind What it does Reason not translated
If branch if !triggerForfeit
Set write sets variable triggerForfeit to true
Refresh effect UI or environment action Refresh(GameServer), logged not performed
Set write sets variable selectedMatch to LookUp(GameServer, (ID = selectedMatch.ID))
Set write sets variable selectedMatch to Patch(GameServer, LookUp(GameServer, (ID = selectedMatch.ID)), {Active: 0, GameData: (selectedMatch.GameData & If(IsEmpty(MatchAll(selectedMatch.GameData, "1-0|0-1|1\/2-1\/2")), (If((CountRows(Filter(Split(selectedMatch.GameData, varDelimiterForData), !IsBlank(Result))) < 2), "1.") & If((varUser.id = selectedMatch.ActivePlayer), " 0-1", " 1-0"))))})
If branch if IsEmpty(Errors(GameServer)) / else Errors is not a classified function
Navigate navigate navigates to Checkmate Screen (ScreenTransition.Fade)
Notify effect UI or environment action Notify(("There was an error in updating the match. Please try again. If this issue persists, please contact an app admin: " & Concat(colAdmins, (Admin & If((Admin <> Last(colAdmins).Admin), ", ", ".")))), NotificationType.Error, 2500), logged not performed
Set write sets variable triggerForfeit to false

Forfeit Dialog/ButtonForfeitCancel.OnSelect

If( !triggerForfeit, Navigate('Actions Screen', ScreenTransition.Fade) )

Step Kind What it does Reason not translated
If branch if !triggerForfeit
Navigate navigate navigates to Actions Screen (ScreenTransition.Fade)

Archive Dialog/ButtonArchiveConfirm.OnSelect

If( !triggerArchive, Set(triggerArchive,true); Refresh(GameServer); Set(selectedMatch,LookUp(GameServer,ID=selectedMatch.ID)); Set(selectedMatch, Patch( GameSer

Step Kind What it does Reason not translated
If branch if !triggerArchive
Set write sets variable triggerArchive to true
Refresh effect UI or environment action Refresh(GameServer), logged not performed
Set write sets variable selectedMatch to LookUp(GameServer, (ID = selectedMatch.ID))
Set write sets variable selectedMatch to Patch(GameServer, LookUp(GameServer, (ID = selectedMatch.ID)), {Active: 0})
If branch if IsEmpty(Errors(GameServer)) / else Errors is not a classified function
Notify effect UI or environment action Notify((("You successfully archived the match with " & Coalesce(LookUp(colPlayerData, (Id <> varUser.id)), First(colPlayerData)).DisplayName) & "."), NotificationType.Information, 2500), logged not performed
Navigate navigate navigates to Join Game Screen (ScreenTransition.Fade)
Notify effect UI or environment action Notify(("There was an error in updating the match. Please try again. If this issue persists, please contact an app admin: " & Concat(colAdmins, (Admin & If((Admin <> Last(colAdmins).Admin), ", ", ".")))), NotificationType.Error, 2500), logged not performed
Set write sets variable triggerArchive to false

Archive Dialog/ButtonArchiveCancel.OnSelect

If( !triggerForfeit, Navigate('Actions Screen', ScreenTransition.Fade) )

Step Kind What it does Reason not translated
If branch if !triggerForfeit
Navigate navigate navigates to Actions Screen (ScreenTransition.Fade)

Home Screen/ImageGoose.OnSelect

Set(varGoose,true)

Step Kind What it does Reason not translated
Set write sets variable varGoose to true

Home Screen/ButtonNewGame.OnSelect

Set(varViewGame,false); Navigate('New Game Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Set write sets variable varViewGame to false
Navigate navigate navigates to New Game Screen (ScreenTransition.Fade)

Home Screen/ButtonJoinGame.OnSelect

Set(varViewGame,false); Navigate('Join Game Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Set write sets variable varViewGame to false
Navigate navigate navigates to Join Game Screen (ScreenTransition.Fade)

Home Screen/ButtonViewGame.OnSelect

Set(varViewGame,true); Navigate('Share Screen',Fade)

Step Kind What it does Reason not translated
Set write sets variable varViewGame to true
Navigate navigate navigates to Share Screen (Fade)

Home Screen/AudioGoose.OnEnd

Set(varGoose,false)

Step Kind What it does Reason not translated
Set write sets variable varGoose to false

Join Game Screen.OnVisible

If( IsBlank(SortDescending1), UpdateContext({SortDescending1: true}) ); Set(varTimeNow,Now());

Step Kind What it does Reason not translated
If branch if IsBlank(SortDescending1)
UpdateContext context sets context variable SortDescending1 = true on Join Game Screen
Set write sets variable varTimeNow to Now()

Join Game Screen/IconHamburger.OnSelect

Navigate('Home Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to Home Screen (ScreenTransition.Fade)

Join Game Screen/IconRefresh1.OnSelect

Set(varTimeNow,Now()); Refresh(GameServer)

Step Kind What it does Reason not translated
Set write sets variable varTimeNow to Now()
Refresh effect UI or environment action Refresh(GameServer), logged not performed

Join Game Screen/IconSortUpDown1.OnSelect

UpdateContext({SortDescending1: !SortDescending1})

Step Kind What it does Reason not translated
UpdateContext context sets context variable SortDescending1 = !SortDescending1 on Join Game Screen

Join Game Screen/IconNewItem1.OnSelect

Navigate('New Game Screen', ScreenTransition.Fade)

Step Kind What it does Reason not translated
Navigate navigate navigates to New Game Screen (ScreenTransition.Fade)

Join Game Screen/ImageGameServer.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryGameServer (runs its OnSelect)

Join Game Screen/LabelPlayers.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryGameServer (runs its OnSelect)

Join Game Screen/LabelPlayerCurrent.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryGameServer (runs its OnSelect)

Join Game Screen/LabelTimeElapsed.OnSelect

Select(Parent)

Step Kind What it does Reason not translated
Select effect selects GalleryGameServer (runs its OnSelect)

Join Game Screen/ButtonJoin.OnSelect

Select(Parent); Set(selectedMatch,LookUp(GameServer,ID=ThisItem.ID)); // Get a table of metadata for each player. ClearCollect(colPlayerData, Ungroup( AddColumn

Step Kind What it does Reason not translated
Select effect selects GalleryGameServer (runs its OnSelect)
Set write sets variable selectedMatch to LookUp(GameServer, (ID = ThisItem.ID))
ClearCollect collection replaces the rows of colPlayerData: Ungroup(AddColumns(colPlayers, "tablePlayerData", With({tablePlayers: AddColumns(AddColumns(RenameColumns(Split(selectedMatch.Players, varDelimiter), "Result", "PlayerData"), "DisplayName", First(Split(PlayerData, " <")).Result, "Id", Substitute(Match(PlayerData, "(?:\<).+?(?=>)").FullMatch, "<", "")), "UserPrincipalName", If(varIsGuest, Coalesce(LookUp(GamePlayerData, (PlayerId = Id)).Title, ""), With(Office365Users.UserProfileV2(Id), If(!("#EXT#" in userPrincipalName), userPrincipalName, Coalesce(With({stringUserPrincipalName: First(Split(userPrincipalName, "#EXT#")).Result}, Lower(Replace(stringUserPrincipalName, Last(MatchAll(stringUserPrincipalName, "_")).StartMatch, 1, "@"))), If(IsMatch(displayName, Match.Email), displayName, ""))))))}, If((Player = 1), FirstN(Filter(tablePlayers, (Id in selectedMatch.ActivePlayer)), 1), Coalesce(FirstN(Filter(tablePlayers, !(Id in selectedMatch.ActivePlayer)), 1), LastN(FirstN(tablePlayers, 2), 1))))), "tablePlayerData")
Set write sets variable varIsNewGame to false
Set write sets variable varOverrideLoad to false
Set write sets variable varLoadFEN to true
Set write sets variable varLoadPGN to true
Clear collection empties colGame
Clear collection empties colPGN
Navigate navigate navigates to Game Screen (Fade)

Join Game Screen/TimerRefreshServer.OnTimerEnd

Set(varTimeNow,Now()); Refresh(GameServer)

Step Kind What it does Reason not translated
Set write sets variable varTimeNow to Now()
Refresh effect UI or environment action Refresh(GameServer), logged not performed

Simulation on the first input set

App.OnStart first, then every event once on the state it left, each with the first gallery row where one is needed.

Event State after Screen Effects logged Error
App.OnStart variables:varDelimiterForData: "||"; variables:varDelimiter: ","; variables:varIsGuest: true; variables:varUser: {"displayName": "", "id": null, "userPrincipalName": "tester; variables:varTenantId: ""; variables:varMatchId: null; variables:varIsAdmin: false; data:colBoard: [{"Y": 1.0, "X": 1.0, "Rank": 8.0, "File": "a", "Id": 1.0, "; data:colPlayers: [{"Player": 1.0, "Color": "White"}, {"Player": 2.0, "Color":; data:colPieces: [{"Piece": 1.0, "Name": "King", "Abbr": "K"}, {"Piece": 2.0,; data:colSVG: [{"Key": "linearGradient", "Value": "<linearGradient id='*|i; data:colAdmins: [{"Admin": "contact@mr-dang.com"}]; data:colIcons: [{"PlayerId": 1.0, "PieceId": 1.0, "Icon": "\u2654"}, {"Play; data:colIntegers: [{"n": 0.0, "Hex": {"$error": "InvalidArgument"}}, {"n": 1.0; data:colNewGame: [{"Player": 1.0, "Color": "White", "Piece": 1.0, "Name": "Ki; data:colNewCastling: [{"RookId": 64.0, "Player": 1.0, "Side": "K", "CanCastle": t Trace(null, {"$option": "Information", "se)
Actions Screen.OnVisible no state change
Game Screen.OnVisible variables:varRotation: 0.0
Join Game Screen.OnVisible variables:varTimeNow: {"$datetime": "2026-10-14T12:34:56.000"}
New Game Screen.OnVisible data:selectedPlayers: [{"Id": null, "DisplayName": "", "UserPrincipalName": "teste
Actions Screen/ButtonActionArchive.OnSelect screen: "Archive Dialog" Archive Dialog Navigate Archive Dialog
Actions Screen/ButtonActionForfeit.OnSelect screen: "Forfeit Dialog" Forfeit Dialog Navigate Forfeit Dialog
Actions Screen/IconBackActions.OnSelect screen: "Game Screen" Game Screen Navigate Game Screen
Archive Dialog/ButtonArchiveCancel.OnSelect no state change
Archive Dialog/ButtonArchiveConfirm.OnSelect variables:selectedMatch: {"Active": 0.0, "ActivePlayer": "Closed", "AppId": "x", "Cre; data:GameServer: [{"Active": 0.0, "ActivePlayer": "Closed", "AppId": "x", "Cr Refresh([{"Active": null, "ActivePlaye); Notify("There was an error in updatin, {"$option": "Error", "set": "N, 2500.0)
Checkmate Screen/ButtonCheckmate.OnSelect screen: "Home Screen" Home Screen Navigate Home Screen
Forfeit Dialog/ButtonForfeitCancel.OnSelect no state change
Forfeit Dialog/ButtonForfeitConfirm.OnSelect no state change
Game Screen/ButtonNotify.OnSelect no state change PowerAppsNotification.SendPushNotification({"recipients": [{"Value": {"Us)
Game Screen/ButtonSelect.OnSelect no state change Select("GallerySelect"); unsupported: event Game Screen/GallerySelect.OnSelect has no handler
Game Screen/IconPlayerMenu.OnSelect variables:selectedPlayerData: {"Color": "Zed Ltd", "Player": 1.0, "DisplayName": "Open", "; screen: "Actions Screen" Actions Screen Select("GalleryPlayers"); unsupported: event Game Screen/GalleryPlayers.OnSelect has no handler; Navigate Actions Screen
Game Screen/ImageMenu.OnSelect no state change Select("GalleryMenu"); unsupported: event Game Screen/GalleryMenu.OnSelect has no handler
Game Screen/InputMove.OnChange variables:triggerMoveValidation: true; variables:varMoveEntry: "O'Neil"
Game Screen/LabelFileBottom.OnSelect no state change Select("GalleryFileBottom"); unsupported: event Game Screen/GalleryFileBottom.OnSelect has no handler
Game Screen/LabelFileTop.OnSelect no state change Select("GalleryFileTop"); unsupported: event Game Screen/GalleryFileTop.OnSelect has no handler
Game Screen/LabelKing.OnSelect no state change Select("GalleryPlayers"); unsupported: event Game Screen/GalleryPlayers.OnSelect has no handler
Game Screen/LabelMenu.OnSelect no state change Select("GalleryMenu"); unsupported: event Game Screen/GalleryMenu.OnSelect has no handler
Game Screen/LabelPGN.OnSelect no state change Select("GalleryPGN"); unsupported: event Game Screen/GalleryPGN.OnSelect has no handler
Game Screen/LabelPlayer.OnSelect no state change Select("GalleryPlayers"); unsupported: event Game Screen/GalleryPlayers.OnSelect has no handler
Game Screen/LabelRankLeft.OnSelect no state change Select("GalleryRankLeft"); unsupported: event Game Screen/GalleryRankLeft.OnSelect has no handler
Game Screen/LabelRankRight.OnSelect no state change Select("GalleryRankRight"); unsupported: event Game Screen/GalleryRankRight.OnSelect has no handler
Game Screen/SliderRotation.OnSelect no state change
Game Screen/TimerMoveTransition.OnTimerEnd controls:TimerMoveTransition: null Reset("TimerMoveTransition")
Game Screen/TimerRefresh.OnTimerEnd no state change
Game Screen/TimerRotate.OnTimerEnd variables:triggerRotation: false; controls:TimerRotate: null Reset("TimerRotate")
Game Screen/ToggleIsMoving.OnCheck no state change
Game Screen/ToggleIsReplayComplete.OnCheck no state change
Game Screen/ToggleIsYourTurn.OnCheck no state change
Game Screen/ToggleLoadGame.OnCheck variables:triggerLoadGame: false; variables:varLoadFEN: false
Game Screen/ToggleMove.OnCheck variables:triggerMove: false; data:colGame: [{"Guid": null, "Id": "", "Name": "Pawn", "Player": 1.0, "Ab
Game Screen/ToggleMoveEnd.OnCheck variables:selectedSquare: null; variables:selectedPiece: null; variables:varIsReplay: false; variables:selectedMove: {"FEN": "Pending"}; variables:selectedMoveNumber: 2667.4; variables:selectedPlayer: {"Player": 1.0, "Color": "White"}; data:selectedPieces: []; data:selectedSquares: []; data:colPGN: [{"Color": "South", "FEN": null, "Move": "Acme", "MoveNumber Reset("AudioMove")
Game Screen/ToggleMoveJump.OnCheck variables:stringFEN: null; variables:varOverrideLoad: true; variables:varLoadFEN: true
Game Screen/ToggleMoveMessage.OnCheck variables:triggerMoveMessage: false; variables:varMoveScan: false; variables:varMoveMessage: "You selected the king on Acme. This piece has no valid move; data:colMessages: [{"Id": "North", "Message": "South", "MoveNumber": null, "Pl Notify("You selected the king on Acme, {"$option": "Information", "se, 5000.0)
Game Screen/ToggleMoveSelect.OnCheck variables:selectedSquare: {"Square": "North"}; variables:varIsReplay: false; data:selectedSquares: [{"Square": "North"}]
Game Screen/ToggleMoveSetup.OnCheck variables:selectedSquare: {"Y": 1.0, "X": 7.0, "Rank": 8.0, "File": "g", "Id": 7.0, "S; variables:selectedPiece: null; variables:triggerMoveSetup: false; variables:varCastlingMetadata: {"IsKingside": true, "King": null, "Rook": null, "KingSquare; variables:triggerMoveMessage: true; variables:selectedMove: {"FEN": "", "Comment": "", "Player": 2.0, "Color": "Open", "; variables:triggerMoveTransition: true; variables:varMoveEntry: null; data:selectedPieces: []; data:colCaptured: [{"Guid": "Zed Ltd", "Name": "x", "Square": "Closed"}, {"Gui; data:selectedSquares: [{"Y": 1.0, "X": 7.0, "Rank": 8.0, "File": "g", "Id": 7.0, "; data:colPGN: [{"Color": "South", "FEN": null, "Move": "Acme", "MoveNumber
Game Screen/ToggleMoveValidation.OnCheck variables:selectedMoveMetadata: {"IsCastling": false, "PieceType": null, "Disambiguation": n
Game Screen/ToggleResetGame.OnCheck variables:varEnPassantSquare: null; variables:selectedSquare: null; variables:selectedPiece: null; variables:triggerMoveSetup: false; variables:triggerResetGame: false; variables:triggerMoveMessage: false; variables:varIsReplay: false; variables:selectedMoveNumber: 1.0; variables:triggerMove: false; variables:selectedPlayer: {"Player": 1.0, "Color": "White"}; data:colMessages: []; data:selectedPieces: []; data:colCaptured: []; data:colGame: [{"Player": 1.0, "Color": "White", "Piece": 1.0, "Name": "Ki; data:selectedSquares: []; data:colCastling: [{"RookId": 64.0, "Player": 1.0, "Side": "K", "CanCastle": t; data:colPGN: []; controls:TimerRotate: null; controls:TimerMoveTransition: null Reset("TimerMoveTransition"); Reset("TimerRotate")
Game Screen/ToggleSaveGame.OnCheck variables:triggerSaveGame: false
Game Screen/ToggleSyncGame.OnCheck no state change
Game Screen/galleryTemplate1.OnSelect no state change
Game Screen/galleryTemplate3.OnSelect screen: "Home Screen" Home Screen Navigate Home Screen
Game Screen/galleryTemplate5.OnSelect no state change
Home Screen/AudioGoose.OnEnd no state change
Home Screen/ButtonJoinGame.OnSelect variables:varViewGame: false; screen: "Join Game Screen" Join Game Screen Navigate Join Game Screen
Home Screen/ButtonNewGame.OnSelect variables:varViewGame: false; screen: "New Game Screen" New Game Screen Navigate New Game Screen
Home Screen/ButtonViewGame.OnSelect screen: "Share Screen" Share Screen Navigate Share Screen
Home Screen/ImageGoose.OnSelect variables:varGoose: true
Join Game Screen/ButtonJoin.OnSelect variables:varLoadPGN: true; variables:varOverrideLoad: false; variables:varIsNewGame: false; variables:varLoadFEN: true; data:colPlayerData: []; data:colGame: []; data:colPGN: []; screen: "Game Screen" Game Screen Select("GalleryGameServer"); unsupported: event Join Game Screen/GalleryGameServer.OnSelect has no handler; Navigate Game Screen
Join Game Screen/IconHamburger.OnSelect screen: "Home Screen" Home Screen Navigate Home Screen
Join Game Screen/IconNewItem1.OnSelect screen: "New Game Screen" New Game Screen Navigate New Game Screen
Join Game Screen/IconRefresh1.OnSelect variables:varTimeNow: {"$datetime": "2026-10-14T12:34:56.000"} Refresh([{"Active": null, "ActivePlaye)
Join Game Screen/IconSortUpDown1.OnSelect context:Join Game Screen/SortDescending1: true
Join Game Screen/ImageGameServer.OnSelect no state change Select("GalleryGameServer"); unsupported: event Join Game Screen/GalleryGameServer.OnSelect has no handler
Join Game Screen/LabelPlayerCurrent.OnSelect no state change Select("GalleryGameServer"); unsupported: event Join Game Screen/GalleryGameServer.OnSelect has no handler
Join Game Screen/LabelPlayers.OnSelect no state change Select("GalleryGameServer"); unsupported: event Join Game Screen/GalleryGameServer.OnSelect has no handler
Join Game Screen/LabelTimeElapsed.OnSelect no state change Select("GalleryGameServer"); unsupported: event Join Game Screen/GalleryGameServer.OnSelect has no handler
Join Game Screen/TimerRefreshServer.OnTimerEnd variables:varTimeNow: {"$datetime": "2026-10-14T12:34:56.000"} Refresh([{"Active": null, "ActivePlaye)
New Game Screen/ButtonCreateGame.OnSelect no state change Notify("Please select an opponent to , {"$option": "Information", "se, 2500.0)
New Game Screen/IconBackNewGame.OnSelect screen: "Home Screen" Home Screen Navigate Home Screen
New Game Screen/Image1.OnSelect no state change Select("GalleryPeople"); unsupported: event New Game Screen/GalleryPeople.OnSelect has no handler
New Game Screen/Title1.OnSelect no state change Select("GalleryPeople"); unsupported: event New Game Screen/GalleryPeople.OnSelect has no handler
New Game Screen/galleryTemplate6.OnSelect data:selectedPlayers: [{"Background": "Beta", "DisplayName": "alpha", "Id": "South
New Game Screen/icoPeopleSelected.OnSelect no state change Select("GalleryPeople"); unsupported: event New Game Screen/GalleryPeople.OnSelect has no handler
Settings Screen/IconBackSettings.OnSelect screen: "Game Screen" Game Screen Navigate Game Screen
Share Screen/ButtonPGNUpdate.OnSelect variables:varOverrideLoad: true; data:colPlayerData: [{"Player": 1.0, "Color": "White"}, {"Player": 2.0, "Color": Notify("Neither the FEN nor PGN could, {"$option": "Warning", "set": , 2500.0)
Share Screen/IconBackPGN.OnSelect screen: "Home Screen" Home Screen Navigate Home Screen
Share Screen/InputDeepLink.OnSelect no state change
Share Screen/InputFEN.OnSelect no state change