function game($s, $m) { global $C, $V, $U, $T, $W; // $U,$T are here for the benefit of eval()d code // log the input l($C[$s][name] . ": {$m}"); // parse $m into command $o and rest $r if ($pos = strpos($m, ' ')) { $o = substr($m, 0, $pos); $r = substr($m, $pos + 1); // handle the case with no arguments, leave $r unset } else { $o = $m; } // If they're a wizard, they can eval() -- execute raw PHP. Powerful stuff. if ($o == 'ev' && $C[$s][wiz] == 1) { eval("{$r};"); } elseif ($V[$o]) { $V[$o]($s, 0, $r); } elseif ($V[substr($o, 0, 1)] && !in_array(substr($o, 0, 1), range('a', 'z'))) { $V[substr($o, 0, 1)]($s, 0, substr($m, 1)); } elseif (gnc($C[$s][a], $C[$s][r], $o)) { $V["go"]($s, 0, $o); } elseif (!$m) { } else { w($s, "Huh?"); } // set the last command -- is down here so that the ! command works if ($m && $C[$s]) { $C[$s][l] = $m; } // Give them a prompt with area and room if they're still here if ($C[$s]) { socket_write($C[$s][s], "{$C[$s][a]}/{$C[$s][r]} {$C[$s][hp]}> "); } }
go // <? if($d){ $C[$s][b]=0; // if the connection (exit) exists if($e=gnc($C[$s][a],$C[$s][r],$r)){ b($s,"~11{$C[$s][name]} ~12leaves: ~03$r"); w($s,"~12You leave: $r"); // handle bidirection exists if($C[$s][r]==$e[t]) $C[$s][r]=$e[f]; else $C[$s][r]=$e[t]; b($s,"~11{$C[$s][name]} ~12arrives"); }else w($s,"~12no such connection"); }else{ $C[$s][b]=1; t('$go',$r,6,$s); w($s,"~12going..."); }