Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Ján Plachý committed Aug 7, 2024
2 parents b6965a8 + 4fcbeae commit 60f32ae
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
20 changes: 16 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ async function home(req: SessionRequest) {
NOT: {
item: null
},
item: {
consumable: true
}
OR: [
{
item: {
consumable: true
}
},
{
item: {
tags: {
some: {
name: "lootbox"
}
},
}
}
]
},
select: {
id: true,
Expand Down Expand Up @@ -47,7 +60,6 @@ async function home(req: SessionRequest) {
item: null
},
item: {
consumable: true,
id: e.id
}
}
Expand Down
2 changes: 1 addition & 1 deletion pages/lootboxes/open/[transactionId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function getRewardPage(){
</div>

<div id="lootbox-reward-overlay">
<p id="lootbox-reward-overlay-text">Tu by mala byt napisana odmena.</p>
<p id="lootbox-reward-overlay-text">Čakám na spojenie s databázou...</p>
<br/>
<img id="lootbox-reward-overlay-picture" src="/static/pou.png"/>
</div>
Expand Down
41 changes: 22 additions & 19 deletions pages/shop/reward.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function generate_lootbox_reward(req: SessionRequest){
}

async function getItemsWithTag(tag: string) {
let items = await db.item!.findMany({
const items = await db.item!.findMany({
where: {
tags: {
some: {
Expand All @@ -40,38 +40,37 @@ async function getItemsWithTag(tag: string) {
}
}
})
console.log(items);
return items;
}

async function reward_item_common(req: SessionRequest){
let items = await getItemsWithTag("lootbox-item-common");
const items = await getItemsWithTag("lootbox-item-common");
items.sort(() => Math.random());
let item = items[0];
const item = items[0];
buy(req.session!.user.id, 0, item);
return [item.name, 0, item.image]; // Number means rarity here
}

async function reward_item_uncommon(req: SessionRequest){
let items = await getItemsWithTag("lootbox-item-uncommon");
const items = await getItemsWithTag("lootbox-item-uncommon");
items.sort(() => Math.random());
let item = items[0];
const item = items[0];
buy(req.session!.user.id, 0, item);
return [item.name, 1, item.image]; // Number means rarity here
}

async function reward_item_rare(req: SessionRequest){
let items = await getItemsWithTag("lootbox-item-rare");
const items = await getItemsWithTag("lootbox-item-rare");
items.sort(() => Math.random());
let item = items[0];
const item = items[0];
buy(req.session!.user.id, 0, item);
return [item.name, 2, item.image]; // Number means rarity here
}

async function reward_item_legendary(req: SessionRequest){
let items = await getItemsWithTag("lootbox-item-legendary");
const items = await getItemsWithTag("lootbox-item-legendary");
items.sort(() => Math.random());
let item = items[0];
const item = items[0];
buy(req.session!.user.id, 0, item);
return [item.name, 3, item.image]; // Number means rarity here
}
Expand All @@ -82,31 +81,35 @@ function reward_one_box(req: SessionRequest){
}

function reward_more_boxes(req: SessionRequest){
let number = Math.floor(Math.random() * 2 + 1);
const number = Math.floor(Math.random() * 2 + 1);
add_lootboxes(req, number);
return ["lootbox", number];
}

function reward_money_small(req: SessionRequest){
let number = Math.floor(Math.random() * 15 + 1);
async function reward_money_small(req: SessionRequest){
const team = await getTeamForUser(req.session!.user.id);
const number = Math.floor(Math.random() * team.money / 1000 * 2+ 1);
add_money(req, number);
return ["money", number];
}

function reward_money_medium(req: SessionRequest){
let number = Math.floor(Math.random() * 50 + 1);
async function reward_money_medium(req: SessionRequest){
const team = await getTeamForUser(req.session!.user.id);
const number = Math.floor(Math.random() * team.money / 300 * 2 + 1);
add_money(req, number);
return ["money", number];
}

function reward_money_big(req: SessionRequest){
let number = Math.floor(Math.random() * 250 + 1);
async function reward_money_big(req: SessionRequest){
const team = await getTeamForUser(req.session!.user.id);
const number = Math.floor(Math.random() * team.money / 100 * 2 + 1);
add_money(req, number);
return ["money", number];
}

function reward_money_huge(req: SessionRequest){
let number = Math.floor(Math.random() * 2500 + 1);
async function reward_money_huge(req: SessionRequest){
const team = await getTeamForUser(req.session!.user.id);
const number = Math.floor(Math.random() * team.money / 10 * 2 + 1);
add_money(req, number);
return ["money", number];
}
Expand Down

0 comments on commit 60f32ae

Please sign in to comment.