Skip to content

Instantly share code, notes, and snippets.

@peterdemartini
Last active December 29, 2015 11:09
Show Gist options
  • Save peterdemartini/7662266 to your computer and use it in GitHub Desktop.
Save peterdemartini/7662266 to your computer and use it in GitHub Desktop.
Video game script, I think it's hilarious. Funny, Coding Humor. Great for testing SugarCRM or calling save() on all Contact
<?php
//Define Entry Point
if(!defined('sugarEntry'))define('sugarEntry', true);
chdir(realpath(dirname(__FILE__)));
require_once('include/entryPoint.php');
class PowerMove {
private $db;
private $hitpoints; //AKA contacts
private $wave = 0; // AKA Page
private $max_xp = 9001; // It is Over 9000!!!
public function __construct(){
global $db;
$this->db = $db;
}
public function charge_up(){
echo "Charging Up, WAVE {$this->wave} \n";
$offset = $this->wave * $this->max_xp;
$res = $this->db->query("
SELECT
contacts.id
FROM contacts
LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c
WHERE
contacts.deleted = 0
LIMIT {$offset}, {$this->max_xp}
");
$c = $this->db->getRowCount($res);
echo "Powering up for a move worth {$c} XP. \n";
if($c == 0) return false;
$this->wave++; // Up 1
while($row = $this->db->fetchByAssoc($res))
$this->mega_thunderstrike($row['id']);
echo ">>>>CAPOOWWWW!!!!! \n";
return true;
}
private function mega_thunderstrike($id){
echo ":";
$HitPoint = BeanFactory::getBean('Contacts', $id);
$HitPoint->save();
return true;
}
}
echo "Round 1 Begins! \n";
$PowerMove = new PowerMove();
while($PowerMove->charge_up()){
echo "Critical Hit!!! \n";
}
die("K/O!!! Dominated! \n");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment