Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- const LONGSTATS = [
- 'hp' => 'health',
- 'str' => 'stamina',
- 'ess' => 'essence',
- 'cur' => 'current',
- 'max' => 'maximum',
- 'spd' => 'recovery',
- 'skil' => 'skill',
- 'lv' => 'level',
- 'exp' => 'experience',
- 'valu' => 'appraisal',
- 'cmbt' => 'combat',
- 'pirc' => 'piercing',
- 'armr' => 'armored',
- 'evad' => 'evasion',
- 'team' => 'affinity',
- 'idty' => 'identity'
- ];
- const CONVERTSTATS = [
- 'spd' => 'str.spd',
- 'hp' => 'hp.cur',
- 'str' => 'str.cur',
- 'ess' => 'ess.cur',
- 'hpcur' => 'hp.cur',
- 'hpspd' => 'hp.spd',
- 'hpmax' => 'hp.max',
- 'strcur' => 'str.cur',
- 'strspd' => 'str.spd',
- 'strmax' => 'str.max',
- 'ess' => 'ess.cur',
- 'esscur' => 'ess.cur',
- 'essspd' => 'ess.spd',
- 'essmax' => 'ess.max',
- 'lv'=>'skil.lv',
- 'exp'=>'skil.exp',
- 'valu'=>'skill.valu',
- 'pirc'=>'cmbt.pirc',
- 'armr'=>'cmbt.armr',
- 'evad'=>'cmbt.evad',
- 'itdy' => 'team.idty'
- ];
- $teststats='CASE "plyr"\r\n
- prflidty$ = "Poindexter"\r\n
- prflactn$ = "wstf"\r\n
- prflgpic$ = "plyr"\r\n
- prflidty! = 5\r\n
- prflhp! = 30\r\n
- prflstr! = 90\r\n
- prfless! = 0\r\n
- prflspd! = 3\r\n
- prflarmr! = 2\r\n
- prflexp! = 10\r\n
- prflvalu! = 15\r\n
- prflpirc! = 2\r\n
- prfllv! = 1\r\n
- prflhpmax! = 30\r\n
- prflstrmax! = 90\r\n
- prflessmax! = 30\r\n
- prflessspd! = .1\r\n
- prflevad! = .07\r\n
- ';
- 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>';
- //echo gen_collectorcard( renderstats( gen_statsheet( load_stats( 'grml' ), array() ) ) );
- function longhand_stat(string $longstats):string {
- return LONGSTATS[$longstats] ?? '';
- }
- function convert_stat(string $convertstats):string {
- return CONVERTSTATS[$convertstats] ?? '';
- }
- function default_stats()
- {
- return array(
- 'hp' => array(
- 'cur' => floatval( 0 ),
- 'max' => floatval( 0 ),
- 'spd' => floatval( 0 )
- ),
- 'str' => array(
- 'cur' => floatval( 0 ),
- 'max' => floatval( 0 ),
- 'spd' => floatval( 0 )
- ),
- 'ess' => array(
- 'cur' => floatval( 0 ),
- 'max' => floatval( 0 ),
- 'spd' => floatval( 0 )
- ),
- 'skil' => array(
- 'lv' => floatval( 0 ),
- 'exp' => floatval( 0 ),
- 'valu' => floatval( 0 )
- ),
- 'cmbt' => array(
- 'pirc' => floatval( 0 ),
- 'armr' => floatval( 0 ),
- 'evad' => floatval( 0 )
- ),
- 'team' => array(
- 'idty' => floatval( 0 )
- )
- );
- }
- function load_stats( $crtn = '____' )
- {
- if( !is_file( $_SERVER[ 'DOCUMENT_ROOT' ]. '/Roe Web Builder/cards out data/'. $crtn. '.dat' ) )
- {
- return '';
- }
- $page = file_get_contents( $_SERVER[ 'DOCUMENT_ROOT' ]. '/Roe Web Builder/cards out data/'. $crtn. '.dat' );
- return $page;
- }
- function gen_statsheet( $page = '', $info = array() )
- {
- if( strlen( $page ) === 0)
- {
- $page = load_stats( '____' );
- }
- elseif( strlen( $page ) === 4 )
- {
- $page = load_stats( $page );
- }
- $pattern = '/(?:prfl(?<stat>[a-z]+)!) = (?<value>[\.\d]+)/';
- while( preg_match( $pattern, $page, $matches, PREG_UNMATCHED_AS_NULL ) )
- {
- if( isset( $matches[ 'stat' ] ) and isset( $matches[ 'value' ] ) )
- {
- if( !is_null( $matches[ 'stat' ] ) and !is_null( $matches[ 'value' ] ) )
- {
- $info[ convert_stat( $matches[ 'stat' ] ) ] = floatval( $matches[ 'value' ] );
- $page = str_replace( $matches[0], '', $page );
- }
- }
- }
- //natsort($info);
- return $info;
- }
- function renderstats( $info = array() )
- {
- $about = array();
- $about = rendermajors( $info, $about, array('hp',',str','ess'), array('max','spd','cur') );
- $about = renderminors( $info, $about, 'cmbt', array('armr','pirc','evad') );
- $about = renderminors( $info, $about, 'skil', array('lv','valu','exp') );
- $about = renderminors( $info, $about, 'team', array('idty') );
- //natsort( $about );
- return $about;
- }
- //----------
- function rendermajors( $info = array(), $about = array(), $major = array(), $minor = array() )
- {
- $pattern = '/(?<major>'.implode('|',$major).')\.(?<minor>'.implode('|',$minor).')/m';
- foreach( $info as $stat => $value )
- {
- if( preg_match( $pattern, $stat, $matches ) )
- {
- if( isset( $matches[ 'major' ] ) and isset( $matches[ 'minor' ] ) )
- {
- if( !is_null( $matches[ 'major' ] ) and !is_null( $matches[ 'minor' ] ) )
- {
- if( strlen( $matches[ 'minor' ] ) === 0 )
- {
- $matches[ 'minor' ] = 'cur';
- }
- $about[ $matches[ 'major' ] ][ $matches[ 'minor' ] ] = floatval($value);
- }
- }
- }
- }
- //natsort( $about );
- return $about;
- }
- //==========
- function renderminors( $info = array(), $about = array(), $major = '', $minor = array() )
- {
- if( is_array( $major ) )
- {
- $about = rendermajors( $info, $about, $major, $minor );
- return $about;
- }
- $pattern = '/(?<minor>'.implode('|',$minor).')/m';
- foreach( $info as $stat => $value )
- {
- if( preg_match( $pattern, $stat, $matches ) )
- {
- if( isset( $matches[ 'minor' ] ) )
- {
- if( !is_null( $matches[ 'minor' ] ) )
- {
- $about[ $major ][ $matches[ 'minor' ] ] = floatval($value);
- }
- }
- }
- }
- //natsort( $about );
- return $about;
- }
- //==========
- function gen_collectorcard( $about = array() )
- {
- $return = '';
- $default = default_stats();
- $box = array();
- foreach( $default as $major => $intermediate )
- {
- $box[ $major ] = '';
- if( !isset( $about[ $major ] ) )
- {
- $about[ $major ] = $default[ $major ];
- }
- //$box[$major] .='<td style="vertical-align:top;text-align:center;"><table>';
- $box[$major] .= '<tr><td colspan="2" style="vertical-align:top;text-align:left;">'. longhand_stat( $major ). '</td></tr>';
- foreach( $intermediate as $minor => $value )
- {
- if( !isset( $about[ $major ][ $minor ] ) )
- {
- $about[ $major ][ $minor ] = floatval( $value );
- }
- $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>';
- }
- $box[$major] = '<table>'. $box[$major]. '</table>';
- }
- $return .= '<tr>'.
- '<tr><td style="vertical-align:top;text-align:left;">'. $box['hp'].
- '</td><td style="vertical-align:top;text-align:left;">'. $box['str'].
- '</td><td style="vertical-align:top;text-align:left;">'. $box['ess'].
- '</td>'.
- '</tr>'.
- '<tr><td style="vertical-align:top;text-align:left;">'. $box['cmbt'].
- '</td><td style="vertical-align:top;text-align:left;">'. $box['skil'].
- '</td><td style="vertical-align:top;text-align:left;">'. $box['team'].
- '</td>'.
- '</tr>';
- $return = '<table style="vertical-align:top;text-align:left;">'. $return. '</table>';
- return $return;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement