You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add keepOrder option to SWAPHANDS
SWAPHANDS collects the cards of a hand in the order they are in that hand
but hands them to the MOVE operation as a collection array, which is
resolved via widgetFilter and therefore processed in widget creation
order. The receiving player thus gets the cards in the order they were
created in instead of the order the previous player had arranged them in.
Since games may rely on the current behavior, the order is only preserved
when the new keepOrder property is set, in which case the cards are moved
one by one.
* Move a hand's cards with one ordered MOVE and test the order
MOVE iterates its collection in array order - only an array of IDs is
re-resolved through widgetFilter, which returns the widgets in creation
order. So instead of generating one MOVE per card, keepOrder can hand the
cards to a single MOVE as an already ordered collection. That keeps the
routine log readable while debugging and avoids re-filtering all widgets
of the room once per card.
tests/testcafe/routines.js covers both the unchanged default (cards
arrive in widget creation order) and keepOrder (cards arrive in the order
of the hand), so the ordering contract is no longer only checked by hand.
* Log what SWAPHANDS did in the routine log
SWAPHANDS was one of the few operations without a
jeLoggingRoutineOperationSummary, so its entry in the DEBUG log was the
bare word SWAPHANDS - with keepOrder there are now two ways it can
behave, which the log should name. It also says so when there are not
enough seated players to swap between, which was silent before.
* Make the SWAPHANDS routine log name the seats it moves cards between
* Keep SWAPHANDS from clobbering a collection of the surrounding routine
SWAPHANDS names the temporary collections it moves through after the
seats they come from, so the routine log reads "from 'hand of seat1'".
Those names are not reserved though: a routine that uses a collection of
that name itself lost it, because SWAPHANDS overwrote and then deleted
it. Remember what was there and put it back instead.
Co-Authored-By: Claude <noreply@anthropic.com>
* Fill the SWAPHANDS collections one move at a time
The generated MOVEs used to look up their widgets when they ran, so a widget
that a routine of an earlier move removed was skipped. Give each MOVE its own
routine call and fill its collection right before it, which restores that and
also keeps the caller's collection shadowed for one move only, even if a MOVE
throws.
Also make the log summary read "hands in a random seat order by 1" instead of
"hands random by 1" and say that nothing was moved when no seat has a hand.
* Update tutorial with keepOrder
---------
Co-authored-by: VTT AI Agent <300563116+VTT-AI-Agent@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: 96LawDawg <76912527+96LawDawg@users.noreply.github.com>
consthow=a.direction=='random' ? `hands in a random seat order by ${a.interval}` : `hands ${a.direction} by ${a.interval}`;
2106
+
jeLoggingRoutineOperationSummary(moves.length ? `${how}${a.keepOrder ? ', keeping the card order' : ''}` : 'no seat with a player has a valid hand, nothing to swap');
2082
2107
}
2108
+
}elseif(jeRoutineLogging){
2109
+
jeLoggingRoutineOperationSummary('less than two seats with a player, nothing to swap');
Copy file name to clipboardExpand all lines: library/tutorials/Functions - SWAPHANDS/0.json
+82-22Lines changed: 82 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -678,7 +678,7 @@
678
678
"css": {
679
679
"font-size": "25px"
680
680
},
681
-
"text": "SWAPHANDS is used to swap the contents of the hands of the given collection of seats. This is especially useful for games which use pick-and-pass card drafting, but also in any situation where one or more players need to exchange hands.\n\nIt's possible to use this in a scenario where all seats share one hand with childrenPerOwner: true, but here separate hands are shown for each user to make the effect clearer.\n\nYou can also sit in multiple seats at once in this room, to test out the different buttons."
681
+
"text": "SWAPHANDS is used to swap the contents of the hands of the given collection of seats. This is especially useful for games which use pick-and-pass card drafting, but also in any situation where one or more players need to exchange hands.\n\nIt's possible to use this in a scenario where all seats share one hand with childrenPerOwner: true, but here separate hands are shown for each user to make the effect clearer.\n\nYou can also sit in multiple seats at once in this room, to test out the different buttons. The keepOrder button in the bottom middle will, for all buttons, either keep the order of the cards as they are passed the same (if true) or not (if false). Even if keepOrder is false, the order may not change, but setting it to true ensures they will not change."
682
682
},
683
683
"seat-p1": {
684
684
"type": "seat",
@@ -1097,7 +1097,8 @@
1097
1097
"text": "Forward",
1098
1098
"clickRoutine": [
1099
1099
{
1100
-
"func": "SWAPHANDS"
1100
+
"func": "SWAPHANDS",
1101
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1101
1102
}
1102
1103
]
1103
1104
},
@@ -1112,7 +1113,8 @@
1112
1113
"clickRoutine": [
1113
1114
{
1114
1115
"func": "SWAPHANDS",
1115
-
"direction": "backward"
1116
+
"direction": "backward",
1117
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1116
1118
}
1117
1119
]
1118
1120
},
@@ -1127,7 +1129,8 @@
1127
1129
"clickRoutine": [
1128
1130
{
1129
1131
"func": "SWAPHANDS",
1130
-
"direction": "random"
1132
+
"direction": "random",
1133
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1131
1134
}
1132
1135
]
1133
1136
},
@@ -1145,7 +1148,8 @@
1145
1148
"source": [
1146
1149
"seat-p1",
1147
1150
"seat-p2"
1148
-
]
1151
+
],
1152
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1149
1153
}
1150
1154
]
1151
1155
},
@@ -1163,7 +1167,8 @@
1163
1167
"source": [
1164
1168
"seat-p1",
1165
1169
"seat-p3"
1166
-
]
1170
+
],
1171
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1167
1172
}
1168
1173
]
1169
1174
},
@@ -1181,7 +1186,8 @@
1181
1186
"source": [
1182
1187
"seat-p1",
1183
1188
"seat-p4"
1184
-
]
1189
+
],
1190
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1185
1191
}
1186
1192
]
1187
1193
},
@@ -1199,7 +1205,8 @@
1199
1205
"source": [
1200
1206
"seat-p4",
1201
1207
"seat-p1"
1202
-
]
1208
+
],
1209
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1203
1210
}
1204
1211
]
1205
1212
},
@@ -1217,7 +1224,8 @@
1217
1224
"source": [
1218
1225
"seat-p4",
1219
1226
"seat-p2"
1220
-
]
1227
+
],
1228
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1221
1229
}
1222
1230
]
1223
1231
},
@@ -1235,7 +1243,8 @@
1235
1243
"source": [
1236
1244
"seat-p4",
1237
1245
"seat-p3"
1238
-
]
1246
+
],
1247
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1239
1248
}
1240
1249
]
1241
1250
},
@@ -1253,7 +1262,8 @@
1253
1262
"source": [
1254
1263
"seat-p2",
1255
1264
"seat-p1"
1256
-
]
1265
+
],
1266
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1257
1267
}
1258
1268
]
1259
1269
},
@@ -1271,7 +1281,8 @@
1271
1281
"source": [
1272
1282
"seat-p2",
1273
1283
"seat-p3"
1274
-
]
1284
+
],
1285
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1275
1286
}
1276
1287
]
1277
1288
},
@@ -1289,7 +1300,8 @@
1289
1300
"source": [
1290
1301
"seat-p2",
1291
1302
"seat-p4"
1292
-
]
1303
+
],
1304
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1293
1305
}
1294
1306
]
1295
1307
},
@@ -1307,7 +1319,8 @@
1307
1319
"source": [
1308
1320
"seat-p3",
1309
1321
"seat-p1"
1310
-
]
1322
+
],
1323
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1311
1324
}
1312
1325
]
1313
1326
},
@@ -1325,7 +1338,8 @@
1325
1338
"source": [
1326
1339
"seat-p3",
1327
1340
"seat-p2"
1328
-
]
1341
+
],
1342
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
1329
1343
}
1330
1344
]
1331
1345
},
@@ -1343,7 +1357,8 @@
1343
1357
"source": [
1344
1358
"seat-p3",
1345
1359
"seat-p4"
1346
-
]
1360
+
],
1361
+
"keepOrder": "${PROPERTY keepOrder OF button-keepOrder}"
0 commit comments