CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2010
    Posts
    6

    card game event reporter

    hi i have a small web project that i am working on and have gotten stuck trying to convert what i have in concept into code.

    the idea is to make a tournement event reporter for a online card game that has no pre installed reporter below is how the reporter would run

    outline for event reporter
    On load
    Player Logs in
    ask player if they want to enter event
    if yes
    enter player into the listings
    if no
    player watches listings
    before round starts
    if first round
    randomly generate match pairings
    else
    pair players on last rounds win/draw/lose ratio and who players haven't played against during this event
    during round
    show current standings of the event
    countdown timer
    start timer at 1:00:00 text colour green
    if timer.time is less than 0:30:00
    text colour = amber
    alert message Half hour left
    else if timer.time is less than 0:15:00
    text colour = Red
    alert message fifteen minutes left
    else if timer.time is 0:00:00
    alert message end of round
    players enter match scores in the form of 2-0/2-1 1-2/0-2 or 1-1
    if player =2-0/2-1
    add 1 to win counter
    else if player = 1-2/0-2
    add 1 to loss counter
    else
    add 1 to both players draw counter
    update standings


    i have already got the user table set up with end of match scores set in a MySQL database the main bits that are troubling me are the IF statments and the 1 hour count down timers

    and sample codes would be greatly apriciated

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: card game event reporter

    We exist to help people. I'm sorry, but our volunteer contributions don't extend to writing massive amounts of code methods for people who have done almost nothing.

    If you have a more concrete setup available, perhaps you could share that code. Then we could assist further.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Oct 2010
    Posts
    6

    Re: card game event reporter

    Quote Originally Posted by PeejAvery View Post
    We exist to help people. I'm sorry, but our volunteer contributions don't extend to writing massive amounts of code methods for people who have done almost nothing.

    If you have a more concrete setup available, perhaps you could share that code. Then we could assist further.
    i understand that i wasnt hoping for loads of doe to be posted for me i was hoping for some sample sippets on how to do certain bits in it as i have only just started workin with php and was getting abit lost in it all. i appologise for any misunderstanding.

    i have gotten the roughs basis for the pairings sorted for the initail start up of the "event" as such but the following rounds has got me puzzled. my code so far for the pairings is

    Code:
    <?php
    // Display records from the table
            $sql = "SELECT * FROM members where picked='0'";
            echo "<table border='1'>";
            do {
                // Select records from the DB
                $query = "SELECT * FROM members WHERE Online='1' AND picked='0'
                  ORDER BY Rand() LIMIT 2";
                $result = mysql_query($query);
    
                while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
                    echo "<tr><td>$row[3]</td>";
                    mysql_query("update members set picked='1' where login='$row[3]'") or die(mysql_error());
                }
                // Display records from the table
                echo "<table border='1'>";
                while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
                    echo "<td>$row[3]</td>";
                    mysql_query("update members set picked='1' where login='$row[3]'") or die(mysql_error());
                }
                echo"</tr>";
            } while ($Result = mysql_query($sql));
            echo "</table>";
    ?>
    which as i said above works for the 1st round pairings but after round one some players will have a win and need to be pair against each other and the same for players with a loss a code snippet on how to do this would be helpfull as i would assume that this could just go inside an if statment or would there be an easier way than that??

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: card game event reporter

    You should have a column for the games played as well. That way you can reference the last game to see if it was a win/loss. If you have that data in your database, then adding a simple WHERE clause will give you the results.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Oct 2010
    Posts
    6

    Re: card game event reporter

    in the mySQl table i have got colums for "win", "loss"and "draw" of which with each round the wins get added to the relevent ones and was thinking if possible do and if statment which will reference a mysqul_query with a where clause in it. i think i know how to write this (and hope i wont get any errors). also is there a way to set what "member ids" or "logins" a certain player has played against??? thank you for all you help

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: card game event reporter

    You should have an additional table for game data. I accidentally said column, but meant table. That way you can reference the latest matches and figure out the winners. It should have the following columns.

    • game_id
    • timestamp
    • player_1_id (match with user's table)
    • player_2_id (match with user's table)
    • winner_id (match with user's table)
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Oct 2010
    Posts
    6

    Re: card game event reporter

    Quote Originally Posted by PeejAvery View Post
    You should have an additional table for game data. I accidentally said column, but meant table. That way you can reference the latest matches and figure out the winners. It should have the following columns.

    • game_id
    • timestamp
    • player_1_id (match with user's table)
    • player_2_id (match with user's table)
    • winner_id (match with user's table)
    thaks for clearing that up. i would assume that i could use the generation code in the above post to generate and then link said login id to the player1/2 columns.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured