Advertisement
WILDAN_IZZUDIN

[JS] FIND THE JOKER CONCEPT

Aug 16th, 2022 (edited)
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const co = require('@colors/colors/safe')
  2. const c = document => console.log(document)
  3. const table = document => console.table(document)
  4. const br = () => c('\n')
  5. const mix = (min, max) => {
  6.    min = Math.ceil(min)
  7.    max = Math.floor(max)
  8.    return Math.floor(Math.random() * (max - min + 1)) + min
  9. }
  10. const delay = time => new Promise(res => setTimeout(res, time))
  11. const enumerate = Object.freeze({
  12.    1: 'JOKER',
  13.    2: 'ROBBER',
  14.    3: 'DETECTIVE',
  15.    4: 'PETRUS',
  16.    5: 'CLOWN',
  17.    6: 'CIVILIAN',
  18.    7: 'OBSERVER'
  19. })
  20. const jid = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
  21. const deck = jid.length
  22. if (deck == 6) {
  23.    var roles = [1, 2, 3, 4, 5, 6].sort(() => Math.random() - 0.5)
  24. } else if (deck == 7) {
  25.    var roles = [1, 2, 3, 4, 5, 6, 6].sort(() => Math.random() - 0.5)
  26. } else if (deck == 8) {
  27.    var roles = [1, 2, 3, 4, 4, 5, 6, 6].sort(() => Math.random() - 0.5)
  28. } else if (deck == 9) {
  29.    var roles = [1, 2, 2, 3, 4, 5, 6, 6, 6].sort(() => Math.random() - 0.5)
  30. }
  31. const player = []
  32. jid.map((v, i) => player.push({
  33.    jid: v,
  34.    role: enumerate[roles[i]],
  35.    leader: false,
  36.    vote: 0,
  37.    turn: false,
  38.    alive: true
  39. }))
  40.  
  41. let FTJ = {
  42.    judgment: false,
  43.    kill: false,
  44.    shooter: false,
  45.    investigate: false,
  46.    stage: 1
  47. }
  48.  
  49. let timeout = 5000,
  50.    alive = player.filter(v => v.alive)
  51.  
  52. const proc = setInterval(async () => {
  53.     c(co.green(`Sirkularitas and act role here!!`))
  54. }, timeout)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement