Skip to content

Commit

Permalink
new(shard deal): Done (pokeclicker#5385)
Browse files Browse the repository at this point in the history
Co-authored-by: Qwertypop04 <[email protected]>
  • Loading branch information
RegisCoaxans and Qwertypop04 authored Jul 9, 2024
1 parent 07c077a commit 60b0f8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/shardTraderModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4 data-bind='text: ShopHandler.shopObservable?.().name'></h4>
<td class='vertical-middle' data-bind="attr: { rowspan: $parent.shards.length }, text: $parent.questPointCost.toLocaleString('en-US')"></td>
<!-- TODO: Make the QP symbol appear in the same TD as the QP Cost -->
<td class='vertical-middle' data-bind="attr: { rowspan: $parent.shards.length }">
<img src='assets/images/currency/questPoint.svg' width="20px'">
<img src='assets/images/currency/questPoint.svg' width="20px" data-bind="attr: { src: `assets/images/currency/${GameConstants.Currency[$parent.currencyType]}.svg`}">
</td>
<td class='vertical-middle' data-bind="attr: { rowspan: $parent.shards.length }"></td>
<td class='vertical-middle' data-bind="attr: { rowspan: $parent.shards.length }">
Expand Down Expand Up @@ -74,7 +74,7 @@ <h4 data-bind='text: ShopHandler.shopObservable?.().name'></h4>
</div>
<div class="modal-footer">
<span>Total Quest Points: <span data-bind="text: App.game.wallet.currencies[GameConstants.Currency.questPoint]().toLocaleString('en-US')">-</span></span>
<img src='assets/images/currency/questPoint.svg' width="20px'">
<img src='assets/images/currency/questPoint.svg' width="20px">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/items/ItemList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ ItemList['Grotle (Acorn)'] = new PokemonItem('Grotle (Acorn)');
ItemList.Combee = new PokemonItem('Combee', 6750);
ItemList['Burmy (Plant)'] = new PokemonItem('Burmy (Plant)', 6750);
ItemList.Cherubi = new PokemonItem('Cherubi', 6750);
ItemList.Spiritomb = new PokemonItem('Spiritomb', 6750);
ItemList.Spiritomb = new PokemonItem('Spiritomb', 432, Currency.diamond);
// Unova
ItemList.Zorua = new PokemonItem('Zorua', 50625);
ItemList['Meloetta (Pirouette)'] = new PokemonItem('Meloetta (Pirouette)', 200000);
Expand Down
14 changes: 11 additions & 3 deletions src/modules/underground/ShardDeal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export class ShardDeal {
public shards: ShardCost[];
public item: { itemType: Item, amount: number };
public questPointCost: number;
public currencyType: Currency;
public static list: Partial<Record<ShardTraderLocations, KnockoutObservableArray<ShardDeal>>> = {};

constructor(shardCosts: ShardCost[], item: Item, itemAmount: number) {
this.shards = shardCosts;
this.shards.forEach((s) => { s.shardType = UndergroundItems.getByName(s.shardTypeString); });
this.item = { itemType: item, amount: itemAmount };
this.questPointCost = this.item.itemType.basePrice / 4 || 1;
this.currencyType = this.item.itemType.currency ?? Currency.questPoint;
}

public isVisible(): boolean {
Expand All @@ -41,7 +43,7 @@ export class ShardDeal {
}
if (ItemList[deal.item.itemType.name].isSoldOut()) {
return false;
} else if (deal.questPointCost > App.game.wallet.currencies[Currency.questPoint]()) {
} else if (deal.questPointCost > App.game.wallet.currencies[deal.currencyType]()) {
return false;
} else {
return deal.shards.every((value) => player.itemList[value.shardType.itemName]() >= value.amount);
Expand All @@ -56,14 +58,14 @@ export class ShardDeal {
const maxShardTrades = Math.floor(amt / shard.amount);
return maxShardTrades;
});
const qp = App.game.wallet.currencies[Currency.questPoint]();
const qp = App.game.wallet.currencies[deal.currencyType]();
const maxCurrencyTrades = Math.floor(qp / deal.questPointCost);
const maxTrades = Math.min(maxCurrencyTrades, trades.reduce((a, b) => Math.min(a, b), tradeTimes));
deal.shards.forEach((value) => player.loseItem(value.shardType.itemName, value.amount * maxTrades));

const amount = deal.item.amount * maxTrades;
deal.item.itemType.gain(deal.item.amount * maxTrades);
App.game.wallet.loseAmount(new Amount(deal.questPointCost * maxTrades, Currency.questPoint));
App.game.wallet.loseAmount(new Amount(deal.questPointCost * maxTrades, deal.currencyType));
Notifier.notify({
message: `You traded for ${amount.toLocaleString('en-US')} × <img src="${deal.item.itemType.image}" height="24px"/> ${pluralizeString(humanifyString(deal.item.itemType.displayName), amount)}.`,
type: NotificationConstants.NotificationOption.success,
Expand Down Expand Up @@ -731,6 +733,12 @@ export class ShardDeal {
);
ShardDeal.list[ShardTraderLocations['Solaceon Town']] = ko.observableArray(
[
new ShardDeal(
[
{ shardTypeString: 'Odd Keystone', amount: 1 },
],
ItemList.Spiritomb,
1),
new ShardDeal(
[
{ shardTypeString: 'Yellow Shard', amount: 20 },
Expand Down
1 change: 0 additions & 1 deletion src/scripts/towns/TownList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3993,7 +3993,6 @@ const SolaceonTownShop = new Shop([
ItemList.Shiny_stone,
ItemList.Dusk_stone,
ItemList.Dawn_stone,
ItemList.Spiritomb,
]);
const PastoriaShop = new Shop([
ItemList.Pokeball,
Expand Down

0 comments on commit 60b0f8b

Please sign in to comment.