Skip to content

Commit

Permalink
asdasdasd
Browse files Browse the repository at this point in the history
  • Loading branch information
leaftail1880 committed Aug 27, 2024
1 parent 4c26198 commit 6763948
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
7 changes: 6 additions & 1 deletion src/lib/quest/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ export abstract class QS<DB = any> extends Temporary {

restoring = false

private active = false

/**
* Enters player in this step
*
* @param firstTime - Whenether function is called in quest restore mode or in first time
*/
enter(firstTime: boolean) {
const cleanup = this.activate(firstTime)
this.active = true
if (cleanup) this.cleaners.push(cleanup.cleanup)

this.activators.forEach(activate => {
Expand Down Expand Up @@ -150,8 +153,9 @@ export abstract class QS<DB = any> extends Temporary {
this.currentPlace = place

if (!this.usingCompass) {
console.log('Setting interval', this.text())
this.onInterval(() => {
this.place && Vector.valid(this.place) && Compass.setFor(this.player, this.place)
this.active && this.place && Vector.valid(this.place) && Compass.setFor(this.player, this.place)
})
this.cleaners.push(() => {
Compass.setFor(this.player, undefined)
Expand Down Expand Up @@ -179,6 +183,7 @@ export abstract class QS<DB = any> extends Temporary {
this.intervalId = this.system.runInterval(
() => {
if (!this.player.isValid()) return
if (this.cleaned) return
this.intervals.forEach(e => e())
},
'quest step',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/rpg/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ContainerSlot, EquipmentSlot, ItemLockMode, ItemStack, ItemTypes, Playe
import { InventoryInterval } from 'lib/action'
import { CustomItems } from 'lib/assets/config'
import { MessageForm } from 'lib/form/message'
import { util } from 'lib/util'
import { stringifyError, util } from 'lib/util'
import { Vector } from 'lib/vector'
import { WeakPlayerMap, WeakPlayerSet } from 'lib/weak-player-storage'
import { ActionForm } from '../form/action'
Expand Down
11 changes: 5 additions & 6 deletions src/modules/places/anarchy/anarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ class AnarchyBuilder extends AreaWithInventory {
const title = Portal.canTeleport(player, { place: '§6> §cAnarchy §6<' })
if (!title) return

this.switchInventory(player)

if (!player.database.survival.anarchy) {
this.learningRTP(player).then(() => {
this.switchInventory(player)
showSurvivalHud(player)
})
} else {
this.switchInventory(player)

player.teleport(player.database.survival.anarchy)
delete player.database.survival.anarchy
showSurvivalHud(player)
title()
}

showSurvivalHud(player)
title()
})

this.portal.command
Expand Down
6 changes: 5 additions & 1 deletion src/modules/quests/learning/airdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ export default new Loot('starter')

.item(CustomItems.Money)
.chance('100%')
.amount({ '90...100': '1%' }).build
.amount({ '64': '100%' })

.item(CustomItems.Money)
.chance('100%')
.amount({ '64': '100%' }).build
34 changes: 22 additions & 12 deletions src/modules/quests/learning/learning.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ItemStack, system } from '@minecraft/server'
import { ActionForm, location, Vector } from 'lib'
import { ActionForm, location, Temporary, Vector } from 'lib'

import { MinecraftBlockTypes as b, MinecraftBlockTypes, MinecraftItemTypes } from '@minecraft/vanilla-data'
import { actionGuard, SafeAreaRegion } from 'lib'
Expand Down Expand Up @@ -27,12 +27,9 @@ class Learning {
id = 'learning'

quest = new Quest('learning', 'Обучение', 'Обучение базовым механикам сервера', (q, player) => {
if (!Anarchy.portal?.from || !Anarchy.portal.to) return q.failed('§cСервер не настроен')
if (!this.randomTeleportLocation.valid || !this.craftingTableLocation.valid)
return q.failed('§cОбучение не настроено')

q.place(Anarchy.portal.from, Anarchy.portal.to, '§6Зайди в портал анархии')

q.counter((current, end) => `§6Добыто дерева: §f${current}/${end}`, 5)
.description('Нарубите дерева')
.activate((ctx, firstTime) => {
Expand Down Expand Up @@ -259,7 +256,7 @@ class Learning {
player.info(
'§fСервер еще не готов. Если вы хотите стать строителем или тестером - подайте заявку на нашем дискорд сервере: §bdsc.gg/lushway§f, а пока вы можете только наблюдать.',
)
} else if (firstJoin) this.quest.enter(player)
}
})

Anarchy.learningRTP = async player => {
Expand All @@ -270,12 +267,25 @@ class Learning {
return
}

player.camera.fade({
fadeColor: { blue: 0, green: 0, red: 0 },
fadeTime: { fadeInTime: 0, holdTime: 90000, fadeOutTime: 2 },
const temp = new Temporary(({ system }) => {
system.runInterval(
() => {
if (player.database.inv !== 'anarchy') return temp.cleanup()

player.camera.fade({
fadeColor: { blue: 0, green: 0, red: 0 },
fadeTime: { fadeInTime: 0, holdTime: 3, fadeOutTime: 2 },
})
},
'asdada',
20,
)
})

return new Promise(r => {
console.log('Teleporting to', Vector.string(this.randomTeleportLocation))
player.teleport(this.randomTeleportLocation)

return new Promise(resolve => {
new ActionForm(
'Заметка',
'Ты - выживший, ты мало что умеешь, и просто так рубить блоки не можешь, да. Следуй по компасу.',
Expand All @@ -284,9 +294,9 @@ class Learning {
player.camera.fade({ fadeTime: { fadeInTime: 0, holdTime: 0, fadeOutTime: 2 } })
if (!this.randomTeleportLocation.valid) return

console.log('Teleporting to', Vector.string(this.randomTeleportLocation))
player.teleport(this.randomTeleportLocation)
r()
temp.cleanup()
resolve()
this.quest.enter(player)
})
.show(player)
})
Expand Down

0 comments on commit 6763948

Please sign in to comment.