smarch/lex

A game-currency management package.

v1.1.4 2016-03-23 21:23 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:30:28 UTC


README

This is probably only of use to me, but I have need of it in multiple apps so I packaged it up in case you want it too. :)

Lex

A game-currency management package. Everything need to add / edit / manage your game's version of currency (pennies, dollars, gold, silver, bucks, dineros, crystals, pounds, etc...) and their relation to each other. Set your lowest form currency (for example - penny) and then add "higher value" / "lower value" / "different value" versions of that base. (i.e. "dollar" = "100" base currency, "silver" = "1350" base value).

Overview

Out of the box, Lex contains all the views necessary to enable "Game Currency" management. It also uses the config file to for you to easily define the necessary permissions to secure your site so that only those allowed to perform the admin functions are permitted (or you can disable ACL altogether). Since it is a config file all views and permissions are configurable so you are free to provide your own views and change the permissions the way your app requires them.

Lex will do the math for you.

Lex will also let you set options on the currencies you add. Perhaps your "gold" can't be bought or sold or traded, only found. Sure, you can do that. Or maybe you decide you don't want your game to use "silver" any more. De-value it or disable it altogether.

Lex also comes with a config file that will allow you to specify the routes, views and / or permissions.

If you have a need for in-game currency management this will be a package to help with that.

Installation

This page is intended for installation, please check out the wiki for more information about usage.

🔲 Composer

composer require "smarch/lex"

📝 Service Provider

Lex uses the HTML Forms package from the "Laravel Collective" for Html & Form rendering so composer will install that as well if you don't already have it installed (you probably do...or should). Once composer has installed the necessary packages for Lex to function you need to open your laravel config page for service providers and add Lex (and if necessary the Laravel Collective Html provider). To properly function you need to have both service providers referenced : HTML Forms and Lex.

config/app.php

   /*
    * Third Party Service Providers
    */
    Collective\Html\HtmlServiceProvider::class, // For Lex Currency Forms to function
    Smarch\Lex\LexServiceProvider::class, // For Lex

📝 Facades

Next you will need to add the Lex and Forms Facades to your config app file.

config/app.php

    /*
    * Third Party Service Providers
    */
    'Form'  => Collective\Html\FormFacade::class,	// required for Lex Forms
    'HTML'  => Collective\Html\HtmlFacade::class,	// required for Lex Forms
    'Lex'	=> Smarch\Lex\Facades\LexFacade::class, // required for Lex:: 

📇 Database Migrations / Seeds

Next you need to add the migration to create the Lex Currency table to hold your game-currency information. From your command prompt (wherever you run your artisan commands) enter the following command php artisan vendor:publish. This will create the Lex config file (which allows you to define any views / permissions you wish to change from their defaults).After you have done that, if you need to change/configure the table or id used for the users (characters), go to the Lex config file and make any changes you need. (see wiki for more information)

php artisan vendor:publish

If you are fine with using the users table as your reference, or have adjusted the config file to your needs, then run the migration command php artisan migrate. This should properly create your necessary tables.

php artisan migrate

❗ Optional - DatabaseSeed

Lex comes equipped with a database seed that can start off your game-currency with some common currencies.

php artisan db:seed --class Smarch\Lex\Seeds\LexTableSeeder     

🔱 Why "Lex"?

I've been a DC geek for over 30 years now. Lex Luther in DC has always been "the money guy" for me so..."Lex". 😄