-
Notifications
You must be signed in to change notification settings - Fork 436
Open
Description
For AttackGym - we need to be able to send repeated BattleAction objects/classes. Currently rpc_api.py only handles "repeated" base-types (i.e., ints, longs, strings) by accepting a "list" and iterating over it and then appending to the necessary attribute. Need improvement to support AttackGym protobuf.
message AttackGymMessage {
string gym_id = 1;
string battle_id = 2;
repeated .POGOProtos.Data.Battle.BattleAction attack_actions = 3;
.POGOProtos.Data.Battle.BattleAction last_retrieved_actions = 4;
double player_latitude = 5;
double player_longitude = 6;
}
Something like: NOTE - COMPLETELY UNTESTED CODE (also, I'm using old protobuf file structure)
for (key, value) in entry_content.items():
if isinstance(value, list):
#self.log.error('Found list: %s - trying as repeated', key)
for i in value:
#self.log.error('Value is %s' % (type(i)))
if isinstance(i, RpcSub.BattleAction):
self.log.error('RpcSub.BattleAction Class')
subsub_ext = get_class('pgoapi.protos.RpcSub_pb2.BattleAction')()
try:
setattr(subsub_ext, 'Type', i.Type)
setattr(subsub_ext, 'action_start_ms', i.action_start_ms)
setattr(subsub_ext, 'duration_ms', i.duration_ms)
setattr(subsub_ext, 'target_index', i.target_index)
r = getattr(subrequest_extension, key)
r.append(subsub_ext)
except Exception as e:
self.log.warning('Argument %s with value %s unknown inside %s (Exception: %s)', key, str(value), proto_name, str(e))
else:
try:
r = getattr(subrequest_extension, key)
r.append(i)
except Exception as e:
self.log.warning('Arguement %s with value %s unknown inside %s (Exception %s)', key, i, proto_name, str(e))
There are probably much sexier python methods to do this
Trolldemorted and Nihisil
Metadata
Metadata
Assignees
Labels
No labels