MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / setTarget

Function setTarget

scripts/wheelOfNames_hack.js:85–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83 }
84
85 function setTarget() {
86 let { values = [], offset } = getCurrentValues();
87
88 targets = targets.filter((_) => values.includes(_));
89 if (targets.length === 0) {
90 reset();
91 return;
92 }
93
94 let target = targets[0];
95 let index = values.indexOf(target);
96
97 if (index >= 0) {
98 let realIndex = index + offset;
99 if (offset && realIndex >= values.length)
100 realIndex = realIndex % values.length;
101 if (offset && realIndex < 0) realIndex = realIndex + values.length;
102
103 Math.random = () => contrain(realIndex / values.length, 0, 1);
104 console.log(
105 `Xong. Kết quả sẽ luôn là '${target}', index: ${realIndex}, Math.random = ${Math.random()}`
106 );
107 } else {
108 reset();
109 }
110 }
111
112 if (!targets && old_targets) {
113 reset();

Callers 1

Calls 4

getCurrentValuesFunction · 0.85
contrainFunction · 0.85
filterMethod · 0.80
resetFunction · 0.70

Tested by

no test coverage detected