So im developing a very simple game. Basically I will be using Swift + Firebase.
Users can login in to my game and click a button to fight a "boss". But other users can also fight the same boss "instance".
On my Firebase DB there will be a reference to this "instance" of the "boss" with a certain amount of "life","dmg to players per second", "# of players fighting it".
I will use the Realtime Database to update the "Boss's Life" and "# of Players Fighting it" on each user's ViewController.
My question is since the "Boss instance" does "damage per second" how can i make sure thats running even when users put the game in background?
I can put NSTimer in viewWillAppear()but I want the player to be damaged even in background and if the player's life reaches 0 -> to save that in DB and note that "player has died" in the DB as well. So when they come back it will run a check and tell them they have died and boot them back to the Main View Controller.
Hope this makes sense!
Iv been trying to figure this out for weeks and well now im at a point where i cant skip it!