Skip to content

Commit 11c6bac

Browse files
authored
Merge pull request #94 from ramonsaraiva/update-15.2.0
✨ Sync with V15.2.0
2 parents 12ffd9b + aa8fb6e commit 11c6bac

File tree

6 files changed

+63
-11
lines changed

6 files changed

+63
-11
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.12.2 / 2019-10-23
2+
3+
* Sync with V15.2.0 - @glmn
4+
15
## 0.12.1 / 2019-10-04
26

37
* Sync with V15.0.0 - @glmn

pubg_python/domain/telemetry/events.py

+18
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,21 @@ class LogRedZoneEnded(Event):
391391
def from_dict(self):
392392
super().from_dict()
393393
self.drivers = self._data.get('drivers', [])
394+
395+
396+
class LogPhaseChange(Event):
397+
398+
def from_dict(self):
399+
super().from_dict()
400+
self.phase = self._data.get('phase')
401+
402+
403+
class LogPlayerUseThrowable(Event):
404+
405+
def from_dict(self):
406+
super().from_dict()
407+
self.attackId = self._data.get('attackId')
408+
self.fire_weapon_stack_count = self._data.get('fireWeaponStackCount')
409+
self.attacker = objects.Character(self._data.get('attacker', {}))
410+
self.attack_type = self._data.get('attackType')
411+
self.weapon = objects.Item(self._data.get('weapon', {}))

pubg_python/domain/telemetry/resources.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@
357357
"Damage_Gun": "Gun Damage",
358358
"Damage_Instant_Fall": "Fall Damage",
359359
"Damage_Melee": "Melee Damage",
360+
"Damage_MeleeThrow": "Melee Throw Damage",
360361
"Damage_Molotov": "Molotov Damage",
361362
"Damage_Punch": "Punch Damage",
362363
"Damage_VehicleCrashHit": "Vehicle Crash Damage",
@@ -447,11 +448,13 @@
447448
OBJECT_TYPE = [
448449
"Door",
449450
"Fence",
450-
"Window",
451-
"Jerrycan"
451+
"Jerrycan",
452+
"VendingMachine",
453+
"Window"
452454
]
453455

454456
OBJECT_TYPE_STATUS = [
457+
'ACTIVATED',
455458
'Closing',
456459
'Opening'
457460
]

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read(fname):
1111

1212
setup(
1313
name='pubg-python',
14-
version='0.12.1',
14+
version='0.12.2',
1515
description='A python wrapper for the PUBG developer API',
1616
long_description=read('README.md'),
1717
long_description_content_type='text/markdown',

tests/telemetry_response.json

+1-1
Large diffs are not rendered by default.

tests/test_telemetry_events.py

+34-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
LogWheelDestroy,
3838
LogPlayerMakeGroggy,
3939
LogPlayerRevive,
40-
LogRedZoneEnded
40+
LogRedZoneEnded,
41+
LogPhaseChange,
42+
LogPlayerUseThrowable
4143
)
4244
from pubg_python.domain.telemetry.objects import (
4345
Location,
@@ -89,7 +91,10 @@ def test_log_player_create():
8991

9092
def test_log_player_position():
9193
events = telemetry.events_from_type('LogPlayerPosition')
92-
data = events[0]
94+
for i in events:
95+
if isinstance(i.vehicle, Vehicle):
96+
data = i
97+
break
9398
assert isinstance(data, LogPlayerPosition)
9499
assert isinstance(data.character, Character)
95100
assert isinstance(data.vehicle, Vehicle)
@@ -110,7 +115,10 @@ def test_log_weapon_fire_count():
110115

111116
def test_log_player_attack():
112117
events = telemetry.events_from_type('LogPlayerAttack')
113-
data = events[62]
118+
for e in events:
119+
if e.weapon.item_id != '':
120+
data = e
121+
break
114122
assert isinstance(data, LogPlayerAttack)
115123
assert isinstance(data.attacker, Character)
116124
assert isinstance(data.weapon, Item)
@@ -128,7 +136,7 @@ def test_log_player_take_damage():
128136
assert isinstance(data, LogPlayerTakeDamage)
129137
assert isinstance(data.attacker, Character)
130138
assert isinstance(data.victim, Character)
131-
assert isinstance(data.damage, float)
139+
assert data.damage > 0
132140
assert data.damage_type_category in DAMAGE_TYPE_MAP
133141
assert data.damage_reason in DAMAGE_REASON
134142
assert data.damage_causer_name in DAMAGE_CAUSER_MAP
@@ -151,7 +159,8 @@ def test_log_player_kill():
151159
assert data.damage_causer_name in DAMAGE_CAUSER_MAP
152160
assert data.damage_reason in DAMAGE_REASON
153161
if data.victim_weapon:
154-
assert data.victim_weapon[:-3] in DAMAGE_CAUSER_MAP
162+
cut_idx = data.victim_weapon.index('_C_') + 2
163+
assert data.victim_weapon[:cut_idx] in DAMAGE_CAUSER_MAP
155164

156165

157166
def test_log_parachute_landing():
@@ -330,7 +339,7 @@ def test_log_vehicle_leave():
330339

331340
def test_log_vehicle_destroy():
332341
events = telemetry.events_from_type('LogVehicleDestroy')
333-
data = events[3]
342+
data = events[0]
334343
assert isinstance(data, LogVehicleDestroy)
335344
assert isinstance(data.attacker, Character)
336345
assert isinstance(data.vehicle, Vehicle)
@@ -474,7 +483,8 @@ def test_log_player_make_groggy():
474483
if not data.victim_weapon:
475484
assert True
476485
else:
477-
assert data.victim_weapon[:-3] in DAMAGE_CAUSER_MAP
486+
cut_idx = data.victim_weapon.index('_C_') + 2
487+
assert data.victim_weapon[:cut_idx] in DAMAGE_CAUSER_MAP
478488

479489

480490
def test_log_player_revive():
@@ -491,3 +501,20 @@ def test_log_red_zone_ended():
491501
data = events[0]
492502
assert isinstance(data, LogRedZoneEnded)
493503
assert isinstance(data.drivers, list)
504+
505+
506+
def test_log_phase_change():
507+
events = telemetry.events_from_type('LogPhaseChange')
508+
data = events[0]
509+
assert isinstance(data, LogPhaseChange)
510+
assert isinstance(data.phase, int)
511+
512+
513+
def test_log_player_use_throwable():
514+
events = telemetry.events_from_type('LogPlayerUseThrowable')
515+
data = events[0]
516+
assert isinstance(data, LogPlayerUseThrowable)
517+
assert isinstance(data.attacker, Character)
518+
assert isinstance(data.weapon, Item)
519+
assert isinstance(data.fire_weapon_stack_count, int)
520+
assert data.attack_type in ATTACK_TYPE

0 commit comments

Comments
 (0)