minimum players to start tourney

Add your suggestions for improving Poker Mavens
loggableim
Posts: 5
Joined: Fri Jul 20, 2012 5:51 pm

minimum players to start tourney

Post by loggableim »

I see that there is an option to let tournaments start earlier if all players agree.


is it also possible to let tournaments only start if they reach an amount of players i define?
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: minimum players to start tourney

Post by Kent Briggs »

loggableim wrote: is it also possible to let tournaments only start if they reach an amount of players i define?
Not directly. However, you could set a tournament for manual start and then have a script run at a set time that checks the count with the API. Then it could decide to start it, cancel it, delay it, etc., with the API.
demon1031
Posts: 21
Joined: Fri Mar 30, 2012 4:23 pm

Re: minimum players to start tourney

Post by demon1031 »

loggableim

If you get the script working in order for the tournament to start only if a certain number of people show up, please share it!! I have been trying to get this to work for weeks but with no avail!
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: minimum players to start tourney

Post by PokerMavenDeveloper »

THIS SCRIPT CAN HELP INCLUDE ANOTHER FEATURE TWITTER PUBLISH TOURNEY WINNERS, ETC

Code: Select all

        <?php
		include "API.php";  // $url, $pw, and Poker_API() defined here
		include "twitteroauth.php";
      $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")
					{
						fwrite($f,"Ebtre a quitarle los reales a los pitrafas\n");
						//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"); 				
			  }
			  
		  }
		  //Buscar si el Torneo es el HU del step 1
		  $l = strtolower(substr($_POST["Name"],-3));
		  $cirsa=0;
		  if($l=="cs1" )
		  {
			//Buscar Ganador al Paso 2
			  $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"); 										
			  $ganador= $api["Place1"];	
              $paso="CIRSA PASO#2-CS2";
			  $pos = strrpos($ganador, "(");
			  $ganador = substr($ganador,0,$pos-1);			  
			  fwrite($f,"Ganador: $ganador al $paso\n");
			  //Enviar Mensaje al ganador
			  //Trear la ssesionid		  AccountsGet 
			  $params = "&Command=AccountsGet&Player=$ganador";
			  $api = Poker_API($params,true);
			  if ($api["Result"] == "Error") fwrite($f,"Error al traer Usuario: " . $api["Error"]."\n"); 													  
			  //Enviar mensaje
			  $sessionid = $api["SessionID"];
			  if($sessionid!="")
			  {
				//Enviar el mensaje
				$msg = "FELICITACIONES AL GANADO LA ENTRADA AL TORNEO CIRSA PASO#2-";
				//ConnectionsMessage 
				  $params = "&Command=ConnectionsMessage&SessionID=$sessionid&Message=".urlencode($msg);
				  $api = Poker_API($params,true);
				  if ($api["Result"] == "Error") fwrite($f,"Error al enviar mensaje: " . $api["Error"]."\n"); 													  				
			  }
			  $cirsa=1;
		  }
		  if($l=="cs2" )
		  {
			//Buscar Ganador al Paso 2
			  $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"); 										
			  $ganador= $api["Place1"];
			  $pos = strrpos($ganador, "(");
			  $ganador = substr($ganador,0,$pos-1);
              $paso="CIRSA FINAL";
			  fwrite($f,"Ganador: $ganador al $paso\n");
			  $cirsa=1;
		  }		  
		  if($cirsa==1)
		  {
				//Buscar el ganador
				//Buscar si es una aseg y si se aborto
			  $params = "&Command=TournamentsRegister&Player=" . $ganador . "&Name=" . urlencode($paso);
			  $api = Poker_API($params,true);
			  if ($api["Result"] == "Error") fwrite($f,"Error al inscribir en torneo: " . $api["Error"]."\n"); 										
			  //inscribir ganador en paso 2 TournamentsRegister 
			  //Buscar al ganador en la lista de conectados y enviarle un mensaje
		  }
          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 find_status_tourney($tourney)
	{
		
	}
	
	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 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 = 'MeXXKARCIq5yGUpGF4lVDA';
		$consumer_secret = 'DtCyPK52RjoN6PQ2mEBZ9QFzS1KPuexT2avtTLze2I';
		$token = '247993297-01y8ng3hH30WEG0IV21tb6ORcErq1KpgFybBCKmh';
		$secret= 'Wvl0iT9w0F0KM2npcvvMOgFasCz17JNTpK7TT4banQg';
		/*$twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret);
		$twitterObjUnAuth = new EpiTwitter($consumer_key, $consumer_secret);
		$status = $twitterObj->post('/statuses/update.json', array('status' => $msg ));
		//$twitterObj->post_statusesUpdate(array('status' => $msg)); 
		print_r($status->response);	 */
 
		$connection = new TwitterOAuth($consumer_key,$consumer_secret, $token, $secret);
		$content = $connection->get('account/verify_credentials');
		$connection->post('statuses/update', array('status' => $msg));		
		
	 }	
	 
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);
			}

		}
	}
	 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);
			}
        }	 
	 }
    ?>

	  
demon1031
Posts: 21
Joined: Fri Mar 30, 2012 4:23 pm

Re: minimum players to start tourney

Post by demon1031 »

Can you please put this in English? I think I have tried this code before but it didn't work because Google translator didn't pick up everything correctly!
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: minimum players to start tourney

Post by PokerMavenDeveloper »

Ok i Explain with more detailhe process ( sorry FOR MY ENGLISH)

the first step, you need to named your tournament in this way

TOURNAMENT-NAME-20P the important part in the tourney name is 20P, 20 is the minimun number of player p IS FOR PLAYER

only with that the process take the decicion

you need to put this script into your server and the poker maven callback call this scriot you need some php skill for that

Code: Select all

<?php
          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":
            $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");
             if($l=="20P" )
             {
                $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"); */
                //find the players 
                $params = "&Command=TournamentsPlaying&Name=$tourney";
                $api = Poker_API($params,true);
                if ($api["Result"] == "Error") fwrite($f,"Error: " . $api["Error"]."\n");
                $inscritos = $api["Count"];//this is the number of player in the tourney
                fwrite($f,"Inscritos: $inscritos\n " ) ;
                if($inscritos<20)//you can replace that with your minimun number
                {
                   //Enviar mensage al torneo TournamentsMessage
                   $msg=urlencode("THE TOURNEY BE CANCELLED,THAT REQUIRE 20 PLAYERS MINIMUN!!!");
                   $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);
                   
                   //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");             
               }
              
            }
          }
          fclose($f);

Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: minimum players to start tourney

Post by Kent Briggs »

loggableim wrote:I see that there is an option to let tournaments start earlier if all players agree.
is it also possible to let tournaments only start if they reach an amount of players i define?
This feature has just been added to 3.06. No need for any custom API work now. :P

http://www.briggsoft.com/forums/viewtop ... f=7&t=1128
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: minimum players to start tourney

Post by PokerMavenDeveloper »

Its possible to add a new feature for the tournaments, guaranteed poker tournaments .
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: minimum players to start tourney

Post by Kent Briggs »

PokerMavenDeveloper wrote:Its possible to add a new feature for the tournaments, guaranteed poker tournaments .
The prize bonus setting works as a guarantee when multiply bonus is set at "no".
PokerMavenDeveloper
Posts: 66
Joined: Fri Feb 24, 2012 5:11 pm

Re: minimum players to start tourney

Post by PokerMavenDeveloper »

For example if a tourney have setting for 100 player with a minimun that 20 player to start, the buy-in -10$ - guarante prize 1000$, the bonus prize is setting to 1000, the buy-in 10 and fee 1$, if only 50 user register in the tourney then the pot is 1000, but if 120 user register in the tourney the pot must be 1200, actualy using this example the pot have 2200 :(, an posible solution is buy-in 0 - fee 11 max player 100 players. 1000 guaranted. :(
Post Reply