ÄÚ¸®¾ÆÈ£½ºÆÃ
±Ù¹«½Ã°£¿Ü¿¡
¹®ÀÇ»çÇ×Àº ¾Æ·¡ÀÇ1:1 »ó´ã¹®ÀÇ ¸¦
ÀÌ¿ëÇϽñ⠹ٶø´Ï´Ù.
ÀÛ¼ºÀÏ :2008-02-29 Á¶È¸ : 540130
MYSQL ½ºÅä¾îµå Æã¼Ç »ç¿ë°¡´ÉÇÑ°¡¿ä
MYSQL ½ºÅä¾îµå Æã¼Ç »ç¿ë°¡´ÉÇÑ°¡¿ä
¹Ø¿¡°Ç ´Ù Áö¿ì¼Åµµ µÇ¿ä µµ¹èÇؼ Á˼Û...
¼³¸íÀÌ ºÎÁ·ÇÑ°Å °°¾Æ¼ ´Ù½Ã Á¤È®ÇÏ°Ô ½è½À´Ï´Ù.
MYSQL ½ºÅä¾îµå Æã¼Ç »ç¿ë°¡´ÉÇÑ°¡¿ä
DELIMITER //
CREATE FUNCTION f_calcres( timberlv INT, claylv INT, ironlv INT, warelv INT, hidinglv INT, attacktime DATETIME, timerleft INT, clayleft INT, ironleft INT, distance DOUBLE) RETURNS INT
BEGIN
DECLARE newtimber INT;
DECLARE newclay INT;
DECLARE newiron INT;
DECLARE maxstorage INT;
DECLARE timeelapse INT;
DECLARE timberproduce INT;
DECLARE clayproduce INT;
DECLARE ironproduce INT;
SET maxstorage = ROUND( POW( 1.2294934136946, warelv - 1 ) * 1000 ) - ROUND( POW( 1.3335005309793, hidinglv - 1 ) * 150 );
SET timeelapse = UNIX_TIMESTAMP( UTC_TIMESTAMP() ) - UNIX_TIMESTAMP( attacktime ) + CEIL( distance * 400 );
SET timberproduce = IF( timberlv = 0, 10/3600, POW( 1.16311804, timberlv - 1 ) / 60 ) * timeelapse;
SET clayproduce = IF( claylv = 0, 10/3600, POW( 1.16311804, claylv - 1 ) / 60 ) * timeelapse;
SET ironproduce = IF( ironlv = 0, 10/3600, POW( 1.16311804, ironlv - 1 ) / 60 ) * timeelapse;
SET newtimber = LEAST( timberproduce, maxstorage );
SET newclay = LEAST( clayproduce , maxstorage );
SET newiron = LEAST( ironproduce , maxstorage );
return CEIL( newtimber + newclay + newiron ) / 80 + 1;
END;
//
DELIMITER ;
DELIMITER //
CREATE FUNCTION f_rade( startx INT, starty INT, targetx INT, targety INT, numlc INT )
RETURNS INT
BEGIN
DECLARE timberpro INT;
DECLARE craypro INT;
DECLARE ironpro INT;
DECLARE needlc INT;
DECLARE timberl INT;
DECLARE crayl INT;
DECLARE ironl INT;
DECLARE timberlev INT;
DECLARE craylev INT;
DECLARE ironlev INT;
DECLARE warelev INT;
DECLARE hidinglev INT;
DECLARE isexist INT DEFAULT 0;
DECLARE elapse FLOAT;
DECLARE maxres INT;
DECLARE distance FLOAT;
DECLARE lastattack DATETIME;
SELECT attacktime, timber, cray, iron, timberleft, crayleft, ironleft, warehouse, hidingplace, 1
INTO lastattack, timberlev, craylev, ironlev, timberl, crayl, ironl, warelev, hidinglev, isexist
FROM farm
WHERE x = targetx AND y = targety;
IF isexist = 0 THEN
RETURN 0;
END IF;
SET distance = SQRT( POW( startx - targetx, 2 ) + pow( starty - targety, 2 ) );
SET elapse = ( UNIX_TIMESTAMP( UTC_TIMESTAMP( ) ) - UNIX_TIMESTAMP( lastattack ) + distance * 400 ) / 60;
SET maxres = ROUND( POW( 1.2294934136946, warelev - 1 ) * 1000 ) - ROUND( POW( 1.3335005309793 , hidinglev - 1 ) * 150 );
SET timberpro = CEIL( LEAST( maxres, IF( timberlev = 0 , 10/60, POW( 1.16311804, timberlev - 1 ) ) * elapse + timberl ) );
SET craypro = CEIL( LEAST( maxres, IF( craylev = 0 , 10/60, POW( 1.16311804, craylev - 1 ) ) * elapse + crayl ) );
SET ironpro = CEIL( LEAST( maxres, IF( ironlev = 0 , 10/60, POW( 1.16311804, ironlev - 1 ) ) * elapse + ironl ) );
SET needlc = CEIL( ( timberpro + craypro + ironpro ) / 80 );
UPDATE farm
SET attacktime = DATE_ADD( UTC_TIMESTAMP(), INTERVAL distance * 400 SECOND ),
timberleft = timberpro * GREATEST( 0, 1 - numlc / needlc ),
crayleft = craypro * GREATEST( 0, 1 - numlc / needlc ),
ironleft = ironpro * GREATEST( 0, 1 - numlc / needlc )
WHERE x = targetx AND y = targety;
RETURN 1;
END;
//
DELIMITER ;
create table ally (
id int(11) NOT NULL, name char(50), tag char(50), members int(11), villages int(11),
points int(11), all_points int(11), rank int(11),
PRIMARY KEY ( id ), INDEX ally_name ( name ), INDEX ally_tag ( tag ) );
create table farm (
x int not null, y int not null, timber int, cray int, iron int, warehouse int, hidingplace int,
attacktime datetime, timberleft int, crayleft int, ironleft int, primary key ( x, y ) );
create table tribe (
id int not null, name varchar(50), tag int, members int, points int, rank int,
primary key ( id ), index tribe_name ( name ), index tribe_tag ( tag ) );
create table village (
id int not null, name varchar(100), x int, y int, tribe int, point int, rank int,
primary key ( id ), index village_name ( name ), index village_pos ( x,y ), index village_tribe ( tribe ) );
´äº¯ : °í°´´Ô²²¼ »ç¿ëÇÏ·Á°í ÇÏ´Â mysql 5.0.2 ¹öÀü ºÎÅÍ
±â´É Á¦°øÀº µÇ°í ÀÖÀ¸³ª ÄÚ¸®¾ÆÈ£½ºÆÃ
¼¹ö¿¡¼´Â Áö¿øÀÌ ¾ÈµË´Ï´Ù.
°¨»çÇÕ´Ï´Ù.