123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|600|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Passive Net Gaming

Wed, 07 Jul 2010, 16:30
BGDDisco
I have an idea for a game. Well, actually, a bit more than that - I wrote a nice little 2 player game (using Blitz2D), a word game where players take turns, trying to better their opponent and/or restrict their next available moves through tactics. At the end of the day it is a pass-and-play turn-based game with no time limit to pressure the combatants. Think Chess or Scrabble, or a kinda combo of those.
Now, the next move for me is to make it playable over the net. BlitzPlay seems to allow this, but I am a total newbie in this area. May I ask advice from other SoCoders?
My questions.
1. The HostNetGame command. Does this have to be on a server? If so how do I access a server to 'host' my code.

2. Is it better to have each gamer have a full version of my game with dictionary, rules checking etc (kind of p2p-alike), or simply a 'front-end' that presents the player with his turn and send a packet to the server which checks the player's turn is valid, calculates points and returns a packet to player and updates opponent (a p1-server-p2).

3. This game would be ideal for mobile phones, but they use Java. Any easy way to convert Blitz2(or3)D source to Java?

I will appreciate any advice or help offered by anyone here. Pro Forma Thanks already.



-=-=-
God gave Man a brain...and a penis...but only enough blood to run one at a time!
Wed, 07 Jul 2010, 21:05
CodersRule
#2: You'll want to store rule-checking on the server.
If you, on the client, try to do something, pretend the following happens:
1: client checks rules (client-side)
2: client sends "do this" to server
3: server performs action
4: server sends info to all clients

If the user sends a forged HTTP request that looks to the server like it was a client's request, that user can make the server think anything happens.
Example time:
On the client game, there is an item in the store. The item costs 600 gold. The client only has 500 gold.
If the user tries to purchase the item, the client will look at the situation and tell the user that he can't buy the item.

Imagine the same situation where the user instead has 700 gold.
When the user tries to purchase the item, the client will decide that the user can purchase the item. The client will (client-side) subtract 600 gold from the user.
This info is sent to the server so all players can know that the user bought the item.
The info sent to the server is in the following format:
"CLIENT 3295 BUY CRYSTAL_SWORD"
As the gold-checking has already been done client-side, it's not important for the server to instead do the checking.

Now, let's go back to the situation where the user only has 500 gold.
Imagine the user forges the server request, so it looks like it came from a genuine client program.
What will happen if he sends the following command to the server?
"CLIENT 3295 BUY CRYSTAL_SWORD"
As the server _assumes_ that the gold-checking has already been done client side, it assumes that the user has the proper amount of gold to buy the item, and that the gold has been subtracted.
In reality, it hasn't been.

HOWEVER; if you do all of the rules server-side, the server knows how many gold pieces the user has. When this command:
"CLIENT 3295 BUY CRYSTAL_SWORD"
is sent to the server, the gold-checking is done _server-side_. If the user only has 500 gold, the server will know that and will not issue the user's client the crystal sword.

Remember that anything you send to the server can be forged:
"CLIENT 3295 BUY CRYSTAL_SWORD FOR 600GP"
If that request is sent, just remember that any skilled user can forge it to:
"CLIENT 3295 BUY CRYSTAL_SWORD FOR 2GP"
Of course, if the server knew that the proper price was 600gp, it would be able to verify the data.

Sorry 'bout the long description, just wanted to make sure you understood

Can't help you with the other two questions, sorry.
Wed, 07 Jul 2010, 22:41
Stealth
1. The HostNetGame command. Does this have to be on a server? If so how do I access a server to 'host' my code.


Not necessarily. In a two player network game without a central server, one player must act as a "host" and the other player connects to them. In a game with a central server, both players connect to the server which hosts the game. Running your own central server is fairly complicated and costs money. I don't recommend it in your situation.

2. Is it better to have each gamer have a full version of my game with dictionary, rules checking etc (kind of p2p-alike), or simply a 'front-end' that presents the player with his turn and send a packet to the server which checks the player's turn is valid, calculates points and returns a packet to player and updates opponent (a p1-server-p2).


CodersRule made a lot of good points on why you would want to have a central server. However, it's possible to be safe without one. The trick is to have both players double check each other and verify that the other player is playing by the rules. If either games detect some oddities, they will declare a "Network Data Error" and end the game.

3. This game would be ideal for mobile phones, but they use Java. Any easy way to convert Blitz2(or3)D source to Java?


I'm fairly sure this doesn't exist. Additionally, if you write it for mobile phones, it really needs to be designed with this in mind from the start. The interface on phones is a lot different than on a PC.

-=-=-
Quit posting and try Google.
Thu, 08 Jul 2010, 05:27
JL235
BGDDisco 2. Is it better to have each gamer have a full version of my game with dictionary, rules checking etc (kind of p2p-alike), or simply a 'front-end' that presents the player with his turn and send a packet to the server which checks the player's turn is valid, calculates points and returns a packet to player and updates opponent (a p1-server-p2).

IMHO it's better to use the latter, with a client-server architecture. All players are clients sending their moves to a server that runs the game. I also believe it'll be easier to build if you keep the server and client parts seperate.

In practice this means whoever starts (and so hosts) the game is running both a client and a server simultanously.

BGDDisco 3. This game would be ideal for mobile phones, but they use Java. Any easy way to convert Blitz2(or3)D source to Java?

Again this doesn't exist. But there are other languages that run on the JVM, however some are nothing more then proof of concept. I'd also be wary of languages that require you including runtime libraries (like JRuby and Scala) as these will probably make your app too big to fit on a mobile phone.

A second alternative could be to build a Blitz3D to Java compiler, i.e. it'll take your B3D code and paste it as Java code. However doing this to a high standard will be non-trivial.

Finally one advantage of using java is that much of your code should run fine on both a mobile and a PC (i.e. a server or a desktop version of your game).
Thu, 08 Jul 2010, 13:13
BGDDisco
Great advice, thanks all.
I'm now thinking the server option is the best for my purposes. As I said this is very much a passive game. Not only that but players may have several games, each with unique opponents, all running at the same time. Sounds complicated but imagine playing 4 hands at a blackjack table, or more like 4 different tables.
I envisage a client logging in, then the server alerts him/her that he (enough of the political correctness - from now on the player is a he) has x number of games open and its his turn in 3 of them. He selects each game and takes his turn.
The game I've written is really quite simple, it only has 3 rules. I lost the original source but have re-written the main Functions from memory - I stopped short of writing another pass'n'play version as I'd done that one to death. I'd really like to see this on the web.

Would anyone like a look at the P'n'P game? I still have the exe file and will try to figure out uploading it here.

-=-=-
God gave Man a brain...and a penis...but only enough blood to run one at a time!
Thu, 08 Jul 2010, 13:39
BGDDisco
Here it is (I think).

Lexicod

-=-=-
God gave Man a brain...and a penis...but only enough blood to run one at a time!
Fri, 30 Jul 2010, 06:14
BGDDisco
A flash of inspiration.
I remembered seeing a library of FTP functions, so I downloaded them. I already have some hosted webspace, so now I'm thinking I could have each player's program do all the spell-checking, calculations, validations etc then upload game-specific data files to my webspace. When opponent logs in to the game, his program downloads updated data files, he takes his turn, uploads happen and so on. Remember, this is passive gaming, not pseudo-realtime action.
I have yet to test the FTP Functions, but I'm sure this should work, in principle.

-=-=-
God gave Man a brain...and a penis...but only enough blood to run one at a time!