Skip to content

Commit

Permalink
New pokemon and raids table pdo (pokepark#162)
Browse files Browse the repository at this point in the history
* New pokemon and raids table schema
* Added missing moves
* Schema changes for better form handling
* Push out current form data as an upgrade
* Fixed typos from unknown gym name check
* Centralize raidpicture URL generation, guard against bad data
* Get Pokemon form id from database using the form name
* Drop getGOHubDB, it's sql export and the outdated static pokedex sql
* Fix more references to old pokedex population methods
* Fix bug where sister elements caused a double boost in CP

Co-authored-by: Ossi Kuisma <[email protected]>
Co-authored-by: Ossi <[email protected]>
  • Loading branch information
3 people authored Aug 26, 2020
1 parent 19bc9e7 commit ef063a7
Show file tree
Hide file tree
Showing 62 changed files with 2,235 additions and 1,914 deletions.
41 changes: 15 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,12 @@ Telegram webhook bot for organizing raids in Pokemon Go. Developers are welcome
* [Adding new config values](#adding-new-config-values)
* [Git Hooks](#git-hooks)
* [pre-commit](#pre-commit)
* [SQL Files](#sql-files)
* [pokemon-raid-bot.sql](#pokemon-raid-botsql)
* [raid-boss-pokedex.sql](#raid-boss-pokedexsql)
* [gohub-raid-boss-pokedex.sql](#gohub-raid-boss-pokedexsql)
* [game-master-raid-boss-pokedex.sql](#game-master-raid-boss-pokedexsql)
* [Translations](#translations)
* [translate.py](#translatepy)
* [Usage](#usage)

<!-- Added by: artanicus, at: Sat Aug 15 16:07:54 EEST 2020 -->
<!-- Added by: artanicus, at: Tue Aug 25 10:33:02 EEST 2020 -->

<!--te-->

Expand Down Expand Up @@ -183,13 +180,12 @@ Import `pokemon-raid-bot.sql` as default DB structure and `raid-boss-pokedex.sql

Command DB structure: `mysql -u USERNAME -p DATABASENAME < sql/pokemon-raid-bot.sql`

Command raid bosses: `mysql -u USERNAME -p DATABASENAME < sql/raid-boss-pokedex.sql`

To get the latest raid bosses via the GOHub API, you can use getGOHubDB.php which will update the sql/gohub-raid-boss-pokedex.sql file. Import is possible too:

Command gohub raid bosses: `mysql -u USERNAME -p DATABASENAME < sql/gohub-raid-boss-pokedex.sql`
To get raid bosses:
```
mysql -u USERNAME -p DATABASENAME < sql/game-master-raid-boss-pokedex.sql`
```

Important: The raid level is NOT set when importing the raid bosses from the gohub sql file! Set them via the /pokedex command, explained below in this readme.
Important: The raid level is NOT set when importing the raid bosses from the sql file! Set them via the /pokedex command, explained below in this readme.

## Docker

Expand Down Expand Up @@ -1133,7 +1129,7 @@ The bot has a version system and checks for updates to the database automaticall

The bot will send a message to the MAINTAINER_ID when an upgrade is required. In case the MAINTAINER_ID is not specified an error message is written to the error log of your webserver.

Required SQL upgrades files can be found under the `sql/upgrade` folder and need to be applied manually!
Required SQL upgrades files can be found under the `sql/upgrade` folder and are applied automatically by default.

After any upgrade you need to make sure to change the bot version in your config.json as that version is used for comparison against the latest bot version in the `VERSION` file.

Expand Down Expand Up @@ -1295,21 +1291,14 @@ To give a little example the bot version `1.9.256.4` means:

This way it is easy to find out when a bot version was released and how old/new a version is.

## SQL Files

The following commands are used to create the raid-pokemon-bot.sql, raid-boss-pokedex.sql and gohub-raid-boss-pokedex.sql files. Make sure to change to the bot directory first and replace USERNAME and DATABASENAME before executing the commands.

### pokemon-raid-bot.sql
The following command is used to create the game-master-raid-boss-pokedex.sql file.

Export command: `mysqldump -u USERNAME -p --no-data --skip-add-drop-table --skip-add-drop-database --skip-comments DATABASENAME | sed 's/ AUTO_INCREMENT=[0-9]*\b/ AUTO_INCREMENT=100/' > sql/pokemon-raid-bot.sql`

### raid-boss-pokedex.sql

Export command: `mysqldump -u USERNAME -p --skip-extended-insert --skip-comments DATABASENAME pokemon > sql/raid-boss-pokedex.sql`

### gohub-raid-boss-pokedex.sql

CLI creation command: `php getGOHubDB.php`
### game-master-raid-boss-pokedex.sql
The following command is used to create the game-master-raid-boss-pokedex.sql file. Normally this file is kept up to date by developers
but if no one has updated it yet, you can generate an updated version (and optionally also create a Pull Request.)
```
php getDB.php
```

## Translations

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.239.1
2.0.239.4
2 changes: 1 addition & 1 deletion commands/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
$raid_day = dt2date($row['start_time']);
$start = dt2time($row['start_time']);
$end = dt2time($row['end_time']);
$text .= get_local_pokemon_name($row['pokemon']) . SP . '' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;
$text .= get_local_pokemon_name($row['pokemon'], $row['pokemon_form']) . SP . '' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;
$keys[] = array(
'text' => $row['gym_name'],
'callback_data' => $row['id'] . ':raids_delete:0'
Expand Down
2 changes: 1 addition & 1 deletion commands/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
$today = dt2date($now);
$start = dt2time($raid['start_time']);
$end = dt2time($raid['end_time']);
$text .= get_local_pokemon_name($raid['pokemon']) . SP . '-' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;
$text .= get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form']) . SP . '-' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;

// Split pokemon and form to get the pokedex id.
$pokedex_id = explode('-', $raid['pokemon'])[0];
Expand Down
2 changes: 1 addition & 1 deletion commands/pokedex.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Pokedex_id received?
if(is_numeric($pokemon)) {
// Always normal form
$pokemon = $pokemon . '-normal';
$pokemon = $pokemon . '-0';
// Set forward to true
$forward = true;

Expand Down
2 changes: 1 addition & 1 deletion commands/pokemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

// Set text and keys.
$text .= $row['gym_name'] . CR;
$text .= get_local_pokemon_name($row['pokemon']) . SP . '' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;
$text .= get_local_pokemon_name($row['pokemon'], $row['pokemon_form']) . SP . '' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;
$keys[] = array(
'text' => $keys_text,
'callback_data' => $row['id'] . ':raid_edit_poke:' . $row['pokemon'],
Expand Down
10 changes: 5 additions & 5 deletions commands/raid.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@
// Get current pokemon from database for raid.
$rs_ex_raid = my_query(
"
SELECT pokemon
SELECT pokemon, pokemon_form
FROM raids
WHERE id = {$raid_id}
"
);

// Get row.
$row_ex_raid = $rs_ex_raid->fetch();
$poke_name = $row_ex_raid['pokemon'];
$poke_name = $row_ex_raid['pokemon'].'-'.$row_ex_raid['pokemon_form'];
debug_log('Comparing the current pokemon to pokemons from ex-raid list now...');
debug_log('Current Pokemon in database for this raid: ' . $poke_name);

// Make sure it's not an Ex-Raid before updating the pokemon.
$raid_level = get_raid_level($poke_name);
$raid_level = get_raid_level($row_ex_raid['pokemon'], $row_ex_raid['pokemon_form']);
if($raid_level == 'X') {
// Ex-Raid! Update only team in raids table.
debug_log('Current pokemon is an ex-raid pokemon: ' . $poke_name);
Expand Down Expand Up @@ -207,8 +207,8 @@

// Raid picture
if($config->RAID_PICTURE) {
$picture_url = $config->RAID_PICTURE_URL . "?pokemon=" . $raid['pokemon'] . "&raid=". $raid['id'];
debug_log('PictureUrl: ' . $picture_url);
require_once(LOGIC_PATH . '/raid_picture.php');
$picture_url = raid_picture_url($raid);
}


Expand Down
Loading

0 comments on commit ef063a7

Please sign in to comment.