You could store, for each user, a date when they last received new turns. If they try to use a turn when they don't have one, check the date. If they're due to get new turns, add them to the turn count and update the date.

You could also store the dates of all of the user's last turns taken. When the user tries to use a turn, delete all the records that are over a day old. If there are still too many turns used, disallow the turn. This gives a slightly different turn allowance, though. It's not x turns every day but x turns in any day-long period.

Update to expand on that second idea a bit (since roboticus likes it): I recall years ago a couple of friends in a turn-based game would make a killing by waiting until the end of the "day" to take all their turns, then wait for the new turns to arrive shortly after, and take all their turns again. By doing this, they could double their effect in a short time. A "turns in time period" approach would defeat that strategy. I don't know anything about Spidey's game, so it may be the case that this "last minute, first minute" approach doesn't really gain the player any advantage.

The down side comes for a user who tries to play at the same time every day. Let's say the player arrives at noon, takes all turns, and returns the next day. The player has to wait for a minute after noon to play again. Every day, the time when play is allowed moves later. This also means that I can't play one afternoon and then play again the next morning.

Perhaps a better solution is a mix of some kind.

The main problem I have with the first approach (all turns arrive at a fixed time every day) is that it might not work well for people in other time zones. If I were playing a game where turns arrive at noon, I'd have to play either in the morning or in the afternoon every day.

Anyway, I'm rambling a lot more than I meant to (and not even with code!).


In reply to Re: Daily Actions by kyle
in thread Daily Actions by Spidy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.