Advertisement
jargon

Roe Web Builder - Stat Sheet Glitch

Oct 16th, 2021
1,574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.83 KB | None | 0 0
  1. <?php
  2.  
  3. const LONGSTATS = [
  4.  
  5.     'hp' => 'health',
  6.     'str' => 'stamina',
  7.     'ess' => 'essence',
  8.  
  9.         'cur' => 'current',
  10.         'max' => 'maximum',
  11.         'spd' => 'recovery',
  12.  
  13.     'skil' => 'skill',
  14.         'lv' => 'level',
  15.         'exp' => 'experience',
  16.         'valu' => 'appraisal',
  17.  
  18.     'cmbt' => 'combat',
  19.         'pirc' => 'piercing',
  20.         'armr' => 'armored',
  21.         'evad' => 'evasion',
  22.  
  23.     'team' => 'affinity',
  24.         'idty' => 'identity'
  25. ];
  26.  
  27. const CONVERTSTATS = [
  28.    
  29.     'spd' => 'str.spd',
  30.  
  31.     'hp' => 'hp.cur',
  32.     'str' => 'str.cur',
  33.     'ess' => 'ess.cur',
  34.  
  35.     'hpcur' => 'hp.cur',
  36.     'hpspd' => 'hp.spd',
  37.     'hpmax' => 'hp.max',
  38.  
  39.     'strcur' => 'str.cur',
  40.     'strspd' => 'str.spd',
  41.     'strmax' => 'str.max',
  42.    
  43.     'ess' => 'ess.cur',
  44.     'esscur' => 'ess.cur',
  45.     'essspd' => 'ess.spd',
  46.     'essmax' => 'ess.max',
  47.  
  48.     'lv'=>'skil.lv',
  49.     'exp'=>'skil.exp',
  50.     'valu'=>'skill.valu',
  51.  
  52.     'pirc'=>'cmbt.pirc',
  53.     'armr'=>'cmbt.armr',
  54.     'evad'=>'cmbt.evad',
  55.  
  56.     'itdy' => 'team.idty'
  57. ];
  58.  
  59.  
  60. $teststats='CASE "plyr"\r\n
  61.   prflidty$ = "Poindexter"\r\n
  62.   prflactn$ = "wstf"\r\n
  63.   prflgpic$ = "plyr"\r\n
  64.   prflidty! = 5\r\n
  65.   prflhp! = 30\r\n
  66.   prflstr! = 90\r\n
  67.   prfless! = 0\r\n
  68.   prflspd! = 3\r\n
  69.   prflarmr! = 2\r\n
  70.   prflexp! = 10\r\n
  71.   prflvalu! = 15\r\n
  72.   prflpirc! = 2\r\n
  73.   prfllv! = 1\r\n
  74.   prflhpmax! = 30\r\n
  75.   prflstrmax! = 90\r\n
  76.   prflessmax! = 30\r\n
  77.   prflessspd! = .1\r\n
  78.   prflevad! = .07\r\n
  79. ';
  80.  
  81. echo '<html><head><title>mk45 CARDS OUT TEST</title></head><body>'.str_replace('\r\n','<br>',htmlentities($teststats)).'<br>'.gen_collectorcard( renderstats( gen_statsheet( $teststats, array() ) ) ).'</body></html>';
  82.  
  83. //echo gen_collectorcard( renderstats( gen_statsheet( load_stats( 'grml' ), array() ) ) );
  84.  
  85. function longhand_stat(string $longstats):string {
  86.     return LONGSTATS[$longstats] ?? '';
  87. }
  88.  
  89. function convert_stat(string $convertstats):string {
  90.     return CONVERTSTATS[$convertstats] ?? '';
  91. }
  92.  
  93. function default_stats()
  94. {
  95.     return array(
  96.    
  97.         'hp' => array(
  98.             'cur' => floatval( 0 ),
  99.             'max' => floatval( 0 ),
  100.             'spd' => floatval( 0 )
  101.         ),
  102.        
  103.         'str' => array(
  104.             'cur' => floatval( 0 ),
  105.             'max' => floatval( 0 ),
  106.             'spd' => floatval( 0 )
  107.         ),
  108.        
  109.         'ess' => array(
  110.             'cur' => floatval( 0 ),
  111.             'max' => floatval( 0 ),
  112.             'spd' => floatval( 0 )
  113.         ),
  114.  
  115.         'skil' => array(
  116.             'lv' => floatval( 0 ),
  117.             'exp' => floatval( 0 ),
  118.             'valu' => floatval( 0 )
  119.         ),
  120.  
  121.         'cmbt' => array(
  122.             'pirc' => floatval( 0 ),
  123.             'armr' => floatval( 0 ),
  124.             'evad' => floatval( 0 )
  125.         ),
  126.  
  127.         'team' => array(
  128.             'idty' => floatval( 0 )
  129.         )
  130.     );
  131. }
  132.  
  133. function load_stats( $crtn = '____' )
  134. {
  135.     if( !is_file( $_SERVER[ 'DOCUMENT_ROOT' ].  '/Roe Web Builder/cards out data/'. $crtn. '.dat' ) )
  136.     {
  137.         return '';
  138.     }
  139.    
  140.     $page = file_get_contents( $_SERVER[ 'DOCUMENT_ROOT' ].  '/Roe Web Builder/cards out data/'. $crtn. '.dat' );
  141.    
  142.     return $page;
  143. }
  144.  
  145. function gen_statsheet( $page = '', $info = array() )
  146. {
  147.     if( strlen( $page ) === 0)
  148.     {
  149.         $page = load_stats( '____' );
  150.     }
  151.     elseif( strlen( $page ) === 4 )
  152.     {
  153.         $page = load_stats( $page );
  154.     }
  155.    
  156.     $pattern =    '/(?:prfl(?<stat>[a-z]+)!) = (?<value>[\.\d]+)/';
  157.    
  158.     while( preg_match( $pattern, $page, $matches, PREG_UNMATCHED_AS_NULL ) )
  159.     {
  160.         if( isset( $matches[ 'stat' ] ) and isset( $matches[ 'value' ] ) )
  161.         {
  162.             if( !is_null( $matches[ 'stat' ] ) and !is_null( $matches[ 'value' ] ) )
  163.             {
  164.                 $info[ convert_stat( $matches[ 'stat' ] ) ] = floatval( $matches[ 'value' ] );
  165.                 $page = str_replace( $matches[0], '', $page );
  166.             }
  167.         }
  168.     }
  169.    
  170.     //natsort($info);
  171.     return $info;
  172. }
  173.  
  174. function renderstats( $info = array() )
  175. {
  176.     $about = array();
  177.    
  178.     $about = rendermajors( $info, $about, array('hp',',str','ess'), array('max','spd','cur') );
  179.     $about = renderminors( $info, $about, 'cmbt', array('armr','pirc','evad') );
  180.     $about = renderminors( $info, $about, 'skil', array('lv','valu','exp') );
  181.     $about = renderminors( $info, $about, 'team', array('idty') );
  182.    
  183.     //natsort( $about );
  184.            
  185.     return $about;
  186. }
  187.  
  188. //----------
  189.  
  190. function rendermajors( $info = array(), $about = array(), $major = array(), $minor = array() )
  191. {
  192.  
  193.     $pattern = '/(?<major>'.implode('|',$major).')\.(?<minor>'.implode('|',$minor).')/m';
  194.    
  195.     foreach( $info as $stat => $value )
  196.     {
  197.         if( preg_match( $pattern, $stat, $matches ) )
  198.         {
  199.             if( isset( $matches[ 'major' ] ) and isset( $matches[ 'minor' ] ) )
  200.             {
  201.                 if( !is_null( $matches[ 'major' ] ) and !is_null( $matches[ 'minor' ] ) )
  202.                 {
  203.                     if( strlen( $matches[ 'minor' ] ) === 0 )
  204.                     {
  205.                         $matches[ 'minor' ] = 'cur';
  206.                     }
  207.                     $about[ $matches[ 'major' ] ][ $matches[ 'minor' ] ] = floatval($value);
  208.                 }
  209.             }
  210.         }
  211.     }
  212.  
  213.     //natsort( $about );
  214.            
  215.     return $about;
  216. }
  217.  
  218. //==========
  219. function renderminors( $info = array(), $about = array(), $major = '', $minor = array() )
  220. {
  221.     if( is_array( $major ) )
  222.     {
  223.         $about = rendermajors( $info, $about, $major, $minor );
  224.         return $about;
  225.     }
  226.    
  227.     $pattern = '/(?<minor>'.implode('|',$minor).')/m';
  228.  
  229.     foreach( $info as $stat => $value )
  230.     {
  231.         if( preg_match( $pattern, $stat, $matches ) )
  232.         {
  233.             if( isset( $matches[ 'minor' ] ) )
  234.             {
  235.                 if( !is_null( $matches[ 'minor' ]  ) )
  236.                 {
  237.                     $about[ $major ][ $matches[ 'minor' ] ] = floatval($value);
  238.                 }
  239.             }
  240.         }
  241.     }
  242.    
  243.     //natsort( $about );
  244.            
  245.     return $about;
  246. }
  247.  
  248. //==========
  249. function gen_collectorcard( $about = array() )
  250. {
  251.     $return = '';
  252.    
  253.     $default = default_stats();
  254.  
  255.     $box = array();
  256.    
  257.     foreach( $default as $major => $intermediate )
  258.     {
  259.         $box[ $major ] = '';
  260.         if( !isset( $about[ $major ] ) )
  261.         {
  262.             $about[ $major ] = $default[ $major ];
  263.         }
  264.         //$box[$major] .='<td style="vertical-align:top;text-align:center;"><table>';
  265.         $box[$major] .= '<tr><td colspan="2" style="vertical-align:top;text-align:left;">'. longhand_stat( $major ). '</td></tr>';
  266.         foreach( $intermediate as $minor => $value )
  267.         {
  268.             if( !isset( $about[ $major ][ $minor ] ) )
  269.             {
  270.                 $about[ $major ][ $minor ] = floatval( $value );
  271.             }
  272.  
  273.            
  274.             $box[$major] .= '<tr><td colspan="1" style="width:100%;vertical-align:top;text-align:left;">'.  longhand_stat( $minor ). '</td><td colspan="1" style="width:100%;vertical-align:top;text-align:left;">'. floatval( $about[ $major ][ $minor ] ). '</td></tr>';
  275.         }
  276.         $box[$major] = '<table>'. $box[$major]. '</table>';
  277.     }
  278.    
  279.     $return .= '<tr>'.
  280.     '<tr><td style="vertical-align:top;text-align:left;">'. $box['hp'].
  281.     '</td><td style="vertical-align:top;text-align:left;">'. $box['str'].
  282.     '</td><td style="vertical-align:top;text-align:left;">'. $box['ess'].
  283.     '</td>'.
  284.     '</tr>'.
  285.     '<tr><td style="vertical-align:top;text-align:left;">'. $box['cmbt'].
  286.     '</td><td style="vertical-align:top;text-align:left;">'. $box['skil'].
  287.     '</td><td style="vertical-align:top;text-align:left;">'. $box['team'].
  288.     '</td>'.
  289.     '</tr>';
  290.     $return = '<table style="vertical-align:top;text-align:left;">'. $return. '</table>';
  291.     return $return;
  292. }
  293.  
  294. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement