There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:I'm not sure I understand the problem, because I would think you'd simply store the time you last gave a gift.
The client would ping for lastGivenTime, and the timer would count down if < 1 hour, else display "you can get your gift now".
When the user clicks the 'get gift', you give them one gift, and reset the lastGivenTime to <now>. The client pings for the new value, and starts over.
fred rosenberger wrote:I'm not sure I understand the problem, because I would think you'd simply store the time you last gave a gift.
The client would ping for lastGivenTime, and the timer would count down if < 1 hour, else display "you can get your gift now".
When the user clicks the 'get gift', you give them one gift, and reset the lastGivenTime to <now>. The client pings for the new value, and starts over.
Mark Spritzler wrote:Here's where that logic fails. I have not received my first free giveaway. I login, so my timer starts. I log out in 59 minutes with one minute left till the first gift will be available. I log back in and there should be 1 minute left. But lastGivenTime is still null. Now you have to do extra work to find last login time, and use that in the calculation too.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
Mark Spritzler wrote:Here's where that logic fails. I have not received my first free giveaway. I login, so my timer starts. I log out in 59 minutes with one minute left till the first gift will be available. I log back in and there should be 1 minute left. But lastGivenTime is still null. Now you have to do extra work to find last login time, and use that in the calculation too.
I really just kind of throwing out random thoughts here. You've probably thought through all this already, but I do find this to be kind of fun.
Mark Spritzler wrote:
Yes 100% it has to be unbreakable
The other criteria was to try and make the server side not have to keep track of time for this,
(But there still will always be the timer) and that is the puzzle of this thread.
Mark
Guillermo Ishi wrote:
Mark Spritzler wrote:
Yes 100% it has to be unbreakable
The other criteria was to try and make the server side not have to keep track of time for this,
(But there still will always be the timer) and that is the puzzle of this thread.
Mark
I think if you are relying on a timer other than one on your server the prizes should not be very valuable! I think the security should be in the timer on your server. I would suggest maybe everybody could be on the same timer and so you might have to be logged in as long as 59 min. before you become eligible (in the next hour). You could display "next giveaway begins in..." A local timer is too easy to defeat, just by switching computers for example.
You mean if I click on something that says free gift I might really get something besides a virus?
permaculture is largely about replacing oil with people. And one tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|