Skip to content

Commit

Permalink
BugFix in ship state system. Game play change of first minute of flee…
Browse files Browse the repository at this point in the history
…t run time is now free
  • Loading branch information
Abstrct committed Mar 16, 2012
1 parent c70f9b3 commit c377da7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG
@@ -1,3 +1,16 @@
# 2012 03 15

create_schemaverse.sql - v1.1.0
tic.pl - v0.11.1

Bug Fixes
-resolved issues with tic.pl and action_permission_check() that allowed for double actions and actions beyond the grave

Gameplay Changes
-First 1 minute of fleet runtime is now free. You can run the upgrade(id, 'FLEET_RUNTIME', 1) once wihtout having the money.
-Players starting balance has been lowered to account for this


# 2012 03 06

create_schemaverse.sql - v1.1.0 location, location, location
Expand Down
41 changes: 29 additions & 12 deletions create_schemaverse.sql
@@ -1,6 +1,6 @@
-- Schemaverse
-- Created by Josh McDougall
-- v1.1.0 - location, location, location
-- v1.1.1 - location, location, location
begin;

CREATE SEQUENCE round_seq
Expand Down Expand Up @@ -75,7 +75,7 @@ CREATE TABLE player
username character varying NOT NULL UNIQUE,
password character(40) NOT NULL, -- 'md5' + MD5(password+username)
created timestamp NOT NULL DEFAULT NOW(),
balance numeric NOT NULL DEFAULT '10010000',
balance numeric NOT NULL DEFAULT '10000',
fuel_reserve integer NOT NULL DEFAULT '1000',
error_channel CHARACTER(10) NOT NULL DEFAULT lower(generate_string(10)),
starting_fleet integer,
Expand Down Expand Up @@ -891,9 +891,17 @@ BEGIN
RETURN FALSE;
END IF;
IF code = 'FLEET_RUNTIME' THEN
IF NOT CHARGE(code, quantity) THEN
EXECUTE 'NOTIFY ' || get_player_error_channel() ||', ''Not enough funds to increase fleet runtime'';';
RETURN FALSE;

IF (SELECT sum(runtime) FROM fleet WHERE player_id=GET_PLAYER_ID(SESSION_USER)) > '0 minutes'::interval THEN
IF NOT CHARGE(code, quantity) THEN
EXECUTE 'NOTIFY ' || get_player_error_channel() ||', ''Not enough funds to increase fleet runtime'';';
RETURN FALSE;
END IF;
ELSEIF quantity > 1 THEN
IF NOT CHARGE(code, quantity-1) THEN
EXECUTE 'NOTIFY ' || get_player_error_channel() ||', ''Not enough funds to increase fleet runtime'';';
RETURN FALSE;
END IF;
END IF;

UPDATE fleet SET runtime=runtime + (quantity || ' minute')::interval where id=reference_id;
Expand Down Expand Up @@ -2002,10 +2010,21 @@ CREATE TRIGGER A_TRADE_ITEM_PERMISSION_CHECK BEFORE INSERT OR DELETE ON trade_it
CREATE OR REPLACE FUNCTION ACTION_PERMISSION_CHECK(ship_id integer) RETURNS boolean AS $action_permission_check$
DECLARE
ships_player_id integer;
lat integer;
exploded boolean;
ch integer;
BEGIN
SELECT player_id into ships_player_id FROM ship WHERE id=ship_id and destroyed='f' and current_health > 0 and last_action_tic != (SELECT last_value FROM tic_seq);
IF ships_player_id = GET_PLAYER_ID(SESSION_USER) OR SESSION_USER = 'schemaverse'
OR CURRENT_USER = 'schemaverse' THEN
SELECT player_id, last_action_tic, destroyed, current_health into ships_player_id, lat, exploded, ch FROM ship WHERE id=ship_id ;
IF ( lat != (SELECT last_value FROM tic_seq)
AND
exploded = 'f'
AND
ch > 0
) AND (
ships_player_id = GET_PLAYER_ID(SESSION_USER)
OR (ships_player_id > 0 AND (SESSION_USER = 'schemaverse' OR CURRENT_USER = 'schemaverse'))
) THEN

RETURN 't';
ELSE
RETURN 'f';
Expand Down Expand Up @@ -2807,10 +2826,8 @@ BEGIN


--Reset player resources
UPDATE player set balance=10010000, fuel_reserve=100000 WHERE (starting_fleet=0 OR starting_fleet IS NULL) AND username!='schemaverse';

UPDATE player set balance=10000, fuel_reserve=100000 WHERE starting_fleet!=0 AND starting_fleet IS NOT NULL;
UPDATE fleet SET runtime='1 minute', enabled='t' FROM player WHERE player.starting_fleet=fleet.id AND player.id=fleet.player_id;
UPDATE player set balance=10000, fuel_reserve=100000 WHERE username!='schemaverse';
UPDATE fleet SET runtime='1 minute', enabled='t' FROM player WHERE player.starting_fleet=fleet.id AND player.id=fleet.player_id;


UPDATE planet SET fuel=20000000 WHERE id=1;
Expand Down
4 changes: 2 additions & 2 deletions tic.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#############################
# Tic v0.11 #
# Tic v0.11.1 #
# Created by Josh McDougall #
#############################
# This no longer sits in the cron and should be run in a screen session instead
Expand Down Expand Up @@ -105,7 +105,7 @@
AND
ship.destroyed='f'
AND
ship.last_move_tic != (SELECT last_value FROM tic_seq);
ship.last_action_tic != (SELECT last_value FROM tic_seq);
COMMIT WORK;
SQLSTATEMENT
$master_connection->do($sql);
Expand Down

0 comments on commit c377da7

Please sign in to comment.