I'm trying to implement a method to copy dungeons in a game managment app.
Here is an example of a Dungeon to be copied:
attributes: { isReady: true, isMainQuest: true, color: "red", partyMax: 8 }
id: 59272
gamerMax: 12
gameId: 3
advLeveling: true
mainObjects: [0: "Treasure" 1: "BossKill"]
stats: { monsterCount: 25, treasureCount: 50, bossCount: 15 }
After reading a lot of posts about Object.keys
, I decided to use that to "deep copy" my dungeon.
My latest interation simply looks like this:
Object.keys(obj).forEach(function (prop) {
console.log("obj[prop]: ", obj[prop]);
}
But in all the versions I tried, including the one above, they never deep copy the nested arrays and objects like attributes, mainObjects, and stats.
Is there a way to copy those as well, no matter how deep?
Thanks!