DEV Community

Play Button Pause Button
Peter Vivo
Peter Vivo

Posted on

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/)

Top comments (0)