How would you approach this? (PHP PBP Engine Advice)

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Devereaux
Posts: 24
Joined: Wed Nov 28, 2012 3:50 am

How would you approach this? (PHP PBP Engine Advice)

Post by Devereaux »

I am trying to figure out how to run a play-by-play simulation(simulator) for a wrestling game(think WWE/F).

Wrestler1 and Wrestler2 have 100% health to start and each move from the move database does x amount of damage and deducts y amount of energy. If the move is hit it subtracts from health and energy and outputs 1 of 3 random text strings describing the move sequence. If the move is missed it does nothing to health or energy and outputs 1 of 3 random string describing the move "failure" sequence.

Each move will be assigned a move_id, move_name, move_damage, move_energy, move_type, move_section, is_pin, cause_blood in the moves table in the database.

move_id = autoincrement
move_name = move name
move_damage = how much damage the move does if successful
move_energy = how much energy the move takes away if successful
move_type = Aerial, Impact, Behind, Submission, Strike
move_section = which sections can this move be performed in? Entrance, Opening, Early, Middle, Late, Finish, Post(can have more than 1 section per move to add more variety to sections)
is_pin = does this move go in to a pin count?
cause_blood = does this move cause the opponent to bleed?

Match Sections
  • Each section will have a three scenarios picked randomly to allow freshness and unpredictability.
  • Each section will randomly select moves from the wrestlers table for moves which will be defined in the database as numbers and then called upon moves.php to associate numbers with moves.
  • Each move has 3 success and 3 failure play-by-play text entries.
  • If the user is determined to be successful, it will select randomly a PBP text to generate from the 3. (Same for failure)
  • It will generate the play-by-play text and display it on screen, then move on to the next move.
  • Each section, except Entrance and Post, will generate 10 moves by random depending upon which move_section in the database the are allowed to be executed in.
  • Match cannot end until Finish. Trying to figure out how to incorporate a random pinning text allowing only 1 and 2 counts from Early to Late and 3 count(end) for Finish.
Entrance

Display by random 1 of 5 different entrance text scenarios.

Opening

Generate 10 moves based on the Opening move_section.

Early

Generate 10 moves based on the Early move_section.

Middle

Generate 10 moves based on the Middle move_section.

Late

Generate 10 moves based on the Late move_section.

Finish

Generate 10 moves based on the Finish move_section.

Post

Display by random 1 of 10 different post-match text scenarios.

Match Summary
$matchwinner defeated $matchloser by $matchfinish(pinfall,submission,etc) at $matchtimelength
$matchrating (* out of 5 stars)(based on algorithm of both wrestlers talent, experience, popularity, modifiers, and boosts)(higher match rating = more skill and experience gains)
$wrestler1 gained $x points in popularity
$wrestler2 lost $y points in popularity

Other Notes
Match PBP will not show sections. It will be the entrance, grouping of 50 moves, post-match, and then followed by the summary.
Files will be match.php, moves.php, match_entrance.php, and match_post.php. (maybe I am structuring this wrong?)
This is not a generic attack, defend, kill type of RPG/game

I'm just looking for advice. I don't need people to write out this engine because how will I learn? I'm trying gather the approaches some of you more seasoned developers would take in this scenario and in the most effective way possible. Thanks in advance and anything helps!

:mrgreen:
Unnamed Wrestling PBBG in Production
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Jackolantern »

I just wanted you to know I am still planning to take a look at this later today.

Mother and I are still collating. :ugeek:
The indelible lord of tl;dr
Devereaux
Posts: 24
Joined: Wed Nov 28, 2012 3:50 am

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Devereaux »

Thanks man, I was starting to think people were just ignoring me. Haha
Unnamed Wrestling PBBG in Production
User avatar
Xaos
Posts: 946
Joined: Wed Jan 11, 2012 4:01 am

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Xaos »

I wouldn't split the pre/mid/post and stuff up into different files. I would just have them in the same and have something like if(fight is over){ post stuff }. And why do you have the moves concrete into sections? Why not implement a fatigue/health system instead? So you would have high fatigue, medium fatigue and low fatigue (or health) and you can only do moves when your opponent is in that section? IE You cant do Move X until your opponent has reached low health. And as far as the PBP or whatever, just do switch or if/elseif statements. if(move = movex){ "wrestler did move x !"} kinda deal. It will produce PBP and you don't have to do much extra. If I didn't answer your questions, just lemme know, and I'll try again, haha. I'm in no means super experienced, but I have worked with stuff like this a bit. I'll include a very simple fight script I made with PBP just so you can look at it

Code: Select all

<?php

$p1attack = $_POST['p1attack'];
$p2defense= $_POST['p2defense'];
$p2elusiveness=$_POST['p2elusiveness'];
$p1dexterity=$_POST['p1dexterity'];
$p1health=$_POST['p1health'];
$p1speed=$_POST['p1speed'];
$p2speed=$_POST['p2speed'];
$p2attack = $_POST['p2attack'];
$p1defense = $_POST['p1defense'];
$p1elusiveness = $_POST['p1elusiveness'];
$p2dexterity = $_POST['p2dexterity'];
$p2health=$_POST['p2health'];
$p1name=$_POST['name1'];
$p2name=$_POST['name2'];



function fight($attack,$defense,$elusiveness,$dexterity,$health){
    $hitchance = rand(1,$dexterity)-rand(1,$elusiveness);
    if($hitchance >= rand(1,$elusiveness)){
        echo "Hit! <br />";
        $damage = ($attack * rand(1,$attack))-($defense * rand(1,$defense));
        if($damage >= 0){
            $health = $health - $damage;
            echo "Damage dealt = $damage <br />"   ;
            echo "Health = $health <br />"   ;
        }else{
            echo "Attack paried!<br />"   ;
        }
    }else{
        echo "Miss!<br />";
    }

    return $health;
}

while($p1health > 0 && $p2health > 0){
  $p1speedchance = (($p1speed + $p1elusiveness)/2) * rand(1,100);
  $p2speedchance = (($p2speed + $p2elusiveness)/2) * rand(1,100);
    if($p1speedchance > $p2speedchance){
    echo "$p1name goes for the attack! <br />";
    $p2health = fight($p1attack,$p2defense,$p2elusiveness,$p1dexterity,$p2health);
        if($p2health <= 0){
        echo "$p2name has perished. $p1name has claimed victory!<br />";
        }
    }else{
    echo "$p2name goes for the attack! <br />";
    $p1health = fight($p2attack,$p1defense,$p1elusiveness,$p2dexterity,$p1health);
        if($p1health <= 0){
            echo "$p1name has perished. $p2name has claimed victory!<br />";
        }
    }
}
?>
Devereaux
Posts: 24
Joined: Wed Nov 28, 2012 3:50 am

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Devereaux »

I was thinking of having an overall health/energy system with the move sections. The reason why I chose sections from an overall start/end/post concept is there is already a few wrestling sim games and they all have the start/end concept with light/medium/heavy moves. The problem with this ultimately as when a match is simulated it comes nowhere close to what a real wrestling match will look like. Being an ex-professional wrestler I know that wrestling is a staged artform with different sections to a match and almost 75% of the time follow this pattern in real life. Now the way I structured my idea may be off from a programming ideology standpoint but the real life pattern is something I am aiming for.

To get a better understanding on how a real professional wrestling match progresses, you can read more here: http://scienceofwrestling.blogspot.com/

Basically for those that don't want to read it, wrestling matches have section pattern in which to entertain a crowd. Ultimately my goal is to produce something that is entertaining to read not just a formality to a browser game. I've included an attachment from a game where they use an engine style that I don't want to go in the direction of. You will see it just gets extremely repetitive and is nowhere near the slightest entertaining to read. More daunting.

I figured the actually PBP will be if/elseif statements but wasn't sure if there was an easier or more efficient way to approach it.

What I don't want: http://s810.photobucket.com/user/Digita ... sort=3&o=0
Unnamed Wrestling PBBG in Production
User avatar
Xaos
Posts: 946
Joined: Wed Jan 11, 2012 4:01 am

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Xaos »

I completely get it now, I didn't even know that about the sections and whatnot. It all makes sense now. You could do for loops, and have it set to once the total moves reaches 10, it advances to the next section. Then for each section, have it pull the fighters moves for that section. IE if it was the Middle sectiono, it would pull all the moves from each of the wrestlers where it was selected to Middle. Then it would go through that fighting section. And the easier way to do the PBP sections is just the switch statements. You wouldn't even have to check for each fighter. Put the actual fighting part into a function, then call the function once the person's turn has been called/determined, check what move it is, spit out a random line. The more moves and lines of PBP you have, the better the sim is, but the more complicated/tedious it is to code (of course)
Devereaux
Posts: 24
Joined: Wed Nov 28, 2012 3:50 am

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Devereaux »

Xaos wrote:I completely get it now, I didn't even know that about the sections and whatnot. It all makes sense now. You could do for loops, and have it set to once the total moves reaches 10, it advances to the next section. Then for each section, have it pull the fighters moves for that section. IE if it was the Middle sectiono, it would pull all the moves from each of the wrestlers where it was selected to Middle. Then it would go through that fighting section. And the easier way to do the PBP sections is just the switch statements. You wouldn't even have to check for each fighter. Put the actual fighting part into a function, then call the function once the person's turn has been called/determined, check what move it is, spit out a random line. The more moves and lines of PBP you have, the better the sim is, but the more complicated/tedious it is to code (of course)
Exactly!

Being fairly new though to PHP (under a year), I just want to make sure this would be the most efficient way to start coding. I'm sure I'll do a lot of backtracking. Just want to make sure I don't do it majorly.
Unnamed Wrestling PBBG in Production
User avatar
Xaos
Posts: 946
Joined: Wed Jan 11, 2012 4:01 am

Re: How would you approach this? (PHP PBP Engine Advice)

Post by Xaos »

Devereaux wrote:
Xaos wrote:I completely get it now, I didn't even know that about the sections and whatnot. It all makes sense now. You could do for loops, and have it set to once the total moves reaches 10, it advances to the next section. Then for each section, have it pull the fighters moves for that section. IE if it was the Middle sectiono, it would pull all the moves from each of the wrestlers where it was selected to Middle. Then it would go through that fighting section. And the easier way to do the PBP sections is just the switch statements. You wouldn't even have to check for each fighter. Put the actual fighting part into a function, then call the function once the person's turn has been called/determined, check what move it is, spit out a random line. The more moves and lines of PBP you have, the better the sim is, but the more complicated/tedious it is to code (of course)
Exactly!

Being fairly new though to PHP (under a year), I just want to make sure this would be the most efficient way to start coding. I'm sure I'll do a lot of backtracking. Just want to make sure I don't do it majorly.
Yup. If you need any help through the process, don't hesistate to post here or PM me for my Skype name, i'm always available on IM. Look at the fight code I posted, it's a good template for getting out PBP. Create the actual fight function for each section, then use however you are determining who is the agressor in the sim and just apply the function. Using good functions, it won't be that complicated nor will you backtrack nearly as much.
Post Reply

Return to “Advanced Help and Support”