Refactor and enhance mouse hold logic in animeCat.js
This commit is contained in:
35
animeCat.js
35
animeCat.js
@@ -261,18 +261,37 @@ _bindMouseHold() {
|
|||||||
this._startBlinking();
|
this._startBlinking();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Trostpreis: siehe oben
|
// Trostpreis: Augen auf, dann mouth_open oder mischievous
|
||||||
else if (heldFor > 1000) {
|
cleanup();
|
||||||
|
mouseDown = false;
|
||||||
reopenEyes();
|
reopenEyes();
|
||||||
const mouthOpenTime = Math.max(heldFor - 1000, 1000);
|
const heldFor = Date.now() - mouseDownAt;
|
||||||
if (mouthOpenTime > 0) {
|
|
||||||
this.img.src = this.images.mouthOpen || this.images.default;
|
if (heldFor > 1000) {
|
||||||
|
// mind. 1000ms oder (heldFor - 1000), je nachdem was größer ist
|
||||||
|
const mouthOpenTime = Math.max(heldFor - 1000, 1000);
|
||||||
|
|
||||||
|
// Bildwahl: mischievous ab 4. Mal, sonst mouth_open
|
||||||
|
let imgToShow = this.images.mouthOpen || this.images.default;
|
||||||
|
if (this._consolationCount >= 3) {
|
||||||
|
// Ab dem vierten Mal: mischievous immer, danach 20% Chance
|
||||||
|
if (
|
||||||
|
this._consolationCount === 3 ||
|
||||||
|
Math.random() < 0.2
|
||||||
|
) {
|
||||||
|
imgToShow = this.images.mischievous || imgToShow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.img.src = imgToShow;
|
||||||
|
this._consolationCount++;
|
||||||
this._startBlinking();
|
this._startBlinking();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!joyActive && !this._isSpeaking && !this._pettingActive) this.img.src = this.images.default;
|
if (!joyActive && !this._isSpeaking && !this._pettingActive) {
|
||||||
|
this.img.src = this.images.default;
|
||||||
|
}
|
||||||
}, mouthOpenTime);
|
}, mouthOpenTime);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this._startBlinking();
|
this._startBlinking();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user