def _init_items(all_items=None):
        if not all_items:
            all_items = riotapi.get_items()
            ItemSet._items_by_id = {item.id: Item(item) for item in all_items if item.maps[cassiopeia.type.core.common.Map.summoners_rift]}
        else:
            ItemSet._items_by_id = all_items

        ItemSet._items_by_name = {item.name: item for _, item in ItemSet._items_by_id.items()}
Example #2
0
def get_item(name_or_id: Union[str, int]) -> Tuple[Optional[Item], int]:
    """Get an item by name with fuzzy search.
    Args:
        name_or_id: Name or id of item 

    Returns:
        Tuple[Optional[Item], int]: Second element represents the query score (how close it is to the actual value).
    """
    if isinstance(name_or_id, int) or name_or_id.isdigit():
        item = riotapi.get_item(int(name_or_id))
        return (item, 100 if item else 0)
    return get_by_name(name_or_id, riotapi.get_items())
Example #3
0
 def __init__(self):
     riotapi.set_region("NA")
     riotapi.set_api_key("462d0d85-d692-4af5-b91f-4ed9cf0b2efe")
     self.champions = riotapi.get_champions()
     self.items = riotapi.get_items()
Example #4
0
def test_items():
    int_test_handler.test_result(riotapi.get_items())
Example #5
0
from fuzzywuzzy import fuzz

from . import util, config

ALLOWED_MODES: Set[str] = {
    mode.upper()
    for mode in config["trivia"]["allowed_modes"]
}
ALLOWED_SPELLS: List[SummonerSpell] = \
    [spell for spell in riotapi.get_summoner_spells() if not ALLOWED_MODES.isdisjoint(spell.data.modes)]

ALLOWED_MAPS: Set[str] = \
    {str(Map[map.lower()].value) if not map.isdigit() else map for map in config["trivia"]["allowed_maps"]}

ALLOWED_ITEMS: List[Item] = []
for item in riotapi.get_items():
    allowed_maps = {map for map, allowed in item.data.maps.items() if allowed}
    if not ALLOWED_MAPS.isdisjoint(allowed_maps):
        ALLOWED_ITEMS.append(item)

PERCENT_STATS: List[str] = [
    "percent", "spell_vamp", "life_steal", "tenacity", "critical",
    "attack_speed", "cooldown"
]


class Question(object):
    """A trivia question
    """
    def __init__(self,
                 title: str,
Example #6
0
 def component_of(self):
     """list<Item>    the items this one is a component of"""
     return riotapi.get_items([int(id_) for id_ in self.data.into])
Example #7
0
 def components(self):
     """list<Item>    the components for this item"""
     return riotapi.get_items([int(id_) for id_ in self.data.from_])
Example #8
0
def BuildItemDF():

    items = cass.get_items()
    df = pd.DataFrame(list(map(lambda x: (x.id,x.name),items)),columns=["id","item"])
    return df
Example #9
0
def test_items():
    int_test_handler.test_result(riotapi.get_items())
Example #10
0
 def component_of(self):
     """list<Item>    the items this one is a component of"""
     return riotapi.get_items([int(id_) for id_ in self.data.into])
Example #11
0
 def components(self):
     """list<Item>    the components for this item"""
     return riotapi.get_items([int(id_) for id_ in self.data.from_])