예제 #1
0
def test_equality():
    nested_join = Join(Collection.ACHIEVEMENT).on("else")
    join1 = Join(Collection.ABILITY).on("something").nest(nested_join)
    join2 = Join(Collection.ABILITY).on("something").nest(nested_join)

    assert join1 == join2

    join1 = join1.to("yet")

    assert join1 != join2

    assert join1 != object()
예제 #2
0
def test_factory_modify_nested():
    join: Join = Join(Collection.ABILITY).on("some_key")
    child_join: Join = Join(Collection.CURRENCY).on("another_key")

    join.nest(child_join)

    factory: Callable[[], Join] = join.get_factory()
    new_join: Join = factory()

    assert new_join == join

    child_join.to("yet_another_key")

    assert new_join != join
예제 #3
0
def test_factory_modify_object():
    join: Join = Join(Collection.ABILITY).on("some_key")
    child_join: Join = Join(Collection.CURRENCY).on("another_key")

    join.nest(child_join)

    factory = join.get_factory()
    new_join: Join = factory()

    assert new_join == join

    join = join.to("yet_another_key")

    assert new_join != join
예제 #4
0
def test_factory_alteration():
    join: Join = Join(Collection.ABILITY).on("some_key")

    factory = join.get_factory()
    new_join: Join = factory()

    assert new_join == join

    new_join = new_join.to("yet_another_key")
    new_new_join: Join = factory()

    assert new_new_join == join
예제 #5
0
def test_items_lateral_nest():
    join = (Join(Collection.ABILITY).on("parent").nest(
        Join(Collection.ACHIEVEMENT).on("child")).nest(
            Join(Collection.CURRENCY).on("sibling")))
    assert str(
        join) == "ability^on:parent(achievement^on:child,currency^on:sibling)"
예제 #6
0
def test_items_deep_nest():
    join = (Join(Collection.ABILITY).on("parent").nest(
        Join(Collection.ACHIEVEMENT).on("child").nest(
            Join(Collection.CURRENCY).on("grandchild"))))
    assert (str(join) ==
            "ability^on:parent(achievement^on:child(currency^on:grandchild))")
예제 #7
0
def test_items_simple_nest():
    join = (Join(Collection.ABILITY).on("parent").nest(
        Join(Collection.ACHIEVEMENT).on("child")))
    assert str(join) == "ability^on:parent(achievement^on:child)"
예제 #8
0
from typing import Callable

from ps2_census import Collection, Join

# Item to weapon
item_to_weapon_join_factory: Callable[[], Join] = (Join(
    Collection.ITEM_TO_WEAPON).on("item_id").to("item_id").inject_at(
        "item_to_weapon").get_factory())

weapon_join_factory: Callable[[], Join] = (Join(Collection.WEAPON).on(
    "weapon_id").to("weapon_id").inject_at("weapon").get_factory())

# Weapon to fire groups
weapon_to_fire_group_join_factory: Callable[[], Join] = (Join(
    Collection.WEAPON_TO_FIRE_GROUP).list(1).on("weapon_id").to(
        "weapon_id").inject_at("weapon_to_fire_groups").get_factory())

# Item to attachments
item_attachment_join_factory: Callable[[], Join] = (Join(
    Collection.ITEM_ATTACHMENT).on("item_id").to("item_id").list(1).inject_at(
        "item_attachments").nest(
            Join(Collection.ITEM).on("attachment_item_id").to("item_id").
            inject_at("item").nest(
                Join(Collection.ZONE_EFFECT).on("passive_ability_id").to(
                    "ability_id").list(1).inject_at("zone_effects").nest(
                        Join(Collection.ZONE_EFFECT_TYPE).on(
                            "zone_effect_type_id").to("zone_effect_type_id").
                        inject_at("zone_effect_type")))).get_factory())

# Weapon to datasheet
weapon_datasheet_join_factory: Callable[[], Join] = (Join(
예제 #9
0
def test_join():
    join = Join(Collection.ACHIEVEMENT)
    query = Query(Collection.ABILITY).join(join)

    assert query.parameters == {"c:join": [str(join)]}
예제 #10
0
##
#
#  This example gets pretty much everything that's to know about the TR TRAC-5 carbine.
#  Output is in the adjacent JSON file.
#
##

from typing import Callable

from ps2_census import Collection, Join, Query

item_to_weapon_join_factory: Callable[[], Join] = (Join(
    Collection.ITEM_TO_WEAPON).on("item_id").to("item_id").inject_at(
        "item_to_weapon").get_factory())

weapon_join_factory: Callable[[], Join] = (Join(Collection.WEAPON).on(
    "weapon_id").to("weapon_id").inject_at("weapon").get_factory())

weapon_to_fire_group_join_factory: Callable[[], Join] = (Join(
    Collection.WEAPON_TO_FIRE_GROUP).list(1).on("weapon_id").to(
        "weapon_id").inject_at("weapon_to_fire_groups").get_factory())

fire_group_join_factory: Callable[[], Join] = (Join(Collection.FIRE_GROUP).on(
    "fire_group_id").to("fire_group_id").inject_at("fire_group").get_factory())

fire_group_to_fire_mode_join_factory: Callable[[], Join] = (Join(
    Collection.FIRE_GROUP_TO_FIRE_MODE).list(1).on("fire_group_id").to(
        "fire_group_id").inject_at("fire_group_to_fire_modes").get_factory())

fire_mode_join_factory: Callable[[], Join] = (Join(Collection.FIRE_MODE_2).on(
    "fire_mode_id").to("fire_mode_id").inject_at("fire_mode").get_factory())
예제 #11
0
def test_outer():
    join = Join(Collection.ABILITY).outer(1)
    assert str(join) == "ability^outer:1"
예제 #12
0
def test_terms():
    join = Join(Collection.ABILITY).terms(("field1", "value1"), ("field2", 2))
    assert str(join) == "ability^terms:field1=value1'field2=2"
예제 #13
0
def test_inject_at():
    join = Join(Collection.ABILITY).inject_at("field")
    assert str(join) == "ability^inject_at:field"
예제 #14
0
def test_hide():
    join = Join(Collection.ABILITY).hide("field1", "field2")
    assert str(join) == "ability^hide:field1'field2"
예제 #15
0
def test_show():
    join = Join(Collection.ABILITY).show("field1", "field2")
    assert str(join) == "ability^show:field1'field2"
예제 #16
0
def test_list():
    join = Join(Collection.ABILITY).list(1)
    assert str(join) == "ability^list:1"
예제 #17
0
def test_simple_nest():
    join = Join(Collection.ABILITY).nest(Join(Collection.ACHIEVEMENT))
    assert str(join) == "ability(achievement)"
예제 #18
0
def test_join():
    join = Join(Collection.ABILITY)
    assert str(join) == "ability"
예제 #19
0
import json
import time
from collections import Counter
from typing import Callable, Dict, Iterable, List, Tuple, Union

from ps2_census import Collection, Join, Query
from ps2_census.enums import Faction
from slugify import slugify

from utils import batch

ACTIVITY_PERIOD: int = 12 * 60 * 60

character_events_query_factory: Callable[[], Query] = Query(
    Collection.CHARACTERS_EVENT).join(
        Join(Collection.ACHIEVEMENT).on("achievement_id").to("achievement_id").
        inject_at("achievement")).join(
            Join(Collection.CHARACTER).outer(0).on("character_id").
            to("character_id").inject_at("character")).join(
                Join(Collection.CHARACTER).on("attacker_character_id").
                to("character_id").inject_at("attacker_character")).join(
                    Join(Collection.ITEM).on("attacker_weapon_id").
                    to("item_id").inject_at("attacker_weapon_item")).join(
                        Join(Collection.VEHICLE).on("attacker_vehicle_id").to(
                            "vehicle_id").inject_at("vehicle")).sort(
                                ("timestamp", -1)).get_factory()

outfit_members_query_factory: Callable[[], Query] = (Query(
    Collection.OUTFIT).join(
        Join(Collection.OUTFIT_MEMBER).on("outfit_id").to("outfit_id").
        outer(0).list(1).inject_at("members").nest(
            Join(Collection.CHARACTER).on("character_id").to("character_id").
예제 #20
0
def test_deep_nest():
    join = Join(Collection.ABILITY).nest(
        Join(Collection.ACHIEVEMENT).nest(Join(Collection.CURRENCY)))
    assert str(join) == "ability(achievement(currency))"
예제 #21
0
def test_multi_join():
    join_1 = Join(Collection.ACHIEVEMENT)
    join_2 = Join(Collection.CHARACTER)
    query = Query(Collection.ABILITY).join(join_1).join(join_2)

    assert query.parameters == {"c:join": [str(join_1), str(join_2)]}
예제 #22
0
def test_lateral_nest():
    join = (Join(Collection.ABILITY).nest(Join(Collection.ACHIEVEMENT)).nest(
        Join(Collection.CURRENCY)))
    assert str(join) == "ability(achievement,currency)"
예제 #23
0
from typing import Callable

from ps2_census import Collection, Join

# Fire group to fire mode
fire_group_to_fire_mode_join_factory: Callable[[], Join] = (
    Join(Collection.FIRE_GROUP_TO_FIRE_MODE)
    .list(1)
    .on("fire_group_id")
    .to("fire_group_id")
    .inject_at("fire_group_to_fire_modes")
    .get_factory()
)

fire_mode_join_factory: Callable[[], Join] = (
    Join(Collection.FIRE_MODE_2)
    .on("fire_mode_id")
    .to("fire_mode_id")
    .inject_at("fire_mode")
    .get_factory()
)

# Fire mode to direct damage effect
fire_mode_to_damage_direct_effect_join_factory: Callable[[], Join] = (
    Join(Collection.EFFECT)
    .on("damage_direct_effect_id")
    .to("effect_id")
    .inject_at("damage_direct_effect")
    .nest(
        Join(Collection.EFFECT_TYPE)
        .on("effect_type_id")
예제 #24
0
def test_on_to():
    join = Join(Collection.ABILITY).on("on_field").to("to_field")
    assert str(join) == "ability^on:on_field^to:to_field"