Hello, friends!
This mode is a whack-a-mole game where you earn points to obtain dark matter.
A mole appears every second, and clicking it earns you 100 points. The game lasts 30 seconds. If you don't reach 1,000 points, you won't receive any.
You can play up to 10 times a day.
You can adjust the dark matter and time by modifying the internal code.
SQL
SQL-Query
- CREATE TABLE `uni1_gamedu` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- `username` VARCHAR(32) NOT NULL DEFAULT '',
- `user_id` INT UNSIGNED NOT NULL DEFAULT 0,
- `time` INT NOT NULL DEFAULT 0,
- `score` INT UNSIGNED NOT NULL DEFAULT 0,
- `type` TINYINT UNSIGNED NOT NULL DEFAULT 0,
- `universe` TINYINT UNSIGNED NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Add php source
includes/pages/game/ShowGameduPage.class.php
PHP Source Code
- <?php
- /**
- * 2Moons
- * @noonn
- */
- class ShowGameduPage extends AbstractGamePage
- {
- public static $requireModule = 0;
- function __construct()
- {
- parent::__construct();
- }
- function show()
- {
- global $LNG, $USER, $resource;
- $db = Database::get();
- //Delete data older than one day
- $sql = "DELETE FROM uni1_gamedu WHERE type = '0' AND time < :time;";
- $db->delete($sql, array(
- ':time' => (TIMESTAMP - (60 * 60 * 24))
- ));
- //Check remaining time
- $sql = "SELECT * FROM uni1_gamedu WHERE type = '0' AND universe = :uni AND user_id = :userid AND time > :time ORDER BY time ASC;";
- $search = $db->select($sql, array(
- ':uni' => Universe::current(),
- ':userid' => $USER['id'],
- ':time' => (TIMESTAMP - (60 * 60 * 24))
- ));
- $SearchResult = array();
- foreach($search as $s)
- {
- $ver = TIMESTAMP - $s['time']; //Save time
- $restart = pretty_time((60 * 60 * 24) - $ver);
- $SearchResult[] = array(
- 'username' => $s['username'],
- 'time' => $restart,
- 'universe' => $s['universe']
- );
- }
- //Check remaining times
- $sql = "SELECT COUNT(*) as count FROM uni1_gamedu WHERE type = '0' AND universe = :universe AND user_id = :user_id;";
- $Count = $db->selectSingle($sql, array(
- ':universe' => Universe::current(),
- ':user_id' => $USER['id']
- ), 'count');
- if(isset($_POST['feld']) && $_POST['feld']=="1")
- {
- $point = HTTP::_GP('gp', 0);
- if(!ctype_digit((string)$point)) {
- $this->printMessage("<span style=font-size:1.2em;color:#9BC800>An incorrect score was entered.</span>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=gamedu'
- )));
- }
- if($Count >= 10){
- $this->printMessage("<span style=font-size:1.2em;color:yellow>You cannot exceed the current possible number of times.</font>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=gamedu'
- )));
- }elseif($point >= 1000 && $point <= 30000 && $Count < 10){
- $USER[$resource[921]] += 50; // <-- 50 dark matter award
- $sql = "INSERT INTO uni1_gamedu SET username = :username, user_id = :user_id, time = :time, score = :score, type = '0', universe = :universe;";
- $db->insert($sql, array(
- ':username' => $USER['username'],
- ':user_id' => $USER['id'],
- ':time' => TIMESTAMP,
- ':score' => $point,
- ':universe' => Universe::current()
- ));
- $this->printMessage("<span style=font-size:1.2em;color:yellow>Obtain 50 dark matter, ".$point." points were registered.</font>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=gamedu'
- )));
- }elseif($point < 1000){
- $this->printMessage("<span style=font-size:1.2em;color:yellow>If your score is lower than 1,000, you cannot register and will not be counted towards your total.<br>You can try again.</font>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=gamedu'
- )));
- }else{
- $this->printMessage("<span style=font-size:1.2em;color:yellow>This is an unusual approach.</font>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=gamedu'
- )));
- }
- }
- $sql = "SELECT username, id, max(score) as score FROM uni1_gamedu WHERE type = '0' AND universe = :universe GROUP BY username ORDER BY score DESC LIMIT 10;";
- $rank = $db->select($sql, array(
- ':universe' => Universe::current()
- ));
- $rankplayer = array();
- foreach($rank as $rankplayerrow) {
- $rankplayer[$rankplayerrow['id']] = "{$rankplayerrow['username']} {$rankplayerrow['score']}";
- }
- $this->assign(array(
- 'rank' => $rankplayer,
- 'count' => $Count,
- 'SearchResult' => $SearchResult
- ));
- $this->display('page.gamedu.default.tpl');
- }
- }
The tpl source is in the reply below.
You can change the image path in css: background: url('styles/theme/gow/dudgi.png') center/cover no-repeat; /* <--------- Mole Image Path */
I've attached the mole image. You can change it to a different image.
Have a good day.
--------------------------------------------------------------------------------------