Commit 02db2a22 authored by Frederik Wegner's avatar Frederik Wegner
Browse files

table for key value storing of settings. Function for easy typesafe setting...

 table for key value storing of settings. Function for easy typesafe setting retrieval. sql script for default game settings
parent a1fd39b7
......@@ -64,6 +64,36 @@ BEGIN
RETURN not_started;
END//
DELIMITER ;
DROP FUNCTION IF EXISTS getSetting_int;
DELIMITER //
CREATE FUNCTION IF NOT EXISTS getSetting_int
(`_key` VARCHAR(255))
RETURNS INT
BEGIN
RETURN (SELECT `value_int` FROM `setting` WHERE `key`=`_key`);
END//
DELIMITER ;
DROP FUNCTION IF EXISTS getSetting_string;
DELIMITER //
CREATE FUNCTION IF NOT EXISTS getSetting_string
(`_key` VARCHAR(255))
RETURNS VARCHAR(511)
BEGIN
RETURN (SELECT `value_string` FROM `setting` WHERE `key`=`_key`);
END//
DELIMITER ;
DROP FUNCTION IF EXISTS getSetting_float;
DELIMITER //
CREATE FUNCTION IF NOT EXISTS getSetting_float
(`_key` VARCHAR(255))
RETURNS FLOAT
BEGIN
RETURN (SELECT `value_float` FROM `setting` WHERE `key`=`_key`);
END//
DELIMITER ;
-- =====================================================
-- END FUNCTION DEFINITIONS
-- =====================================================
......@@ -774,6 +804,18 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `setting`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `setting` (
`key` VARCHAR(255) NOT NULL PRIMARY KEY,
`type` ENUM('int', 'string', 'float'),
`value_int` INT NULL,
`value_string` VARCHAR(511) NULL,
`vlaue_float` FLOAT NULL
)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.question.answer.points.option', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.question.answer.points.text', 'int', 6);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.question.answer.max', 'int', 6);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.question.answer.min', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.question.answer.def', 'int', 4);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.question.experience', 'int', 50);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.round.questions.max', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.round.questions.min', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.round.questions.def', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.duel.rounds.max', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.duel.rounds.min', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.duel.rounds.def', 'int', 2);
INSERT INTO `setting` (`key`, `type`, `value_int`) VALUES('game.user.max-name-length', 'int', 42);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment