Monday, March 21, 2016

Documentation - Inventory System

This entry is to document one of the basic systems that are in place so that the information exists in more than just a notebook.

Inventory

player.js

Objects

invSlot

item

Variables:

  • name
  • desc
  • img

Methods:

  • getItem: (display the item information in a new action window)
  • setItem: (sets the variables of the item object)
  • delItem: (empties the variables of the item object)

Variables:

  • slot
  • qty

Methods:

  • getSlot: (display the slot information on the screen)
  • setSlot: (sets the variables of the slot object including the item variables)

Process

initialization.js -> Create x number of inventory objects
-> Fill slots from API: /character/inventory
ui.js:InventoryClick -> Create a new action window and load inventory.html
-> Loop through all inventory objects and initiate getSlot()

Data Structure

a
characters
P K id
U name
K user_id
K city_id
id--->character_id
b
inventory
P K id
K character_id
K item_id
item_count
slot
item_id<---id
c
item
P K id
U name
description
stackable
icon

API: GET /Character/Inventory

Returns the following structure:

c.name c.description c.icon b.item_count b.slot
item_name item_desc item_icon item_count inv_slot

Thursday, March 17, 2016

Refactoring

Refactoring Code

I'm pretty happy with the progress so far. While it may not be anything pretty at this point, it is all at least functioning as expected. I've been taking some time to read up on object oriented programming and am refactoring my code to align with that model. So far I've added in a very basic inventory system which uses inventory slot objects which are extension of basic item objects. The item object can be set with item details, and can display information about the object in an in-game window. The inventory object extends the item object to include a specific inventory slot number. All inventory slot objects get created on game initialization, and the the appropriate slot objects gets updated with item data based on which item should be in that slot. There is still much more work to be done, but this at least give me something to build on.

I'm going back and refactoring my city map code to be an object oriented system as well with each city building being an object that gets loaded with information about the building, and the city being an object with information specific to the city. The city object will contain a method to fill in the city title and background image, then kick off a displayBuilding method from the building objects which will draw their information to the map.

What's Next?

Next I'm going to be spending some time building out the interfaces for some of the buildings. The town hall building should be fairly straight forward, so I'll probably focus on that one first. It should display the current city members as well as the city leadership and what kind of city leadership is in place. (Monarchy, democracy, city council) Once I have that in place I may begin to work out some of the functions to change city leadership types, or perhaps start to work on some of the core game play mechanics such as trading, fighting, or questing.

On The Interwebs!

I have purchased a VPS which I'm planning on running the game on as well as setup a domain name to point to the server. I have not yet loaded the game code up to the server, but I have it somewhat secured at this point. Once I have the game up to a level where I'm looking for some people to do some very basic functionality testing I'll start publishing the code up to the site and keeping it up to date. Until then, enjoy the Apache default page at http://technochimp.tk

Friday, March 4, 2016

Slim Chance

Rest API

Initially I had started with the goal of building the backend API leveraging the Phalcon framework, but while developing I came to realize that Phalcon is a little over my head at this point. While I would love to sit and dig into and learn it all, I also need to get some progress or I'm going to drive myself insane. After some more looking around I finally circled back around on Slim which appears to give me the basic functionality I'm looking for which being a bit less complex to implement.

Where Are We Captain?

At this point I've ripped out the Phalcon implementation I had started on and have replace it with Slim. I have re-implemented the registration API, and have managed to build a very simple login API which will now allow me to begin the build more of the game and database.

So far I've started to fill a notebook with various ideas for game mechanics, building ideas, city leadership, and back-end database table structures. I have no idea if I'm heading in the right direction or not, but at least I'm enjoying the ride. Hopefully I'll have something to show for it down the road, but if not I won't be upset.

Where to Next?

Next up will be starting to integrate the game interface with the database. I've done some very basic tests to pull some data from the back-end to verify it functions, but now it's time to start piecing it together. Hopefully by this time next week I'll have a couple of unique towns that can pull from their own data.