Page 2 of 2

Re: Asking for help - Timer question

Posted: Fri Jan 29, 2010 5:43 pm
by Christopher
How is it any more hackable than any other kind of request?

Re: Asking for help - Timer question

Posted: Fri Jan 29, 2010 5:57 pm
by VladSun
arborint wrote:How is it any more hackable than any other kind of request?
If one stops the execution of JS, the server side update is not going to happen, right?

Re: Asking for help - Timer question

Posted: Fri Jan 29, 2010 6:34 pm
by JakeJ
arborint wrote:Yes, but is this a multi-player game? I didn't get the sense it was. If it is not, then you could recalculate those values when the user logs-in -- based on the last time they were online.
Wouldn't that involve some complicated session control? I guess the in-browser game could send out a ping every so often and that would take care of it.

I'm not entirely disagreeing with you. I'm just thinking of scalability issues if he decides to go big with it.

Re: Asking for help - Timer question

Posted: Fri Jan 29, 2010 7:33 pm
by Christopher
VladSun wrote:If one stops the execution of JS, the server side update is not going to happen, right?
Agreed ... but that's not hackable, that's just breakable. ;) But that is no different than any Javascript web application.
JakeJ wrote:Wouldn't that involve some complicated session control? I guess the in-browser game could send out a ping every so often and that would take care of it.
I was just thinking that requests would update a timestamp, so the system would know the time of the last request. When you logged-in it would compare the current time with the last timestamp and update game values accordingly. You could reduce database writes by only writing the timestamp every minute or so -- by checking against a copy of the last timestamp in the session.

Re: Asking for help - Timer question

Posted: Fri Jan 29, 2010 7:45 pm
by SpHawk
OK, I wasn't trying to get this wordy, or ovewrload anybody with data, but here it is. 8)

The game as currently envisioned.
The user logs in, MySql has userid, health, energy, possessions, money, favor points and so forth. You can choose to go do jobs, etc.
An example of a tier 1 job is hurdle jumping. 10 sets of addition problems are made from numbers randomly generated from 1 - 9. It costs 1 energy to play. And the stopwatch starts. If you fail a problem, you lose 1 pt of health as your character stumbles. and it costs 1 second. You must still answer the qustion to continue. At the end of the race, your time is posted with other hurdle race scores. (Only the scores of that job, so that the tier 12 jobs aren't listed head to head making the kindergardeners feel bad.) The pay out is leather, and 1 t-bill. There is also a possibility of a big reward, but those are rare and scattered through the whole thing.
One can trade t-bills for crafting stuff, and craft with the materials they have. Crafting materials or finished goods can be traded with other players. The finished goods can be sold for silver coins. Silver coins can be used to buy properties and businesses that make you Gold coins. The wiser the investment, the better the return. The game will fluctuate in business, so staying on top of it will matter.
Gold coins can be used to buy favors, batches of cookies, bannana bread, trips to the park, pizza, a gift card from Toys R us, etc. You can send gifts to friends and we might open up a port for other kids from church to play. (Or maybe someday... FACEBOOK!) :twisted:

And that's my intention. All server side work with a web interface. A lot of the game is put down and done in excel and I'm traslating to PHP. My wife has been building pages for jobs, crafting, so forth.

But seriously, if PHP w/MySql isn't the langauge I should be using, let me know. Should I be looking for an external server with Unix? (And PHP and MySql. But they all seem to have that.)

Bob

Re: Asking for help - Timer question

Posted: Fri Jan 29, 2010 9:56 pm
by Christopher
SpHawk wrote:...And that's my intention. All server side work with a web interface. ... But seriously, if PHP w/MySql isn't the langauge I should be using, let me know.
Web applications have database and server side programming, they also use Javascript (not Java) to do work in the browser. Some of that work is to lessen the work on the server; some of that work is to do things like animation or CSS manipulations that can only be done in the browser. So it is not PHP or Javascript, it is very much becoming a requirement for PHP AND Javascript -- especially for rich interfaces like games. You will need to learn both. I would recommend using a Javascript library like jQuery. That will greatly increase you capabilities to do interesting stuff in the browser.
SpHawk wrote:Should I be looking for an external server with Unix? (And PHP and MySql. But they all seem to have that.
If you write it for Apache/PHP running on Windows then you will have few/no problems moving it to a Linux/Apache server later. Many of us work on Mac/Windows and deploy to Linux servers. Just don't use IIS.

Re: Asking for help - Timer question

Posted: Wed Feb 17, 2010 2:39 pm
by BDKR
While I did read a bit of this, I've kind of skipped to the end here so forgive me if I re-hash something.

I don't see any reason why you couldn't run something like a scheduler that's always running and at certain intervals updates player information based on configuration data found either on file or in a db. PHP can do this and can even do it on Windows.

I'm finishing up V1 of something very similar to this right now. It was originally developed on LAMP platform, but ended up being migrated with Win/MSSQL. If you are religious about mysql_free_result, it won't leak memory either. My running application barely uses more then 2.5 megs and will run for days and send hundreds and hundreds of emails based on exceptions found and configuration.

For you, the good thing about such a setup is that updates (such as increasing health) will happen regardless of a browser being open or someone logged in. THIS IS THE WAY IT SHOULD BE.

At the risk of making it sound too easy, just start with a loop with a sleep interval at the bottom and attached arrays of objects that can act as abstractions for users, events, and even routine maintenance. The big thing to remember is that even though the scheduler may cycle through these object arrays every 5 to 10 seconds, they are not required to do anything. Each should have it's own configurable frequency (how often it is supposed to run). Obviously, players would run more often then others.

Now it sounds like you've already gotten a ways into it and may not want to back up and create what I'm talking about now. I can understand this. But I really think it will clear up a lot of issues for you if you do.

Cheers

Re: Asking for help - Timer question

Posted: Fri Feb 19, 2010 7:58 pm
by SpHawk
Actually Robin, we've been moving and hadn't started it. I was going to put the project together during some late nights when I could study the solutions, because to be frank, I'm too much a newb to put together some of the solutions I saw. Right now, at worst this game wouldn't have more than 20 players, and maybe 60-80 characters. We think each character could have investments and stats that would update totaling maybe 40 at the worst. Would your solution kill my server? Or would the memory still be for the one task and instead of trying to create a hundred sub-tasks? But it sounds like what we were looking for.

Thanks,
Bob