Page 1 of 1

Fight Time Restrictions

Posted: Tue Mar 13, 2018 11:10 pm
by Fireal
Hey everyone, still plugging away at a game I'm working on and I'm trying to figure out the best way to approach a fight restriction based on time. Basically, a user can only fight once every 15 minutes. And until the timer is expired they can't click on a "Fight!" button. Now, I understand everyone has issues with energy/time related limitations in games but I'm using it for more of a realistic approach rather than a monetary one. I mean if you get in a fight you are pretty damn tired, you aren't going to rush in to fights back to back. Makes no sense to me. Plus it allows a user to take time to strategize a bit before a fight.

I am using pure php, jquery, and mysql. I am tossing around one approach and I'm curious to hear how anyone of you would approach this.

Idea 1:
Basically when a user clicks fight, it will insert a timestamp of the current time plus 15 minutes into the fighters table under 'nextFightTime'. Then use a db call to check if that time has passed before allowing the user to click again. Of course I would include jquery somewhere for the actual countdown. Just not sure if this is the most efficient.

Anyways thanks in advance for the advice guys.

Re: Fight Time Restrictions

Posted: Wed Mar 14, 2018 12:30 am
by Jackolantern
I would say your Idea 1 is how to handle it. Once the player is committed to a fight, go ahead and make the timestamp in the database. Then after the fight, any time the page reloads and you need to display the countdown timer, check that timestamp in the database and determine how long it will be before they can fight again and use that to pass the time left into the JS code to start showing the timer (you could use PHP to write the value directly into the JS script). This way the server knows how long it will be before the player can fight again. You will no doubt have some smarty-pants players who mess with the JS and turn the timer to 0 with the Dev Tools and then try to fight only to see that the server knows how long they have to wait.

As far as the mechanics of it, I think it would be cool if how long the player has to wait was kind of in their control. For example, if they push their fighter harder, take more damage over and over, the time goes up. If they do some other activities they can rebound from a fight more quickly. This could be a source of strategy to your game and would help keep the fight cooldown time from feeling arbitrary.

Hope this helps. Best of luck and let us know if you have any more questions!

Re: Fight Time Restrictions

Posted: Wed Mar 14, 2018 3:19 pm
by hallsofvallhalla
Yup thats exactly the way I would do it too. Good idea on the different timings. Especially if it is a one hit one kill type thing.

Re: Fight Time Restrictions

Posted: Sat Jul 07, 2018 1:04 am
by KyleMassacre
I will concur with Jack and Halls. By doing it this way you can expand a little as well. For example

Code: Select all

$numTimes = 3;
$count = $db->query(“select count(userId) from fightTable where userId = ? and fightTime <= ?”,$userId, time());
if($count >= $numTimes) {
  // show message saying they can’t fight
} else {
  // insert into fight table
  // trigger a fight
}

Re: Fight Time Restrictions

Posted: Fri Aug 10, 2018 8:35 am
by williamnorman
This could be a certain source of strategy to the game and would help keep the fight cooldown time from feeling voluntary.

Re: Fight Time Restrictions

Posted: Tue May 30, 2023 4:07 am
by annemanike
your approach of implementing a time restriction for fights in your game to add realism and strategic thinking is a valid one. Idea 1 seems reasonable, as it utilizes a timestamp in the database to track the next available fight time and checks it with a database call. Additionally, incorporating jQuery for the countdown can enhance the user experience. However, it's important to consider potential optimizations based on your specific game requirements and user load to ensure efficiency.ApplinkedAptoide TV[B612 apkAndroid Camera