array(1=>' ',2=>1,3=>''), 2=>array(1=>' ',2=>0,3=>''), 3=>array(1=>' ',2=>0,3=>''), 4=>array(1=>' ',2=>1,3=>''), 5=>array(1=>' ',2=>1,3=>''), 11=>array(1=>'.',2=>1,3=>'land'), 12=>array(1=>'*',2=>0,3=>'tree'), 13=>array(1=>'~',2=>0,3=>'water'), 14=>array(1=>'&',2=>1,3=>'monster'), 15=>array(1=>'+',2=>1,3=>'dragon'), ); function seed($t, $n, &$r){ for($i=0;$i<$n;$i++){ $r[rand(0,60)][rand(0,60)] = $t; } } function genM(){ global $tls; $r = array(); for($y=0;$y<61;$y++) $r[$y] = array_fill(0,60,1); seed(2, rand(55,150), $r); seed(3, rand(40,150), $r); seed(4, rand(150,250), $r); seed(5, 1, $r); $r[2][2] = 1; return $r; } function init(){ global $s; $s['st'] = 1; $s['x'] = 2; $s['y'] = 2; $s['h'] = 10; $s['a'] = 2; $s['d'] = 2; $s['i'] = array(); $s['m'] = genM(); } function r($t){ printf('
tiny rpg
%s', $t); } function st(){ r(''); } function play(){ global $s; global $tl; global $p; for($y=$s['y']-1;$y<$s['y']+2;$y++){ for($x=$s['x']-1;$x<$s['x']+2;$x++){ if($s['m'][$y][$x]<10){ $s['m'][$y][$x] +=10; } } } $t='| ';
if (isset($p['run'])){
$t.=' You ran away from the battle. Shame on you '; $s['st']=1; } $t.='';
if($s['st']==1){
foreach($s['m'] as $y=>$r){
foreach($r as $x=>$otl){
if ($y==$s['y'] && $x==$s['x']){
$t.='@';
} else {
$t.=$tl[$otl][1];
}
}
$t.="\n";
}
$t.=' ';
} else {
if(isset($p['att'])){
$at = rnd($s['a']);
if ($at== $at+2) $at *=2;
$hit = $at-$s['mn']['d'];
$hit = ($hit<1)?0:$hit;
$t.=sprintf('You attack and take %d HP ', $hit); $s['mn']['h'] -= $hit; if($s['mn']['h'] <1){ if($s['st']==2){ r('You attack and kill the monster. You can continue your quest. '); $s['m'][$s['y']][$s['x']]=11; $s['h'] += floor($s['mn']['mh']/2); $s['a'] +=1; $s['d'] +=1; unset($s['mn']); $s['st']=1; die(); } else { r('You killed the mighty dragon. Now you can get the girl, jump into your red ferrary and ride to the beautyful sunset. The end!Monster attacks and takes %d HP ', $hit); $s['h'] -= $hit; if($s['h']<1){ r('You are dead!Better luck next time. Start again. '); session_destroy(); die(); } } $mn = $s['m'][$s['y']][$s['x']]; $t.=' Fight'; $t.='
| ';
$t.='';
$t.='Move'; $t.=''; $t.='Hero stats'; $t.='Health: '.$s['h']; $t.='Attack: '.$s['a']; $t.=' Defense: '.$s['d']; $t.=' Position: '.$s['x'].'x'.$s['y']; $t.=' Legend'; foreach($tl as $k=>$a){ if($k>10) $t.= $a[1].' '.$a[3].''; } $t.=' | ';
$t.='