The beginnings of a currency

When I moved back to the PHP version of Gastropoda I implemented snail death, so that snails actually die when their energy reaches 0. This resulted in all of my snails dying because they were both far below 0 (the cron job that depleted their energy daily continued to run while I was on a different branch).

So there’s currency now. Each user gets 500SEK when they start their stable. I’ve already used mine up on lettuce leaves from the other new thing - the Corner Store:

Gastropoda corner store

(Eh, obviously I need to still build grouping of listings of the same item/price combinations).

When I buy an item it ends up in my closet, which is accessible from my Stable page.

Gastropoda closet

From there you can choose what to do with the item (so far you can only place it in a jar). It ends up here:

Lettuce in jar

At which point snails can eat it to absorb the vitamins and nutrients from that item.

Now…lettuce leaves don’t contain much other than water, so unless I want to keep buying craploads of lettuce leaves on a daily basis to stick them in for the snails they are still going to die. Not to mention, I can’t stock up on lettuce leaves in advance because food is soon going to rot just as in real life if left too long. Snails can handle rotten food, but only to an extent.

Oh also the store restocks itself based on the rarity of each item template. Eh…very far from done, but here:

    function RestockStore() {
        $itemmanager = new ItemManager();
        // Loop through all item templates
        $qry = 'Select templateID, basePrice, rarity from item_templates';
        $result = DB::$mysqli->query($qry);
        if (!$result) {
            return false;
        }
        // Get each template as an array (to make into object later..this is separate from the Item object)
        while ($itemTemplate = $result->fetch_assoc()) {
            // Generate a random integer from 0 to 100
            $randomInteger = Utility::RandomInteger(0,100);
            // If the random integer is higher than the item's rarity (from 0-100)...
            if ($randomInteger > $itemTemplate['rarity']) {
                // Create one instance of that item 
                $item = $itemmanager->CreateNewItem($itemTemplate['templateID']);
                // Create a store listing
                $storeListing = new StoreListing();
                $storeListing->itemID = $item->itemID;
                $storeListing->sellerID = 0;
                $storeListing->price = $itemTemplate['basePrice'];
                $storeListing->SaveListing();
            }
        }
        return true;        
    }

{:lang=“php”}

This currently runs every 5 minutes, but I will make this less frequent when I’ve made it restock multiple instances of the same item.

Up next…

Next I will do a few days of bug fixing and cleaning everything up, then I’ll add a more substantial consumable (so that I can feed the snails only once a day for example), and then I need to start taking a look at snail growth. Currently babies are born at their adult size, but in reality they need to grow over the course of at least a few days.

comments powered by Disqus