Production adjustment fix
* The production adjustment function was completely off (and always has been). It has been fixed. * The problem with the adjustment function not being reported means that no-one ever encountered it. As a consequence, happiness strike threshold has been increased to 50% /!\ Full database reset required (or at least much easier than other options).
This commit is contained in:
parent
c94958a058
commit
afa1224391
4 changed files with 95 additions and 8 deletions
legacyworlds-server-data/db-structure/tests
admin/040-functions/050-computation
user/040-functions/050-computation
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Test the verse.adjust_production() function
|
||||
*/
|
||||
BEGIN;
|
||||
-- Create a table of input values
|
||||
CREATE TABLE test_input(
|
||||
prod REAL ,
|
||||
happ REAL
|
||||
);
|
||||
|
||||
-- Set the happiness strike level to 50%
|
||||
SELECT sys.uoc_constant( 'game.happiness.strike' , '(test)' , 'Happiness' , 0.5 );
|
||||
|
||||
-- ***** TESTS BEGIN HERE *****
|
||||
SELECT plan( 3 );
|
||||
|
||||
INSERT INTO test_input VALUES
|
||||
( 10 , 1 ) , ( 100 , 1 ) ,
|
||||
( 10 , 0.9 ) , ( 100 , 0.9 ) ,
|
||||
( 10 , 0.8 ) , ( 100 , 0.8 ) ,
|
||||
( 10 , 0.7 ) , ( 100 , 0.7 ) ,
|
||||
( 10 , 0.6 ) , ( 100 , 0.6 ) ,
|
||||
( 10 , 0.5 ) , ( 100 , 0.5 );
|
||||
SELECT diag_test_name( 'verse.adjust_production() - Production is unaffected when happiness >= game.happiness.strike' );
|
||||
SELECT is_empty(
|
||||
$$ SELECT * FROM test_input WHERE prod <> verse.adjust_production( prod , happ ); $$
|
||||
);
|
||||
DELETE FROM test_input;
|
||||
|
||||
INSERT INTO test_input VALUES
|
||||
( 10 , 0.5 ) , ( 10 , 0.4 ) ,
|
||||
( 10 , 0.3 ) , ( 10 , 0.2 ) ,
|
||||
( 10 , 0.1 ) , ( 10 , 0 );
|
||||
SELECT diag_test_name( 'verse.adjust_production() - Production is unaffected when happiness >= game.happiness.strike' );
|
||||
SELECT set_eq(
|
||||
$$ SELECT rank( ) OVER( ORDER BY happ ) AS r1 ,
|
||||
rank( ) OVER ( ORDER BY verse.adjust_production( prod , happ ) ) AS r2
|
||||
FROM test_input; $$ ,
|
||||
$$ VALUES ( 1 , 1 ) , ( 2 , 2 ) , ( 3 , 3 ) , ( 4 , 4 ) , ( 5 , 5 ) , ( 6 , 6 ) $$
|
||||
);
|
||||
DELETE FROM test_input;
|
||||
|
||||
SELECT diag_test_name( 'verse.adjust_production() - Happiness = 0 => production = 0' );
|
||||
INSERT INTO test_input VALUES
|
||||
( 1 , 0 ) , ( 10 , 0 ) , ( 100 , 0 ) , ( 1000 , 0 ) , ( 10000 , 0 );
|
||||
SELECT is_empty(
|
||||
$$ SELECT * FROM test_input WHERE verse.adjust_production( prod , happ ) <> 0; $$
|
||||
);
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Test privileges on verse.adjust_production()
|
||||
*/
|
||||
BEGIN;
|
||||
|
||||
SELECT plan( 1 );
|
||||
|
||||
SELECT diag_test_name( 'verse.adjust_production( ) - EXECUTE privilege' );
|
||||
SELECT lives_ok( $$ SELECT verse.adjust_production( 1 , 1 ) $$ );
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
Reference in a new issue