X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=database%2Ffunctions%2Fcovop_alert.sql;fp=database%2Ffunctions%2Fcovop_alert.sql;h=1d3d2a6b7a4e85f3776b9b362934b0f3c0f93f67;hb=76887e53c27118fe04ae8fe75dce610a398b5853;hp=0000000000000000000000000000000000000000;hpb=73119e806350719e2ce899bfbaa2ba19f0dc87d1;p=ndwebbie.git diff --git a/database/functions/covop_alert.sql b/database/functions/covop_alert.sql new file mode 100644 index 0000000..1d3d2a6 --- /dev/null +++ b/database/functions/covop_alert.sql @@ -0,0 +1,16 @@ + +CREATE OR REPLACE FUNCTION covop_alert(secs integer, strucs integer, roids integer + , guards integer, gov governments, population integer) RETURNS integer + AS $_$ + SELECT ((50 + COALESCE($4*5.0/($3+1.0),$6)) + * (1.0+2*LEAST(COALESCE($1::float/CASE $2 + WHEN 0 THEN 1 ELSE $2 END,$6),0.30) + + (CASE $5 + WHEN 'Dic' THEN 0.20 + WHEN 'Feu' THEN -0.20 + WHEN 'Uni' THEN -0.10 + ELSE 0 + END) + $6/100.0 + ))::integer; +$_$ + LANGUAGE sql IMMUTABLE;