DEV Community

0 seconds of 9 minutes, 46 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
09:46
 
Peter Vivo
Peter Vivo

Posted on • Edited on

8 1

This is How I Code

After a Long Night of Coding, I just practicing my english skill. Technic recording as I speak of my current hobby project: pure web instead react. Meanwhile I found I maked a bug of my code, but I don't care, because this is a lego development process, I programing my current program, on top of the previous program, which is indicate if I am screw up something. And also Indicate the performance bottleneck. So this is a TDD, but not a direct one.

Movie maked by: ScreenRec
Enchant: iMovie ( speed: 177% )

gameFlow

zignal use Proxy, so this gameFlow fare more easy compare to react reducer counterpart. For example draw a card is game.deck.shift()

export const gameFlow = async (ms = 200) => {
  const game = zignal(monitor)(structuredClone(setup))
  globalThis.ss = game;
    await delay(ms)
  Object.keys(game.table).map(key => game.table[key] = null)
    await delay(ms)
  game.deck = cardCollection.slice(0,11).map(({name,power,type,side}) => [name,power,type,side].join('|') )
    await delay(ms)
  game.table.HERO = game.deck.shift()
    await delay(ms)
  const bum = setInterval(() => game.deck.sort(() => Math.random() > .5 ? -1 : 1),ms)
  await delay(ms * 5)
  clearInterval(bum)
    await delay(ms)
  const fillUp = () => ["L1", "L2", "L3", "L4"]
    .filter(slot => !game.table[slot])
    .map(slot => game.table[slot] = game.deck.shift())
    await delay(ms)
  fillUp()
    await delay(ms)
  let enemy = game.table.L2
    await delay(ms)
  game.fly = enemy;
    await delay(ms)
  game.fly = game.fly.split('|')
    await delay(ms)
  game.table.L2 = null;
    await delay(ms)
  game.table.HERO = game.table.HERO.split('|')
    await delay(ms)
  game.table.HERO[1] = + game.table.HERO[1]
    await delay(ms)
  game.table.HERO[1] -= +game.fly[1]
    await delay(ms)
  game.table.HERO = game.table.HERO.join('|')
    await delay(ms)
  game.lost.push(enemy)
    await delay(ms)
  game.lost.push(game.table.HERO)
    await delay(ms)
  game.table.HERO = null
    await delay(ms)
  game.phases = "THE END"
}
Enter fullscreen mode Exit fullscreen mode

grug no able see complexity demon, but grug sense presence in code base
(https://grugbrain.dev/)

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Visualizing Promises and Async/Await 🤓

async await

☝️ Check out this all-time classic DEV post on visualizing Promises and Async/Await 🤓

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay