JernejHabjan / fuzzy-waddle

Game development with Phaser and networking available on https://fuzzy-waddle.onrender.com and https://jernejhabjan.github.io/fuzzy-waddle
https://fuzzy-waddle.onrender.com
MIT License
0 stars 0 forks source link

Probable Waffle Client - Server replication #128

Open JernejHabjan opened 11 months ago

JernejHabjan commented 11 months ago

how to achieve this in typescript:

I have complex nested object of classes like this:

class GameState{ playTime = 0; howLongPlaying(){...} } class Weapon{ attackDmg=10, currentCooldown = 5 } class Warrior{ health:100, weapon: Weapon attack(){...}, } class Player{ warriors:Warrior[]=[] getWarriors(){...} getPlayerId(){...} }

class Game{ gameState: GameState players:Player[] = []; }

I want to replicate this game object between server and client. How do I do that in Typescript? Server is NestJs, and client is Angular

JernejHabjan commented 7 months ago

Mark property as replicable easier way?

JernejHabjan commented 7 months ago

Maybe use proxy and in proxy send socket-io request to server

https://stackoverflow.com/a/50723478/5909875

https://www.npmjs.com/package/proxy-deep

https://www.npmjs.com/package/@qiwi/deep-proxy