October-November Updates: Themes, JavaScript and PHP Tools

November 24, 2014

Categorized: Kate's Updates

Code and fun updates from October and November!

  • CSS and Themes
  • Game Age Calculator
  • phpBB Automatic Master/Sub Account List
  • phpBB Automatic Topic Archival

CSS and Themes

katemwalsh.com

kmw

I chucked some CSS on top of the default TwentyThirteen theme I was using. I didn’t change it significantly — I only added some extra stuff and altered some basics. No biggie.

The picture is from the Atlantic City boardwalk looking out toward the ocean. It’s during winter and there’s snow on the ground in other pictures in the set. I chose the picture because I really like Atlantic City. Atlantic City in the winter — when it’s very quiet and very cold — is one of my favorite times to be there, too. I have a lot of good memories from that area in youth — we vacationed there for many, many years. It makes me happy to look at this picture! Credit to botanygirl9@Flickr.

I got everything it set up with Grunt, SASS, Git, and faster deployment with SSH as described in this post about workflow (kinda). So the cooler stuff is definitely the less visible stuff, unfortunately!

phpBB Forum Skins

Did two forum skins for ‘Souls RPG (phpBB). Both of them used Grunt to compile minified SASS into CSS. One uses a forum header created by Raze of ‘Souls, the other uses art created by Kiriska.

Game Age Calculator

I built a JavaScript/jQuery age calculator for ‘Souls RPG. Kiriska helped me with some of the logic — primarily the math and numbers. I tried to reverse engineer a chart that had some of the ages listed. Unfortunately, I wound up with some number overlap and some things that didn’t make much numerical sense.

Although this age calculator worked fine on my local development environment and CodePen, we had some trouble getting it to go in WordPress for some reason. The eventual fix was to swap the calls to the inputs from #months input to #months-input. I’m not sure why that worked or why WordPress decided it didn’t like this (again, CodePen and my local environment were fine with it…). But there’s that! It works now!

Why an Age Calculator

I thought an age calculator would be a neat tool to have. We have our own species on the game, and their aging doesn’t really match up with reality. It tends to confuse people. Prior to building the age calculator, we had only a chart reference.

So, not only did we have something that confused people, we had bad reference for it, too! The age calculator provides a very visual reminder when the character is outside the bounds of the species’ aging (red borders, red warning). This should help players choose appropriate ages for their game characters.

Also — we have the same issue with species sizing (which is way, way more complicated than age). It’s an eventual aspiration to build something capable of calculating size, too, and an age calculator is pretty good practice for that.

phpBB Automatic Master/Sub Account List

I built an automatic account list for ‘Souls RPG using PHP and a MySQL query. I wanted a list to grab all of these and spit it out with subaccounts associated to the master accounts.

Basically, there are master accounts and “sub-accounts” for players who have more than one account. The set-up of the databases was a little confusing and seems a bit less-than-optimal for what I wanted to do. Master accounts have a master_id of 0, whereas subaccounts have a master_id matching the user_id of the master account. I tried a few different MySQL joins, sub-SELECTs, and other stuff to get it to do right, but I couldn’t.

I eventually just pushed all the masters into one array, and then used nested foreach statements to get first the masters, then the sub-accounts of those masters.

Why an Automatic Account List

phpBB has a built-in memberlist function — this is neat for viewing all accounts, or all accounts under a certain group. Unfortunately, we have a group set-up that does not make all active accounts viewable through phpBB’s default functionality.

Additionally, we currently have a manually updated list of master-subaccounts. Manually updated anything is not optimal! More time, more maintenance, less accuracy. An automatic list will save all of the above. It’s also nice to have one central place to view active accounts!

phpBB Automatic Topic Archival

A while back, I built a smaller script to grab topics ready for archival (that is, inactive for the last 30 days, and without a certain topic icon that denotes that it should be kept out of the archive).

It doesn’t do anything other than spit out a list of links to those topics. I left the actual archival process manual. Even that was helpful as previously it required finding archival-ready topics manually.

Well, I started messing with this script again. There are phpBB documentation/forum warnings not to simply update rows with a SQL query. phpBB’s tables often cross-reference one another. So the rows in the forum table containing the topic counts would not update if we simply updated the topic row’s forum location number. That’s a problem.

Thankfully, phpBB has helpful functions that do these things for you — move_topics() and sync(). I updated the original script I had to get topics satisfying archival criteria, feeding topic_ids into move_topics(). From there, it just needs to use sync() to synchronize the forums, and we’re good! Automatic archival of everything!