[project1dev] Re: networking pirate dice woes

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: project1dev@xxxxxxxxxxxxx
  • Date: Mon, 22 Feb 2010 14:53:58 -0800

"Before the game initilizes it will need connect connect to the game

You'll have to do a game server login before anything else.  That logs into
the central game server with the username and password from the
scripts/config.lua file.

"This will need to check to see if there is a server. If it is there
connect. If not create one."

That's how the chat program works but i think we need to do it differently
for pirate dice.  You should be able to specify whether you want to create a
new game or join an existing one.

If creating a new one it should be real easy just to create the game.

If joining an existing one we'll have to show them a list of games that can
be joined and let them choose (the chat script does this too but it just
joins the first available one).

"The game server will then need to wait for a full game"

I think really you are just waiting on the host to click the "start game"
button, so long as there is more than one player (disable button if there is
no one else in the room?).  You could give the host the option to sit bots
into empty spots if you wanted to, but if that complicates stuff too much
dont even worry about it.

"For this part each player would just do thier thing individually right?"

This is a really good question.  Normally in a networked game, the server is
in charge of all the important stuff because if any of the clients are in
charge of saying what they rolled etc, thats how cheats happen.

In this case, we don't really have a trusted server to do the rolls and
other important stuff.

For now, yeah go ahead and do it that way where everybody does their own

Another way to do it would be to make the host do all the rolls for everyone
and send the information to them.  Going this route, the host could be a big
cheater though so it's still not a good solution.  I need to think about
this a lil bit to come up with a better, less cheating prone way to do it.

It should be turn based though where if i act after you act, i shouldnt be
able to bet before you do.

"All of this information would then get sent back to the players."

sounds good yep!

"First player is also blinds so they will need to send that amount to the

or the server enforces blinds, whichever way you want to do it.

Sounds pretty good, lets get it working like you described (:

We'll have to think later about anti cheating stuff but lets get it working
first then worry about making it better afterwords.

Sound ok to you?

On Mon, Feb 22, 2010 at 1:44 PM, Kent Petersen <kentkmp@xxxxxxxxx> wrote:

> Ok. Let's see here. Maybe if I write it out and discuss it I will be able
> to make myself an outline or some framework to work with.
> Let's say I wanted to add networking to piratedice. What would I need to
> do?
> Before the game initilizes it will need connect connect to the game server.
> This will need to check to see if there is a server. If it is there connect.
> If not create one.
> The game server will then need to wait for a full game. so it would need to
> know how many players should join (arbitrarily 4) and how many it has. Each
> player joining would need to send the information that they joined to the
> server.
> After the game has enough playersit will then need to initialize the game
> and draw the interface. For this part each player would just do thier thing
> individually right? After all the players are loaded and the game is ready
> to begin all of the players will need to send their player information to
> the server. Then each player would send their dice roll to the server and
> also their name, player number, and amount of gold. All of this information
> would then get sent back to the players.
> Player 1s turn. First player is also blinds so they will need to send that
> amount to the server. The server then passes this info back to the other
> players. Player1 then decides what they have in their hand. Calls, raises,
> or folds. Player 1 makes their choices and ends their turn
> Player 1s choice get's sent to the server. Server sends the choice to the
> players.
> Player 2s turn... repeat for player 2
> Does this sound right?
> On Mon, Feb 22, 2010 at 9:08 AM, Alan Wolfe <alan.wolfe@xxxxxxxxx> wrote:
>> Well I'm not sure if this clears much up or not but you don't need to
>> create a server AND join a server, you either do one or the other.
>> If you want to join an existing game you join it
>> if you want to make a new game you create it (which joins it automatically
>> after you create it)
>> On Mon, Feb 22, 2010 at 8:11 AM, Kent Petersen <kentkmp@xxxxxxxxx> wrote:
>>> Ok, so ultimately, I want to add networking to pirate dice.
>>> First, should I try getting a networking script working on its own? At
>>> first I was just trying to add the code to pirate dice. Pirate Dice's code
>>> can get a little confusing especially when it comes to the starting
>>> initization code (because it does it 2x!?). So this whole thing got really
>>> confusing really quickly.
>>> Then, I was trying to make something simple like you log on and it tells
>>> you, you log on but I just couldn't piece together the info. I guess a
>>> little step by step guide would be more helpful? Like you need to login,
>>> create a game server, connect to the server, send message, receive message
>>> (even if its just a variable) but when it comes to coding it I keep getting
>>> confused.
>>> I think... I'm still just confused
>>> On Sun, Feb 21, 2010 at 9:58 PM, Alan Wolfe <alan.wolfe@xxxxxxxxx>wrote:
>>>> well hrm, what kind of problems are you having? i might be able to help
>>>> you out by explaining better
>>>> On Sun, Feb 21, 2010 at 9:42 PM, Kent Petersen <kentkmp@xxxxxxxxx>wrote:
>>>>> I still seem to be having a problem trying to figure out how to use the
>>>>> commands. Can you possibly make a different kind of network script that I
>>>>> can also use for reference?
>>>>> On Sat, Feb 13, 2010 at 2:35 PM, Kent Petersen <kentkmp@xxxxxxxxx>wrote:
>>>>>> I think that helps. I will take another stab at it next chance I get.
>>>>>> You are welcome to take and delegate tasks that are needed. If
>>>>>> something becomes urgent scripting-wise let me know.
>>>>>> I did see the commands in the scripting help but I did not find the
>>>>>> documents very helpful. They explained the variables and values but I
>>>>>> couldn't really figure out how to use the commands.
>>>>>> On Sat, Feb 13, 2010 at 9:34 AM, Alan Wolfe <alan.wolfe@xxxxxxxxx>wrote:
>>>>>>> Hey Kent,
>>>>>>> Totally understandable about your shift in time usage.  I figure i'll
>>>>>>> take on some of the scripting tasks but leave the important stuff like
>>>>>>> networked pirate dice to you.
>>>>>>> If anything becomes uber important and you dont have time to do it, i
>>>>>>> have no problem takin it over so we should be fine (:
>>>>>>> Ok, about the network stuff hrmms...
>>>>>>> #1 - GetServerList: well first things first, i added the network
>>>>>>> script functions to the script help documents.  Have you seen those?  
>>>>>>> If so
>>>>>>> were they not too helpful?  If not let me know, maybe i need to document
>>>>>>> things better.
>>>>>>> Anyhow, GetServerList is only useful for searching for existing
>>>>>>> servers.  Theres another function for creating servers but you are 
>>>>>>> right,
>>>>>>> you would change the string to PirateDice and thats all you need to do 
>>>>>>> to
>>>>>>> make it work for pirate dice.
>>>>>>> #2 - SendChat: yeah this is the only place it sends to the server.
>>>>>>>  For the success thing, basically what thats about is every network 
>>>>>>> function
>>>>>>> returns whether or not it was successful.  If it wasn't, you should 
>>>>>>> display
>>>>>>> an error message to the player and then bail out of the game.  The 
>>>>>>> reasons
>>>>>>> it wouldnt be successful is like if they unplugged their internet cable 
>>>>>>> or
>>>>>>> something.
>>>>>>> #3 - OnNetworkMessage: This guy is called by the game whenever it
>>>>>>> receives a network message from the server.  How network messages work 
>>>>>>> is
>>>>>>> you send a message to the server which consists of "MessageName" and
>>>>>>> "MessageValue".  After it gets to the server, the server sends it down 
>>>>>>> to
>>>>>>> all of the clients, including the person who sent the message in the 
>>>>>>> first
>>>>>>> place.  OnNetworkMessage is called once for each message received so 
>>>>>>> that
>>>>>>> you can respond to the message (like if someone raised a bet, you can 
>>>>>>> update
>>>>>>> the pot size).  Everyone receives messages in the same order (:
>>>>>>> Since messages have both a name and a value you can do something like
>>>>>>> all chat messages have the message name "Chat" and all message values 
>>>>>>> are
>>>>>>> what the person typed for chat.
>>>>>>> For when anyone takes a turn you might make a message named
>>>>>>> "TakeTurn" and then have the message value be something like "call", 
>>>>>>> "fold",
>>>>>>> "raise 10" etc.
>>>>>>> OnNetworkMessage also receives messages when players join or leave.
>>>>>>> Also each network message (i think... going from memory) give you
>>>>>>> both the name of the player, as well as a "PlayerID" which is a unique 
>>>>>>> ID#
>>>>>>> associated with that player (if its ever useful to know, this ID# is 
>>>>>>> always
>>>>>>> the same for the same player, it's like an account number).
>>>>>>> Does this help at all?
>>>>>>> On Sat, Feb 13, 2010 at 2:05 AM, Kent Petersen <kentkmp@xxxxxxxxx>wrote:
>>>>>>>> Tonight is the first time I really spent any time on the network
>>>>>>>> code and let me tell you I am confused as hell. If I follow along the 
>>>>>>>> lobby
>>>>>>>> code I can make enough sense of it but when it comes time for me to 
>>>>>>>> recreate
>>>>>>>> it I can't get shit to work right. I can get it to log in to a server 
>>>>>>>> by
>>>>>>>> copying the "Join chat server" section of the lobby code but I don't 
>>>>>>>> really
>>>>>>>> understand what to do from there.
>>>>>>>> Here are some questions off the top of my head
>>>>>>>> in the "Join chat server" section I think I would want to change
>>>>>>>> GameServer_GetServerList("Chat") to GameServer_GetServerList("Pirate 
>>>>>>>> Dice")
>>>>>>>> I think this would cause the game to join the game server Pirate
>>>>>>>> Dice. Am I right?
>>>>>>>> is the function SendChat the only point in the code where the player
>>>>>>>> can send information to the server? I don't really get the success= 
>>>>>>>> part?
>>>>>>>> I also don't really understand the OnNetworkMessage part. I think it
>>>>>>>> has something to do with sending messages to the server and out to the
>>>>>>>> players but I don't see how it does it. I understand that the bottom 
>>>>>>>> portion
>>>>>>>> of OnNetworkMessage is updating the chatroom. Pirate Dice should 
>>>>>>>> probably
>>>>>>>> have an in game chat.
>>>>>>>> I want to start Pirate Dice. Have a button for join network game.
>>>>>>>> This will look through for a list of servers and then create one if 
>>>>>>>> there is
>>>>>>>> nothing available. Like the lobby, I believe. Pirate Dice will then 
>>>>>>>> begin as
>>>>>>>> it does now.
>>>>>>>> Somehow I want the players name and ID to be assigned to the player
>>>>>>>> value. For example Player1 will say Atrix.
>>>>>>>> Somehow I want the players game choices to get sent to the server
>>>>>>>> and back to the players. The information that should be sent would, the
>>>>>>>> choice they made (raise, bluff, call), what they have in their hand 
>>>>>>>> (pair,
>>>>>>>> three of a kind), and any money information (amount raised, raising to 
>>>>>>>> the
>>>>>>>> called amount)
>>>>>>>> Between work and school I just don't have a lot of time to invest
>>>>>>>> right now. So this is mostly for discussion and to get my brain 
>>>>>>>> thinking. I
>>>>>>>> love working on this stuff I do it for fun and relaxation these days. I
>>>>>>>> might be able to squeeze some time in on the weekends or if I finally 
>>>>>>>> get
>>>>>>>> ahead on homework. The workload will definitely drop as I get the hang 
>>>>>>>> of my
>>>>>>>> job and as I finish off my internet classes.
>>>>>>>> Any help is greatly appreciated.

Other related posts: