Ripping apart Gastropoda

For the record, this post isn’t about ripping apart real snails and slugs. It’s about ripping apart pretty much all of my existing code, which is what I’ve been doing over this weekend.

I started this game relying heavily on “manager” classes - a snailmanager.php, jarmanager.php, stablemanager.php, etc.

But a snail itself wasn’t an object - it was a variable created in the snail manager class. Same with jars, for example.

So this weekend I kind of picked everything apart and created snail.class.php, jar.class.php, etc. The snail manager class is still there - it generates a new Snail(); instead of just doing someting along the lines of $snail['name'] = "blah"; $snail['shellColorR'] = 0; return $snail;

I also made a switch from mysql to mysqli and instead of making a query (for example) like this:

$connectionmanager = new ConnectionManager();
$connectionmanager->DBLogin();
$qry = "blah";
$result = mysqli_query($connectionmanager->connection, $qry);

{:lang=“php”}

it’s now more like this:

$qry = "blah";
$result = DB::$mysqli->query($qry);

{:lang=“php”}

Up next I’m going to make use of prepared statements throughout and then…hopefully…going back to implementing the first version of breeding.

comments powered by Disqus