-
Notifications
You must be signed in to change notification settings - Fork 15
Tutorial 1 Create a game model
laggery edited this page Jun 4, 2014
·
24 revisions
- In the navigation tabs of the Wegas project, open the "Web Pages" folder and create a new folder named wegas-tuto. The standard structure of a project Wegas is as follows:
- css: contains the styles sheets of your game
- db : contains JSON files of Game Model (or scenario) and Page (architecture of pages (or interfaces) of the game). In a future version of Wegas, all the data contained in these files will be created from the online editor of Wegas.
- images : contains various images (small size) of the project, all game model will share these images. Large images will must be uploaded from the editor and stored in the "file repository".
- js : This folder will contain widgets created specifically for your project.Preferably, the name of each file follows this format: "Wegas-[game name]-[potential accuracy of item].[Extension]. Thus, for instance, the widget "piece" for a chess game will be named "wegas-chess-piece.js."
If you have any doubt about the structures of the files or the contents of a file, don't hesitate to see how it's done in an another project of Wegas
-
Create a wegas-tuto/css/wegas-tuto.css file.
-
Create a wegas-tuto/db/wegas-tuto-pages.json file with the following content:
[{
"id": 1,
"type": "Text",
"content": "Hello world"
}]
-
Login in on home page (http://localhost:8080/Wegas) using the default admin account (username: root@root.com, password: 1234 )
-
Create a new game by sending the following json to http://localhost:8080/Wegas/rest/GameModel/ using POST method and application/json for the Content-type header parameter.
{
"@class": "GameModel",
"name": "Book",
"properties": {
"cssUri":"wegas-book/css/wegas-book.css",
"pagesUri":"wegas-book/db/wegas-book-pages.json?"
},
"childVariableDescriptors":[{
"@class":"NumberDescriptor",
"name":"combatSkill",
"editorLabel":"Talent de combat",
"label":"Combat skill",
"defaultInstance":{
"@class":"NumberInstance",
"value":1.0
},
"scope":{
"@class":"TeamScope"
},
"minValue":1,
"maxValue":20
}, {
"@class":"NumberDescriptor",
"name":"stamina",
"editorLabel":"Vigueur",
"label":"Stamina",
"defaultInstance":{
"@class":"NumberInstance",
"value":1.0
},
"scope":{
"@class":"TeamScope"
},
"minValue":1,
"maxValue":20
},{
"@class":"NumberDescriptor",
"name":"currentPage",
"editorLabel":"currentPage",
"label":"currentPage",
"defaultInstance":{
"@class":"NumberInstance",
"value":2.0
},
"scope":{
"@class":"TeamScope"
}
}]
}
This JSON can be savec in the "db" folder of your project, It create a game model with the following properties:
- @class serves to clarify what is this file.
- name is the name of your game model.
- scriptLibrary Global scripts used by your game (here, no script is used)
- cssUri is the relative path to access the CSS of your game.
- pageUri is the relative path to access the file "page" (the structure of interfaces) of your game.
- games behave information of games, teams and players. Elements ** name ** is used as token (keyword used to link a player to a game) and must be unique.
- childVariableDescriptors Variables of the game model, it is a list of objects VariableDescriptor. Variables involved, it is a list of objects VariableDescriptor. Properties can be see in the java classes on (Wegas source / packages / ... / persistence / [name of the variable (descriptor or instance)]. Java) , by creating the desired variable in the editor and then exporting the game model by a REST client or by loocking in an other wegas project.
- Go back to http://localhost:8080/Wegas/ where you will find your newly created game model. Select it and click on the game to edit it.