|
@@ -166,6 +166,496 @@
|
|
|
return $efficiency;
|
|
return $efficiency;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Parses the JSONs relateds to an Arena run and saves the data.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param SQLiteConn $db Database connection.
|
|
|
|
|
+ * @param int $uid Player UID.
|
|
|
|
|
+ * @param int $id Run ID.
|
|
|
|
|
+ * @param JSON[] $json List of received JSONs.
|
|
|
|
|
+ */
|
|
|
|
|
+ function log_arena_run($db, $id, $uid, $json){
|
|
|
|
|
+ // Only the result request and response JSONs are needed:
|
|
|
|
|
+ $response = $json["result_res"];
|
|
|
|
|
+
|
|
|
|
|
+ // Prepare the "run" insert.
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run (
|
|
|
|
|
+ uid,
|
|
|
|
|
+ id,
|
|
|
|
|
+ dtime,
|
|
|
|
|
+ area_type,
|
|
|
|
|
+ area,
|
|
|
|
|
+ stage,
|
|
|
|
|
+ difficulty,
|
|
|
|
|
+ win,
|
|
|
|
|
+ time,
|
|
|
|
|
+ mana,
|
|
|
|
|
+ energy,
|
|
|
|
|
+ crystal,
|
|
|
|
|
+ guild_points,
|
|
|
|
|
+ honor_points,
|
|
|
|
|
+ helper,
|
|
|
|
|
+ score,
|
|
|
|
|
+ rank
|
|
|
|
|
+ ) VALUES (
|
|
|
|
|
+ :uid,
|
|
|
|
|
+ :id,
|
|
|
|
|
+ :dtime,
|
|
|
|
|
+ :area_type,
|
|
|
|
|
+ :area,
|
|
|
|
|
+ :stage,
|
|
|
|
|
+ :difficulty,
|
|
|
|
|
+ :win,
|
|
|
|
|
+ :time,
|
|
|
|
|
+ :mana,
|
|
|
|
|
+ :energy,
|
|
|
|
|
+ :crystal,
|
|
|
|
|
+ :guild_points,
|
|
|
|
|
+ :honor_points,
|
|
|
|
|
+ :helper,
|
|
|
|
|
+ :score,
|
|
|
|
|
+ :rank
|
|
|
|
|
+ );
|
|
|
|
|
+ ");
|
|
|
|
|
+
|
|
|
|
|
+ // Bind data and insert
|
|
|
|
|
+ $statement->bindValue(":uid", $uid);
|
|
|
|
|
+ $statement->bindValue(":id", $id);
|
|
|
|
|
+ $statement->bindValue(":dtime", $response->{"tvaluelocal"});
|
|
|
|
|
+ $statement->bindValue(":area_type", AREA_TYPE_ID::ARENA);
|
|
|
|
|
+ $statement->bindValue(":area", AREA_TYPE_ID::ARENA);
|
|
|
|
|
+ $statement->bindValue(":stage", null);
|
|
|
|
|
+ $statement->bindValue(":difficulty", null);
|
|
|
|
|
+ $statement->bindValue(":win", $response->{"win_lose"});
|
|
|
|
|
+ $statement->bindValue(":time", 1);
|
|
|
|
|
+ if (array_key_exists("mana", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":mana", $response->{"reward"}->{"mana"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":mana", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("energy", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":energy", $response->{"reward"}->{"energy"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":energy", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("crystal", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":crystal", $response->{"reward"}->{"crystal"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":crystal", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $statement->bindValue(":guild_points", 0);
|
|
|
|
|
+ if (array_key_exists("honor_point", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":honor_points", $response->{"reward"}->{"honor_point"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":honor_points", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $statement->bindValue(":helper", 0);
|
|
|
|
|
+ $statement->bindValue(":score", null);
|
|
|
|
|
+ $statement->bindValue(":rank", null);
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+
|
|
|
|
|
+ // Parse party
|
|
|
|
|
+ $leader = 1;
|
|
|
|
|
+ foreach ($response->{"unit_list"} as $unit){
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run_party
|
|
|
|
|
+ (run, unit, k_unit, leader, front)
|
|
|
|
|
+ VALUES
|
|
|
|
|
+ (:run, :unit, :k_unit, :leader, :front);"
|
|
|
|
|
+ );
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":unit", $unit->{"unit_id"});
|
|
|
|
|
+ $statement->bindValue(":k_unit", $unit->{"unit_master_id"});
|
|
|
|
|
+ $statement->bindValue(":leader", $leader);
|
|
|
|
|
+ $leader = 0;
|
|
|
|
|
+ $statement->bindValue(":front", 0);
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Return success
|
|
|
|
|
+ return "201 Created.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Parses the JSONs relateds to a Dimensional Rift run and saves the data.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param SQLiteConn $db Database connection.
|
|
|
|
|
+ * @param int $uid Player UID.
|
|
|
|
|
+ * @param int $id Run ID.
|
|
|
|
|
+ * @param JSON[] $json List of received JSONs.
|
|
|
|
|
+ */
|
|
|
|
|
+ function log_dark_portal_run($db, $id, $uid, $json){
|
|
|
|
|
+ // Only the result request and response JSONs are needed:
|
|
|
|
|
+ $response = $json["result_res"];
|
|
|
|
|
+
|
|
|
|
|
+ // Prepare the "run" insert.
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run (
|
|
|
|
|
+ uid,
|
|
|
|
|
+ id,
|
|
|
|
|
+ dtime,
|
|
|
|
|
+ area_type,
|
|
|
|
|
+ area,
|
|
|
|
|
+ stage,
|
|
|
|
|
+ difficulty,
|
|
|
|
|
+ win,
|
|
|
|
|
+ time,
|
|
|
|
|
+ mana,
|
|
|
|
|
+ energy,
|
|
|
|
|
+ crystal,
|
|
|
|
|
+ guild_points,
|
|
|
|
|
+ honor_points,
|
|
|
|
|
+ helper,
|
|
|
|
|
+ score,
|
|
|
|
|
+ rank
|
|
|
|
|
+ ) VALUES (
|
|
|
|
|
+ :uid,
|
|
|
|
|
+ :id,
|
|
|
|
|
+ :dtime,
|
|
|
|
|
+ :area_type,
|
|
|
|
|
+ :area,
|
|
|
|
|
+ :stage,
|
|
|
|
|
+ :difficulty,
|
|
|
|
|
+ :win,
|
|
|
|
|
+ :time,
|
|
|
|
|
+ :mana,
|
|
|
|
|
+ :energy,
|
|
|
|
|
+ :crystal,
|
|
|
|
|
+ :guild_points,
|
|
|
|
|
+ :honor_points,
|
|
|
|
|
+ :helper,
|
|
|
|
|
+ :score,
|
|
|
|
|
+ :rank
|
|
|
|
|
+ );
|
|
|
|
|
+ ");
|
|
|
|
|
+
|
|
|
|
|
+ // Bind data and insert
|
|
|
|
|
+ $statement->bindValue(":uid", $uid);
|
|
|
|
|
+ $statement->bindValue(":id", $id);
|
|
|
|
|
+ $statement->bindValue(":dtime", $response->{"tvaluelocal"});
|
|
|
|
|
+ $statement->bindValue(":area_type", AREA_TYPE_ID::DIMENSIONAL_RIFT);
|
|
|
|
|
+ // The area is the region the portal is open in.
|
|
|
|
|
+ $statement->bindValue(":area", $response->{"region_id"});
|
|
|
|
|
+ $statement->bindValue(":stage", null);
|
|
|
|
|
+ $statement->bindValue(":difficulty", $response->{"difficulty"});
|
|
|
|
|
+ $statement->bindValue(":win", $response->{"win_lose"});
|
|
|
|
|
+ $statement->bindValue(":time", 1);
|
|
|
|
|
+ if (array_key_exists("mana", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":mana", $response->{"reward"}->{"mana"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":mana", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("energy", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":energy", $response->{"reward"}->{"energy"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":energy", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("crystal", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":crystal", $response->{"reward"}->{"crystal"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":crystal", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $statement->bindValue(":guild_points", 0);
|
|
|
|
|
+ $statement->bindValue(":honor_points", 0);
|
|
|
|
|
+ $statement->bindValue(":helper", 0);
|
|
|
|
|
+ $statement->bindValue(":score", null);
|
|
|
|
|
+ $statement->bindValue(":rank", null);
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+
|
|
|
|
|
+ // Parse party
|
|
|
|
|
+ $leader = 1;
|
|
|
|
|
+ foreach ($response->{"unit_list"} as $unit){
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run_party
|
|
|
|
|
+ (run, unit, k_unit, leader, front)
|
|
|
|
|
+ VALUES
|
|
|
|
|
+ (:run, :unit, :k_unit, :leader, :front);"
|
|
|
|
|
+ );
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":unit", $unit->{"unit_id"});
|
|
|
|
|
+ $statement->bindValue(":k_unit", $unit->{"unit_master_id"});
|
|
|
|
|
+ $statement->bindValue(":leader", $leader);
|
|
|
|
|
+ $leader = 0;
|
|
|
|
|
+ $statement->bindValue(":front", 0);
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Return success
|
|
|
|
|
+ return "201 Created.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Parses the JSONs relateds to a scenario run and saves the data.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param SQLiteConn $db Database connection.
|
|
|
|
|
+ * @param int $uid Player UID.
|
|
|
|
|
+ * @param int $id Run ID.
|
|
|
|
|
+ * @param JSON[] $json List of received JSONs.
|
|
|
|
|
+ */
|
|
|
|
|
+ function log_scenario_run($db, $id, $uid, $json){
|
|
|
|
|
+ // Only the result request and response JSONs are needed:
|
|
|
|
|
+ $response = $json["result_res"];
|
|
|
|
|
+
|
|
|
|
|
+ if ($json["start_res"] === null){
|
|
|
|
|
+ return ("400 Start response is required to parse scenario runs.");
|
|
|
|
|
+ }
|
|
|
|
|
+ $request = $json["start_res"];
|
|
|
|
|
+
|
|
|
|
|
+ // Prepare the "run" insert.
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run (
|
|
|
|
|
+ uid,
|
|
|
|
|
+ id,
|
|
|
|
|
+ dtime,
|
|
|
|
|
+ area_type,
|
|
|
|
|
+ area,
|
|
|
|
|
+ stage,
|
|
|
|
|
+ difficulty,
|
|
|
|
|
+ win,
|
|
|
|
|
+ time,
|
|
|
|
|
+ mana,
|
|
|
|
|
+ energy,
|
|
|
|
|
+ crystal,
|
|
|
|
|
+ guild_points,
|
|
|
|
|
+ honor_points,
|
|
|
|
|
+ helper,
|
|
|
|
|
+ score,
|
|
|
|
|
+ rank
|
|
|
|
|
+ ) VALUES (
|
|
|
|
|
+ :uid,
|
|
|
|
|
+ :id,
|
|
|
|
|
+ :dtime,
|
|
|
|
|
+ :area_type,
|
|
|
|
|
+ :area,
|
|
|
|
|
+ :stage,
|
|
|
|
|
+ :difficulty,
|
|
|
|
|
+ :win,
|
|
|
|
|
+ :time,
|
|
|
|
|
+ :mana,
|
|
|
|
|
+ :energy,
|
|
|
|
|
+ :crystal,
|
|
|
|
|
+ :guild_points,
|
|
|
|
|
+ :honor_points,
|
|
|
|
|
+ :helper,
|
|
|
|
|
+ :score,
|
|
|
|
|
+ :rank
|
|
|
|
|
+ );
|
|
|
|
|
+ ");
|
|
|
|
|
+
|
|
|
|
|
+ // Bind data and insert
|
|
|
|
|
+ $statement->bindValue(":uid", $uid);
|
|
|
|
|
+ $statement->bindValue(":id", $id);
|
|
|
|
|
+ $statement->bindValue(":dtime", $response->{"tvaluelocal"});
|
|
|
|
|
+ $statement->bindValue(":area_type", AREA_TYPE_ID::SCENARIO);
|
|
|
|
|
+ $statement->bindValue(":area", $response->{"scenario_info"}->{"region_id"});
|
|
|
|
|
+ $statement->bindValue(":stage", $response->{"scenario_info"}->{"stage_no"});
|
|
|
|
|
+ $statement->bindValue(":difficulty", $response->{"scenario_info"}->{"difficulty"});
|
|
|
|
|
+ $statement->bindValue(":win", $response->{"win_lose"});
|
|
|
|
|
+ $statement->bindValue(":time", $response->{"clear_time"}->{"current_time"});
|
|
|
|
|
+ if (array_key_exists("mana", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":mana", $response->{"reward"}->{"mana"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":mana", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("energy", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":energy", $response->{"reward"}->{"energy"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":energy", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("crystal", $response->{"reward"})){
|
|
|
|
|
+ $statement->bindValue(":crystal", $response->{"reward"}->{"crystal"});
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":crystal", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $statement->bindValue(":guild_points", 0);
|
|
|
|
|
+ $statement->bindValue(":honor_points", 0);
|
|
|
|
|
+ if (array_key_exists("helper_unit_list", $request) && sizeof($request->{"helper_unit_list"}) > 0){
|
|
|
|
|
+ $statement->bindValue(":helper", 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":helper", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $statement->bindValue(":score", null);
|
|
|
|
|
+ $statement->bindValue(":rank", null);
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+
|
|
|
|
|
+ // Parse various types of reward
|
|
|
|
|
+ if (array_key_exists("crate", $response->{"reward"})){
|
|
|
|
|
+ $crate = $response->{"reward"}->{"crate"};
|
|
|
|
|
+ if (array_key_exists("unit_info", $crate)){
|
|
|
|
|
+ $item = $crate->{"unit_info"};
|
|
|
|
|
+ $statement = $db->prepare("INSERT INTO run_drop_unit (run, unit) VALUES (:run, :unit);");
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":unit", $unit->{"unit_master_id"});
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("craft_stuff", $crate)){
|
|
|
|
|
+ $item = $crate->{"craft_stuff"};
|
|
|
|
|
+ $statement = $db->prepare("INSERT INTO run_drop_item (run, item, amount) VALUES (:run, :item, :amount);");
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":item", $item->{"item_master_id"});
|
|
|
|
|
+ $statement->bindValue(":amount", $item->{"item_quantity"});
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("random_scroll", $crate)){
|
|
|
|
|
+ $item = $crate->{"random_scroll"};
|
|
|
|
|
+ $statement = $db->prepare("INSERT INTO run_drop_item (run, item, amount) VALUES (:run, :item, :amount);");
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":item", $item->{"item_master_id"});
|
|
|
|
|
+ $statement->bindValue(":amount", $item->{"item_quantity"});
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (array_key_exists("rune", $crate)){
|
|
|
|
|
+ $rune = $crate->{"rune"};
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run_drop_rune (
|
|
|
|
|
+ run,
|
|
|
|
|
+ id,
|
|
|
|
|
+ type,
|
|
|
|
|
+ slot,
|
|
|
|
|
+ stars,
|
|
|
|
|
+ ancient,
|
|
|
|
|
+ quality,
|
|
|
|
|
+ value,
|
|
|
|
|
+ efficiency,
|
|
|
|
|
+ max_efficiency,
|
|
|
|
|
+ main_stat,
|
|
|
|
|
+ main_stat_value,
|
|
|
|
|
+ innate_stat,
|
|
|
|
|
+ innate_stat_value,
|
|
|
|
|
+ substat_1,
|
|
|
|
|
+ substat_1_value,
|
|
|
|
|
+ substat_2,
|
|
|
|
|
+ substat_2_value,
|
|
|
|
|
+ substat_3,
|
|
|
|
|
+ substat_3_value,
|
|
|
|
|
+ substat_4,
|
|
|
|
|
+ substat_4_value
|
|
|
|
|
+ ) VALUES (
|
|
|
|
|
+ :run,
|
|
|
|
|
+ :id,
|
|
|
|
|
+ :type,
|
|
|
|
|
+ :slot,
|
|
|
|
|
+ :stars,
|
|
|
|
|
+ :ancient,
|
|
|
|
|
+ :quality,
|
|
|
|
|
+ :value,
|
|
|
|
|
+ :efficiency,
|
|
|
|
|
+ :max_efficiency,
|
|
|
|
|
+ :main_stat,
|
|
|
|
|
+ :main_stat_value,
|
|
|
|
|
+ :innate_stat,
|
|
|
|
|
+ :innate_stat_value,
|
|
|
|
|
+ :substat_1,
|
|
|
|
|
+ :substat_1_value,
|
|
|
|
|
+ :substat_2,
|
|
|
|
|
+ :substat_2_value,
|
|
|
|
|
+ :substat_3,
|
|
|
|
|
+ :substat_3_value,
|
|
|
|
|
+ :substat_4,
|
|
|
|
|
+ :substat_4_value
|
|
|
|
|
+ );
|
|
|
|
|
+ ");
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":id", $rune->{"rune_id"});
|
|
|
|
|
+ $statement->bindValue(":type", $rune->{"set_id"});
|
|
|
|
|
+ $statement->bindValue(":slot", $rune->{"slot_no"});
|
|
|
|
|
+ $statement->bindValue(":value", $rune->{"sell_value"});
|
|
|
|
|
+ if ($rune->{"class"} > 10){
|
|
|
|
|
+ // Ancient rune
|
|
|
|
|
+ $statement->bindValue(":ancient", 1);
|
|
|
|
|
+ $statement->bindValue(":stars", intval($rune->{"class"}) - 10);
|
|
|
|
|
+ $statement->bindValue(":quality", intval($rune->{"rank"}) - 10);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ // Non Ancient rune
|
|
|
|
|
+ $statement->bindValue(":ancient", 0);
|
|
|
|
|
+ $statement->bindValue(":stars", $rune->{"class"});
|
|
|
|
|
+ $statement->bindValue(":quality", $rune->{"rank"});
|
|
|
|
|
+ }
|
|
|
|
|
+ $efficiency = calculate_efficiency($rune);
|
|
|
|
|
+ $max_efficiency = calculate_maximum_efficiency($rune);
|
|
|
|
|
+ $statement->bindValue(":efficiency", $efficiency);
|
|
|
|
|
+ $statement->bindValue(":max_efficiency", $max_efficiency);
|
|
|
|
|
+ $statement->bindValue(":main_stat", $rune->{"pri_eff"}[0]);
|
|
|
|
|
+ $statement->bindValue(":main_stat_value", $rune->{"pri_eff"}[1]);
|
|
|
|
|
+ if ($rune->{"prefix_eff"}[0] > 0){
|
|
|
|
|
+ $statement->bindValue(":innate_stat", $rune->{"prefix_eff"}[0]);
|
|
|
|
|
+ $statement->bindValue(":innate_stat_value", $rune->{"prefix_eff"}[1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":innate_stat", null);
|
|
|
|
|
+ $statement->bindValue(":innate_stat_value", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sizeof($rune->{"sec_eff"}) > 0){
|
|
|
|
|
+ $statement->bindValue(":substat_1", $rune->{"sec_eff"}[0][0]);
|
|
|
|
|
+ $statement->bindValue(":substat_1_value", $rune->{"sec_eff"}[0][1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":substat_1", null);
|
|
|
|
|
+ $statement->bindValue(":substat_1_value", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sizeof($rune->{"sec_eff"}) > 1){
|
|
|
|
|
+ $statement->bindValue(":substat_2", $rune->{"sec_eff"}[1][0]);
|
|
|
|
|
+ $statement->bindValue(":substat_2_value", $rune->{"sec_eff"}[1][1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":substat_2", null);
|
|
|
|
|
+ $statement->bindValue(":substat_2_value", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sizeof($rune->{"sec_eff"}) > 2){
|
|
|
|
|
+ $statement->bindValue(":substat_3", $rune->{"sec_eff"}[2][0]);
|
|
|
|
|
+ $statement->bindValue(":substat_3_value", $rune->{"sec_eff"}[2][1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":substat_3", null);
|
|
|
|
|
+ $statement->bindValue(":substat_3_value", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sizeof($rune->{"sec_eff"}) > 3){
|
|
|
|
|
+ $statement->bindValue(":substat_4", $rune->{"sec_eff"}[3][0]);
|
|
|
|
|
+ $statement->bindValue(":substat_4_value", $rune->{"sec_eff"}[3][1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ $statement->bindValue(":substat_4", null);
|
|
|
|
|
+ $statement->bindValue(":substat_4_value", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Parse party
|
|
|
|
|
+ $leader = 1;
|
|
|
|
|
+ foreach ($response->{"unit_list"} as $unit){
|
|
|
|
|
+ $statement = $db->prepare("
|
|
|
|
|
+ INSERT INTO run_party
|
|
|
|
|
+ (run, unit, k_unit, leader, front)
|
|
|
|
|
+ VALUES
|
|
|
|
|
+ (:run, :unit, :k_unit, :leader, :front);"
|
|
|
|
|
+ );
|
|
|
|
|
+ $statement->bindValue(":run", $id);
|
|
|
|
|
+ $statement->bindValue(":unit", $unit->{"unit_id"});
|
|
|
|
|
+ $statement->bindValue(":k_unit", $unit->{"unit_master_id"});
|
|
|
|
|
+ $statement->bindValue(":leader", $leader);
|
|
|
|
|
+ $leader = 0;
|
|
|
|
|
+ $statement->bindValue(":front", 0);
|
|
|
|
|
+ $statement->execute();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Return success
|
|
|
|
|
+ return "201 Created.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Parses the JSONs relateds to a cairos run and saves the data.
|
|
* Parses the JSONs relateds to a cairos run and saves the data.
|
|
|
*
|
|
*
|
|
@@ -198,6 +688,7 @@
|
|
|
energy,
|
|
energy,
|
|
|
crystal,
|
|
crystal,
|
|
|
guild_points,
|
|
guild_points,
|
|
|
|
|
+ honor_points,
|
|
|
helper,
|
|
helper,
|
|
|
score,
|
|
score,
|
|
|
rank
|
|
rank
|
|
@@ -215,6 +706,7 @@
|
|
|
:energy,
|
|
:energy,
|
|
|
:crystal,
|
|
:crystal,
|
|
|
:guild_points,
|
|
:guild_points,
|
|
|
|
|
+ :honor_points,
|
|
|
:helper,
|
|
:helper,
|
|
|
:score,
|
|
:score,
|
|
|
:rank
|
|
:rank
|
|
@@ -240,6 +732,7 @@
|
|
|
$statement->bindValue(":energy", 0);
|
|
$statement->bindValue(":energy", 0);
|
|
|
$statement->bindValue(":crystal", 0);
|
|
$statement->bindValue(":crystal", 0);
|
|
|
$statement->bindValue(":guild_points", 0);
|
|
$statement->bindValue(":guild_points", 0);
|
|
|
|
|
+ $statement->bindValue(":honor_points", 0);
|
|
|
$statement->bindValue(":helper", 0);
|
|
$statement->bindValue(":helper", 0);
|
|
|
$statement->bindValue(":score", null);
|
|
$statement->bindValue(":score", null);
|
|
|
$statement->bindValue(":rank", null);
|
|
$statement->bindValue(":rank", null);
|
|
@@ -352,6 +845,7 @@
|
|
|
energy,
|
|
energy,
|
|
|
crystal,
|
|
crystal,
|
|
|
guild_points,
|
|
guild_points,
|
|
|
|
|
+ honor_points,
|
|
|
helper,
|
|
helper,
|
|
|
score,
|
|
score,
|
|
|
rank
|
|
rank
|
|
@@ -369,6 +863,7 @@
|
|
|
:energy,
|
|
:energy,
|
|
|
:crystal,
|
|
:crystal,
|
|
|
:guild_points,
|
|
:guild_points,
|
|
|
|
|
+ :honor_points,
|
|
|
:helper,
|
|
:helper,
|
|
|
:score,
|
|
:score,
|
|
|
:rank
|
|
:rank
|
|
@@ -404,6 +899,7 @@
|
|
|
$statement->bindValue(":crystal", 0);
|
|
$statement->bindValue(":crystal", 0);
|
|
|
}
|
|
}
|
|
|
$statement->bindValue(":guild_points", 0);
|
|
$statement->bindValue(":guild_points", 0);
|
|
|
|
|
+ $statement->bindValue(":honor_points", 0);
|
|
|
$statement->bindValue(":helper", 0); // TODO Where is this information??
|
|
$statement->bindValue(":helper", 0); // TODO Where is this information??
|
|
|
$statement->bindValue(":score", null);
|
|
$statement->bindValue(":score", null);
|
|
|
$statement->bindValue(":rank", null);
|
|
$statement->bindValue(":rank", null);
|
|
@@ -600,6 +1096,7 @@
|
|
|
energy,
|
|
energy,
|
|
|
crystal,
|
|
crystal,
|
|
|
guild_points,
|
|
guild_points,
|
|
|
|
|
+ honor_points,
|
|
|
helper,
|
|
helper,
|
|
|
score,
|
|
score,
|
|
|
rank
|
|
rank
|
|
@@ -617,6 +1114,7 @@
|
|
|
:energy,
|
|
:energy,
|
|
|
:crystal,
|
|
:crystal,
|
|
|
:guild_points,
|
|
:guild_points,
|
|
|
|
|
+ :honor_points,
|
|
|
:helper,
|
|
:helper,
|
|
|
:score,
|
|
:score,
|
|
|
:rank
|
|
:rank
|
|
@@ -650,6 +1148,7 @@
|
|
|
$statement->bindValue(":crystal", 0);
|
|
$statement->bindValue(":crystal", 0);
|
|
|
}
|
|
}
|
|
|
$statement->bindValue(":guild_points", 0);
|
|
$statement->bindValue(":guild_points", 0);
|
|
|
|
|
+ $statement->bindValue(":honor_points", 0);
|
|
|
$statement->bindValue(":helper", 0); // TODO Where is this information??
|
|
$statement->bindValue(":helper", 0); // TODO Where is this information??
|
|
|
$statement->bindValue(":score", null);
|
|
$statement->bindValue(":score", null);
|
|
|
$statement->bindValue(":rank", null);
|
|
$statement->bindValue(":rank", null);
|
|
@@ -898,7 +1397,10 @@
|
|
|
$accepted_commands = [
|
|
$accepted_commands = [
|
|
|
"BattleDungeonResult_V2", // Dungeon Run
|
|
"BattleDungeonResult_V2", // Dungeon Run
|
|
|
"BattleDimensionHoleDungeonResult_v2", // Dimension Hole Run
|
|
"BattleDimensionHoleDungeonResult_v2", // Dimension Hole Run
|
|
|
- "BattleRiftOfWorldsRaidResult" // Rift Raid Run
|
|
|
|
|
|
|
+ "BattleRiftOfWorldsRaidResult", // Rift Raid Run
|
|
|
|
|
+ "BattleScenarioResult", // Scenario Run
|
|
|
|
|
+ "BattleArenaResult", // Arena Run
|
|
|
|
|
+ "BattleDarkPortalResult" // Dimensinal Rift Run
|
|
|
];
|
|
];
|
|
|
if (!in_array($command, $accepted_commands)){
|
|
if (!in_array($command, $accepted_commands)){
|
|
|
header("HTTP/1.1 405 Command not implemented.");
|
|
header("HTTP/1.1 405 Command not implemented.");
|
|
@@ -939,6 +1441,15 @@
|
|
|
case "BattleRiftOfWorldsRaidResult":
|
|
case "BattleRiftOfWorldsRaidResult":
|
|
|
$result = log_rift_raid_run($db, $id, $uid, $json);
|
|
$result = log_rift_raid_run($db, $id, $uid, $json);
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case "BattleScenarioResult":
|
|
|
|
|
+ $result = log_scenario_run($db, $id, $uid, $json);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "BattleArenaResult":
|
|
|
|
|
+ $result = log_arena_run($db, $id, $uid, $json);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "BattleDarkPortalResult":
|
|
|
|
|
+ $result = log_dark_portal_run($db, $id, $uid, $json);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Process result
|
|
// Process result
|