7){ return -31; } if (!($difficulty == 0 || APPLICATION::valid_id("DIFFICULTY_ID", $difficulty) || $difficulty == DIFFICULTY_ID::EASY)){ return -32; } if ($id_count < 1 || $id_count > 4){ return -33; } if (!APPLICATION::valid_id("SCENARIO_ID", $area)){ return -34; } break; case AREA_TYPE_ID::CAIROS_DUNGEON: if ($stage < 0){ return -35; } if ($stage > 12 && (DUNGEON_ID::GIANTS_KEEP == $area || DUNGEON_ID::DRAGONS_LAIR == $area || DUNGEON_ID::NECROPOLIS == $area)){ return -35; } if ($stage > 10 && ($area != DUNGEON_ID::GIANTS_KEEP && $area != DUNGEON_ID::DRAGONS_LAIR && $area != DUNGEON_ID::NECROPOLIS)){ return -35; } $difficulty = null; if ($id_count < 1 || $id_count > 5){ return -36; } if (!APPLICATION::valid_id("DUNGEON_ID", $area)){ return -37; } break; case AREA_TYPE_ID::RIFT_DUNGEON: $stage = null; $difficulty = null; if ($id_count < 1 || $id_count > 6){ return -39; } if (!APPLICATION::valid_id("ELEMENTAL_RIFT_DUNGEON_ID", $area)){ return -40; } break; case AREA_TYPE_ID::RIFT_RAID: if ($stage < 0 || $stage > 5){ return -41; } $difficulty = null; if ($id_count < 1 || $id_count > 6){ return -42; } $area = null; break; case AREA_TYPE_ID::ARENA: $area = null; $stage = null; $difficulty = null; break; case AREA_TYPE_ID::GUILD_WAR: $area = null; $stage = null; $difficulty = null; break; case AREA_TYPE_ID::GUILD_SIEGE: $area = null; $stage = null; $difficulty = null; break; case AREA_TYPE_ID::TARTARUS_LABYRINTH: if ($difficulty != null && !APPLICATION::valid_id("DIFFICULTY_ID", $difficulty)){ return -43; } if ($id_count < 1 || $id_count > 5){ return -44; } if (!APPLICATION::valid_id("LABYRINTH_STAGES_ID", $stage)){ return -45; } break; case AREA_TYPE_ID::TRIAL_OF_ASCENSION: if ($difficulty != null && $difficulty != DIFFICULTY_ID::NORMAL && $difficulty != DIFFICULTY_ID::HARD){ $difficulty = null; } $stage = null; if ($id_count < 1 || $id_count > 5){ return -47; } $area = null; break; case AREA_TYPE_ID::DIMENSIONAL_HOLE: if ($stage < 0 || $stage > 5){ return -48; } $difficulty = null; if ($id_count < 1 || $id_count > 4){ return -49; } if (!APPLICATION::valid_id("DUNGEON_ID", $area)){ return -50; } break; case AREA_TYPE_ID::DIMENSIONAL_RIFT: if ($difficulty != 0 && $difficulty != DIFFICULTY_ID::NORMAL && $difficulty != DIFFICULTY_ID::HARD){ return -51; } $stage = null; if ($id_count < 1 || $id_count > 5){ return -52; } $area = null; break; default: return -3; } $unique_id = array_unique($id); if ($id_count != sizeof($unique_id)){ return -4; } $s = "SELECT CASE WHEN MAX(id) IS NULL THEN 1 ELSE MAX(id) + 1 END AS id FROM team;"; $q = $db->query($s); $r = $q->fetchArray(SQLITE3_ASSOC); $team_id = $r["id"]; $statement = $db->prepare('INSERT INTO team (uid, id, name, description, area_type, area, stage, difficulty, score) VALUES (:uid, :id, :name, :description, :area_type, :area, :stage, :difficulty, :score);'); $statement->bindValue(':uid', $player, SQLITE3_INTEGER); $statement->bindValue(':id', $team_id, SQLITE3_INTEGER); $statement->bindValue(':name', $name, SQLITE3_TEXT); $statement->bindValue(':description', $description, SQLITE3_TEXT); $statement->bindValue(':area_type', $area_type, SQLITE3_INTEGER); $statement->bindValue(':area', $area, SQLITE3_INTEGER); $statement->bindValue(':stage', $stage, SQLITE3_INTEGER); $statement->bindValue(':difficulty', $difficulty, SQLITE3_INTEGER); $statement->bindValue(':score', $score, SQLITE3_INTEGER); $res = $statement->execute(); if (!$res){ return -5; } $j = 0; foreach ($id as $i){ $leader = 0; if ((string) $i == (string) $leader_id){ $leader = 1; } $front = 0; if ($j < $total_front){ $front = 1; } $statement = $db->prepare(" INSERT INTO team_unit (team, unit, leader, front) VALUES (:team, :unit, :leader, :front); "); $statement->bindValue(':team', $team_id, SQLITE3_INTEGER); $statement->bindValue(':unit', $i, SQLITE3_INTEGER); $statement->bindValue(':leader', $leader, SQLITE3_INTEGER); $statement->bindValue(':front', $front, SQLITE3_INTEGER); $db->query($s); $j ++; } return 0; } ?>