@bct-app/game-engine 0.1.14 → 0.1.15
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.js +27 -13
- package/dist/index.mjs +27 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1110,6 +1110,7 @@ var applyOperationToPlayers = ({
|
|
|
1110
1110
|
}
|
|
1111
1111
|
operationsByTimeline.get(timelineIndex)?.push(operation);
|
|
1112
1112
|
});
|
|
1113
|
+
const preconditionCache = /* @__PURE__ */ new Map();
|
|
1113
1114
|
const runReplay = (lifetimeSnapshotSeatMap) => {
|
|
1114
1115
|
const playersWithStatus = copyPlayers(players);
|
|
1115
1116
|
const applyOpsSequence = (ops) => {
|
|
@@ -1131,7 +1132,7 @@ var applyOperationToPlayers = ({
|
|
|
1131
1132
|
}
|
|
1132
1133
|
return snapshotSeatMap;
|
|
1133
1134
|
};
|
|
1134
|
-
ability.effects.forEach((effect) => {
|
|
1135
|
+
ability.effects.forEach((effect, effectIdx) => {
|
|
1135
1136
|
const resolvedTargets = resolveEffectTargets({
|
|
1136
1137
|
effect,
|
|
1137
1138
|
operation,
|
|
@@ -1144,18 +1145,31 @@ var applyOperationToPlayers = ({
|
|
|
1144
1145
|
return;
|
|
1145
1146
|
}
|
|
1146
1147
|
const precondition = "precondition" in effect ? effect.precondition : void 0;
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1148
|
+
let gatedTargets;
|
|
1149
|
+
if (precondition) {
|
|
1150
|
+
const cachedSeats = preconditionCache.get(operation)?.get(effectIdx);
|
|
1151
|
+
if (cachedSeats) {
|
|
1152
|
+
gatedTargets = resolvedTargets.filter((t) => cachedSeats.has(t.seat));
|
|
1153
|
+
} else {
|
|
1154
|
+
gatedTargets = evaluatePrecondition({
|
|
1155
|
+
expr: precondition,
|
|
1156
|
+
operationTimelineIdx: operationInTimelineIdx,
|
|
1157
|
+
nowTimelineIndex,
|
|
1158
|
+
timelines,
|
|
1159
|
+
effector,
|
|
1160
|
+
targets: resolvedTargets,
|
|
1161
|
+
snapshotSeatMap: playerSeatMap,
|
|
1162
|
+
characterMap,
|
|
1163
|
+
payloads,
|
|
1164
|
+
customResolver
|
|
1165
|
+
});
|
|
1166
|
+
const opCache = preconditionCache.get(operation) ?? /* @__PURE__ */ new Map();
|
|
1167
|
+
opCache.set(effectIdx, new Set(gatedTargets.map((t) => t.seat)));
|
|
1168
|
+
preconditionCache.set(operation, opCache);
|
|
1169
|
+
}
|
|
1170
|
+
} else {
|
|
1171
|
+
gatedTargets = resolvedTargets;
|
|
1172
|
+
}
|
|
1159
1173
|
if (gatedTargets.length === 0 && resolvedTargets.length > 0) {
|
|
1160
1174
|
return;
|
|
1161
1175
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1070,6 +1070,7 @@ var applyOperationToPlayers = ({
|
|
|
1070
1070
|
}
|
|
1071
1071
|
operationsByTimeline.get(timelineIndex)?.push(operation);
|
|
1072
1072
|
});
|
|
1073
|
+
const preconditionCache = /* @__PURE__ */ new Map();
|
|
1073
1074
|
const runReplay = (lifetimeSnapshotSeatMap) => {
|
|
1074
1075
|
const playersWithStatus = copyPlayers(players);
|
|
1075
1076
|
const applyOpsSequence = (ops) => {
|
|
@@ -1091,7 +1092,7 @@ var applyOperationToPlayers = ({
|
|
|
1091
1092
|
}
|
|
1092
1093
|
return snapshotSeatMap;
|
|
1093
1094
|
};
|
|
1094
|
-
ability.effects.forEach((effect) => {
|
|
1095
|
+
ability.effects.forEach((effect, effectIdx) => {
|
|
1095
1096
|
const resolvedTargets = resolveEffectTargets({
|
|
1096
1097
|
effect,
|
|
1097
1098
|
operation,
|
|
@@ -1104,18 +1105,31 @@ var applyOperationToPlayers = ({
|
|
|
1104
1105
|
return;
|
|
1105
1106
|
}
|
|
1106
1107
|
const precondition = "precondition" in effect ? effect.precondition : void 0;
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1108
|
+
let gatedTargets;
|
|
1109
|
+
if (precondition) {
|
|
1110
|
+
const cachedSeats = preconditionCache.get(operation)?.get(effectIdx);
|
|
1111
|
+
if (cachedSeats) {
|
|
1112
|
+
gatedTargets = resolvedTargets.filter((t) => cachedSeats.has(t.seat));
|
|
1113
|
+
} else {
|
|
1114
|
+
gatedTargets = evaluatePrecondition({
|
|
1115
|
+
expr: precondition,
|
|
1116
|
+
operationTimelineIdx: operationInTimelineIdx,
|
|
1117
|
+
nowTimelineIndex,
|
|
1118
|
+
timelines,
|
|
1119
|
+
effector,
|
|
1120
|
+
targets: resolvedTargets,
|
|
1121
|
+
snapshotSeatMap: playerSeatMap,
|
|
1122
|
+
characterMap,
|
|
1123
|
+
payloads,
|
|
1124
|
+
customResolver
|
|
1125
|
+
});
|
|
1126
|
+
const opCache = preconditionCache.get(operation) ?? /* @__PURE__ */ new Map();
|
|
1127
|
+
opCache.set(effectIdx, new Set(gatedTargets.map((t) => t.seat)));
|
|
1128
|
+
preconditionCache.set(operation, opCache);
|
|
1129
|
+
}
|
|
1130
|
+
} else {
|
|
1131
|
+
gatedTargets = resolvedTargets;
|
|
1132
|
+
}
|
|
1119
1133
|
if (gatedTargets.length === 0 && resolvedTargets.length > 0) {
|
|
1120
1134
|
return;
|
|
1121
1135
|
}
|