From 8cfa7e5332b4e22df613b8b0fd4441990bc39f5c Mon Sep 17 00:00:00 2001 From: hecht Date: Wed, 28 Sep 2011 21:40:01 +0000 Subject: [PATCH] adjusted the clanfights so some things are now persisted (there is also a small test-php file that can be tempoary be used to run some things localy) --- ag/include/char.inc.php | 9 ++ ag/include/clan_fights.inc.php | 44 +++++-- ag/include/event.inc.php | 107 +++++++++++++++ ag/include/kampf_wrapper.inc.php | 215 +++++++++++++++++++++++++++++++ ag/include/user.inc.php | 24 +++- ag/test.php | 23 ++++ db/animegame_svn.sql | 121 ++++++++++++++++- 7 files changed, 529 insertions(+), 14 deletions(-) create mode 100644 ag/include/event.inc.php create mode 100644 ag/include/kampf_wrapper.inc.php create mode 100644 ag/test.php diff --git a/ag/include/char.inc.php b/ag/include/char.inc.php index 710629a..7ddfc5a 100644 --- a/ag/include/char.inc.php +++ b/ag/include/char.inc.php @@ -15,6 +15,9 @@ * */ +// required for status calculation! +include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan_fights.inc.php'); + /* * Char Status */ @@ -64,6 +67,12 @@ function getStatus($charid, $buffer_enabled = true) { $GLOBALS['char_buffered_statuses'][$charid] = 'Angemeldet'; return 'Angemeldet'; } + + if(isCharBusyWithClanfighting($charid)) { + $GLOBALS['char_buffered_statuses'][$charid] = 'Clanfight'; + return 'Clanfight'; + } + $GLOBALS['char_buffered_statuses'][$charid] = 'Frei'; return 'Frei'; } diff --git a/ag/include/clan_fights.inc.php b/ag/include/clan_fights.inc.php index 47eb06a..4a53b80 100644 --- a/ag/include/clan_fights.inc.php +++ b/ag/include/clan_fights.inc.php @@ -7,7 +7,9 @@ */ include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/clan.inc.php'); +include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf_wrapper.inc.php'); include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/semaphore.inc.php'); +include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/event.inc.php'); define("MIN_MEMBERS", 5); @@ -148,7 +150,7 @@ function acceptChallengeRequest($clan_challenge_id, array $user) { while(!$finished) { $row = mysql_fetch_row(mysql_query('select IFNULL(max(clan_challenge_id),0) + 1 from clan_challenge')); mysql_query('INSERT INTO clan_challenge(clan_challenge_id) values('.$row[0].')'); - $finished = mysql_affected_rows(); + $finished = mysql_affected_rows() > 0; $id = $row[0]; } @@ -256,6 +258,12 @@ function getParticipatingClanIDs($clan_challenge_id) { return $array; } +function isCharBusyWithClanfighting($char_id) { + $sql = 'SELECT count(*) as anzahl FROM clan_challenge_participants ccp INNER JOIN clan_challenges cc on ccp.clan_challenge_id = cc.clan_challenge_id WHERE cc.calculated = FALSE AND char_id = ' .$char_id; + $row = mysql_fetch_row(mysql_query($sql)); + return $row[0] > 0; +} + function getParticipatingCharIDs($clan_challenge_id, $clan_id) { $array = array(); $sql = 'SELECT char_id, slot FROM clan_challenge_participants WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = ' .$clan_id; @@ -328,6 +336,10 @@ function joinChallenge($clan_challenge_id, array $user, $charid, $slot ) { return 'Du kannst den Char nicht an dem Kampf teilnehmen lassen, da er dir nicht gehört!'; } + if($char['status'] != 'Frei') { + return 'Du kannst den Char nicht an dem Kampf teilnehmen lassen, da er nicht frei ist!'; + } + $clan_challenge = getChallenge($clan_challenge_id); $clan_ids = getParticipatingClanIDs($clan_challenge['clan_challenge_id']); @@ -414,9 +426,12 @@ function calculateChallenge($clan_challenge_id) { $clan_ids = getParticipatingClanIDs($clan_challenge_id); $clan_chars = array(); + $event_id = createEvent(EVENT_CLAN_FIGHT); + foreach ($clan_ids as $clan_id) { $clan_char_ids = getParticipatingCharIDs($clan_challenge_id, $clan_id); foreach ($clan_char_ids as $slot => $char_id) { + addParticipant($event_id, getChar($char_id)); $clan_chars[$clan_id][$slot] = getChar($char_id); } } @@ -424,10 +439,10 @@ function calculateChallenge($clan_challenge_id) { // okay now determine the type of fight switch($challenge['type']) { case DAVY_BACK_FIGHT: - return calculateDavyBackClanFight($clan_ids, $clan_chars); + return calculateDavyBackClanFight($event_id, $clan_ids, $clan_chars); break; case SURVIVAL: - return calculateSurvivalClanFight($clan_ids, $clan_chars); + return calculateSurvivalClanFight($event_id, $clan_ids, $clan_chars); break; default: // cannot create anything -.- @@ -437,7 +452,7 @@ function calculateChallenge($clan_challenge_id) { return NULL; } -function calculateDavyBackClanFight(array $clan_ids, array $clan_char_array) { +function calculateDavyBackClanFight($event_id, array $clan_ids, array $clan_char_array) { // okay, davy back fights are 1 vs. 1 and the winner is the one that has won the most fights. if(count($clan_char_array) != 2) { return 'Davy Back Fights können nur zwischen 2 Clans ausgetragen werden und nicht von ' . count($clan_char_array); @@ -452,11 +467,11 @@ function calculateDavyBackClanFight(array $clan_ids, array $clan_char_array) { $char_clan_2 = $clan_char_array[$clan_ids[1]][$runde]; // we do not need to know right now who won the battle! This is required in the post processing (cronjob)! - battle($char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT); + battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT); } } -function calculateSurvivalClanFight(array $clan_ids, array $clan_char_array) { +function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char_array) { // okay, survival fights are 1 vs. 1 and the winner is the one that has the last man standing. if(count($clan_char_array) != 2) { return 'Survival Fights können nur zwischen 2 Clans ausgetragen werden und nicht von ' . count($clan_char_array); @@ -473,7 +488,7 @@ function calculateSurvivalClanFight(array $clan_ids, array $clan_char_array) { // As long as char 1 and char 2 are set while($char_clan_1 != NULL && $char_clan_2 != NULL) { - $sieger = battle($char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL); + $sieger = battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL); if($sieger['id'] != $char_clan_1['id']) { // the loser is of clan 1 $char_clan_1 = $clan_char_array[$clan_ids[0]][++$counter_clan_1]; @@ -489,13 +504,24 @@ function calculateSurvivalClanFight(array $clan_ids, array $clan_char_array) { /** * This function calculates the battle between two chars. + * @param int $event_id the event id * @param array $char1 * @param array $char2 * @param int $attack_set the attack set that should be used! * @return the winners array */ -function battle(array $char1, array $char2, $attack_set) { - // TODO: Implement the single fight ... +function battle($event_id, array $char1, array $char2, $attack_set) { + $combinedArray = calculateFight($char1, $char2); + + // first persist the fight and then check who was the winner and adjust the char array for him ;) + persistFight($event_id, $combinedArray); + + // now determine the winner + // TODO: implement + + // now adjust the winners array + // TODO: implement + } diff --git a/ag/include/event.inc.php b/ag/include/event.inc.php new file mode 100644 index 0000000..6a17744 --- /dev/null +++ b/ag/include/event.inc.php @@ -0,0 +1,107 @@ + 0; + $id = $row[0]; + } + + return $id; +} +/** + * Adds a participant to a given event + * @param int event_id + * @param array $char + * @return int the id of the participant (usually the charid), NULL on failure! + */ +function addParticipant($event_id, array $char) { + // Okay now add the char ;) + $user = getUser($char['besitzer']); + $hp = explode(',', $char['hp']); + $mp = explode(',', $char['mp']); + + $sql = 'INSERT INTO event_chars(event_id, event_char_id, char_id, char_name, char_bild, user_id, user_name, hp, mp, strength, speed, defense, luck, stamina)'; + $sql .= ' value('. $event_id . ', '.$char['id'] .', '.$char['id'] .', \''.$char['name'].'\', \''.$char['bild'].'\', '.$char['besitzer'].', \''.$user['nickname'].'\', '.$hp[1].', '.$mp[1].', '.$char['starke'].', '.$char['speed'].', '.$char['verteidigung'].', '.$char['glueck'].', '.$char['ausdauer'].')'; + +// echo $sql . '
'; + + mysql_query($sql); + if(mysql_affected_rows() == 0) + return NULL; + return $char['id']; +} + +/** + * Persists a fight of one event. + * @param int $event_id + * @param array combined array that is calculated in the kampf_wrapper + * @return int the id of the fight + */ +function persistFight($event_id, array $combinedArray) { + // persist a fight of two chars (calculated by the wrapper) ^^" + //echo 'The fight was about ' . count($combinedArray) . ' rounds
'; + + // first get a fight id ;). + $finished = FALSE; + while(!$finished) { + $sql = 'SELECT IFNULL(max(event_fight_id),0) + 1 FROM event_fights'; + $row = mysql_fetch_row(mysql_query($sql)); + mysql_query('INSERT INTO event_fights(event_id, event_fight_id) values('.$event_id.', \''.$row[0].'\')'); + $finished = mysql_affected_rows() > 0; + $event_fight_id = $row[0]; + } + + // now we have a $event_fight_id ;) lets insert the other stuff ;) + + + + for($round = 0; $round < count($combinedArray) ; $round++) { + // persist this round ^^" + + // first persist char1 + $chara_1 = $combinedArray[$round]['char1_array']; + + $sql = 'INSERT INTO event_fight_rounds(event_id, event_fight_id, round, event_char_id, hp, mp, strength, speed, defense, luck, stamina, attack, damage)'; + $sql .= ' values('.$event_id.','.$event_fight_id.','.$round.',' .$chara_1['id'].','. $chara_1['hp'].', '. $chara_1['mp'].', '. $chara_1['starke'].', '. $chara_1['speed'].', '. $chara_1['verteidigung'].', '. $chara_1['glueck'].', '. $chara_1['ausdauer'].', \''. $combinedArray[$round]['atk_char1'] .'\', \''. $combinedArray[$round]['dmg_char1'] .'\')'; + +// echo $sql .'
'; + + mysql_query($sql); + // now persist char2 + $chara_2 = $combinedArray[$round]['char2_array']; + + $sql = 'INSERT INTO event_fight_rounds(event_id, event_fight_id, round, event_char_id, hp, mp, strength, speed, defense, luck, stamina, attack, damage)'; + $sql .= ' values('.$event_id.','.$event_fight_id.','.$round.',' .$chara_2['id'].', '. $chara_2['hp'].', '. $chara_2['mp'].', '. $chara_2['starke'].', '. $chara_2['speed'].', '. $chara_2['verteidigung'].', '. $chara_2['glueck'].', '. $chara_2['ausdauer'].', \''. $combinedArray[$round]['atk_char2'] .'\', \''. $combinedArray[$round]['dmg_char2'] .'\')'; + +// echo $sql .'
'; + + mysql_query($sql); + + } +} + +?> \ No newline at end of file diff --git a/ag/include/kampf_wrapper.inc.php b/ag/include/kampf_wrapper.inc.php new file mode 100644 index 0000000..293c12b --- /dev/null +++ b/ag/include/kampf_wrapper.inc.php @@ -0,0 +1,215 @@ +'; + $qry = mysql_query($sql); + while($row = mysql_fetch_assoc($qry)) { + for($i=0;$i 0) { + $sql = 'SELECT * FROM attacken WHERE id IN(' .implode(',', $kombined) . ')'; +// echo $sql .'
'; + $qry = mysql_query($sql); + + $attack_data = array(); + while($row = mysql_fetch_assoc($qry)) { + $attack_data[$row['id']] = $row; + } + } + + ## Start the fight ;) + + // The "rundenArray" has a specific structure. For each round played another entry is placed. + // An entry contains { char1_array*, char2_array*, atk_char1, atk_char2, dmg_char1, dmg_char2 } + // the char arrays contain the stats of the chars at the end of the round ! + + + + $rundenArray = array(); + + $tmp_hp = array(); + while ($k_hp[0] > $k_aufgabe[0] AND $k_hp[1] > $k_aufgabe[1] AND $x < 10) { + + $runde = array(); + $runde['char1_array'] = $char1; + $runde['char2_array'] = $char2; + + $technick1 = $attack_data[$k_attacke1[$x]]; + $technick2 = $attack_data[$k_attacke2[$x]]; + + ///////////////////Hier laedt er den RELOAD der technik wenn die zusammen setzung nicht stimmen sollte + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/andere_technik.php'); /////////////////// Wenn man ne andere technik sich aussuchen will... + + $speeds_char1 = ($k_speed[0] + $technick1[speed]); + $speeds_char2 = ($k_speed[1] + $technick2[speed]); + + ////// MUSS SO BLEIBEN WICHTIG + $aussetzten_runde = ''; + $tmp_hp[0] = 0; + $tmp_hp[1] = 0; + ##################################MP, SSJ Verwandlungen, HP, Koerper Tausch Technicken + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/majin.php'); + + if (!$aussetzten_runde) { /////DAS FUER MAJIN ATTACKEN + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/atk_wert.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/tausch2.php'); //////////////////Muss ganz oben sein wegen technik Tauschen + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/gift.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/frucht.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/mp.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/hp.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/hp2.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/SSJ.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/kaioken.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/kaioken2.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/copy.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/lose.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/lose2.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/ausdauer.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/mpv.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/tausch.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/hpmp.php'); + //Als letztes um alle HP-Attacken zu kontern (in $tmp_hp gespeichert) + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/konter_heal.php'); + //include "kampf/summon.php"; + } + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/atk_wert.php'); + if (!$aussetzten_runde) { /////DAS FUER MAJIN ATTACKEN + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/schatten.php'); + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/runde.php'); + } + + #####################################KAMPF SYSTEM + include ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf/kampf_rechnung.php'); + + // $db_query = mysql_fetch_array(mysql_query("SELECT * FROM kampf WHERE (char1='$chara_1[id]' OR char1='$chara_2[id]') AND dauer='0' order by id DESC LIMIT 1")); + // mysql_query("UPDATE kampf SET hp1='$db_query[hp1],$k_hp7[0]', hp2='$db_query[hp2],$k_hp7[1]', mp1='$db_query[mp1],$k_mp7[0]', mp2='$db_query[mp2],$k_mp7[1]', schaden1='$db_query[schaden1],$schaden_1', schaden2='$db_query[schaden2],$schaden_2', attacke1='$db_query[attacke1],$technick1[name]', attacke2='$db_query[attacke2],$technick2[name]', starke1='$db_query[starke1],$k_starke[0]', starke2='$db_query[starke2],$k_starke[1]', ver1='$db_query[ver1],$k_ver[0]', ver2='$db_query[ver2],$k_ver[1]', speed1='$db_query[speed1],$k_speed[0]', speed2='$db_query[speed2],$k_speed[1]', ausdauer1='$db_query[ausdauer1],$k_ausdauer[0]', ausdauer2='$db_query[ausdauer2],$k_ausdauer[1]', glueck1='$db_query[glueck1],$k_glueck[0]', glueck2='$db_query[glueck2],$k_glueck[1]' WHERE id='$db_query[id]'"); + + + // stupid, i know .... but what else should i do if i don't want to rewrite it all -.- + + $chara_1['starke'] = $k_starke[0]; + $chara_1['speed'] = $k_speed[0]; + $chara_1['verteidigung'] = $k_ver[0]; + $chara_1['ausdauer'] = $k_ausdauer[0]; + $chara_1['glueck'] = $k_glueck[0]; + + $chara_1['hp'] = $k_hp[0]; + $chara_1['hp_max'] = $k_hp1[1]; + $chara_1['mp'] = $k_mp[0]; + $chara_1['mp_max'] = $k_mp1[1]; + + $chara_2['starke'] = $k_starke[1]; + $chara_2['speed'] = $k_speed[1]; + $chara_2['verteidigung'] = $k_ver[1]; + $chara_2['ausdauer'] = $k_ausdauer[1]; + $chara_2['glueck'] = $k_glueck[1]; + + $chara_2['hp'] = $k_hp[1]; + $chara_2['hp_max'] = $k_hp2[1]; + $chara_2['mp'] = $k_hp[1]; + $chara_2['mp_max'] = $k_hp2[1]; + + $runde['char1_array'] = $chara_1; + $runde['char2_array'] = $chara_2; + $runde['atk_char1'] = $technick1['name']; + $runde['atk_char2'] = $technick2['name']; + $runde['dmg_char1'] = $schaden_1; + $runde['dmg_char2'] = $schaden_2; + + $x++; + $rundenArray[] = $runde; + + } + + return $rundenArray; +} + +?> \ No newline at end of file diff --git a/ag/include/user.inc.php b/ag/include/user.inc.php index b37d287..9f2e334 100644 --- a/ag/include/user.inc.php +++ b/ag/include/user.inc.php @@ -9,12 +9,28 @@ include_once($_SERVER['DOCUMENT_ROOT'] . 'ag/include/config/server.inc.php'); include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/cheater.inc.php'); +$GLOBALS['user_buffered_instances'] = array (); + + +function getUser($userid, $buffer_enabled = true) { + // Fehlerkontrolle + if(!is_numeric($userid)){ + return null; + } + // Wenn Char nicht im Puffer ist, oder nicht gepuffert werden soll + if ($GLOBALS['user_buffered_instances'][$userid] == null || !$buffer_enabled) { + $user = mysql_fetch_assoc(mysql_query('SELECT * FROM user WHERE id = '.$userid)); + $GLOBALS['user_buffered_instances'][$userid] = $user; + } + return $GLOBALS['user_buffered_instances'][$userid]; +} + function checkSessionPasswort($userid, $password){ $sql = 'SELECT passwort from user where id = \''.$userid.'\''; $row = mysql_fetch_assoc(mysql_query($sql)); if($row['passwort'] != null){ -// echo $password.' == '.$row['passwort']; + // echo $password.' == '.$row['passwort']; return $password == $row['passwort']; } else{ return false; @@ -34,7 +50,7 @@ function checkCookiePassword($username, $password){ function checkLoginPassword($username, $password){ $sql = 'SELECT SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) as encrypt_password, passwort from user where nickname = \''.$username.'\''; -// echo $sql.'
'; + // echo $sql.'
'; $row = mysql_fetch_assoc(mysql_query($sql)); if($row){ if($row['encrypt_password'] != $row['passwort'] && md5($password) == $row['passwort']){ @@ -51,14 +67,14 @@ function checkLoginPassword($username, $password){ function setCookies($nick_name, $password){ checkCookies($nick_name, $_COOKIE['yps']); $row = mysql_fetch_assoc(mysql_query('select SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) as pw')); - setcookie('name',$nick_name,time()+864000); + setcookie('name',$nick_name,time()+864000); setcookie('passwort',$row['pw'],time()+864000); setcookie('yps',$nick_name.','.md5($nick_name),time()+864000); } function setPassword($username, $password){ $sql = 'UPDATE user set passwort = SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) where nickname = \''.$username.'\''; -// echo $sql.'
'; + // echo $sql.'
'; mysql_query($sql); } diff --git a/ag/test.php b/ag/test.php new file mode 100644 index 0000000..a0ae54c --- /dev/null +++ b/ag/test.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/db/animegame_svn.sql b/db/animegame_svn.sql index 933c7f8..e5b2343 100644 --- a/db/animegame_svn.sql +++ b/db/animegame_svn.sql @@ -2297,7 +2297,6 @@ CREATE TABLE `clan_challenge_clans` ( /*!40000 ALTER TABLE `clan_challenge_clans` DISABLE KEYS */; LOCK TABLES `clan_challenge_clans` WRITE; -INSERT INTO `clan_challenge_clans` VALUES (1,786,400); UNLOCK TABLES; /*!40000 ALTER TABLE `clan_challenge_clans` ENABLE KEYS */; @@ -2380,6 +2379,126 @@ LOCK TABLES `clan_challenges` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `clan_challenges` ENABLE KEYS */; + + + + +-- +-- Definition of table `event_chars` +-- + +DROP TABLE IF EXISTS `event_chars`; +CREATE TABLE `event_chars` ( + `event_char_id` int(11) unsigned NOT NULL, + `char_id` int(11) DEFAULT NULL, + `char_name` varchar(30) NOT NULL, + `char_bild` varchar(100) NOT NULL, + `user_id` int(11) DEFAULT NULL, + `user_name` varchar(30) NOT NULL, + `event_id` int(11) unsigned NOT NULL, + `block_begin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `block_end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `hp` int(11) NOT NULL, + `mp` int(11) NOT NULL, + `strength` int(11) NOT NULL, + `speed` int(11) NOT NULL, + `defense` int(11) NOT NULL, + `luck` int(11) NOT NULL, + `stamina` int(11) NOT NULL, + PRIMARY KEY (`event_id`,`event_char_id`), + KEY `char_bild` (`char_bild`), + CONSTRAINT `event_chars_event_id` FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `event_chars` +-- + +/*!40000 ALTER TABLE `event_chars` DISABLE KEYS */; +LOCK TABLES `event_chars` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `event_chars` ENABLE KEYS */; + + +-- +-- Definition of table `event_fight_rounds` +-- + +DROP TABLE IF EXISTS `event_fight_rounds`; +CREATE TABLE `event_fight_rounds` ( + `event_id` int(10) unsigned NOT NULL, + `event_fight_id` int(10) unsigned NOT NULL, + `event_char_id` int(10) unsigned NOT NULL, + `round` int(10) unsigned NOT NULL, + `hp` int(11) NOT NULL, + `mp` int(11) NOT NULL, + `strength` int(11) NOT NULL, + `speed` int(11) NOT NULL, + `defense` int(11) NOT NULL, + `luck` int(11) NOT NULL, + `stamina` int(11) NOT NULL, + `attack` varchar(30) NOT NULL, + `damage` varchar(30) NOT NULL, + PRIMARY KEY (`event_id`,`event_fight_id`,`event_char_id`,`round`), + KEY `event_fight_rounds_chars` (`event_id`,`event_char_id`), + CONSTRAINT `event_fight_rounds_chars` FOREIGN KEY (`event_id`, `event_char_id`) REFERENCES `event_chars` (`event_id`, `event_char_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `event_fight_rounds_event_figths` FOREIGN KEY (`event_id`, `event_fight_id`) REFERENCES `event_fights` (`event_id`, `event_fight_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `event_fight_rounds` +-- + +/*!40000 ALTER TABLE `event_fight_rounds` DISABLE KEYS */; +LOCK TABLES `event_fight_rounds` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `event_fight_rounds` ENABLE KEYS */; + + +-- +-- Definition of table `event_fights` +-- + +DROP TABLE IF EXISTS `event_fights`; +CREATE TABLE `event_fights` ( + `event_id` int(10) unsigned NOT NULL, + `event_fight_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`event_id`,`event_fight_id`), + UNIQUE KEY `new_index` (`event_fight_id`), + CONSTRAINT `event_fights_event_id` FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `event_fights` +-- + +/*!40000 ALTER TABLE `event_fights` DISABLE KEYS */; +LOCK TABLES `event_fights` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `event_fights` ENABLE KEYS */; + + +-- +-- Definition of table `events` +-- + +DROP TABLE IF EXISTS `events`; +CREATE TABLE `events` ( + `event_id` int(11) unsigned NOT NULL, + `event_type` int(11) unsigned NOT NULL, + PRIMARY KEY (`event_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- +-- Dumping data for table `events` +-- + +/*!40000 ALTER TABLE `events` DISABLE KEYS */; +LOCK TABLES `events` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `events` ENABLE KEYS */; + + /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;