Author Topic: Turn Based  (Read 788 times)

Offline Ashoar

  • Level 1
  • *
  • Posts: 2
  • Reputation: +0/-0
    • View Profile
Turn Based
« on: August 28, 2008, 08:44:18 AM »
I am in the middle of making a Turn based browser game.
I have completed most of the coding needed for it but i am now up too one of my last parts.

I have read the article about it, and searched the internet for tutorials but couldn't seem to find anything that actually helped me. So i was wondering if someone could help me out by ether coding one out and put comments in showing the steps taken, or walk me through it.

This is what i need too do.

Every 30 minutes each player recieves 1 extra turn in which they can use too attack another player. I need too also show each user how long it is untill their next turn (this will be displayed in their main page).
I need a timer system to do that.
I have tried hard but cant seem to do this myself, and it seems so simple.

Thanks too anyone that can help.
- Ashoar

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: Turn Based
« Reply #1 on: August 28, 2008, 09:33:09 AM »
1. add updatetime (INT,unsigned) to your player table
2. when user register ... updatetime = time()
3. time for next turn:
updatetime+600 (600 is 10 minutes...this number is time in seconds)
if ($player['updatetime']+600<=time()) { //update user }
seconds remaining: updatetime+600-time()

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal