Advertisement
jargon

Roe Collector Card Game (juast the card regex)

Sep 30th, 2021
1,749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. function regex_cards( $page = '' )
  2. {
  3.     $nen = nen_ini();
  4.     $result = '';
  5.    
  6.     //load card regular expression
  7.    
  8.     $card_pattern ='/CASE "(?<cardname>_{4}|[a-z][a-z0-9_]{3})"(?:\s*+(?!CASE).*\n)*/m';
  9.     $card_pattern2 = file_get_contents( $nen[ 'root' ]. 'pcre/card data.pattern.pcre' );
  10.     if( $card_pattern !== $card_pattern2 )
  11.     {
  12.         $card_pattern = $card_pattern2;
  13.     }
  14.     unset( $card_pattern2 );
  15.    
  16.     // assign replacement (unused)
  17.     $card_replace = "$0\n";
  18.    
  19.     // create desination folder if it does not exist
  20.     if( !is_dir( $nen[ 'root' ]. 'cards out data' ) )
  21.     {
  22.         mkdir ( $nen[ 'root' ]. 'cards out data' );
  23.     }
  24.    
  25.     // perform current page data regex
  26.    
  27.     if(
  28.         preg_match_all(
  29.         $card_pattern,
  30.         $page,
  31.         $card_matches
  32.         )
  33.     )  
  34.     {
  35.         //foreach($card_matches as $card_key => $card_value )
  36.         //{
  37.             //trk_echo2( 'card', array( 'cardname' => $card_matches[ 'cardname' ], 'card_value' => $card_matches[ 0 ] ) );
  38.            
  39.             // save creation card collection to file
  40.             file_put_contents( $nen[ 'root' ]. 'cards out data/'. $card_matches[ 'cardname' ][ 0 ]. '.dat', $card_matches[ 0 ][ 0 ] );
  41.         //}
  42.        
  43.     }
  44.            
  45.     return $result;
  46.    
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement