Skip to content

Commit

Permalink
Merge pull request #94 from ramonsaraiva/update-15.2.0
Browse files Browse the repository at this point in the history
✨ Sync with V15.2.0
  • Loading branch information
ramonsaraiva authored Oct 24, 2019
2 parents 12ffd9b + aa8fb6e commit 11c6bac
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.2 / 2019-10-23

* Sync with V15.2.0 - @glmn

## 0.12.1 / 2019-10-04

* Sync with V15.0.0 - @glmn
Expand Down
18 changes: 18 additions & 0 deletions pubg_python/domain/telemetry/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,21 @@ class LogRedZoneEnded(Event):
def from_dict(self):
super().from_dict()
self.drivers = self._data.get('drivers', [])


class LogPhaseChange(Event):

def from_dict(self):
super().from_dict()
self.phase = self._data.get('phase')


class LogPlayerUseThrowable(Event):

def from_dict(self):
super().from_dict()
self.attackId = self._data.get('attackId')
self.fire_weapon_stack_count = self._data.get('fireWeaponStackCount')
self.attacker = objects.Character(self._data.get('attacker', {}))
self.attack_type = self._data.get('attackType')
self.weapon = objects.Item(self._data.get('weapon', {}))
7 changes: 5 additions & 2 deletions pubg_python/domain/telemetry/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
"Damage_Gun": "Gun Damage",
"Damage_Instant_Fall": "Fall Damage",
"Damage_Melee": "Melee Damage",
"Damage_MeleeThrow": "Melee Throw Damage",
"Damage_Molotov": "Molotov Damage",
"Damage_Punch": "Punch Damage",
"Damage_VehicleCrashHit": "Vehicle Crash Damage",
Expand Down Expand Up @@ -447,11 +448,13 @@
OBJECT_TYPE = [
"Door",
"Fence",
"Window",
"Jerrycan"
"Jerrycan",
"VendingMachine",
"Window"
]

OBJECT_TYPE_STATUS = [
'ACTIVATED',
'Closing',
'Opening'
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def read(fname):

setup(
name='pubg-python',
version='0.12.1',
version='0.12.2',
description='A python wrapper for the PUBG developer API',
long_description=read('README.md'),
long_description_content_type='text/markdown',
Expand Down
2 changes: 1 addition & 1 deletion tests/telemetry_response.json

Large diffs are not rendered by default.

41 changes: 34 additions & 7 deletions tests/test_telemetry_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
LogWheelDestroy,
LogPlayerMakeGroggy,
LogPlayerRevive,
LogRedZoneEnded
LogRedZoneEnded,
LogPhaseChange,
LogPlayerUseThrowable
)
from pubg_python.domain.telemetry.objects import (
Location,
Expand Down Expand Up @@ -89,7 +91,10 @@ def test_log_player_create():

def test_log_player_position():
events = telemetry.events_from_type('LogPlayerPosition')
data = events[0]
for i in events:
if isinstance(i.vehicle, Vehicle):
data = i
break
assert isinstance(data, LogPlayerPosition)
assert isinstance(data.character, Character)
assert isinstance(data.vehicle, Vehicle)
Expand All @@ -110,7 +115,10 @@ def test_log_weapon_fire_count():

def test_log_player_attack():
events = telemetry.events_from_type('LogPlayerAttack')
data = events[62]
for e in events:
if e.weapon.item_id != '':
data = e
break
assert isinstance(data, LogPlayerAttack)
assert isinstance(data.attacker, Character)
assert isinstance(data.weapon, Item)
Expand All @@ -128,7 +136,7 @@ def test_log_player_take_damage():
assert isinstance(data, LogPlayerTakeDamage)
assert isinstance(data.attacker, Character)
assert isinstance(data.victim, Character)
assert isinstance(data.damage, float)
assert data.damage > 0
assert data.damage_type_category in DAMAGE_TYPE_MAP
assert data.damage_reason in DAMAGE_REASON
assert data.damage_causer_name in DAMAGE_CAUSER_MAP
Expand All @@ -151,7 +159,8 @@ def test_log_player_kill():
assert data.damage_causer_name in DAMAGE_CAUSER_MAP
assert data.damage_reason in DAMAGE_REASON
if data.victim_weapon:
assert data.victim_weapon[:-3] in DAMAGE_CAUSER_MAP
cut_idx = data.victim_weapon.index('_C_') + 2
assert data.victim_weapon[:cut_idx] in DAMAGE_CAUSER_MAP


def test_log_parachute_landing():
Expand Down Expand Up @@ -330,7 +339,7 @@ def test_log_vehicle_leave():

def test_log_vehicle_destroy():
events = telemetry.events_from_type('LogVehicleDestroy')
data = events[3]
data = events[0]
assert isinstance(data, LogVehicleDestroy)
assert isinstance(data.attacker, Character)
assert isinstance(data.vehicle, Vehicle)
Expand Down Expand Up @@ -474,7 +483,8 @@ def test_log_player_make_groggy():
if not data.victim_weapon:
assert True
else:
assert data.victim_weapon[:-3] in DAMAGE_CAUSER_MAP
cut_idx = data.victim_weapon.index('_C_') + 2
assert data.victim_weapon[:cut_idx] in DAMAGE_CAUSER_MAP


def test_log_player_revive():
Expand All @@ -491,3 +501,20 @@ def test_log_red_zone_ended():
data = events[0]
assert isinstance(data, LogRedZoneEnded)
assert isinstance(data.drivers, list)


def test_log_phase_change():
events = telemetry.events_from_type('LogPhaseChange')
data = events[0]
assert isinstance(data, LogPhaseChange)
assert isinstance(data.phase, int)


def test_log_player_use_throwable():
events = telemetry.events_from_type('LogPlayerUseThrowable')
data = events[0]
assert isinstance(data, LogPlayerUseThrowable)
assert isinstance(data.attacker, Character)
assert isinstance(data.weapon, Item)
assert isinstance(data.fire_weapon_stack_count, int)
assert data.attack_type in ATTACK_TYPE

0 comments on commit 11c6bac

Please sign in to comment.