Hi all, quick question.
In our old home group, we would assign points for finishing positions. We would take a bit of money from each buy in, and then use the standings at the end of a specified time to award prizes or assign chip amounts for a free roll tournament.
Is there an easy way to get a list of players and places they've finished in any tournaments they have played in? Also, is there a way to add a tournament leaderboard to the site for players to see where they rank for the week, month, year, etc?
Thanks
Shock
Tournament Standings - Leaderboard
-
- Site Admin
- Posts: 5880
- Joined: Wed Mar 19, 2008 8:47 pm
Re: Tournament Standings - Leaderboard
A text-based results file is recorded at the end of each tournament and saved to your data folder (System tab -> Help button -> Locate data folder).
-
- Posts: 170
- Joined: Thu May 21, 2020 5:05 pm
Re: Tournament Standings - Leaderboard
I recommend StatsGenie to track your league. You'll have to hand enter the results from each tourney from Poker Mavens, but it's not that bad. Once the data is in, you can easily manage leaderboard rankings.
You can also assign virtual trophies, quickly export results from any tournament, it tracks Net Gain/Losses by player, etc...
It's free software, a little dated, but it still works great. I have logged 2 seasons and over 150 tournaments into it so far.
~ Supersonics
You can also assign virtual trophies, quickly export results from any tournament, it tracks Net Gain/Losses by player, etc...
It's free software, a little dated, but it still works great. I have logged 2 seasons and over 150 tournaments into it so far.
~ Supersonics
-
- Posts: 213
- Joined: Tue Jul 04, 2017 6:44 am
Re: Tournament Standings - Leaderboard
I can post my callback code if you're interested.
Fair warning : I'm what you'd call a shitcoder and have no idea what I'm doing but I've been doing it well for a year now and it's worked perfectly.
Also note, my code uses existing PM database fields to store information, which your site may already be using. You can use any fields you like or create your own database to store the information.
Simply change the point calculation to your liking.
Fair warning : I'm what you'd call a shitcoder and have no idea what I'm doing but I've been doing it well for a year now and it's worked perfectly.
Also note, my code uses existing PM database fields to store information, which your site may already be using. You can use any fields you like or create your own database to store the information.
Simply change the point calculation to your liking.
Re: Tournament Standings - Leaderboard
Wow! Nice. I'd love to see your code, even if it is "shit"
-
- Posts: 213
- Joined: Tue Jul 04, 2017 6:44 am
Re: Tournament Standings - Leaderboard
thlayli wrote:Wow! Nice. I'd love to see your code, even if it is "shit"
Ok I will get it together as soon as I can and post it here. If you don't already run the Callback system you will need to set that up in PM for this to work. Then when a tourney completes it will calculate the points and write them to the PM database (we use the Custom field) to the field you specify in the code and the leaderboard page will load everyone's points from there. It may be a week or so before I can get around to breaking it all down for you.thlayli wrote:Wow! Nice. I'd love to see your code, even if it is "shit"
-
- Posts: 213
- Joined: Tue Jul 04, 2017 6:44 am
Re: Tournament Standings - Leaderboard
Well I have some time now it turns out, but I'm just going to post all I have for the Callback portion instead of cleaning it up. If you need it completely cleaned out to where it only post points let me know and I'll do that when I have time. I also have not included the page that post the actual points, you can get that off the API examples page and simply use the field you store the points in from this code. But if you need me to post it just let me know. It also has some extra's in it you likely won't need so I will have to clean it up as well or I can just post it as is if you want (with Tourney's played, excluding 0 point players, sorting, etc).
This goes in your callback.php (or whatever you name it) file. Edit as necessary, I left everything we use in (Team points, excluding certain tourneys) so take out what you don't need. Note that I'm writing all of this data directly to the PM database using fields we don't use otherwise (Custom, ERake, PRake, etc), so adjust these fields to suit your needs. This is shitcode level infinity I'm sure, so if you're lucky someone who actually knows what they're doing will post and show the proper way to code this. But ... it works flawlessly for us.
If you need to calc existing points from previously run tourney files I also have a (terrible) way to do that as well, then this below will add to the points total from there after each game. I could never find a good way to get point totals from a ton of existing tourney history without timeouts, so the method I have has to be run in batches to get around the timeouts. Someone smarter could likely code it up to where it will run through everything faster, that person is simply not me.
Also note you can show the Custom and/or Level field when a player is mouseover'd at a table, which is why I chose those fields to store the points/team points.
This goes in your callback.php (or whatever you name it) file. Edit as necessary, I left everything we use in (Team points, excluding certain tourneys) so take out what you don't need. Note that I'm writing all of this data directly to the PM database using fields we don't use otherwise (Custom, ERake, PRake, etc), so adjust these fields to suit your needs. This is shitcode level infinity I'm sure, so if you're lucky someone who actually knows what they're doing will post and show the proper way to code this. But ... it works flawlessly for us.
If you need to calc existing points from previously run tourney files I also have a (terrible) way to do that as well, then this below will add to the points total from there after each game. I could never find a good way to get point totals from a ton of existing tourney history without timeouts, so the method I have has to be run in batches to get around the timeouts. Someone smarter could likely code it up to where it will run through everything faster, that person is simply not me.
Also note you can show the Custom and/or Level field when a player is mouseover'd at a table, which is why I chose those fields to store the points/team points.
Code: Select all
case "TourneyFinish":
fwrite($f,"Event = " . $event . "\n");
fwrite($f,"Name = " . $_POST["Name"] . "\n");
fwrite($f,"Number = " . $_POST["Number"] . "\n");
fwrite($f,"Time = " . $_POST["Time"] . "\n");
fwrite($f,"\n");
$TourneyName = $_POST["Name"];
$TNumber = $_POST["Number"];
$FirstTPoints = 0;
// find latest file
$path = "C:/Your_Path/TourneyResults";
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
// Find all players and give points
$getinfo = file_get_contents($path . "/" . $latest_filename);
preg_match("/Entrants=(.*?)\s/s", $getinfo, $entries);
$entrants = $entries[1];
// This line below can exclude heads up tourneys, ones that use certain tickets or have a certain word in the name - adjust as needed
if (($entrants > 2) && (strpos($TourneyName, 'Ticket') == false) && (strpos($TourneyName, 'Keyword') == false)) {
$getinfo = file_get_contents($path . "/" . $latest_filename);
preg_match("/Entrants=(.*?)\s/s", $getinfo, $entries);
$entrants = $entries[1];
for ($p = 1; $p <= $entrants; $p++) {
$getinfo = file_get_contents($path . "/" . $latest_filename);
preg_match("/Place$p=(.*?)\s/s", $getinfo, $playerplace);
$playername = $playerplace[1];
$params = array("Command" => "AccountsGet", "Player" => $playername);
$api = Poker_API($params);
// get current points - store in any PM database field you prefer - we use Custom field
$CurrentLevel = $api -> Custom;
// get current tourney # played - Remove this if not tracked
$CurrentTourney = $api -> ERake;
// Get current TU tourneys played - For team points remove if not tracked
$CurrentTUPTourney = $api -> PRake2;
// get current team up points - for team points remove if not used
$CurrentTUPs = $api -> Level;
$params = array("Command" => "TournamentsGet", "Name" => $TourneyName);
$api = Poker_API($params);
$BuyInAmt = $api -> BuyIn;
// point calculation - change as desired
$CalcPoints = sqrt($entrants * ($BuyInAmt + 0.25)) / (1 + $p);
$LevelAmt = round(abs($CalcPoints),3) + $CurrentLevel;
$params = array("Command" => "AccountsEdit", "Player" => $playername, "Custom" => $LevelAmt);
$api = Poker_API($params);
$result = $api -> Result;
// add entry to log file
$LogCalcPoints = round(abs($CalcPoints),3);
$params = array("Command" => "LogsAddEvent", "Log" => $playername . " awarded " . $LogCalcPoints . " Tourney Points");
$api = Poker_API($params);
// get # of tournies played in - remove if not used
$TourniesPlayed = $CurrentTourney + 1;
$params = array("Command" => "AccountsEdit", "Player" => $playername, "ERake" => $TourniesPlayed);
$api = Poker_API($params);
$result = $api -> Result;
// get 1st place points for bot below - only used if posting to discord bot
if ($p == 1) $PostPoints = round(abs($CalcPoints),3);
// calc team up points - only used if using team points otherwise remove
if (strpos($TourneyName, 'TEAM UP') !== false) {
$TUPPlayed = $CurrentTUPTourney + 1;
$params = array("Command" => "AccountsEdit", "Player" => $playername, "PRake2" => $TUPPlayed);
$api = Poker_API($params);
$result = $api -> Result;
$AwardedPoints = round(($entrants / $p),3);
$TeamPoints = round(($entrants / $p),3) + $CurrentTUPs;
$params = array("Command" => "AccountsEdit", "Player" => $playername, "Level" => $TeamPoints);
$api = Poker_API($params);
$result = $api -> Result;
// add entry to log file
$params = array("Command" => "LogsAddEvent", "Log" => $playername . " awarded " . $AwardedPoints . " Team Up Points");
$api = Poker_API($params);
if ($p == 1) $FirstTPoints = round(($entrants / $p),3);
}
}
}
// post message in discord chan - only used for discord bot posting results otherwise remove
$getinfo = file_get_contents($path . "/" . $latest_filename);
preg_match_all("/Number=($TNumber).*?Place1=(.*?)\s/s", $getinfo, $info);
$Winner = $info[2][0];
$message = "**$TourneyName Results** \nTourney Number: $TNumber \n**Winner: $Winner**\n**Points:** $PostPoints\n**Team Points:** $FirstTPoints";
$data = ['content' => $message];
$options = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents('https://discordapp.com/api/webhooks/your_webhook_here', false, $context);
break;
Re: Tournament Standings - Leaderboard
this is awesome, thanks for sharing
i actually put this into my server and i was able to get the points update.
However, i noticed that when I play the same sit and go several times, it will keep reading the top result of the tournament and keep feeding those points into from that original tournament.
the $tnumber is not used except in the discord, is it possible to have to read each tournament result separately?
i actually put this into my server and i was able to get the points update.
However, i noticed that when I play the same sit and go several times, it will keep reading the top result of the tournament and keep feeding those points into from that original tournament.
the $tnumber is not used except in the discord, is it possible to have to read each tournament result separately?
Re: Tournament Standings - Leaderboard
i was able to solve this by adding this
rename($path . "/" . $latest_filename,$path . "/" . $latest_filename . "-" . $TNumber . ".txt"); // this line renames after processing
rename($path . "/" . $latest_filename,$path . "/" . $latest_filename . "-" . $TNumber . ".txt"); // this line renames after processing
Re: Tournament Standings - Leaderboard
could you share the code to display the leaderboard?
I have been using a modified version of the leaderboard but I can't seem to pull the tournaments played into that 2D array.
I have been using a modified version of the leaderboard but I can't seem to pull the tournaments played into that 2D array.