]> ruin.nu Git - ndwebbie.git/commitdiff
Remove points when unclaiming launched target
authorMichael Andreen <harv@ruin.nu>
Tue, 6 Nov 2007 18:31:32 +0000 (19:31 +0100)
committerMichael Andreen <harv@ruin.nu>
Tue, 6 Nov 2007 18:31:32 +0000 (19:31 +0100)
database/raids.sql [new file with mode: 0644]

diff --git a/database/raids.sql b/database/raids.sql
new file mode 100644 (file)
index 0000000..b9bc894
--- /dev/null
@@ -0,0 +1,22 @@
+
+/*Changes when target is unclaimed */
+CREATE OR REPLACE FUNCTION unclaim_target()
+  RETURNS "trigger" AS
+$BODY$
+if ($_TD->{event} eq 'DELETE' && $_TD->{old}{launched} eq 't'){
+       my $uid = $_TD->{old}{uid};
+       my $query = spi_prepare(q{UPDATE users
+               SET attack_points = attack_points - 1
+               WHERE uid = $1},'int4');
+       spi_exec_prepared($query,$uid);
+       spi_freeplan($query);
+}
+return;
+$BODY$  LANGUAGE 'plperl' VOLATILE;
+ALTER FUNCTION updated_target() OWNER TO ndawn;
+
+
+CREATE TRIGGER unclaim_target AFTER DELETE
+   ON raid_claims FOR EACH ROW
+   EXECUTE PROCEDURE PUBLIC.unclaim_target();
+