refactor code

main
Khiem Ton 2 years ago
parent 2eb2e7d1b0
commit be8842de35
Signed by: th4tkh13m
GPG Key ID: 4D9CF147DCADD05D

@ -1,3 +0,0 @@
class Object():
def __init__(self):
self.location = None

@ -0,0 +1,9 @@
class Object():
def __init__(self, location=None):
self.location = location
def distance_to(self, other):
return self.location.distance(other.location)
def cooldown_to(self, other):
return self.location.get_cooldown(other.location) + 1

@ -1,5 +1,5 @@
from geopy.geocoders import Nominatim from geopy.geocoders import Nominatim
from ..location import Location from ..core.location import Location
from .object import Object from .object import Object
class Player(Object): class Player(Object):
@ -14,7 +14,7 @@ class Player(Object):
self.location = Location(getLoc.latitude, getLoc.longitude) self.location = Location(getLoc.latitude, getLoc.longitude)
def set_location(self, location, did_activity): def set_location(self, location, did_activity):
next_cd = self.get_cooldown_to(location) next_cd = self.cooldown_to(location)
if did_activity: if did_activity:
if next_cd + self.current_cooldown >= 120: if next_cd + self.current_cooldown >= 120:
self.current_cooldown = 120 self.current_cooldown = 120
@ -24,7 +24,3 @@ class Player(Object):
def get_location(self): def get_location(self):
return self.location return self.location
def get_cooldown_to(self, location):
# + 1 for map loading and activities
return self.location.get_cooldown(location) + 1

@ -2,6 +2,7 @@ from .object import Object
class Raid(Object): class Raid(Object):
def __init__(self, name, number, level, location, start_time, end_time, country): def __init__(self, name, number, level, location, start_time, end_time, country):
super().__init__()
self.name = name self.name = name
self.number = number self.number = number
self.level = level self.level = level

@ -2,14 +2,14 @@ from bs4 import BeautifulSoup
import requests import requests
from ..objects.pokemon import Pokemon from ..objects.pokemon import Pokemon
from ..objects.raid import Raid from ..objects.raid import Raid
from ..location import Location from ..core.location import Location
from datetime import datetime from datetime import datetime
class Scraper(): class Scraper():
def __init__(self): def __init__(self):
self.HUNDO_URL = "https://moonani.com/PokeList/index.php" self.HUNDO_URL = "https://moonani.com/PokeList/index.php"
self.PVP_URL = "https://moonani.com/PokeList/raid.php" self.PVP_URL = "https://moonani.com/PokeList/pvp.php"
def get_pokemons(self, url): def get_pokemons(self, url):
pokemon_lst = [] pokemon_lst = []
Loading…
Cancel
Save