Email based gameplay

  • Posted by Matthew Lauritzen
  • at 16:04 -
  • 0 comments

As I mentioned before, I really don't like the idea of trying to play a networked 5hr plus game over a possible 3 hour (or more) time difference.  So the next best idea is do figure out a way to play a game based on email.  Here's what I came up with:
  1. Player plays his turn
  2. Game automatically emails the next player with the current state of the game
  3. When the next player receives an email, it will have a save file attachment, he loads that attachment and it automatically sets up the board state and resumes play from that point
This is the basic logic of a "pen-pal chess" game.  But there are a couple of challenges I had to over come
  1.  How do you keep the file from being "hacked"
    1. Well, this one will always be tough, but as long as the file is written in binary that's a pretty good start.  The bigger issue is trying to keep players from "replaying" their turn.  There's no real solution for this other than the emails are sent automatically by the program, so if emails are received out of order, the game will suddenly have 2 different possible states... right now I'm relying the people playing to not be complete dicks >_<
  2. How do you actually send emails from C++ code
    1. I had a course on networking in college where we did exactly this, but we never sent file attachments.  So I hit google and found a number of resources, and shortcuts (or what I thought would be shortcuts) for sending emails from code.
      1. Attempt #1: http://johnwiggins.net/jwsmtp - John's website is one for the first that comes up when searching for code examples on this topic, and he's shared his code out for the world to use... must be good right?  Meh... It sends emails, and if your attachment were pictures, it would get the job done, but for everything else it tries to encrypt and add the attachment into the body of the message of the email... not what I wanted at all
      2. Attempt #2: http://www.emailarchitect.net/easendmail/ex/vc/14.aspx - Another site that seems to have it's shit together, but this garbage couldn't even open a connection to any mail server I picked.  Complete waste of a weekend
      3. Attempt #3: http://msdn.microsoft.com/en-us/library/system.net.mail.aspx - I finally wised up and just went straight to the source... the managed C++ libraries I normally find to be complete crap.... but this was everything I needed and it all worked on the first try.

0 comments: