Page 1 of 1

The best cose to ever exist!

Posted: Thu May 03, 2007 3:57 pm
by Hellonagol
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The following will save lives and make people millions of dollars

Code: Select all

<?php
function get_input($length = 255) {
	$fr = fopen("php://stdin", "r");
	$input = fgets($fr, $length); 
	$input = rtrim($input);
	fclose($fr);
	return $input;
}
echo "Pikachu attacks!\n";
$pikhealth = 100;
$pikattack = 4;
echo "attack , pokeball , flee\n";
echo "Choose a move: ";
$move = get_input(10);
if ($move == attack){
	echo "Pikachu has Fainted!\n";
}
else if ($move == pokeball){
	echo "You catch the wild Pikachu!\n";
	echo "Give it a name?\n";
	echo "Answer yes or no\n";
	$yesno = get_input(10);
	if ($yesno == yes){
		echo "Enter a name: ";
		$name = get_input(20);
		echo "$name was transfered to box1 in someones pc!\n";
	}
	if ($yesno == no){
		echo "Pikachu was transfered to box1 in someones pc!\n";
	}
	else if ($move == flee){
		echo "You fail to escape!\n";
		echo "Pikachu uses thunderbolt!\n";
		echo "You get killed\n";
	}
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu May 03, 2007 4:04 pm
by Hellonagol
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Okay that last one is not the best but this is

Code: Select all

<?php
function get_input($length = 255) {
	$fr = fopen("php://stdin", "r");
	$input = fgets($fr, $length); 
	$input = rtrim($input);
	fclose($fr);
	return $input;
}
echo "Pikachu attacks!\n";
echo "attack , pokeball , flee\n";
echo "Choose a move: ";
$move = get_input(10);
if ($move == attack){
	echo "Pikachu has Fainted!\n";
}
else if ($move == pokeball){
	echo "You catch the wild Pikachu!\n";
	echo "Give it a name?\n";
	echo "Answer yes or no\n";
	$yesno = get_input(10);
	if ($yesno == yes){
		echo "Enter a name: ";
		$name = get_input(20);
		echo "$name was transfered to box1 in someones pc!\n";
	}
	if ($yesno == no){
		echo "Pikachu was transfered to box1 in someones pc!\n";
	}
	}
	else if ($move == flee){
		echo "You fail to escape!\n";
		echo "Pikachu uses thunderbolt!\n";
		echo "You get killed\n";
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu May 03, 2007 4:08 pm
by onion2k
I bet Nintendo are really worried. This game could ruin them.

Posted: Thu May 03, 2007 4:11 pm
by jayshields
How is the first snippet different to the second one?

Posted: Thu May 03, 2007 5:14 pm
by Ambush Commander
The indentation is a bit wonky. I don't know how you could possible call this the "Best cose" ;-)

Posted: Thu May 03, 2007 5:19 pm
by Christopher
I used a Wii controller to press the keys on the keyboard to type my answers into a terminal window -- and it really felt like I was fighting Pikachu!

Best cose of all times!

Posted: Thu May 03, 2007 6:24 pm
by RobertGonzalez
I was just thinking that I needed some best cose to ever exist.