Devana how a browser game is made

21Nov/1019

the economy

I've finished the database structure for the economical part of the game; that includes module construction, resource management and various costs and requirements.

The multilingual system now includes a database side for the game assets localization. All asset names and descriptions will be stored in the labels table.
The labels are identified by type (numeric value that identifies which asset type it represents), id (asset id) and language (language id defined in each language's file in the languages folder).

Each faction has max values for how many nodes and modules (per node) one player can have. The faction type is assigned to each node.

Nodes have a lastCheck value, defined as a datetime type which indicates the last time the game has calculated the resource production values and other queue related calculations like module construction, unit training, ...

Modules are divided into types, based on what function they will have. The main mechanic is that modules require a static resource type, a resource type that cannot be produced, but exists in finite quantity. Think of modules as machines that require energy to produce stuff; where the energy is the static resource type, and the "stuff" is the dynamic resource type. Dynamic resources can be stored.
Each module requires an input (the static resource type), a maxInput value and a ratio. The ratio is an unsigned floating point number that defines the output based on the input using the following formula: output = input*ratio; the output is a "per hour" value.
The game determines the output type based on what entry the "module" column one resource type has.
0 is for static resources, while any other unsigned int designates the id of the module where that resource is to be produced.
Resources also have a max storage value.
The dynamic resources are stored as values in the resource_storage table, per node, and per resource type. And yes, static resources do not have entries there.
Free static resources are determined by the following formula: their maxStorage value minus all input values from all modules that require them as input.
Modules slots are stored in the module_slots table, with an assigned value for the module's required input. These entries are defined per module and per node.

Costs are stored in the costs table. The costs are defined per type (module, item, unit, ...), id (be it moduleId, unitId, ...) and faction. Each entry has a (dynamic) resource type defined and the value of that resource type required.
One can define costs as being comprised of 1 or more cost entries; 1 for each required resource type.
Example: there will b 3 entries in the costs table if the sword item costs 3 lumber, 5 steel and 10 gold.

Requirements are stored in the requirements table. The requirements are defined per type (module, item, unit, ...) and id (be it moduleId, unitId, ...). Each entry has a value associated to it depicting the id of the required type.
One can define requirements as being comprised of 1 or more requirement entries; 1 for each required requirement type.
Example: there will be 2 entries in the requirements table if the barracks module requires the blacksmith and mill modules.

And here's the sql structure: economyStructure

Comments (19) Trackbacks (1839)
  1. I saw you have in core.php functions for set,remove etc but don’t use them. Can you make the links( to can change password,remove accounts and all other) and give them to us? I make 40% of them( i think) but you are better than me.

  2. If you are referring to an admin panel, yes, there will be one.
    I put the code here only to document the development. It’s more than likely that things will change a lot until we get to the final release version.
    And yes, the code I uploaded so far had no account page for users to edit stuff like their email or password. I did that today. :P

    If you were referring to something else, let me know.

  3. You can use in header.php something like ?section=… for the links. and from index.php to make this:
    if(isset($_GET["section"]))
    {
    $a = $_GET["section"];
    }

    $b = templates/”.$_SESSION["user"]['template'].”".$a.”.php”;
    if(file_exists(“$b”))
    require “$b”;
    else
    echo”there is not such site.”;

    I think it will work faster and you can delete some files from the main folder. ;) I made this but without “templates/”.$_SESSION["user"]['template']” for now. I put avatar, change password and e-mail. I will be happy what you made today and tomorrow(if you make something). Please post here your work or PM me at e-mail:altimir14@abv.bg, skype: black-stankia

    • how did you put an avatar ?

      • Sorry. I saw your message now.
        I made the script. 1 small script to put the image you sent to 1 folder(avatars for example) and the name is the same like the username. And after that where i want to be the avatar i put with his name, if he don’t hae avatar, he will see custom avatar.

  4. And make the map to be like square, not diamond(rhomb) it will be better.

  5. Congratulations Devland!!! Your project is really exciting!

  6. nice step, but still far away :D

  7. Devland, if you want a full-blown installer made for Devana 2.0, contact me. I have written a script that could be easily customizable to work with devana.

  8. @Anon, actually, I was thinking of making a wizard of sorts to the easy modding of game content. It’s too early though to start anything in that direction. :P

  9. Hey, cool project :) But templates engine sucks… I think you can use Smarty or this one – http://www.raintpl.com/ It’s my favourite template engine. Also in my projects I use this framework modification – http://www.rainframework.com/ It’s a brilliant and really lightweight. But It hasn’t user management class… Anyway you can rewrite this one http://php-login-script.com/ and use it with rainframework together ;)

  10. I’ve heard that before. The current template system remains. It’s dead simple and it works.
    There will be no third party code, and no frameworks used.

  11. hey devland check out your game here : http://naivart.isgreat.org

    your game is so great that if i have a credit account( but i dont have ), i will donate you for $$$ ;) . Too bad i am not a php programmer, but a .net programmer. Nice work devland, very nice :D

  12. did devana just update? all the sudden the formatting is right all the sudden

  13. Hi, nice work. I browsed your 1.x code some time aga and got inspired.

    Q: How do you plan to calculate growth of resources over time? Will you have a background job for that or will it be triggered by player activity? If you use player activity how can you be sure that the growth will be right?

  14. Resources will no longer grow. Buildings will no longer have levels. They will have a max amount of workers that can be assigned to them, and based on that number the production is calculated.

  15. OK, I think that’s nice, it will save the players from the endless clicking (travian style).

    But I assume production will still be calculated over time, in this case based on number of workers. How will this be done? Are you using player activity in the end user code or do you plan to have a dedicated background job, like a server process or admin page with timer handling that drives the calculation of production?

  16. Resource production will be handled similar to devana 1.x.x. There will be no cron jobs or anything like that.


Leave a comment

(required)

*
= 5 + 4