add feature to disable IAPs, add warnings for import and cloud overwrite for IAP, move $ to the left, fix shop button alignment

This commit is contained in:
IvarK 2022-08-15 22:31:09 +03:00
parent 344a27997e
commit 1f3d293203
11 changed files with 126 additions and 20 deletions

View File

@ -265,6 +265,7 @@ Modal.addCloudConflict = function(saveId, saveComparison, cloudSave, localSave,
imaginaryMachines: 0,
dilatedTime: new Decimal(0),
bestLevel: 0,
totalSTD: 0
};
resources.realTimePlayed = save.records.realTimePlayed;
resources.totalAntimatter.copyFrom(new Decimal(save.records.totalAntimatter));
@ -277,6 +278,7 @@ Modal.addCloudConflict = function(saveId, saveComparison, cloudSave, localSave,
resources.imaginaryMachines = save.reality.iMCap;
resources.dilatedTime.copyFrom(new Decimal(save.dilation.dilatedTime));
resources.bestLevel = save.records.bestReality.glyphLevel;
resources.totalSTD = save?.IAP?.totalSTD ?? 0;
return resources;
}

View File

@ -49,12 +49,12 @@ class ShopPurchaseState extends RebuyableMechanicState {
get currentMult() {
if (!this.displayMult) return "";
return this.config.multiplier(this.purchases);
return this.config.multiplier(player.IAP.disabled ? 0 : this.purchases);
}
get nextMult() {
if (!this.displayMult) return "";
return this.config.multiplier(this.purchases + 1);
return this.config.multiplier(player.IAP.disabled ? 0 : this.purchases + 1);
}
purchase() {

View File

@ -884,6 +884,7 @@ window.player = {
allDimPurchases: 0,
replicantiPurchases: 0,
dilatedTimePurchases: 0,
disabled: false,
checkoutSession: {
id: false,
}

View File

@ -5775,6 +5775,12 @@ br {
width: 45rem;
}
.c-modal-IAP__warning {
color: #ff6666;
font-size: 1.6rem;
font-weight: bold;
}
/* #endregion c-modal-import */
/* #region c-modal-import-tree */

View File

@ -10,7 +10,8 @@ export default {
},
data() {
return {
input: ""
input: "",
importCounter: 0,
};
},
computed: {
@ -49,6 +50,12 @@ export default {
},
inputIsSecret() {
return isSecretImport(this.input) || Theme.isSecretTheme(this.input);
},
hasLessSTDs() {
return player.IAP.totalSTD > (this.player?.IAP?.totalSTD ?? 0);
},
clicksLeft() {
return 5 - this.importCounter;
}
},
mounted() {
@ -56,6 +63,8 @@ export default {
},
methods: {
importSave() {
this.importCounter++;
if (this.hasLessSTDs && this.clicksLeft > 0) return;
if (!this.inputIsValid) return;
this.emitClose();
GameStorage.import(this.input);
@ -101,6 +110,13 @@ export default {
<div class="c-modal-import__warning">
(your current save file will be overwritten!)
</div>
<div
v-if="hasLessSTDs"
class="c-modal-IAP__warning"
>
IMPORTED SAVE HAS LESS STDs BOUGHT, YOU WILL LOSE THEM WITH YOUR SAVE.
<b />CLICK THE BUTTON 5 TIMES TO CONFIRM.
</div>
</template>
<div v-else-if="hasInput">
Not a valid save:
@ -114,7 +130,7 @@ export default {
class="o-primary-btn--width-medium c-modal-message__okay-btn c-modal__confirm-btn"
@click="importSave"
>
Import
Import <span v-if="hasLessSTDs">({{ clicksLeft }})</span>
</PrimaryButton>
</ModalWrapperChoice>
</template>
</template>

View File

@ -35,6 +35,16 @@ export default {
type: String,
required: false,
default: undefined
},
confirmFn: {
type: Function,
required: false,
default: undefined
},
cancelFn: {
type: Function,
required: false,
default: undefined
}
},
created() {
@ -42,12 +52,18 @@ export default {
},
methods: {
doConfirm() {
this.$emit("confirm");
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);
if (this.confirmFn) this.confirmFn();
else {
this.$emit("confirm");
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);
}
},
doCancel() {
this.$emit("cancel");
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);
if (this.cancelFn) this.cancelFn();
else {
this.$emit("cancel");
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);
}
},
closeModal() {
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);

View File

@ -31,7 +31,7 @@ export default {
class="o-modal-store-btn"
@click="purchase"
>
<span>{{ cost }}</span> $
$<span>{{ cost }}</span>
</button>
</div>
</template>

View File

@ -8,6 +8,11 @@ export default {
ModalWrapperChoice,
CloudConflictRecordModal,
},
data() {
return {
overwriteCounter: 0,
};
},
computed: {
conflict() {
return this.$viewModel.modal.cloudConflict;
@ -17,11 +22,20 @@ export default {
},
farther() {
return this.conflict.saveComparison.farther === 1;
},
hasLessSTDs() {
return this.conflict.local.totalSTD > this.conflict.cloud.totalSTD;
},
clicksLeft() {
return 5 - this.overwriteCounter;
}
},
methods: {
confirm() {
this.overwriteCounter++;
if (this.hasLessSTDs && this.clicksLeft > 0) return;
this.conflict.onAccept?.();
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);
}
}
};
@ -32,7 +46,7 @@ export default {
class="c-modal-options__large"
:cancel-class="'c-modal-message__okay-btn'"
:confirm-class="'c-modal-message__okay-btn c-modal__confirm-btn'"
@confirm="confirm"
:confirm-fn="confirm"
>
<template #header>
Load Game from Cloud
@ -61,11 +75,18 @@ export default {
:save-id="conflict.saveId"
save-type="Cloud Save"
/>
<div
v-if="hasLessSTDs"
class="c-modal-IAP__warning"
>
CLOUD SAVE HAS LESS STDs BOUGHT, YOU WILL LOSE THEM IF YOU OVERWRITE.
<b />CLICK THE BUTTON 5 TIMES TO CONFIRM.
</div>
<template #cancel-text>
Keep Local Save
</template>
<template #confirm-text>
Overwrite Local with Cloud Save
Overwrite Local with Cloud Save <span v-if="hasLessSTDs">({{ clicksLeft }})</span>
</template>
</ModalWrapperChoice>
</template>
</template>

View File

@ -8,6 +8,11 @@ export default {
ModalWrapperChoice,
CloudConflictRecordModal,
},
data() {
return {
overwriteCounter: 0,
};
},
computed: {
conflict() {
return this.$viewModel.modal.cloudConflict;
@ -17,6 +22,12 @@ export default {
},
farther() {
return this.conflict.saveComparison.farther === -1;
},
hasLessSTDs() {
return this.conflict.cloud.totalSTD > this.conflict.local.totalSTD;
},
clicksLeft() {
return 5 - this.overwriteCounter;
}
},
methods: {
@ -26,6 +37,14 @@ export default {
if (accepted) {
this.conflict.onAccept?.();
}
},
cancel() {
this.overwriteCounter++;
if (this.hasLessSTDs && this.clicksLeft > 0) return;
Cloud.hasSeenSavingConflict = true;
Cloud.shouldOverwriteCloudSave = true;
this.conflict.onAccept?.();
EventHub.dispatch(GAME_EVENT.CLOSE_MODAL);
}
},
};
@ -36,7 +55,7 @@ export default {
class="c-modal-options__large"
:cancel-class="'c-modal-message__okay-btn'"
:confirm-class="'c-modal-message__okay-btn c-modal__confirm-btn'"
@cancel="saveClick(true)"
:cancel-fn="cancel"
@confirm="saveClick(false)"
>
<template #header>
@ -67,11 +86,18 @@ export default {
<br>
Would you like to overwrite the Cloud Save? Your choice here will apply for every
time the game automatically attempts to Cloud Save, until the page is reloaded.
<div
v-if="hasLessSTDs"
class="c-modal-IAP__warning"
>
LOCAL SAVE HAS LESS STDs BOUGHT, YOU WILL LOSE THEM IF YOU OVERWRITE.
<b />CLICK THE BUTTON 5 TIMES TO CONFIRM.
</div>
<template #cancel-text>
Overwrite Cloud Save
Overwrite Cloud Save <span v-if="hasLessSTDs">({{ clicksLeft }})</span>
</template>
<template #confirm-text>
Do not overwrite
</template>
</ModalWrapperChoice>
</template>
</template>

View File

@ -56,6 +56,10 @@ export default {
border-radius: var(--var-border-radius, 0.5rem);
margin: 0.5rem;
padding: 1rem;
height: 16rem;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.o-shop-button-button {
@ -65,8 +69,7 @@ export default {
background: turquoise;
border: none;
border-radius: var(--var-border-radius, 0.5rem);
margin: auto;
margin-top: 1rem;
margin: 0 auto;
padding: 0.5rem 2rem;
cursor: pointer;
}

View File

@ -5,18 +5,22 @@ import Loading from "vue-loading-overlay";
import Payments from "../../../../javascripts/core/payments";
import PrimaryToggleButton from "../../PrimaryToggleButton";
import ShopButton from "./ShopButton";
export default {
name: "ShopTab",
components: {
ShopButton,
Loading
Loading,
PrimaryToggleButton
},
data() {
return {
STD: 0,
isLoading: false
isLoading: false,
IAPsDisabled: false,
};
},
computed: {
@ -27,10 +31,16 @@ export default {
return "Buy More";
}
},
watch: {
IAPsDisabled(newValue) {
player.IAP.disabled = newValue;
}
},
methods: {
update() {
this.STD = player.IAP.totalSTD - player.IAP.spentSTD;
this.isLoading = Boolean(player.IAP.checkoutSession.id);
this.IAPsDisabled = player.IAP.disabled;
},
showStore() {
SecretAchievement(33).unlock();
@ -49,6 +59,11 @@ export default {
Disclaimer: These are not required to progress in the game, they are just for supporting the developer.
The game is balanced without the use of any microtransactions.
</div>
<PrimaryToggleButton
v-model="IAPsDisabled"
class="o-primary-btn--subtab-option"
label="Disable in-app-purchases:"
/>
<div class="c-shop-header">
<span>You have {{ STD }}</span>
<img