-
Notifications
You must be signed in to change notification settings - Fork 4
Games
- Login with your admin account
- Go to
administration > games > view list
- Choose the game you want to edit
- Set the waiting time in minutes, or make it a daily game.
- Login with your admin account
- Go to
administration > games > add
- Fill out the form
- For
Type
choose 'lucky' - Define choices, either as texts, or by providing image paths
- Define possible results
- There has to be at least the same number of results as there are choices
- But it is possible to have more results than choices
- Prize result options are:
win-card:[NUMBER]
win-money:[NUMBER]
lost
(replace [NUMBER] with any positive integer)
- Insert 'game_default_lucky' as
Routing Identifier
, if you don't want/need a custom URL for your Game.
- For
You can add your own games and use the existing framework to hand out the prizes.
But you'll need to have at least some coding experience to alter any preexisting game code you have, to send a post request containing the game result.
(Basically sending some sort of form data.)
Follow these steps to add a JavaScript game:
- Create a view for your game.
Best put it in theapp/views/(lang)/games
folder with the other games.
(Most importantly, add it in your main language!)
There you'll also find a simple template file for you to copy and edit.
If your game requires you to add some HTML also put it in the view file. - Update your JavaScript game
This is the part, where you have to find the part in your game's JavaScript code where the game ends at.
If you use the template view file, you can use the following snipped at the point the player wins:
document.getElementById('result-input').value = 'won';
document.getElementById('my-custom-game').submit();
And where the player looses, add:
document.getElementById('result-input').value = 'lost';
document.getElementById('my-custom-game').submit();
The first line updates the value of the hidden input in the HTML, and the second submits the form. - Does the JavaScript code come as a separate file?
Put it in thepublic/js
folder. - Login with your admin account
- Navigate to
administration > games > add
- Fill out the form
- For
Type
choose 'custom' - define possible results and corresponding prizes
- Format is [RESULT]=>[PRIZE]
- separated by ','
- Prize result options are:
win-card:[NUMBER]
win-money:[NUMBER]
lost
(replace [NUMBER] with any positive integer) - example for the two JavaScript results form step 2:
won=>win-money:100, lost=>lost
- View File is the one from step 1
- JavaScript File is optional (see step 3)
- Insert 'game_custom' as
Routing Identifier
, if you don't want/need a custom URL for your Game.
- For
Open the game_settings.php in the app root folder.
What you need to change is the last value in the line, referring to the game you want to change:
'wait_minutes'=>30
The value in this example is 30, which means 30 minutes.
Possible values are:
- Positive Integers - referring to minutes
- 0 - for no waiting time at all
- false - game is playable only once per day (Note, that you do not have to put this in quotes, as it is a binary value.)
miniTCG provides a model class to let you create your own lucky games easily.
-
Add a new method within the gameController class for your new game Open controllers/game.php and scroll all the way down. Where there is a comment block, with short explanation of how to do it.
public function yourGameName() {
$game_key = 'YOUR_GAME_KEY'; // key will be needed in /game_settings.php
$description = 'YOUR TEXT HERE'; // text for game detail page
$choice_type = 'text'; // [text|image] currently only text is possible!
$choice_elements = array('CHOICE1','CHOICE2'); // user choices, add as many as you need
$possible_results = array('win-card:1','lost'); // possible results; NOTE: amount of choices and results needs to be the same!
// Don't change the line below!
$this->lucky_game($game_key, $description, $choice_type, $choice_elements, $possible_results);
}
How use
$possible_results
?
The possible values are:'win-card:0'
,'win-money:0'
,'lost'
You can change the integer values of the first two result options to whatever you like, e.g. 'win-money:250'.
The game model class will take care of the rest. :) -
Add a route to
/routing.php
see How to add a new page Step 3! -
Add your game to
/games_settings.php
Open the game Settings file in the root folder of the app. You will find something like this:define('GAMES_SETTINGS', array(
'lucky_number' => array('name'=>'Glückszahl', 'routing'=>'game_lucky_number', 'wait_minutes'=>30),
'head_or_tail' => array('name'=>'Kopf oder Zahl', 'routing'=>'game_head_or_tail', 'wait_minutes'=>false),
'trade_in' => array('name'=>'Tausch Mich', 'routing'=>'game_trade_in', 'wait_minutes'=>0)
));
When adding a new line make sure to put ',' after the last existing entry! So it will look like this:
'trade_in' => array('name'=>'Tausch Mich', 'routing'=>'game_trade_in', 'wait_minutes'=>0),
'YOUR_GAME_KEY' => array('name'=>'GAME NAME', 'routing'=>'GAME_ROUTING_IDENTIFIER', 'wait_minutes'=>WAIT_TIME)
-
YOUR_GAME_KEY
: as you set it in step 1 when creating the method -
GAME_NAME
: How it will be displayed on the Website -
GAME_ROUTING_IDENTIFIER
: as you set it in step 2 when adding the route -
WAIT_TIME
: see Change waiting times above, for what the possible values are.
-