Skip to content

Commit

Permalink
Merge pull request #19 from thecodeflayer/item-shuffle
Browse files Browse the repository at this point in the history
Item shuffle
  • Loading branch information
thecodeflayer authored Jul 9, 2020
2 parents 44a2506 + 647c52a commit 15d615e
Show file tree
Hide file tree
Showing 22 changed files with 302 additions and 67 deletions.
22 changes: 20 additions & 2 deletions app/GameSaveHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ export class GameSaveHelper {
standard: 'Standard',
inverted: 'Inverted'
}
static itemShuffleOptions = {
standard : {
id:'standard',
label: 'Standard'
},
mc: {
id:'mc',
label: 'Maps and Compasses'
},
mcsk: {
id: 'mcsk',
label: 'Maps, Compasses and Small Keys'
},
keysanity: {
id: 'keysanity',
label: 'Keysanity'
}
}
constructor() {
}

Expand All @@ -19,8 +37,8 @@ export class GameSaveHelper {
g.timestamp = this.parseDate(modelManager.gameSaves[key].timestamp);
g.valid = modelManager.validateGame(modelManager.gameSaves[key]);
g.loaded = modelManager.settings.gameSlot === key;
g.gameMode = this.labels[modelManager.settings.gameMode];
g.itemShuffle = this.labels[modelManager.settings.itemShuffle];
g.gameMode = this.labels[modelManager.gameSaves[key].settings.gameMode];
g.itemShuffle = this.itemShuffleOptions[modelManager.gameSaves[key].settings.itemShuffle].id;
}
retval[key]=g;
i++;
Expand Down
2 changes: 1 addition & 1 deletion app/components/DarkMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
dungeons: this.$modelManager.map.darkworld.dungeons,
bosses: this.$modelManager.map.darkworld.bosses,
dungeonValues: this.$modelManager.dungeons,
staticDungeonValues: this.$sol.getStaticDungeons(this.$modelManager.getGameMode()),
staticDungeonValues: this.$sol.getStaticDungeons(this.$modelManager.getGameMode(), this.$modelManager.getItemShuffle()),
centerKey: undefined
},
mapWidth:1500,
Expand Down
13 changes: 7 additions & 6 deletions app/components/Dungeons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
</template>

<script>
//import {staticDungeons} from "~/standard/staticDungeons";
import {GameSaveHelper} from "~/GameSaveHelper";
export default {
data: function() {
Expand All @@ -40,14 +41,14 @@
} else if (typeof this.$modelManager.getDungeonValue(key, item) === "number") {
let val = -1;
let max = 'max'+item.substr(0, 1).toUpperCase()+item.substr(1);
if(item === 'chests' || item === 'smallkeys') {
if(item === 'chests' || (item === 'smallkeys' && this.$modelManager.getItemShuffle() === GameSaveHelper.itemShuffleOptions.standard.id)) {
val = this.$modelManager.getDungeonValue(key, item) - 1;
if(val < 0) {
val = this.$sol.getStaticDungeons(this.$modelManager.getGameMode())[key][max];
val = this.$sol.getStaticDungeons(this.$modelManager.getGameMode(), this.$modelManager.getItemShuffle())[key][max];
}
} else {
val = this.$modelManager.getDungeonValue(key, item) + 1;
if(val > this.$sol.getStaticDungeons(this.$modelManager.getGameMode())[key][max]) {
if(val > this.$sol.getStaticDungeons(this.$modelManager.getGameMode(), this.$modelManager.getItemShuffle())[key][max]) {
val = 0;
}
}
Expand All @@ -72,13 +73,13 @@
const keys = this.$modelManager.getDungeonKeys();
for(const key of keys) {
retval.bosses[key] = '~/img/dungeons/'+key+'_boss'+(dungeons[key].boss ? '1' : '0')+'.png';
retval.crystals[key] = this.$sol.getStaticDungeons(this.$modelManager.getGameMode())[key].maxCrystal === 0 ? '~/img/dungeons/blank.png' : '~/img/dungeons/crystal'+dungeons[key].crystal+'.png';
retval.crystals[key] = this.$sol.getStaticDungeons(this.$modelManager.getGameMode(), this.$modelManager.getItemShuffle())[key].maxCrystal === 0 ? '~/img/dungeons/blank.png' : '~/img/dungeons/crystal'+dungeons[key].crystal+'.png';
retval.chests[key] = '~/img/dungeons/chest'+dungeons[key].chests+'.png';
retval.bosskeys[key] = key === 'aga' ? '~/img/dungeons/blank.png' : '~/img/dungeons/bosskey'+(dungeons[key].bosskey ? '1' : '0')+'.png';
retval.maps[key] = key === 'aga' ? '~/img/dungeons/blank.png' : '~/img/dungeons/map'+(dungeons[key].map ? '1' : '0')+'.png';
retval.compasses[key] = key === 'aga' ? '~/img/dungeons/blank.png' : '~/img/dungeons/compass'+(dungeons[key].compass ? '1' : '0')+'.png';
retval.smallkeys[key] = '~/img/dungeons/smallkey'+dungeons[key].smallkeys+'.png';
retval.medallion[key] = this.$sol.getStaticDungeons(this.$modelManager.getGameMode())[key].maxMedallion === 0 ? '~/img/dungeons/blank.png' : '~/img/dungeons/medallion'+dungeons[key].medallion+'.png';
retval.medallion[key] = this.$sol.getStaticDungeons(this.$modelManager.getGameMode(), this.$modelManager.getItemShuffle())[key].maxMedallion === 0 ? '~/img/dungeons/blank.png' : '~/img/dungeons/medallion'+dungeons[key].medallion+'.png';
}
return retval;
},
Expand Down
225 changes: 192 additions & 33 deletions app/components/GameEdit.vue
Original file line number Diff line number Diff line change
@@ -1,65 +1,153 @@
<template>
<Page backgroundColor="black">
<Navbar></Navbar>
<StackLayout orientation="vertical" class="save-wrapper"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">
<Label :text="game.name +(game.loaded ? ': Active Game':'')" fontSize="24" />
<Label v-if="!game.timestamp" text="Game Slot Empty"/>
<Label v-if="game.timestamp" :text="'Game Mode: '+game.gameMode"/>
<Label v-if="game.timestamp" :text="'Item Shuffle: '+game.itemShuffle"/>
<Label height="15"/>
<Button v-if="!game.loaded && game.valid && game.timestamp" class="btn" @tap="loadGame"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Load Game</Button>
<Button v-if="!game.timestamp" class="btn" @tap="createGame"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Create New Game</Button>
<Button v-if="allowDelete && game.timestamp && !game.loaded" class="btn" @tap="deleteGame"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Delete</Button>
<Button v-if="game.loaded" class="btn" @tap="resetItems"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Reset Items</Button>
<Button v-if="game.loaded" class="btn" @tap="resetDungeons"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Reset Dungeons</Button>
<Button v-if="game.loaded" class="btn" @tap="resetMap"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Reset Map</Button>
<Button class="btn" @tap="cancel"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Back</Button>
<Label height="15"/>
<Label v-if="!game.timestamp" textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: Game options coming soon! For now all games are Standard."/>
<Label v-if="allowDelete && game.timestamp && game.loaded" textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: You cannot delete the active game. Load another game before deleting this one."/>
<Label v-if="!allowDelete && game.timestamp" textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: At least one game must be active. Create another game using an empty game slot before deleting this game."/>

</StackLayout>
<GridLayout>
<StackLayout v-if="(game.timestamp && game.valid)" :key="updateKey"
orientation="vertical" class="save-wrapper" :class="game.loaded ? 'loaded' : 'valid'">
<Label :text="game.name +(game.loaded ? ': Active Game':'')" fontSize="24" />
<Label :text="'Game Mode: '+game.gameMode"/>
<Label :text="'Item Shuffle: '+itemShuffleOptions[game.itemShuffle].label"/>
<Label height="15"/>
<Button :visibility="!game.loaded && game.valid && game.timestamp ? 'visible': 'collapsed'" class="btn" @tap="loadGame"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Load Game</Button>
<Button :visibility="allowDelete && game.timestamp && !game.loaded ? 'visible': 'collapsed'" class="btn" @tap="openModal('deleteGame')"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Delete</Button>
<Button :visibility="game.loaded ? 'visible': 'collapsed'" class="btn" @tap="openModal('resetItems')"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Reset Items</Button>
<Button :visibility="game.loaded ? 'visible': 'collapsed'" class="btn" @tap="openModal('resetDungeons')"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Reset Dungeons</Button>
<Button :visibility="game.loaded ? 'visible': 'collapsed'" class="btn" @tap="openModal('resetMap')"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Reset Map</Button>
<Button class="btn" @tap="cancel"
:class="game.loaded ? 'loaded' : !game.timestamp ? 'empty' : game.valid ? 'valid': 'invalid'">Back</Button>
<Label height="15"/>
<Label :visibility="allowDelete && game.timestamp && game.loaded ? 'visible': 'collapsed'" textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: You cannot delete the active game. Load another game before deleting this one."/>
<Label :visibility="!allowDelete && game.timestamp ? 'visible': 'collapsed'" textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: At least one game must be active. Create another game using an empty game slot before deleting this game."/>
</StackLayout>
<StackLayout v-if="(game.timestamp && !game.valid)" :key="updateKey"
orientation="vertical" class="save-wrapper invalid">
<Label :text="game.name" fontSize="24" />
<Label :text="'Game Mode: '+game.gameMode"/>
<Label :text="'Item Shuffle: '+itemShuffleOptions[game.itemShuffle].label"/>
<Button :visibility="allowDelete && game.timestamp && !game.loaded ? 'visible': 'collapsed'"
class="btn invalid" @tap="deleteGame">Delete</Button>
<Label textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: This game is based on an old version. You must delete this game."/>
<Label :visibility="!allowDelete && game.timestamp ? 'visible': 'collapsed'" textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: At least one game must be active. Create another game using an empty game slot before deleting this game."/>
</StackLayout>
<StackLayout v-if="!game.timestamp" orientation="vertical" class="save-wrapper empty" :key="updateKey">
<Label :text="game.name" fontSize="24" />
<Label text="Game Slot Empty"/>
<StackLayout orientation="vertical">
<Label text="Game Mode: Standard"/>
<Label text="Item Shuffle:"/>
<StackLayout orientation="horizontal" v-for="key in itemShuffleKeys" @tap="clickItemShuffle(key)">
<Image :key="updateKey" :src="getItemShuffleCheckImage(key)" width="20" height="20" />
<Label :text="itemShuffleOptions[key].label" verticalAlignment="center" marginLeft="5" fontSize="20" />
</StackLayout>
</StackLayout>
<Label height="15"/>
<Button class="btn empty" @tap="createGame">Create New Game</Button>
<Button class="btn empty" @tap="cancel">Back</Button>
<Label height="15"/>
<Label textWrap="true" fontSize="16" textAlignment="center"
text="NOTE: More game options coming soon!"/>
</StackLayout>
<AbsoluteLayout class="modal-wrapper" :class="{'open': modalOpen, 'closed':!modalAnimating}">
<AbsoluteLayout class="modal-bg" @tap="interceptClick"/>
<StackLayout orientation="vertical" class="modal-dialog" :width="modalWidth" :class="{'open': modalOpen}">
<Label :visibility="modalAction === 'deleteGame' ? 'visible':'collapsed'" textWrap="true"
textAlignment="center" style="padding-bottom: 10"
text="Are you sure you want to delete this game?"/>
<Label :visibility="modalAction === 'resetItems' ? 'visible':'collapsed'" textWrap="true"
textAlignment="center" style="padding-bottom: 10"
text="Are you sure you want to reset the item data for this game?"/>
<Label :visibility="modalAction === 'resetDungeons' ? 'visible':'collapsed'" textWrap="true"
textAlignment="center" style="padding-bottom: 10"
text="Are you sure you want to reset the dungeon data for this game?"/>
<Label :visibility="modalAction === 'resetMap' ? 'visible':'collapsed'" textWrap="true"
textAlignment="center" style="padding-bottom: 10"
text="Are you sure you want to reset the map data for this game?"/>
<Label text="This cannot be undone!" textAlignment="center" style="padding-bottom: 10"/>
<Button class="btn invalid" @tap="closeModal(true)">OK</Button>
<Button class="btn invalid" @tap="closeModal(false)">Cancel</Button>
</StackLayout>
</AbsoluteLayout>
</GridLayout>
</Page>
</template>

<script>
import SaveList from "~/components/SaveList";
import {GameSaveHelper} from "~/GameSaveHelper";
import {screen} from 'tns-core-modules/platform';
export default {
props:['game'],
props:['game_id'],
data: function() {
return {
allowDelete: this.$modelManager.allowGameDelete()
allowDelete: this.$modelManager.allowGameDelete(),
itemShuffleOptions: GameSaveHelper.itemShuffleOptions,
itemShuffleKeys: Object.keys(GameSaveHelper.itemShuffleOptions),
game: GameSaveHelper.parseGameSaves(this.$modelManager)[this.$props.game_id],
updateKey:Date.now(),
modalOpen:false,
screen: screen,
modalWidth: 0,
modalAnimating: false,
modalAction: undefined
}
},
created() {
this.checkEmptyGameState();
this.modalWidth = (this.screen.mainScreen.widthPixels / this.screen.mainScreen.scale) - 40;
console.log(this.modalWidth);
},
mounted() {
},
methods: {
interceptClick() {
console.log('no clicky!');
},
openModal(opt) {
this.modalAction = opt;
this.modalOpen = true;
this.modalAnimating=true;
},
closeModal(doAction) {
if(doAction){
if(this.modalAction === 'deleteGame') {
this.deleteGame();
} else if(this.modalAction === 'resetItems'){
this.resetItems();
} else if(this.modalAction === 'resetDungeons'){
this.resetDungeons();
} else if(this.modalAction === 'resetMap'){
this.resetMap();
}
}
this.modalAction = undefined;
this.modalOpen = false;
setTimeout(()=>{this.modalAnimating=false;},500);
},
loadGame() {
this.$modelManager.loadGame(this.game.id);
this.$navigateTo(SaveList);
},
createGame() {
this.$modelManager.createGame(this.game.id);
if(!this.game.itemShuffle) {return; }
this.$modelManager.createGame(this.game.id, this.game.itemShuffle);
this.game = GameSaveHelper.parseGameSaves(this.$modelManager)[this.game.id];
this.updateKey = Date.now();
},
deleteGame() {
this.$modelManager.deleteGame(this.game.id);
this.game = GameSaveHelper.parseGameSaves(this.$modelManager)[this.game.id];
this.checkEmptyGameState();
},
cancel() {
this.$navigateTo(SaveList);
Expand All @@ -72,6 +160,19 @@
},
resetMap() {
this.$modelManager.resetMap();
},
clickItemShuffle(id) {
this.game.itemShuffle = id;
this.updateKey = Date.now();
},
checkEmptyGameState(){
if(!this.game.timestamp) {
this.game.itemShuffle = this.itemShuffleOptions.standard.id;
}
this.updateKey = Date.now();
},
getItemShuffleCheckImage(key) {
return this.game.itemShuffle === key ? '~/img/checked.png' : '~/img/unchecked.png';
}
}
};
Expand Down Expand Up @@ -133,4 +234,62 @@
background-color: darkred;
}
}
.modal-wrapper {
visibility: visible;
width: 100%;
height: 100%;
background-color: transparent;
animation-name:fade-out;
animation-duration: 500ms;
animation-fill-mode: forwards;
&.closed {
visibility: collapsed;
}
&.open {
visibility: visible;
animation-duration: 500ms;
animation-name:fade-in;
animation-fill-mode: forwards;
}
}
.modal-bg {
background-color: black;
opacity: 0.4;
width: 100%;
height: 100%;
}
.modal-dialog {
background-color: darkred;
border-width: 2px;
border-color: #004c00;
padding: 10;
margin: 20;
color: white;
font-family: "Return of Ganon", "ReturnofGanon";
font-size: 20;
animation-name:slide-up;
animation-duration: 500ms;
animation-fill-mode: forwards;
&.open {
animation-duration: 1s;
animation-name:slide-down;
animation-fill-mode: forwards;
}
}
@keyframes fade-out {
from {opacity: 1;}
to {opacity: 0;}
}
@keyframes fade-in {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes slide-up {
from {transform:translate(0,0);}
to {transform:translate(0,-400);}
}
@keyframes slide-down {
from {transform:translate(0,-400);}
to {transform:translate(0,0);}
}
</style>
Loading

0 comments on commit 15d615e

Please sign in to comment.