8 Replies Latest reply on May 8, 2008 12:46 PM by kenji776

    How would you tackle this project

    kenji776 Level 1
      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!
        • 1. Re: How would you tackle this project
          Level 7
          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.
          • 2. Re: How would you tackle this project
            TSB Level 1
            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.

            • 3. Re: How would you tackle this project
              kenji776 Level 1
              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?
              • 4. Re: How would you tackle this project
                TSB Level 1
                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
                • 5. Re: How would you tackle this project
                  kenji776 Level 1
                  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.
                  • 6. Re: How would you tackle this project
                    davidmedifit Level 1
                    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.


                    • 7. Re: How would you tackle this project
                      TSB Level 1
                      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.

                      • 8. Re: How would you tackle this project
                        kenji776 Level 1
                        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.