Fight Time Restrictions

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.

Fight Time Restrictions

Postby Fireal » Tue Mar 13, 2018 6:10 pm

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.
User avatar
Posts: 11
Joined: Sun May 21, 2017 12:51 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Fight Time Restrictions

Postby Jackolantern » Tue Mar 13, 2018 7:30 pm

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!
The indelible lord of tl;dr
User avatar
Posts: 10893
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 92 times
Blog: View Blog (1)

Re: Fight Time Restrictions

Postby hallsofvallhalla » Wed Mar 14, 2018 10:19 am

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.
User avatar
Site Admin
Posts: 12008
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 164 times
Blog: View Blog (3)

Re: Fight Time Restrictions

Postby KyleMassacre » Fri Jul 06, 2018 8:04 pm

I will concur with Jack and Halls. By doing it this way you can expand a little as well. For example
Code: Select all

= 3;
$count = $db->query(“select count(userId) from fightTable where userId = ? and fightTime <= ?,$userId, time());
$count >= $numTimes) {
  // show message saying they can’t fight
} else {
  // insert into fight table
  // trigger a fight
Skype: KyleMassacre
My NWE Modules
User avatar
Posts: 572
Joined: Wed Nov 27, 2013 7:42 am
Has thanked: 19 times
Been thanked: 36 times

Re: Fight Time Restrictions

Postby williamnorman » Fri Aug 10, 2018 3:35 am

This could be a certain source of strategy to the game and would help keep the fight cooldown time from feeling voluntary.
Posts: 1
Joined: Fri Aug 10, 2018 3:30 am
Has thanked: 0 time
Been thanked: 0 time

Return to Beginner Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest