Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / May 2008



Tip: Looking for answers? Try searching our database.

How would you tackle this project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kenji776 - 08 May 2008 14:57 GMT
Hello all,
My friends have asked that I try to write a turn based game in CF, focusing
around player on player turn based matches in which each player chooses
fighting moves to try and bring the others hit points down to zero. Very
similar to facebook wrestling for those of you who may know that. I have the
whole framework up for everything besides the actual fighting (choosing moves,
fighting styles, buying items, scheduling fights and so on is done). I'm having
a bit of a hard time thinking of a good way to accomplish a turn based stat
calculate that provides the same results to both clients when random variables
(such as odd's of blocking, dodging etc) are involved.

I was thinking of having on page where the user chooses what moves they want
to use (moves will be sent in groups of three, such as kick, kick block, or
punch, kick, counter, etc) and those move choices are then sent to a page that
calulates if they succeed or not, and the results are posted to a database.
Once they results are posted, the opposing player sees the results via an ajax
page that refreshes every few seconds. The problem is, the calculate page needs
to know what both players did before it can calculate anything, such as say
player one chose kick, block punch, and player two chose block, kick, kick, the
calculation page needs to know that player 2 blocked player 1's kick before it
can try to calculate damage done and such.

I know this sounds like a dumb goofy project, but hey, why not have some fun.
Take a break from thinking business code for a second and have some fun helping
a dude make a game. If you are interested and want to see what I have so far,
please visit www.digitalswordsmen.com/pit_fighter
Let me know what you think and post any ideas/suggestions you might have.
Thanks!
Ian Skinner - 08 May 2008 15:58 GMT
This may be a bit beyond just a ColdFusion solution.

The difficulty is tying two separate sessions together.  This is
something ColdFusion is not really built to do.

I can imagine that you maybe able to do something with an application
data structure that joins pairs of sessions together.

But if you have access to use Flex it does have built in sharing|pushing
capabilities and could make this task easier.  Depending on how agile
you are at picking up the concepts of Flex.  Just a note on cost.  One
can do Flex for free as long as you make do without the handy-dandy Flex
builder tool.
TSB - 08 May 2008 16:53 GMT
This is a perfect fit for an Application variable. You could have an
application var with an array of session vars.  Or you could just control the
whole flow from the application level.  Just make sure to use cflock when
updating the app var.

Trevor
kenji776 - 08 May 2008 17:16 GMT
You may be onto something there. So have an application variable for each duel,
and within that a session var for player 1 health, player 2 health, player 1
move choice and so on? Where then should the calculations be done?
TSB - 08 May 2008 18:06 GMT
You would need an action type cfm file on the server that contained all the
logic code for the game.  Like you said this page could be called via ajax and
game info (moves, results, etc...) could be passed back and forth from the
server to the client.  I did sudoku helper program that uses ajax like that at
http://www.burnette.us/blog/index.cfm/2006/9/21/You-Say-Sudoku-I-Say-Sudoko
kenji776 - 08 May 2008 18:26 GMT
Ah, very impressive. I will just throw this out there, TSB would you be
interested in helping me code this? I could get you login information and such
to my server, and access to the database and all that. I have a ton of work to
do on this app, and you seem like you could be a great help. Let me know if you
want to/have time. Thanks! That offer goes for anyone else who is interested, I
can use all the help I can get with this project.
davidmedifit - 08 May 2008 19:33 GMT
This sounds like a great application for LiveCycle data services. I assume
you'll need to use the express (free) version to start. You would need to
create a data set, and broadcast messages to the browser once the data set is
updated.

Cheers,

David
Eivind - 09 May 2008 08:51 GMT
TSB skreiv:
> You would need an action type cfm file on the server that contained all the
> logic code for the game.  Like you said this page could be called via ajax and
> game info (moves, results, etc...) could be passed back and forth from the
> server to the client.  I did sudoku helper program that uses ajax like that at
> http://www.burnette.us/blog/index.cfm/2006/9/21/You-Say-Sudoku-I-Say-Sudoko

                 </td>
                            </cfloop>
                          </tr>
                        </cfloop>
                      </table>
                    </td>
                  </cfloop>
                </tr>
              </cfloop>
            </table>
          </td>
        </cfloop>
      </tr>
    </cfloop>
  </table>
</cfoutput>

(quote from that program)

Just out of curiosity, did you use to be a lisp-programmer ?

    Eivind
TSB - 08 May 2008 20:20 GMT
Kenji, I have ajax examples on the site and you can email me with questions, my
address is on the website burnette.us.  I will try and email help with any
problems you run into building the app but I don't have that much free time
anymore.  As you can see I have not posted code examples on my site in over a
year.  About the time I went from programmer to IT manager.

Trevor
kenji776 - 08 May 2008 20:46 GMT
David,
Thanks for the input, I will certainly check out LiveCycle. I am always
hesitant to try new technologies, as I only have a such a loose handle on the
ones I already use :P Is it hard to get started with? TSB, thanks for the
sample code and such, I am sure it will be very valuable, and I will probably
ask for your help a few times. Thanks to some suggestions from other people, I
know have to basically overhaul my fighting moves database, as we are moving a
tree based skill system (similar to Diablo for those who have played that). I
will work on getting that all changed over to the new style and come back to
this part of the project hopefully in a day or two.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.