Quantcast

Jump to content


Photo

Looking For A (smaller) Alternative For This...


  • Please log in to reply
8 replies to this topic

#1 sLAUGHTER

sLAUGHTER
  • Dinnerbone'd

  • 490 posts


Users Awards

Posted 28 July 2010 - 10:36 PM

I'm working on stuff for my Android-based PHP botting system.

Obviously, this is a bank-auto-upgrading system.

But: I'd like more condensed code. Posted Image

Anyone think they can do something shorter?
<?

public function upgrade(){
	$types []= "Junior Saver"; $amounts [] = array(0, 1000);
	$types []= "Neopian Student"; $amounts [] = array(1001, 2500);
	$types []= "Bronze Saver"; $amounts [] = array(2501, 5000);
	$types []= "Silver Saver"; $amounts [] = array(5001, 10000);
	$types []= "Super Gold Plus"; $amounts [] = array(10001, 25000);
	$types []= "Platinum Extra"; $amounts [] = array(25001, 50000);
	$types []= "Double Platinum"; $amounts [] = array(50001, 75000);
	$types []= "Triple Platinum"; $amounts [] = array(75001, 100000);
	$types []= "Diamond Deposit"; $amounts [] = array(100001, 250000);
	$types []= "Diamond Deposit Plus"; $amounts [] = array(250001, 500000);
	$types []= "Diamond Deposit Gold"; $amounts [] = array(500001, 1000000);
	$types []= "Millionaire Platinum"; $amounts [] = array(1000001, 2000000);
	$types []= "Millionaire Double Platinum"; $amounts [] = array(2000001, 5000000);
	$types []= "Millionaire Mega-Platinum"; $amounts [] = array(5000001, 7500000);
	$types []= "Neopian Mega-Riches"; $amounts [] = array(7500001, 10000000);
	$types [] = "Ultimate Riches!";
	end($types); // for error prevention because there is no "isBetweenRange" type for 10 mil, up to infinity
	$account_key = key($types); // gets the key for Ultimate Riches (for error prevention above)
	// Assume that $balance is any positive number
	while ($amount = current($amounts)) {
        if(isBetweenRange($balance, $amount[0], $amount[1])){ // I'm sure I don't have to put the function here...It's self-explanatory.
			$account_key = key($amounts); // will overwrite the Ultimate Riches (unless they're Ultimately Rich) o-o
		}
		next($amounts);
	}
	// Bank Changing Code, Hidden <img src='http://www.neocodex.us/forum/public/style_emoticons/<#EMO_DIR#>/biggrin.gif' class='bbc_emoticon' alt=':D' />
	echo "Bank Account Changed To {$types[$account_key]}!";}

Good god, the editor here rapes my indenting.

Edited by sLAUGHTER, 28 July 2010 - 10:45 PM.


#2 Noitidart

Noitidart
  • Neocodex Co-Founder

  • 23214 posts


Users Awards

Posted 28 July 2010 - 10:54 PM

Hmm how about this?

$max = array('Junior Saver'=>1000,'Neopian Student'=>2500,'Brozne Saver'=>5000,'Silver Saver'=>10000,'Super Gold Plus'=>25000,'Platinum Extra'=>50000,'Double Platinum'=>75000,'Triple Platinum'=>100000,'Diamond Deposit'=>250000,'Diamond Deposit Plus'=>500000,'Diamond Deposit Gold'=>1000000,'Millionare Platinum'=>2000000,'Millionare Double Platinum'=>5000000,'Millionaire Mega-Platinum'=>7500000,'Neopian Mega-Riches'=>10000000,'Ultimate Riches!'=>999999999999);

foreach($max as $type=>$limit){
if ($balance <= $limit){
break;
}
}

 echo "Bank Account Changed To {$type}!";



#3 sLAUGHTER

sLAUGHTER
  • Dinnerbone'd

  • 490 posts


Users Awards

Posted 28 July 2010 - 11:17 PM

Ah, optimal, thanks buddy! :D Posted Image

#4 Noitidart

Noitidart
  • Neocodex Co-Founder

  • 23214 posts


Users Awards

Posted 28 July 2010 - 11:20 PM

Anytime bro :)
I used 999999999999 for the max on ultimate riches. But try using 1/0. Or something to represent infinity. In javascript I know we have an Infinity word. Im not sure about php :(
But 999999999999 is just 1 np less than a trillion np. i dont think anyone has that much np :p you can always add more 9's haha

#5 sLAUGHTER

sLAUGHTER
  • Dinnerbone'd

  • 490 posts


Users Awards

Posted 28 July 2010 - 11:41 PM

I don't think I'd need to. It makes $type Ultimate Riches before it breaks, so it'd be fine. :D

#6 Noitidart

Noitidart
  • Neocodex Co-Founder

  • 23214 posts


Users Awards

Posted 28 July 2010 - 11:47 PM

Omg :doh: duh. You're totally right. So really you can just set to zero. haha

#7 sLAUGHTER

sLAUGHTER
  • Dinnerbone'd

  • 490 posts


Users Awards

Posted 28 July 2010 - 11:54 PM

Yep Posted Image

Thanks broseph! Posted Image

#8 matessim

matessim
  • 17 posts

Posted 16 August 2010 - 07:43 AM

not sure about PHP, but in java theres a limit on the max int, though , being php and all, it might be just fine to throw in anything and it will change to a Big Int(64 bit maybe)?

#9 Abrar

Abrar
  • 157 posts

Posted 16 August 2010 - 02:51 PM

how come no one uses python ;(


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users