ygopro-msg-encode 1.1.13 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +166 -159
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +163 -157
- package/dist/index.mjs.map +3 -3
- package/dist/src/protos/common/card-query.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1093,170 +1093,175 @@ var CardQuery = class {
|
|
|
1093
1093
|
return this;
|
|
1094
1094
|
}
|
|
1095
1095
|
toPayload() {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1096
|
+
return serializeCardQuery(this);
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
function serializeCardQuery(card) {
|
|
1100
|
+
const source = card || {};
|
|
1101
|
+
const flags = source.flags || 0;
|
|
1102
|
+
let size = 4;
|
|
1103
|
+
if (flags & OcgcoreCommonConstants.QUERY_CODE) size += 4;
|
|
1104
|
+
if (flags & OcgcoreCommonConstants.QUERY_POSITION) size += 4;
|
|
1105
|
+
if (flags & OcgcoreCommonConstants.QUERY_ALIAS) size += 4;
|
|
1106
|
+
if (flags & OcgcoreCommonConstants.QUERY_TYPE) size += 4;
|
|
1107
|
+
if (flags & OcgcoreCommonConstants.QUERY_LEVEL) size += 4;
|
|
1108
|
+
if (flags & OcgcoreCommonConstants.QUERY_RANK) size += 4;
|
|
1109
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) size += 4;
|
|
1110
|
+
if (flags & OcgcoreCommonConstants.QUERY_RACE) size += 4;
|
|
1111
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTACK) size += 4;
|
|
1112
|
+
if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) size += 4;
|
|
1113
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) size += 4;
|
|
1114
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) size += 4;
|
|
1115
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON) size += 4;
|
|
1116
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) size += 4;
|
|
1117
|
+
if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) size += 4;
|
|
1118
|
+
if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
|
|
1119
|
+
size += 4 + (source.targetCards?.length || 0) * 4;
|
|
1120
|
+
}
|
|
1121
|
+
if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
|
|
1122
|
+
size += 4 + (source.overlayCards?.length || 0) * 4;
|
|
1123
|
+
}
|
|
1124
|
+
if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
|
|
1125
|
+
size += 4 + (source.counters?.length || 0) * 4;
|
|
1126
|
+
}
|
|
1127
|
+
if (flags & OcgcoreCommonConstants.QUERY_OWNER) size += 4;
|
|
1128
|
+
if (flags & OcgcoreCommonConstants.QUERY_STATUS) size += 4;
|
|
1129
|
+
if (flags & OcgcoreCommonConstants.QUERY_LSCALE) size += 4;
|
|
1130
|
+
if (flags & OcgcoreCommonConstants.QUERY_RSCALE) size += 4;
|
|
1131
|
+
if (flags & OcgcoreCommonConstants.QUERY_LINK) size += 8;
|
|
1132
|
+
const result = new Uint8Array(size);
|
|
1133
|
+
const view = new DataView(result.buffer);
|
|
1134
|
+
let offset = 0;
|
|
1135
|
+
view.setInt32(offset, flags, true);
|
|
1136
|
+
offset += 4;
|
|
1137
|
+
if (source.empty || flags === 0) {
|
|
1138
|
+
return result;
|
|
1139
|
+
}
|
|
1140
|
+
if (flags & OcgcoreCommonConstants.QUERY_CODE) {
|
|
1141
|
+
view.setInt32(offset, source.code || 0, true);
|
|
1131
1142
|
offset += 4;
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1143
|
+
}
|
|
1144
|
+
if (flags & OcgcoreCommonConstants.QUERY_POSITION) {
|
|
1145
|
+
const pdata = (source.position || 0) << 24 >>> 0;
|
|
1146
|
+
view.setInt32(offset, pdata, true);
|
|
1147
|
+
offset += 4;
|
|
1148
|
+
}
|
|
1149
|
+
if (flags & OcgcoreCommonConstants.QUERY_ALIAS) {
|
|
1150
|
+
view.setInt32(offset, source.alias || 0, true);
|
|
1151
|
+
offset += 4;
|
|
1152
|
+
}
|
|
1153
|
+
if (flags & OcgcoreCommonConstants.QUERY_TYPE) {
|
|
1154
|
+
view.setInt32(offset, source.type || 0, true);
|
|
1155
|
+
offset += 4;
|
|
1156
|
+
}
|
|
1157
|
+
if (flags & OcgcoreCommonConstants.QUERY_LEVEL) {
|
|
1158
|
+
view.setInt32(offset, source.level || 0, true);
|
|
1159
|
+
offset += 4;
|
|
1160
|
+
}
|
|
1161
|
+
if (flags & OcgcoreCommonConstants.QUERY_RANK) {
|
|
1162
|
+
view.setInt32(offset, source.rank || 0, true);
|
|
1163
|
+
offset += 4;
|
|
1164
|
+
}
|
|
1165
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTRIBUTE) {
|
|
1166
|
+
view.setInt32(offset, source.attribute || 0, true);
|
|
1167
|
+
offset += 4;
|
|
1168
|
+
}
|
|
1169
|
+
if (flags & OcgcoreCommonConstants.QUERY_RACE) {
|
|
1170
|
+
view.setInt32(offset, source.race || 0, true);
|
|
1171
|
+
offset += 4;
|
|
1172
|
+
}
|
|
1173
|
+
if (flags & OcgcoreCommonConstants.QUERY_ATTACK) {
|
|
1174
|
+
view.setInt32(offset, source.attack || 0, true);
|
|
1175
|
+
offset += 4;
|
|
1176
|
+
}
|
|
1177
|
+
if (flags & OcgcoreCommonConstants.QUERY_DEFENSE) {
|
|
1178
|
+
view.setInt32(offset, source.defense || 0, true);
|
|
1179
|
+
offset += 4;
|
|
1180
|
+
}
|
|
1181
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_ATTACK) {
|
|
1182
|
+
view.setInt32(offset, source.baseAttack || 0, true);
|
|
1183
|
+
offset += 4;
|
|
1184
|
+
}
|
|
1185
|
+
if (flags & OcgcoreCommonConstants.QUERY_BASE_DEFENSE) {
|
|
1186
|
+
view.setInt32(offset, source.baseDefense || 0, true);
|
|
1187
|
+
offset += 4;
|
|
1188
|
+
}
|
|
1189
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON) {
|
|
1190
|
+
view.setInt32(offset, source.reason || 0, true);
|
|
1191
|
+
offset += 4;
|
|
1192
|
+
}
|
|
1193
|
+
if (flags & OcgcoreCommonConstants.QUERY_REASON_CARD) {
|
|
1194
|
+
view.setInt32(offset, 0, true);
|
|
1195
|
+
offset += 4;
|
|
1196
|
+
}
|
|
1197
|
+
if (flags & OcgcoreCommonConstants.QUERY_EQUIP_CARD) {
|
|
1198
|
+
const equipCard = source.equipCard || {
|
|
1199
|
+
controller: 0,
|
|
1200
|
+
location: 0,
|
|
1201
|
+
sequence: 0
|
|
1202
|
+
};
|
|
1203
|
+
view.setUint8(offset, equipCard.controller);
|
|
1204
|
+
view.setUint8(offset + 1, equipCard.location);
|
|
1205
|
+
view.setUint8(offset + 2, equipCard.sequence);
|
|
1206
|
+
view.setUint8(offset + 3, 0);
|
|
1207
|
+
offset += 4;
|
|
1208
|
+
}
|
|
1209
|
+
if (flags & OcgcoreCommonConstants.QUERY_TARGET_CARD) {
|
|
1210
|
+
const targets = source.targetCards || [];
|
|
1211
|
+
view.setInt32(offset, targets.length, true);
|
|
1212
|
+
offset += 4;
|
|
1213
|
+
for (const target of targets) {
|
|
1214
|
+
view.setUint8(offset, target.controller);
|
|
1215
|
+
view.setUint8(offset + 1, target.location);
|
|
1216
|
+
view.setUint8(offset + 2, target.sequence);
|
|
1201
1217
|
view.setUint8(offset + 3, 0);
|
|
1202
1218
|
offset += 4;
|
|
1203
1219
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
view.setUint8(offset + 2, target.sequence);
|
|
1212
|
-
view.setUint8(offset + 3, 0);
|
|
1213
|
-
offset += 4;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
|
|
1217
|
-
const overlays = this.overlayCards || [];
|
|
1218
|
-
view.setInt32(offset, overlays.length, true);
|
|
1219
|
-
offset += 4;
|
|
1220
|
-
for (const card of overlays) {
|
|
1221
|
-
view.setInt32(offset, card, true);
|
|
1222
|
-
offset += 4;
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
|
|
1226
|
-
const counters = this.counters || [];
|
|
1227
|
-
view.setInt32(offset, counters.length, true);
|
|
1228
|
-
offset += 4;
|
|
1229
|
-
for (const counter of counters) {
|
|
1230
|
-
view.setUint16(offset, counter.type, true);
|
|
1231
|
-
view.setUint16(offset + 2, counter.count, true);
|
|
1232
|
-
offset += 4;
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
|
|
1236
|
-
view.setInt32(offset, this.owner || 0, true);
|
|
1237
|
-
offset += 4;
|
|
1238
|
-
}
|
|
1239
|
-
if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
|
|
1240
|
-
view.setInt32(offset, this.status || 0, true);
|
|
1241
|
-
offset += 4;
|
|
1242
|
-
}
|
|
1243
|
-
if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
|
|
1244
|
-
view.setInt32(offset, this.lscale || 0, true);
|
|
1245
|
-
offset += 4;
|
|
1246
|
-
}
|
|
1247
|
-
if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
|
|
1248
|
-
view.setInt32(offset, this.rscale || 0, true);
|
|
1220
|
+
}
|
|
1221
|
+
if (flags & OcgcoreCommonConstants.QUERY_OVERLAY_CARD) {
|
|
1222
|
+
const overlays = source.overlayCards || [];
|
|
1223
|
+
view.setInt32(offset, overlays.length, true);
|
|
1224
|
+
offset += 4;
|
|
1225
|
+
for (const card2 of overlays) {
|
|
1226
|
+
view.setInt32(offset, card2, true);
|
|
1249
1227
|
offset += 4;
|
|
1250
1228
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1229
|
+
}
|
|
1230
|
+
if (flags & OcgcoreCommonConstants.QUERY_COUNTERS) {
|
|
1231
|
+
const counters = source.counters || [];
|
|
1232
|
+
view.setInt32(offset, counters.length, true);
|
|
1233
|
+
offset += 4;
|
|
1234
|
+
for (const counter of counters) {
|
|
1235
|
+
view.setUint16(offset, counter.type, true);
|
|
1236
|
+
view.setUint16(offset + 2, counter.count, true);
|
|
1255
1237
|
offset += 4;
|
|
1256
1238
|
}
|
|
1257
|
-
return new Uint8Array(view.buffer, view.byteOffset, offset);
|
|
1258
1239
|
}
|
|
1259
|
-
|
|
1240
|
+
if (flags & OcgcoreCommonConstants.QUERY_OWNER) {
|
|
1241
|
+
view.setInt32(offset, source.owner || 0, true);
|
|
1242
|
+
offset += 4;
|
|
1243
|
+
}
|
|
1244
|
+
if (flags & OcgcoreCommonConstants.QUERY_STATUS) {
|
|
1245
|
+
view.setInt32(offset, source.status || 0, true);
|
|
1246
|
+
offset += 4;
|
|
1247
|
+
}
|
|
1248
|
+
if (flags & OcgcoreCommonConstants.QUERY_LSCALE) {
|
|
1249
|
+
view.setInt32(offset, source.lscale || 0, true);
|
|
1250
|
+
offset += 4;
|
|
1251
|
+
}
|
|
1252
|
+
if (flags & OcgcoreCommonConstants.QUERY_RSCALE) {
|
|
1253
|
+
view.setInt32(offset, source.rscale || 0, true);
|
|
1254
|
+
offset += 4;
|
|
1255
|
+
}
|
|
1256
|
+
if (flags & OcgcoreCommonConstants.QUERY_LINK) {
|
|
1257
|
+
view.setInt32(offset, source.link || 0, true);
|
|
1258
|
+
offset += 4;
|
|
1259
|
+
view.setInt32(offset, source.linkMarker || 0, true);
|
|
1260
|
+
offset += 4;
|
|
1261
|
+
}
|
|
1262
|
+
return new Uint8Array(view.buffer, view.byteOffset, offset);
|
|
1263
|
+
}
|
|
1264
|
+
__name(serializeCardQuery, "serializeCardQuery");
|
|
1260
1265
|
|
|
1261
1266
|
// src/proto-base/ygopro-proto-base.ts
|
|
1262
1267
|
var YGOProProtoBase = class extends PayloadBase {
|
|
@@ -5954,7 +5959,7 @@ var YGOProMsgUpdateCard = class extends YGOProMsgBase {
|
|
|
5954
5959
|
return this;
|
|
5955
5960
|
}
|
|
5956
5961
|
toPayload() {
|
|
5957
|
-
const cardPayload = this.card
|
|
5962
|
+
const cardPayload = serializeCardQuery(this.card);
|
|
5958
5963
|
const length = 4 + cardPayload.length;
|
|
5959
5964
|
const result = new Uint8Array(4 + length);
|
|
5960
5965
|
const view = new DataView(result.buffer);
|
|
@@ -6067,7 +6072,7 @@ var YGOProMsgUpdateData = class extends YGOProMsgBase {
|
|
|
6067
6072
|
let totalSize = 3;
|
|
6068
6073
|
const cardPayloads = [];
|
|
6069
6074
|
for (const card of this.cards || []) {
|
|
6070
|
-
const payload = card
|
|
6075
|
+
const payload = serializeCardQuery(card);
|
|
6071
6076
|
cardPayloads.push(payload);
|
|
6072
6077
|
totalSize += 4 + payload.length;
|
|
6073
6078
|
}
|
|
@@ -6900,6 +6905,7 @@ export {
|
|
|
6900
6905
|
YGOProStocWaitingSide,
|
|
6901
6906
|
fillBinaryFields,
|
|
6902
6907
|
isIndexResponse,
|
|
6908
|
+
serializeCardQuery,
|
|
6903
6909
|
toBinaryFields
|
|
6904
6910
|
};
|
|
6905
6911
|
//# sourceMappingURL=index.mjs.map
|