Skip to content

Commit

Permalink
Deploy preview for PR 5080 🛫
Browse files Browse the repository at this point in the history
  • Loading branch information
RedSparr0w committed Feb 9, 2024
1 parent da61e93 commit e7f4000
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
15 changes: 12 additions & 3 deletions docs/preview/pr-5080/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ <h5 class="card-header">
<div id="dungeonGuidesModalHelpTab" class="tab-pane fade col-10 offset-1 text-center">
<h4><u>Help</u></h4>
<p>Dungeon guides will automatically guide you through the dungeon, opening any chest they come accross, go down ladders they find and start boss battles.</p>
<p>They do not guarantee a successful dungeon clear, and will charge regardless of the outcome.</p>
<p>You must pay an upfront cost for however many clears you want to run of the dungeon <span class="text-danger">(non refundable)</span>, they will however give you a discount the more runs you purchase in one go.</p>
<p>Ensure you have sufficient Dungeon Tokens remaining to cover the cost of the dungeons themselves, as running out will bring your dungeon runs to an end early.</p>
<p>Each guide operates at their own speed, with some possessing a sense for specific dungeon tiles and others actively avoiding particular tiles whenever possible.</p>
</div>
</div>
Expand All @@ -777,7 +777,7 @@ <h5 class="modal-title">Explore Dungeon</h5>
</div>
<div class="modal-body text-left p-2">
<!-- ko if: player.town() instanceof DungeonTown -->
<table class="table table-striped table-hover m-0">
<table class="table table-striped table-hover m-0 text-center">
<tbody>
<tr>
<td>Dungeon Attempts</td>
Expand All @@ -788,13 +788,22 @@ <h5 class="modal-title">Explore Dungeon</h5>
</td>
</tr>
<tr>
<td>Total Cost</td>
<td>Guide Cost</td>
</tr>
<tr>
<td data-bind="foreach: DungeonGuides.calcCost()">
<knockout data-bind="template: { name: 'currencyTemplate', data: {'amount': $data.amount, 'currency': $data.currency}}"></knockout><br/>
</td>
</tr>
<tr>
<td>Dungeon Cost</td>
</tr>
<tr data-bind="with: DungeonGuides.calcDungeonCost()">
<td data-bind="template: { name: 'currencyTemplate', data: {'amount': $data.amount, 'currency': $data.currency}}"></td>
</tr>
<tr class="bg-danger">
<td>ALL CHARGES NON REFUNDABLE</td>
</tr>
</tbody>
<tfoot>
<tr>
Expand Down
39 changes: 26 additions & 13 deletions docs/preview/pr-5080/scripts/script.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -20367,11 +20367,20 @@ class DungeonGuides {
static calcCost() {
return this.list[this.selected()].calcCost(this.clears(), player.town().dungeon.tokenCost, player.region);
}
static canAfford() {
return this.calcCost().every((cost) => this.canAffordCurrency(cost));
static calcDungeonCost() {
return new Amount(player.town().dungeon.tokenCost * this.clears(), Currency.dungeonToken);
}
static canAffordCurrency(cost) {
return App.game.wallet.hasAmount(cost);
static canAfford() {
const costs = {
[Currency.dungeonToken]: this.calcDungeonCost(),
};
this.calcCost().forEach((cost) => {
var _a;
const tempAmount = (_a = costs[cost.currency]) !== null && _a !== void 0 ? _a : new Amount(0, cost.currency);
tempAmount.amount += cost.amount;
costs[cost.currency] = tempAmount;
});
return Object.values(costs).every((cost) => App.game.wallet.hasAmount(cost));
}
static hire() {
const guide = this.list[this.selected()];
Expand All @@ -20387,6 +20396,7 @@ class DungeonGuides {
}
// Charge the player
this.calcCost().forEach((cost) => App.game.wallet.loseAmount(cost));
App.game.wallet.loseAmount(this.calcDungeonCost());
// Hide modals
$('.modal.show').modal('hide');
// Hire the guide
Expand Down Expand Up @@ -20420,7 +20430,7 @@ DungeonGuides.add(new DungeonGuide('Jimmy', 'Doesn\'t really know their way arou
const randomTile = DungeonGuides.getRandomWeightedNearbyTile(nearbyTiles);
DungeonRunner.map.moveToTile(randomTile.position);
}));
DungeonGuides.add(new DungeonGuide('Timmy', 'Can smell when there is treasure chest on a tile near them!', [[5, Currency.money], [1, Currency.dungeonToken]], [new Amount(1, Currency.questPoint)], 2000, () => {
DungeonGuides.add(new DungeonGuide('Timmy', 'Can smell when there is treasure chest on a tile near them!', [[4, Currency.money], [1, Currency.dungeonToken]], [], 2000, () => {
// Get current position
const pos = DungeonRunner.map.playerPosition();
const nearbyTiles = DungeonRunner.map.nearbyTiles(pos);
Expand Down Expand Up @@ -20514,7 +20524,7 @@ DungeonGuides.add(new DungeonGuide('Georgia', 'Knows the path to the boss, avoid
const randomTile = DungeonGuides.getRandomWeightedNearbyTile(nearbyTiles);
DungeonRunner.map.moveToTile(randomTile.position);
}));
DungeonGuides.add(new DungeonGuide('Drake', 'Knows the shortest path to the boss!', [[25, Currency.money], [25, Currency.dungeonToken]], [new Amount(10, Currency.diamond)], 800, () => {
DungeonGuides.add(new DungeonGuide('Drake', 'Knows the shortest path to the boss!', [[20, Currency.money], [20, Currency.dungeonToken]], [new Amount(8, Currency.diamond)], 800, () => {
var _a, _b;
// Get current position
const pos = DungeonRunner.map.playerPosition();
Expand Down Expand Up @@ -20723,14 +20733,17 @@ class DungeonRunner {
return false;
}
DungeonRunner.dungeon = dungeon;
if (!DungeonRunner.hasEnoughTokens()) {
Notifier.notify({
message: 'You don\'t have enough Dungeon Tokens.',
type: NotificationConstants.NotificationOption.danger,
});
return false;
// Only charge the player if they aren't using a dungeon guide as they are charged when they start the dungeon
if (!DungeonGuides.hired()) {
if (!DungeonRunner.hasEnoughTokens()) {
Notifier.notify({
message: 'You don\'t have enough Dungeon Tokens.',
type: NotificationConstants.NotificationOption.danger,
});
return false;
}
App.game.wallet.loseAmount(new Amount(DungeonRunner.dungeon.tokenCost, GameConstants.Currency.dungeonToken));
}
App.game.wallet.loseAmount(new Amount(DungeonRunner.dungeon.tokenCost, GameConstants.Currency.dungeonToken));
// Reset any trainers/pokemon if there was one previously
DungeonBattle.trainer(null);
DungeonBattle.trainerPokemonIndex(0);
Expand Down

0 comments on commit e7f4000

Please sign in to comment.