Tournaments

For discussion of the Poker Mavens server module and other administration topics
demon1031
Posts: 21
Joined: Fri Mar 30, 2012 4:23 pm

Tournaments

Post by demon1031 »

Is there a way to not pay out a Tournament unless there is a certain number of people?

Example

I wish to run a free roll to give away free points, is there a way not to pay out unless there are 6 players minimum? I have the payout structure to be 6-1000 so theoretically, it should not pay out unless there are at least 6. Correct? Well, it pays out if 2 people are in there.

I would set the options for start min 6 but what if the first 6 people get in there and hit start? What about the other people that might want to play ?


Just wondering if there is an easy fix for this ??

Thanks
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: Tournaments

Post by PokerMavenDeveloper »

you can to build a script to when the tournament start verify if has the minimum player this is a code for that, put this in your callback, i hope this help

Code: Select all

<?php
      //Tournament name example : FREEROLL Bs.100|01PM|20J
      include "API.php";  // $url, $pw, and Poker_API() defined here
      $pw = $_POST["Password"];
      if ($pw != "test") exit;
      $f = fopen("Callback.txt","a");
      $event = $_POST["Event"];
      switch ($event)
      {
        case "TourneyStart":
			//"-20JMIN"
		  $l = strtoupper(substr($_POST["Name"],-3));
		  $pos= ($l=="aseg.bs");
		  $name = $_POST["Name"];
		  $time = $_POST["Time"];
          fwrite($f,"Event: $event | Name: $name | Time: $time Subsrt: $l\n");
		  //buscar el Torneo
			if($l=="20J" )
			{
				$tourney = urlencode($name);
				fwrite($f,"$tourney  es un asegurado\n");
				//pausar el torneo TournamentsPause
				/*$params = "&Command=TournamentsPause&Name=$tourney";
				$api = Poker_API($params,true);
				if ($api["Result"] == "Error") fwrite($f,"Error: " . $api["Error"]."\n"); */
				//buscar el numero de inscritos
				$params = "&Command=TournamentsPlaying&Name=$tourney";
				$api = Poker_API($params,true);
				if ($api["Result"] == "Error") fwrite($f,"Error: " . $api["Error"]."\n"); 
				$inscritos = $api["Count"];
				fwrite($f,"Inscritos: $inscritos\n " ) ;
				if($inscritos<20)
				{
					//Enviar mensage al torneo TournamentsMessage 
					$msg=urlencode("EL TORNEO SERA CANCELADO, SE REQUIERE DE 20 JUGADORES MINIMO!!!");
					$params = "&Command=TournamentsMessage&Name=$tourney&Message=$msg";
				    $api = Poker_API($params,true);	
					if ($api["Result"] == "Error") fwrite($f,"Error: " . $api["Error"]."\n"); 					
					//cancelar el torneo
					$params = "&Command=TournamentsOffline&Name=$tourney&Now=Yes";
				    $api = Poker_API($params,true);
					if ($api["Result"] == "Error") fwrite($f,"Error al colocar Offline: " . $api["Error"]."\n"); 
				}

			}

          break;
        case "TourneyFinish":
		  $l = strtoupper(substr($_POST["Name"],-3));
		  $name = $_POST["Name"];
		  $time = $_POST["Time"];
          fwrite($f,"Event: $event | Name: $name | Time: $time Subsrt: $l\n");
		  
          $trname = $_POST["Name"];
          $trdate = substr($_POST["Time"],0,10);
		  if($l=="20J" )
		  {
		      $tourney = urlencode($_POST["Name"]);
			  fwrite($f,"$tourney  es un asegurado - fecha $trdate\n");
			  //Buscar si es una aseg y si se aborto
			  $params = "&Command=TournamentsResults&Date=" . $trdate . "&Name=" . urlencode($trname);
			  $api = Poker_API($params,true);
			  if ($api["Result"] == "Error") fwrite($f,"Error al traer resultados: " . $api["Error"]."\n"); 										
			  $stop= $api["Stop"];
			  fwrite($f,"$stop\n");
			  //Buscar si esta la palabra abort
			  $pos = strrpos($stop, "(Abort)");
			  if($pos != false)
			  {
				//actualizar la fecha y poner online el torneo
				//cancelar el torneo
					sleep(10);
					//Buscar si es un freeroll
					$pos = strrpos($trname, "FREEROLL");
					$l = strtoupper(substr($trname,0,8));
					fwrite($f,"palabra $l\n");
					if($l=="FREEROLL")
					{
						//QUITAR EL SALDO A LOS GANADORES
						QuitarPremioJugadores($trname, $trdate ,$f);	
					}
					
					//Modificar la fecha
					$newdate = add_date( $_POST["Time"],1,0,0);
					fwrite($f,"$newdate\n");
					//TournamentsResume 
					$params = "&Command=TournamentsEdit&Name=$tourney&StartTime=$newdate";
				    $api = Poker_API($params,true);
					if ($api["Result"] == "Error") fwrite($f,"Error al actualizar la fecha: " . $api["Error"]."\n"); 	 								
					//ColocarOnline de nevo
					$params = "&Command=TournamentsOnline&Name=$tourney";
				    $api = Poker_API($params,true);
					if ($api["Result"] == "Error") fwrite($f,"Error al colocar Online: " . $api["Error"]."\n"); 				
			  }
			  
		  }

          break;
        case "TourneyError":
          fwrite($f,"Event = " . $event . "\n");
          fwrite($f,"Name = " . $_POST["Name"] . "\n");
          fwrite($f,"Error = " . $_POST["Error"] . "\n");
          fwrite($f,"Time = " . $_POST["Time"] . "\n");
          fwrite($f,"\n");
          break;
      }
      fclose($f);

	function add_date($givendate,$day=0,$mth=0,$yr=0) 
	{
		$cd = strtotime($givendate);
		$newdate = date('Y-m-d h:i:s', mktime(date('h',$cd),
		date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
		date('d',$cd)+$day, date('Y',$cd)+$yr));
		return $newdate;
	}
	function ordinal($lugar)
      {
          switch ($lugar)
          {
              case 1: $o = "1er Lugar: "; break;
              case 2: $o = "2do Lugar: "; break;
              case 3: $o = "3er Lugar: "; break;
              case 4: $o = "4to Lugar: "; break;
              case 5: $o = "5to Lugar: "; break;

          }
		  return $o;
      }
	 
function QuitarPremioJugadores($trname,$trdate,$f)
	{
        // retrieve file
        $params = "&Command=TournamentsResults&Date=" . $trdate . "&Name=" . urlencode($trname);
        $api = Poker_API($params,false);
        // check for error
        if ($api[0] == "Result=Error") fwrite($f,($api[1]));
        // display results
        $msg="Ganadores del Torneo [$trname]:  ";
		
        for ($i=1; $i<count($api); $i++)
        {
			$place="";
            $place= substr($api[$i], 0,5);
            $lugar =substr($api[$i], 5,1);
			$player= substr($api[$i], 7);
            $l = strrpos($player, "(");
			$stop = substr($api[$i], 0,5);
            $player=trim(substr($player, 0,$l));
			$buyin = substr($api[$i], 0,5);
			if($buyin=="BuyIn")
			{
				//encontrar donde esta el mas
				$pos = strrpos($api[$i], "+");
				$fee = substr($api[$i],$pos+1);				
			}
            if($place=="Place")
                {
                    $won=str_replace(")", "",   str_replace("(", "",  substr( $api[$i], 7)));
					$won=(int) str_replace($player, "", $won);
                    if($won>0)
                    {
                        $ganador[$lugar]=$player;
                        $ganado[$lugar] = $won;
						fwrite($f,"Ganador: $player Fichas: $won"."\n");
						$params = "&Command=AccountsDecBalance&Player=$player&Amount=$won";
						$api2 = Poker_API($params,true);
						if ($api2["Result"] == "Error") fwrite($f,"Error: " . $api2["Error"]) ;
						if ($api2[Result] == "Ok") fwrite($f,"The chip balance is " . $api2[Balance] ."\n");						
						//echo "Player: $player Posicion:$lugar Ganado:$won </br>";
						$place ="";
                    }                
				}
			if($stop=="Stop=")
			{
				$finish=substr($api[$i], 5);
				//Aqui postear el resultado
				//PublicarenTwitter($msg,$ganador,$finish);
			}

		}
	}
	 
    ?>

	  

PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: Tournaments

Post by PokerMavenDeveloper »

a gift a procedure to post tournament result in twitter

Code: Select all



function TournamentsWinners($tourney)
	 {
// split out date and tourney name from selected value

        $tourney = stripslashes($_REQUEST["tourney"]);
		echo $tourney;
        $trdate = Substr($tourney,0,10);
        $trname = Substr($tourney,12);


        // retrieve file

        $params = "&Command=TournamentsResults&Date=" . $trdate . "&Name=" . urlencode($trname);
        $api = Poker_API($params,false);

        // check for error

        if ($api[0] == "Result=Error") die($api[1]);
         
        // display results
        $msg="Ganadores del Torneo [$trname]:  ";
		
        for ($i=1; $i<count($api); $i++)
        {
			$place="";
            $place= substr($api[$i], 0,5);
            $lugar =substr($api[$i], 5,1);
			$player= substr($api[$i], 7);
            $l = strrpos($player, "(");
			$stop = substr($api[$i], 0,5);
            $player=trim(substr($player, 0,$l));
			echo $api[$i]."</br>";
			$buyin = substr($api[$i], 0,5);
			if($buyin=="BuyIn")
			{
				//encontrar donde esta el mas
				$pos = strrpos($api[$i], "+");
				$fee = substr($api[$i],$pos+1);				
			}
            if($place=="Place")
                {
                    $won=str_replace(")", "",   str_replace("(", "",  substr( $api[$i], 7)));
					$won=(int) str_replace($player, "", $won);
                    if($won>0)
                    {
                        $ganador[$lugar]=$player;
                        $ganado[$lugar] = $won;
						//echo "Player: $player Posicion:$lugar Ganado:$won </br>";
                    }                
				}
			if($stop=="Stop=")
			{
				$finish=substr($api[$i], 5);
				//Aqui postear el resultado
				PublicarenTwitter($msg,$ganador,$finish);
			}
        }	 
	 }

Code: Select all

function PublicarenTwitter($msg,$ganador,$finish)
	 {
		for($i=1; $i<=sizeof($ganador); $i++)
		{
			if($i<=3) $msg .= "[".ordinal($i).$ganador[$i]."]-";
		}
		$msg.=$finish;
		$msg = substr($msg,0,140);
		$consumer_key = 'YOUR CONSUMER KEY';
		$consumer_secret = 'YOUR SECRET KEY';
		$token = 'YOUR TOKEN';
		$secret= 'SECRET WORD'; //ALL THIS PARAMETER GIVE IN TWITTER API
 
		$connection = new TwitterOAuth($consumer_key,$consumer_secret, $token, $secret);
		$content = $connection->get('account/verify_credentials');
		$connection->post('statuses/update', array('status' => $msg));		
		
	 }	
Attachments
TWITTER-API.zip
(9.14 KiB) Downloaded 405 times
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: Tournaments

Post by Kent Briggs »

demon1031 wrote:I have the payout structure to be 6-1000 so theoretically, it should not pay out unless there are at least 6. Correct?
No, the system will not leave money in the prize pool and you cannot modify tournament settings once you've put it online. If you implemented an external registration system on your web site, you could use API functions to set a prize bonus or not set a prize bonus based on the number of entries and then put it online via code.
demon1031
Posts: 21
Joined: Fri Mar 30, 2012 4:23 pm

Re: Tournaments

Post by demon1031 »

//Enviar mensage al torneo TournamentsMessage
$msg=urlencode("EL TORNEO SERA CANCELADO, SE REQUIERE DE 20 JUGADORES MINIMO!!!");


Love the spanish in the code!!!
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: Tournaments

Post by PokerMavenDeveloper »

Sorry im from Colombia, jejejeje
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: Tournaments

Post by PokerMavenDeveloper »

IM VERY PROUD TO BE A LATINOAMERICAN PROGRAMMER. LATAM RULES :D
demon1031
Posts: 21
Joined: Fri Mar 30, 2012 4:23 pm

Re: Tournaments

Post by demon1031 »

For the English people here !!!

<? Php
/ / Tournament name example: FREEROLL Bs.100 | 01pm | 20J
include "api.php" / / $ url, $ pw, and Poker_API () defined here
$ Pw = $ _POST ["password"];
if ($ pw! = "test") exit;
$ F = fopen ("Callback.txt", "a");
$ Event = $ _POST ["Event"];
switch ($ event)
{
case "TourneyStart"
/ / "-20JMIN"
$ L = strtoupper (substr ($ _POST ["Name"], -3));
$ Pos = ($ l == "aseg.bs");
$ Name = $ _POST ["Name"];
$ Time = $ _POST ["Time"];
fwrite ($ f, "Event: $ event | Name: $ name | Time: $ time Subsrt: $ l \ n");
/ / Find the Tournament
if ($ l == "20J")
{
$ Tourney = urlencode ($ name);
fwrite ($ f, "$ tourney is an insured \ n");
/ / Pause the tournament TournamentsPause
/ * $ Params = "& Command = TournamentsPause & Name = $ tourney";
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Error:". $ api ['Error']. "\ n") * /
/ / Find the number of registered
$ Params = "& Command = TournamentsPlaying & Name = $ tourney";
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Error:". $ api ['Error']. "\ n");
$ Registered = $ api ["Count"];
fwrite ($ f, "Members: $ entered \ n");
if ($ registered <20)
{
/ / Send message to the tournament TournamentsMessage
$ Msg = urlencode ("THE TOURNAMENT WILL BE CANCELLED, REQUIRED MINIMUM OF 20 PLAYERS!");
$ Params = "& Command = TournamentsMessage & Name = $ tourney & Message = $ msg";
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Error:". $ api ['Error']. "\ n");
/ / Cancel the tournament
$ Params = "& Command = TournamentsOffline & Name = $ tourney & Now = Yes";
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Failed to place Offline". $ api ['Error']. "\ n");
}

}

break;
case "TourneyFinish"
$ L = strtoupper (substr ($ _POST ["Name"], -3));
$ Name = $ _POST ["Name"];
$ Time = $ _POST ["Time"];
fwrite ($ f, "Event: $ event | Name: $ name | Time: $ time Subsrt: $ l \ n");

$ Trname = $ _POST ["Name"];
$ Trdate = substr ($ _POST ["Time"], 0.10);
if ($ l == "20J")
{
$ Tourney = urlencode ($ _POST ["Name"]);
fwrite ($ f, "$ tourney member - $ trdate date \ n");
/ / Check if a SEAGA and if abortion
$ Params = "& Command = TournamentsResults & Date =". $ Trdate. "& Name =". urlencode ($ trname);
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Failed to bring results". $ api ['Error']. "\ n");
$ Stop = $ api ["Stop"];
fwrite ($ f, "$ stop \ n");
/ / Check if this the word abort
$ Pos = strrpos ($ stop, "(Abort)");
if ($ pos! = false)
{
/ / Update the date and put the tournament online
/ / Cancel the tournament
sleep (10);
/ / Check if it is a freeroll
$ Pos = strrpos ($ trname, "FREEROLL");
$ L = strtoupper (substr ($ trname, 0,8));
fwrite ($ f "word $ l \ n");
if ($ l == "FREEROLL")
{
/ / REMOVE THE BALANCE TO THE WINNERS
QuitarPremioJugadores ($ trname, $ trdate, $ f);
}

/ / Change the date
$ NewDate = add_date ($ _POST ["Time"], 1,0,0);
fwrite ($ f, "$ NewDate \ n");
/ / TournamentsResume
$ Params = "& Command = TournamentsEdit & Name = $ tourney & StartTime = $ NewDate";
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Failed to update the date". $ api ['Error']. "\ n");
/ / ColocarOnline nevus
$ Params = "& Command = TournamentsOnline & Name = $ tourney";
$ Api = Poker_API ($ params, true);
if ($ api ['Result'] == "Error") fwrite ($ f, "Failed to place Online:". $ api ['Error']. "\ n");
}

}

break;
case "TourneyError"
fwrite ($ f, "Event =". $ event. "\ n");
fwrite ($ f, "Name =". $ _POST ["Name"]. "\ n");
fwrite ($ f, "Error =". $ _POST ["error"]. "\ n");
fwrite ($ f, "Time =". $ _POST ["Time"]. "\ n");
fwrite ($ f, "\ n");
break;
}
fclose ($ f);

add_date function ($ givendate, $ day = 0, $ mth = 0, $ r = 0)
{
$ Cd = strtotime ($ givendate);
$ NewDate = date ('Ymd h: i: s', mktime (date ('h', $ cd)
date ('i', $ cd), date ('s', $ cd), date ('m', $ cd) + $ mth,
date ('d', $ cd) + $ day, date ('Y', $ cd) + $ r));
return $ NewDate;
}
function ordinal ($ location)
{
switch ($ location)
{
case 1: $ o = "1st Place" break;
case 2: $ o = "2nd Place" break;
case 3: $ o = "3rd Place" break;
case 4: $ o = "4th Place" break;
case 5: $ o = "5th Place" break;

}
return $ o;
}

QuitarPremioJugadores function ($ trname, $ trdate, $ f)
{
/ / Retrieve file
$ Params = "& Command = TournamentsResults & Date =". $ Trdate. "& Name =". urlencode ($ trname);
$ Api = Poker_API ($ params, false);
/ / Check for errors
if ($ api [0] == "Result = Error") fwrite ($ f, ($ api [1]));
/ / Display results
$ Msg = "Tournament Winners [$ trname]:";

for ($ i = 1; $ i <count ($ api); $ i + +)
{
$ Place = "";
$ Place = substr ($ api [$ i], 0.5);
$ Location = substr ($ api [$ i], 5.1);
$ Player = substr ($ api [$ i], 7);
$ L = strrpos ($ player, "(");
$ Stop = substr ($ api [$ i], 0.5);
$ Player = trim (substr ($ player, 0, $ l));
$ Buyin = substr ($ api [$ i], 0.5);
if ($ buyin == "buyin")
{
/ / Find where the most
$ Pos = strrpos ($ api [$ i], "+");
$ Fee = substr ($ api [$ i], $ pos +1);
}
if ($ place == "Place")
{
$ Won = str_replace (")", "", str_replace ("(", "", substr ($ api [$ i], 7)));
$ Won = (int) str_replace ($ player, "", $ won);
if ($ won> 0)
{
$ Win [$ location] = $ player;
$ Won [$ location] = $ won;
fwrite ($ f, "Winner: $ player Chips: $ won." "\ n");
$ Params = "& Command = AccountsDecBalance & Player = $ player & Amount = $ won";
$ API2 = Poker_API ($ params, true);
if ($ API2 ["Result"] == "Error") fwrite ($ f, "Error:". $ API2 ["Error"]);
if ($ API2 [Result] == ​​"Ok") fwrite ($ f, "The chip is balance." $ API2 [Balance]. "\ n");
/ / Echo "Player: $ player Location: $ location Earned: $ won </ br>";
$ Place = "";
}
}
if ($ stop == "Stop =")
{
$ Finish = substr ($ api [$ i], 5);
/ / Post the result here
/ / PublicarenTwitter ($ msg, $ win, $ finish);
}

}
}

?>



Still not completely English. If anyone can fix it more, feel free to!!!
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: Tournaments

Post by PokerMavenDeveloper »

Thnaks demon1031 for Translate my code, if anyone need help dont be hesite to answer me, demon1031 what do you think about my code???
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: Tournaments

Post by Kent Briggs »

$ Msg = urlencode ("THE TOURNAMENT WILL BE CANCELLED, REQUIRED MINIMUM OF 20 PLAYERS!");
By the way, cancelling the tournament was not what the original poster was asking about. I think he wanted it to continue on but not pay out any of the prize bonus.
Post Reply