|
| 1 | +import { displayDialogue, displayPermissionBox } from '../../utils'; |
| 2 | + |
| 3 | +const alredyUnlockText = ['The challenge is waiting for you!']; |
| 4 | + |
| 5 | +const firstText = [ |
| 6 | + 'You shall not pass! Bruruuuuu!', |
| 7 | + 'Hehe, you’ve found me, just as I was practicing my lines!', |
| 8 | + 'Cof cof… the dust of ancient tomes, no doubt!', |
| 9 | + 'I am the Mage of the House, keeper of secrets, and I hold a special challenge within the depths of this computer!', |
| 10 | + 'I can unlock the computer for thee, but beware—thou shalt have but one chance to find the right answer!', |
| 11 | +]; |
| 12 | + |
| 13 | +const questionText = [ |
| 14 | + 'Do you dare to try thy hand at this most perilous trial?', |
| 15 | +]; |
| 16 | + |
| 17 | +const spell = [ |
| 18 | + 'By the stars above, and the code beneath, unlock this mystery, to test their wit and feat!', |
| 19 | + 'The computer suddenly glows with a bright light, and the screen changes to show a challenge.', |
| 20 | +]; |
| 21 | + |
| 22 | +const noSpell = [ |
| 23 | + 'It does not seem like thou art yet prepared for the challenge...', |
| 24 | +]; |
| 25 | + |
| 26 | +export const mageInteractions = async (player, k, map) => { |
| 27 | + const [computer] = map.query({ include: 'computer' }); |
| 28 | + let mageInteractionCounter = 0; |
| 29 | + player.state.alreadyTalkedToMage = false; |
| 30 | + |
| 31 | + //TODO: You can add some prize for the player if they solve the challenge and get back to the mage |
| 32 | + player.onCollide('mage', async () => { |
| 33 | + computer.play('on'); |
| 34 | + |
| 35 | + if (!player.state.alreadyTalkedToMage) { |
| 36 | + mageInteractionCounter++; |
| 37 | + |
| 38 | + if (mageInteractionCounter === 1) { |
| 39 | + player.isInDialog = true; |
| 40 | + await displayDialogue({ |
| 41 | + k, |
| 42 | + player, |
| 43 | + text: firstText, |
| 44 | + characterName: 'Mage', |
| 45 | + onDisplayEnd: () => { |
| 46 | + player.isInDialog = false; |
| 47 | + }, |
| 48 | + }); |
| 49 | + } |
| 50 | + |
| 51 | + if (mageInteractionCounter >= 2) { |
| 52 | + player.isInDialog = true; |
| 53 | + |
| 54 | + let tryChallenge = await displayPermissionBox({ |
| 55 | + k, |
| 56 | + player, |
| 57 | + text: questionText, |
| 58 | + onDisplayEnd: () => { |
| 59 | + player.isInDialog = false; |
| 60 | + }, |
| 61 | + }); |
| 62 | + |
| 63 | + if (tryChallenge) { |
| 64 | + player.isInDialog = true; |
| 65 | + await displayDialogue({ |
| 66 | + k, |
| 67 | + player, |
| 68 | + text: spell, |
| 69 | + characterName: 'Mage', |
| 70 | + onDisplayEnd: () => { |
| 71 | + player.isInDialog = false; |
| 72 | + }, |
| 73 | + }); |
| 74 | + |
| 75 | + //TODO: You can add a flickering effect to the dialog box to make it more magical |
| 76 | + |
| 77 | + player.state.alreadyTalkedToMage = true; |
| 78 | + } else { |
| 79 | + player.isInDialog = true; |
| 80 | + await displayDialogue({ |
| 81 | + k, |
| 82 | + player, |
| 83 | + text: noSpell, |
| 84 | + characterName: 'Mage', |
| 85 | + onDisplayEnd: () => { |
| 86 | + player.isInDialog = false; |
| 87 | + }, |
| 88 | + }); |
| 89 | + } |
| 90 | + } |
| 91 | + } else { |
| 92 | + player.isInDialog = true; |
| 93 | + computer.play('on'); |
| 94 | + |
| 95 | + await displayDialogue({ |
| 96 | + k, |
| 97 | + player, |
| 98 | + text: alredyUnlockText, |
| 99 | + onDisplayEnd: () => { |
| 100 | + player.isInDialog = false; |
| 101 | + }, |
| 102 | + }); |
| 103 | + } |
| 104 | + }); |
| 105 | + |
| 106 | + player.onCollideEnd('mage', () => { |
| 107 | + computer.play('off'); |
| 108 | + }); |
| 109 | +}; |
0 commit comments