Skip to content

Commit f03ebbf

Browse files
committed
Removes old processing methods
1 parent fe2b7ae commit f03ebbf

File tree

1 file changed

+0
-212
lines changed

1 file changed

+0
-212
lines changed

sc2reader/processors.py

Lines changed: 0 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -275,215 +275,3 @@ def Full(replay):
275275
pass
276276

277277
return replay
278-
279-
"""
280-
def PeopleProcessor(replay):
281-
obs_players = list(replay.player_names)
282-
for player in replay.players:
283-
try:
284-
obs_players.remove(player.name)
285-
except ValueError:
286-
pass #Must be a computer player!!
287-
288-
for pid,name in enumerate(obs_players):
289-
replay.observers.append(Observer(pid+len(replay.players)+1,name,replay))
290-
291-
for person in replay.observers+replay.players:
292-
replay.people.append(person)
293-
replay.person[person.pid] = person
294-
295-
return replay
296-
297-
def AttributeProcessor(replay):
298-
data = defaultdict(dict)
299-
for attr in replay.attributes:
300-
data[attr.player][attr.name] = attr.value
301-
302-
#Get global settings first
303-
replay.speed = data[16]['Game Speed']
304-
305-
#TODO: Do we need the category variable at this point?
306-
replay.category = data[16]['Category']
307-
replay.is_ladder = (replay.category == "Ladder")
308-
replay.is_private = (replay.category == "Private")
309-
310-
replay.type = data[16]['Game Type']
311-
312-
#Set player attributes as available, requires already populated player list
313-
for pid, attributes in data.iteritems():
314-
if pid != 16:
315-
if attributes['Player Type'] == 'Open':
316-
print "Open Player {0}".format(pid)
317-
318-
if attributes['Player Type'] == 'Computer':
319-
print "Computer Player {0}".format(pid)
320-
player = Player(pid,"Player {0}".format(pid),replay)
321-
replay.people.append(player)
322-
replay.person[pid] = player
323-
324-
if attributes['Player Type'] in ('Human','Computer'):
325-
player = replay.person[pid]
326-
player.color_text = attributes['Color']
327-
player.team = attributes['Teams'+replay.type]
328-
player.choosen_race = attributes['Race']
329-
player.difficulty = attributes['Difficulty']
330-
player.type = attributes['Player Type']
331-
332-
print repr(replay.person.keys())
333-
return replay
334-
335-
def RecorderProcessor(replay):
336-
recorders = list(replay.people)
337-
for person in list(replay.people):
338-
if person.pid in replay.other_people:
339-
recorders.remove(person)
340-
341-
if len(recorders) == 1:
342-
replay.recorder = recorders[0]
343-
replay.recorder.recorder = True
344-
345-
return replay
346-
347-
def MessageProcessor(replay):
348-
for message in replay.messages:
349-
try:
350-
message.sender = replay.person[message.sender_id]
351-
except KeyError:
352-
#Some sites will add messages as a non-existant player
353-
#In this instances, just drop the messages
354-
pass
355-
356-
return replay
357-
358-
def TeamsProcessor(replay):
359-
for player in replay.players:
360-
replay.teams[player.team].append(player)
361-
362-
return replay
363-
364-
def EventProcessor(replay):
365-
replay.events_by_type = defaultdict(list)
366-
for event in replay.events:
367-
if event.is_local:
368-
person = replay.person[event.pid]
369-
event.player = person
370-
person.events.append(event)
371-
372-
event.apply()
373-
replay.events_by_type[event.name].append(event)
374-
375-
return replay
376-
377-
#####################################################
378-
379-
def ApmProcessor(replay):
380-
# Set up needed variables
381-
for player in replay.players:
382-
player.avg_apm = 0
383-
player.aps = dict() # Doesn't contain seconds with zero actions
384-
player.apm = dict() # Doesn't contain minutes with zero actions
385-
# Gather data
386-
for event in replay.events:
387-
if event.is_local and event.is_player_action:
388-
person = event.player
389-
if not person.is_observer:
390-
# Calculate APS, APM and average
391-
if event.second in person.aps:
392-
person.aps[event.second] += 1
393-
else:
394-
person.aps[event.second] = 1
395-
396-
minute = event.second/60
397-
if minute in person.apm:
398-
person.apm[minute] += 1
399-
else:
400-
person.apm[minute] = 1
401-
402-
person.avg_apm += 1
403-
404-
# Average the APM for actual players
405-
for player in replay.players:
406-
if player.events:
407-
event_minutes = player.events[-1].second/60.0
408-
if event_minutes:
409-
player.avg_apm /= event_minutes
410-
else:
411-
player.avg_apm = 0
412-
else:
413-
player.avg_apm = 0
414-
415-
return replay
416-
417-
#####################################################
418-
419-
def ResultsProcessor(replay):
420-
def process_results(replay):
421-
#Knowing the team results, map results to the players as well
422-
for player in replay.players:
423-
player.result = replay.results[player.team]
424-
425-
# Check if replay file has recorded the winner
426-
remaining = set()
427-
for player in replay.players:
428-
if player.result == 1:
429-
replay.results[player.team] = "Won"
430-
elif player.result == 2:
431-
replay.results[player.team] = "Lost"
432-
else:
433-
remaining.add(player.team)
434-
if len(remaining) == 0:
435-
process_results(replay)
436-
return replay
437-
438-
#Remove players from the teams as they drop out of the game
439-
replay.results = dict([team, len(players)] for team, players in replay.teams.iteritems())
440-
441-
for event in replay.events_by_type['PlayerLeave']:
442-
#Some observer actions seem to be recorded, they aren't on teams anyway
443-
#Their pid will always be higher than the players
444-
if event.pid <= len(replay.players):
445-
team = replay.person[event.pid].team
446-
replay.results[team] -= 1
447-
448-
#mark all teams with no players left as losing, save the rest of the teams
449-
remaining = set()
450-
for team, count in replay.results.iteritems():
451-
if count == 0:
452-
replay.results[team] = "Lost"
453-
else:
454-
remaining.add(team)
455-
456-
#If, at the end, only one team remains then that team has won
457-
if len(remaining) == 1:
458-
replay.results[remaining.pop()] = "Won"
459-
460-
#Because you can also end the game by destroying all buildings, games
461-
#with 1 player teams can't be known unless all other players leave
462-
#we also can't do this if replay.recorder is unknown
463-
elif replay.type != 'FFA' and replay.type != '1v1' and replay.recorder:
464-
#The other results are unknown except in the (common) case that the
465-
#recorder is the last one on his team to leave. In this case, the
466-
#result for his team can be known
467-
for team in set(remaining):
468-
#the new set above is important because you shouldn't modify
469-
#elements in collections that you are currently looping over
470-
if team == replay.recorder.team and replay.results[team] == 1:
471-
replay.results[team] = "Lost"
472-
remaining.remove(team)
473-
else:
474-
replay.results[team] = "Unknown"
475-
476-
#If, at the end, only one team remains then that team has won
477-
if len(remaining) == 1:
478-
replay.results[remaining.pop()] = "Won"
479-
replay.winner_known = True
480-
481-
#If the winner can't be known mark all remaining player.result as unknown
482-
else:
483-
for team in remaining:
484-
replay.results[team] = "Unknown"
485-
486-
process_results(replay)
487-
488-
return replay
489-
"""

0 commit comments

Comments
 (0)