From 7519e69207f885055e790d8c3408b511134ed9d9 Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Thu, 24 Mar 2022 02:06:46 +0100 Subject: [PATCH 01/14] Several python3 fixes, menu doesn't work yet --- builder/dataSelector.py | 21 +++++++++++++++------ builder/subactionSelector.py | 21 +++++++++++++++------ engine/article.py | 2 +- engine/statusEffect.py | 2 +- engine/subaction.py | 4 ++-- menu/css.py | 4 ++-- menu/mainMenu.py | 2 +- musicManager.py | 2 +- settingsManager.py | 2 +- 9 files changed, 39 insertions(+), 21 deletions(-) diff --git a/builder/dataSelector.py b/builder/dataSelector.py index 6109724..e542d6c 100644 --- a/builder/dataSelector.py +++ b/builder/dataSelector.py @@ -1,9 +1,18 @@ -from Tkinter import * -import settingsManager -from idlelib.ObjectBrowser import _object_browser -from tkFileDialog import askopenfile,askdirectory +import sys import os -import tkMessageBox + +# Python 3 compatibility +if sys.version_info[0] == 3: + from tkinter import * + from tkinter.filedialog import askopenfile, askdirectory + import tkinter.messagebox as tkMessageBox +else: + from Tkinter import * + from tkFileDialog import askopenfile, askdirectory + import tkMessageBox + +import settingsManager +#from idlelib.ObjectBrowser import _object_browser import engine.action import inspect @@ -723,4 +732,4 @@ def packChildren(self): def update(self): if self.target_object: self.tran_data.set(getattr(self.target_object, self.var_name)) - self.packChildren() \ No newline at end of file + self.packChildren() diff --git a/builder/subactionSelector.py b/builder/subactionSelector.py index 9fc4705..58eb047 100644 --- a/builder/subactionSelector.py +++ b/builder/subactionSelector.py @@ -1,10 +1,19 @@ -from Tkinter import * +import sys import os -from tkFileDialog import askopenfile, askdirectory -import ttk + +# Python 3 compatibility +if sys.version_info[0] == 3: + import tkinter as tk + from tkinter.filedialog import askopenfile, askdirectory + from tkinter import ttk +else: + import Tkinter as tk + from tkFileDialog import askopenfile, askdirectory + import ttk + import settingsManager -class Selector(Label): +class Selector(tk.Label): def __init__(self,_root): self.display_name = StringVar() self.display_name.set('') @@ -92,7 +101,7 @@ def updateName(self, _string=None): if hasattr(_owner, _varname): fielddata = getattr(_owner, _varname) self.display_name.set(self.data[0]+': '+ str(fielddata)) -class ChangeAttributeFrame(Frame): +class ChangeAttributeFrame(tk.Frame): def __init__(self,_root,_attribSet): Frame.__init__(self,_root,height=_root.winfo_height()) self.root = _root @@ -191,7 +200,7 @@ def pickFile(self,_resultVar, _filetype='file', _extensions=[]): res = os.path.relpath(loaded_name,os.path.dirname(self.root.root.fighter_file.name)) _resultVar.set(res) -class BasePropertiesFrame(Frame): +class BasePropertiesFrame(tk.Frame): def __init__(self,_root,_subaction): Frame.__init__(self, _root, height=_root.winfo_height()) self.root = _root diff --git a/engine/article.py b/engine/article.py index d3587af..883474e 100644 --- a/engine/article.py +++ b/engine/article.py @@ -5,7 +5,7 @@ import settingsManager import engine.hitbox as hitbox import engine.collisionBox as collisionBox -import subaction +import engine.subaction import numpy """ diff --git a/engine/statusEffect.py b/engine/statusEffect.py index 73c7730..c21e5d7 100644 --- a/engine/statusEffect.py +++ b/engine/statusEffect.py @@ -5,7 +5,7 @@ import settingsManager import engine.hitbox as hitbox import engine.collisionBox as collisionBox -import subaction +import engine.subaction import numpy """ diff --git a/engine/subaction.py b/engine/subaction.py index c27b859..852efde 100644 --- a/engine/subaction.py +++ b/engine/subaction.py @@ -1,7 +1,7 @@ import engine.hitbox import engine.hurtbox import engine.statusEffect -import baseActions +import engine.baseActions import pygame.color import builder.subactionSelector as subactionSelector import xml.etree.ElementTree as ElementTree @@ -501,4 +501,4 @@ def getXmlElement(self): @staticmethod def buildFromXml(_name,_node): - subactionFactory.buildFromXml(_name, _node) \ No newline at end of file + subactionFactory.buildFromXml(_name, _node) diff --git a/menu/css.py b/menu/css.py index a335df1..498f56f 100644 --- a/menu/css.py +++ b/menu/css.py @@ -8,7 +8,7 @@ import stages.true_arena as stage import engine.cpuPlayer as cpuPlayer import engine.abstractFighter as abstractFighter -import sss +import menu.sss import musicManager class CSSScreen(): @@ -308,4 +308,4 @@ def recolorIcon(self,_reset=False): self.icon.recolor(self.icon.image, self.icon_color, new_color) - self.icon_color = new_color \ No newline at end of file + self.icon_color = new_color diff --git a/menu/mainMenu.py b/menu/mainMenu.py index 8836243..e14f4fe 100644 --- a/menu/mainMenu.py +++ b/menu/mainMenu.py @@ -8,7 +8,7 @@ import engine.article import engine.controller import sys -import css +import menu.css import spriteManager import battle import updater diff --git a/musicManager.py b/musicManager.py index e16f8e8..f9093fd 100644 --- a/musicManager.py +++ b/musicManager.py @@ -1,7 +1,7 @@ import pygame import random import settingsManager -import thread +import _thread as thread """ The Music Manager is an object that is meant to store the list of music diff --git a/settingsManager.py b/settingsManager.py index 8314786..389e92e 100644 --- a/settingsManager.py +++ b/settingsManager.py @@ -258,7 +258,7 @@ def loadControls(self): timing_window[key] = int(self.parser.get(group_name,key)) for opt in self.parser.options(group_name): - if self.key_name_map.has_key(opt): + if opt in self.key_name_map: bindings[self.key_name_map[opt]] = self.parser.get(group_name, opt) self.setting[group_name] = engine.controller.Controller(bindings,timing_window) From a9422ddaaa4f6d8b208e01d17637720e9f0afd34 Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Tue, 19 Apr 2022 23:03:56 +0200 Subject: [PATCH 02/14] More conversion code --- engine/subaction.py | 32 +++++++++++----------- engine/subactions/behavior/applyHitstop.py | 9 ++++-- engine/subactions/behavior/changeECB.py | 9 ++++-- engine/subactions/behavior/createMask.py | 12 ++++++-- engine/subactions/control/event.py | 4 +-- engine/subactions/control/executeCode.py | 4 +-- engine/subactions/control/setFrame.py | 7 ++++- engine/subactions/hitbox/createHitbox.py | 13 +++++++-- menu/mainMenu.py | 1 + 9 files changed, 60 insertions(+), 31 deletions(-) diff --git a/engine/subaction.py b/engine/subaction.py index 852efde..87d2473 100644 --- a/engine/subaction.py +++ b/engine/subaction.py @@ -105,14 +105,14 @@ def initialize(self): def getSubaction(self,_name): if not self.initialized: self.initialize() - if self.subaction_dict.has_key(_name): + if _name in self.subaction_dict: return self.subaction_dict[_name] else: return None def getName(self,_subaction): if not self.initialized: self.initialize() - if self.name_dict.has_key(_subaction): + if _subaction in self.name_dict: return self.name_dict[_subaction] else: return None @@ -145,13 +145,13 @@ def parseData(_data,_type="string",_default=None): if _data.find('var') is not None: #If the data has a Var tag varTag = _data.find('var') - if varTag.attrib.has_key('source'): source = varTag.attrib['source'] + if 'source' in varTag.attrib: source = varTag.attrib['source'] else: source = 'object' return VarData(source,varTag.text) if _data.find('function') is not None: funcTag = _data.find('function') - if funcTag.attrib.has_key('source'): source = funcTag.attrib['source'] + if 'source' in funcTag.attrib: source = funcTag.attrib['source'] else: source = 'object' funcName = loadNodeWithDefault(funcTag, 'functionName', '') @@ -159,7 +159,7 @@ def parseData(_data,_type="string",_default=None): args = dict() if funcTag.find('args') is not None: for arg in funcTag.find('args'): - if arg.attrib.has_key('type'): + if 'type' in arg.attrib: vartype = arg.attrib['type'] else: vartype = 'string' @@ -170,13 +170,13 @@ def parseData(_data,_type="string",_default=None): if _data.find('eval') is not None: evalTag = _data.find('eval') - if evalTag.attrib.has_key('scope'): scope = evalTag.attrib['scope'] + if 'scope' in evalTag.attrib: scope = evalTag.attrib['scope'] else: scope = 'object' return EvalData(scope, evalTag.text) if _type=="dynamic": - if _data.attrib.has_key('type'): + if 'type' in _data.attrib: _type = _data.attrib['type'] else: _type = 'string' if _type=="string": return _data.text @@ -196,15 +196,15 @@ def __init__(self,_source,_var): def unpack(self,_action,_actor): if self.source == 'article' and hasattr(_actor, 'owner'): - if _actor.variables.has_key(self.var): + if self.var in _actor.variables: return _actor.variables[self.var] elif hasattr(_actor, self.var): return getattr(_actor, self.var) else: return None if self.source == 'object': - if hasattr(_actor, 'stats') and _actor.stats.has_key(self.var): + if self.var in hasattr(_actor, 'stats') and _actor.stats: return _actor.stats[self.var] - elif _actor.variables.has_key(self.var): + elif self.var in _actor.variables: return _actor.variables[self.var] elif hasattr(_actor, self.var): return getattr(_actor, self.var) @@ -212,9 +212,9 @@ def unpack(self,_action,_actor): if self.source == 'actor': if hasattr(_actor, 'owner'): _actor = _actor.owner - if _actor.stats.has_key(self.var): + if self.var in _actor.stats: return _actor.stats[self.var] - elif _actor.variables.has_key(self.var): + elif self.var in _actor.variables: return _actor.variables[self.var] elif hasattr(_actor, self.var): return getattr(_actor, self.var) @@ -348,7 +348,7 @@ def __init__(self,_variableName,_variableType,_path,_defaultValue): def getTypeFromData(self,_data): if self.variableType=="dynamic": - if _data.attrib.has_key('type'): + if 'type' in _data.attrib: self.variableType = _data.attrib['type'] else: self.variableType = 'string' if self.variableType=="string": return _data @@ -369,7 +369,7 @@ def populateFromXML(self,_subAction,_rootNode): if len(nodeList) == 1: #We only have the root or a root attribute nodePath = nodeList[0] if len(nodePath) > 1: #If we've hit an attribute - if _rootNode.attrib.has_key(nodePath[1]): + if nodePath[1] in _rootNode.attrib: _subAction.defaultVars[self.variableName] = self.getTypeFromData(_rootNode.attrib[nodePath[1]]) setattr(_subAction, self.variableName, self.getTypeFromData(_rootNode.attrib[nodePath[1]])) else: @@ -388,7 +388,7 @@ def populateFromXML(self,_subAction,_rootNode): setattr(_subAction,self.variableName,self.defaultValue) return if len(nodePath) > 1: #If we've hit an attribute - if currentPosition.attrib.has_key(nodePath[1]): + if nodePath[1] in currentPosition.attrib: _subAction.defaultVars[self.variableName] = self.getTypeFromData(currentPosition.attrib[nodePath[1]]) setattr(_subAction, self.variableName, self.getTypeFromData(currentPosition.attrib[nodePath[1]])) else: @@ -448,7 +448,7 @@ def loadValueOrVariable(_node, _sub_node, _type="string", _default=""): if _node.find(_sub_node) is not None: if _node.find(_sub_node).find('var') is not None: #if there's a var set var_node = _node.find(_sub_node).find('var') - if not var_node.attrib.has_key('from'): + if not 'from' in var_node.attrib: fromKey = 'action' else: fromKey = var_node.attrib['from'] if fromKey == 'actor': diff --git a/engine/subactions/behavior/applyHitstop.py b/engine/subactions/behavior/applyHitstop.py index 73d13d1..aba06cc 100644 --- a/engine/subactions/behavior/applyHitstop.py +++ b/engine/subactions/behavior/applyHitstop.py @@ -1,5 +1,10 @@ from engine.subaction import * -from Tkinter import * +import sys + +if sys.version_info[0] == 3: + from tkinter import * +else: + from Tkinter import * class applyHitstop(SubAction): subact_group = 'Behavior' @@ -78,4 +83,4 @@ def update(self): else: self.string_entry.config(state=DISABLED) """ - self.packChildren() \ No newline at end of file + self.packChildren() diff --git a/engine/subactions/behavior/changeECB.py b/engine/subactions/behavior/changeECB.py index d346706..8ae7c5b 100644 --- a/engine/subactions/behavior/changeECB.py +++ b/engine/subactions/behavior/changeECB.py @@ -1,5 +1,10 @@ from engine.subaction import * -from Tkinter import * +import sys + +if sys.version_info[0] == 3: + from tkinter import * +else: + from Tkinter import * class changeECB(SubAction): subact_group = 'Behavior' @@ -84,4 +89,4 @@ def packChildren(self): self.off_y_entry.grid(row=2,column=2) def update(self): - self.packChildren() \ No newline at end of file + self.packChildren() diff --git a/engine/subactions/behavior/createMask.py b/engine/subactions/behavior/createMask.py index aeed6a7..33e80ee 100644 --- a/engine/subactions/behavior/createMask.py +++ b/engine/subactions/behavior/createMask.py @@ -1,6 +1,12 @@ from engine.subaction import * -from Tkinter import * -from tkColorChooser import askcolor +import sys + +if sys.version_info[0] == 3: + from tkinter import * + from tkinter.colorchooser import askcolor +else: + from Tkinter import * + from tkColorChooser import askcolor class createMask(SubAction): subact_group = 'Behavior' @@ -80,4 +86,4 @@ def update(self): else: self.string_entry.config(state=DISABLED) """ - self.packChildren() \ No newline at end of file + self.packChildren() diff --git a/engine/subactions/control/event.py b/engine/subactions/control/event.py index e5a9738..2ab1208 100644 --- a/engine/subactions/control/event.py +++ b/engine/subactions/control/event.py @@ -28,6 +28,6 @@ def getXmlElement(self): def customBuildFromXml(_node): event_actions = [] for subact in _node: - if subactionFactory.subaction_dict.has_key(subact.tag): + if subact.tag in subactionFactory.subaction_dict: event_actions.append(subactionFactory.buildFromXml(subact.tag,subact)) - return Event(event_actions) \ No newline at end of file + return Event(event_actions) diff --git a/engine/subactions/control/executeCode.py b/engine/subactions/control/executeCode.py index 6cb44eb..615f1fe 100644 --- a/engine/subactions/control/executeCode.py +++ b/engine/subactions/control/executeCode.py @@ -31,7 +31,7 @@ def execute(self, _action, _actor): else: print(self.scope + " is not a valid scope") return None - exec self.codeString in globals(), working_locals + exec(self.codeString, globals(), working_locals) def getDisplayName(self): - return 'Execute ' + self.codeString + ' in the ' + self.scope + ' scope' \ No newline at end of file + return 'Execute ' + self.codeString + ' in the ' + self.scope + ' scope' diff --git a/engine/subactions/control/setFrame.py b/engine/subactions/control/setFrame.py index 4e556e0..f2823e5 100644 --- a/engine/subactions/control/setFrame.py +++ b/engine/subactions/control/setFrame.py @@ -1,5 +1,10 @@ from engine.subaction import * -from Tkinter import * +import sys + +if sys.version_info[0] == 3: + from tkinter import * +else: + from Tkinter import * # Change the frame of the action to a value. class changeActionFrame(SubAction): diff --git a/engine/subactions/hitbox/createHitbox.py b/engine/subactions/hitbox/createHitbox.py index 052c3ec..ee468fc 100644 --- a/engine/subactions/hitbox/createHitbox.py +++ b/engine/subactions/hitbox/createHitbox.py @@ -1,6 +1,13 @@ from engine.subaction import * -import ttk -from Tkinter import * + +import sys + +if sys.version_info[0] == 3: + from tkinter import * + from tkinter import ttk +else: + import ttk + from Tkinter import * # Create a new hitbox class createHitbox(SubAction): @@ -343,4 +350,4 @@ def validateFloat(self, action, index, value_if_allowed, else: return False else: - return True \ No newline at end of file + return True diff --git a/menu/mainMenu.py b/menu/mainMenu.py index e14f4fe..8c23af7 100644 --- a/menu/mainMenu.py +++ b/menu/mainMenu.py @@ -12,6 +12,7 @@ import spriteManager import battle import updater +from menu import css def main(): Menu() From 3c06dc134dc49ad43fc8ea3955905573312dce8a Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Sun, 1 May 2022 03:18:23 +0200 Subject: [PATCH 03/14] More python3 syntax changes --- builder/builderWindow.py | 26 +++---- builder/subactionSelector.py | 18 ++--- engine/abstractFighter.py | 15 ++-- engine/actionLoader.py | 8 +-- engine/article.py | 8 +-- engine/articleLoader.py | 26 +++---- engine/baseActions.py | 7 +- engine/hitbox.py | 2 +- engine/hurtbox.py | 5 +- engine/subaction.py | 4 +- engine/subactions/armor/createArmor.py | 4 +- engine/subactions/armor/modifyArmor.py | 12 ++-- engine/subactions/armor/removeArmor.py | 6 +- engine/subactions/articles/activateArticle.py | 2 +- .../subactions/articles/deactivateArticle.py | 2 +- engine/subactions/base_subactions.py | 68 +++++++++---------- engine/subactions/control/conditional.py | 8 +-- engine/subactions/control/debugAction.py | 2 +- engine/subactions/control/doTransition.py | 2 +- engine/subactions/control/ifButton.py | 8 +-- engine/subactions/control/setFighterVar.py | 4 +- engine/subactions/control/setVar.py | 4 +- engine/subactions/events/registerEvent.py | 2 +- engine/subactions/hitbox/activateHitbox.py | 2 +- engine/subactions/hitbox/createHitbox.py | 18 ++--- engine/subactions/hitbox/deactivateHitbox.py | 2 +- engine/subactions/hitbox/modifyHitbox.py | 6 +- engine/subactions/hitbox/unlockHitbox.py | 2 +- engine/subactions/hurtbox/activateHurtbox.py | 2 +- engine/subactions/hurtbox/createHurtbox.py | 2 +- .../subactions/hurtbox/deactivateHurtbox.py | 2 +- engine/subactions/hurtbox/modifyHurtbox.py | 6 +- menu/css.py | 1 + settingsManager.py | 8 +-- 34 files changed, 149 insertions(+), 145 deletions(-) diff --git a/builder/builderWindow.py b/builder/builderWindow.py index 44cfc1a..a7d50d9 100755 --- a/builder/builderWindow.py +++ b/builder/builderWindow.py @@ -187,7 +187,7 @@ def changeAction(self,*_args): global changed_actions global fighter if fighter: - if changed_actions.has_key(self.action_string.get()): + if self.action_string.get() in changed_actions: action = changed_actions[self.action_string.get()] else: action = fighter.getAction(self.action_string.get()) @@ -239,7 +239,7 @@ def saveFighter(self): global action global changed_actions - for actName, new_action in changed_actions.iteritems(): + for actName, new_action in changed_actions.items(): if hasattr(fighter.actions, 'modifyAction'): fighter.actions.modifyAction(actName, new_action) if hasattr(fighter.actions,'saveActions'): @@ -311,7 +311,7 @@ def submit(self,*_args): name = self.name.get() if name: if not fighter.actions.hasAction(name): #if it doesn't already exist - if not changed_actions.has_key(name): #and we didn't already make one + if not name in changed_actions: #and we didn't already make one act = engine.action.Action() act.name = name self.root.addAction(act) @@ -324,7 +324,7 @@ def submitBasic(self,*_args): name = self.basic_choice.get() if name: if not fighter.actions.hasAction(name): #if it doesn't already exist - if not changed_actions.has_key(name): #and we didn't already make one + if not name in changed_actions: #and we didn't already make one if hasattr(engine.baseActions, name): act = getattr(engine.baseActions, name)() act.name = name @@ -349,7 +349,7 @@ def submit(self,*_args): global action name = self.name.get() - if name and not action.conditional_actions.has_key(name): + if name and not name in action.conditional_actions: action.conditional_actions[name] = [] self.root.actionModified() self.destroy() @@ -740,7 +740,7 @@ def printNode(self,_node,_prefix=''): text += _node.text.lstrip() if _node.text is not None else '' if len(_node.attrib) > 0: #if it has attributes text += ' (' - for name,atr in _node.attrib.iteritems(): + for name,atr in _node.attrib.items(): text+=name+': '+str(atr) text+=',' text = text[:-1] #chop off the last comma @@ -804,7 +804,7 @@ def groupChanged(self,*_args): self.showSubactionList() elif self.group == 'Attributes': - for tag,val in fighter.var.iteritems(): + for tag,val in fighter.var.items(): panel = subactionSelector.SubactionSelector(self.scroll_frame,[(tag,type(val).__name__,fighter.var,tag)],tag+': '+str(val)) self.subaction_list.append(panel) @@ -909,7 +909,7 @@ def __init__(self,_parent,_root): 'Article': self.article_window } - for name,window in subact_windows.iteritems(): + for name,window in subact_windows.items(): self.new_subaction_frame.add(window,text=name) subaction_lists = {'Control':[], @@ -918,7 +918,7 @@ def __init__(self,_parent,_root): 'Hitbox':[], 'Article':[]} - for name,subact in engine.subaction.SubactionFactory.subaction_dict.iteritems(): + for name,subact in engine.subaction.SubactionFactory.subaction_dict.items(): if subact.subact_group in subact_windows.keys(): short_name = (name[:19] + '..') if len(name) > 22 else name button = Button(subact_windows[subact.subact_group],text=short_name,command=lambda subaction=subact: self.addSubaction(subaction)) @@ -949,7 +949,7 @@ def addSubaction(self,_subaction): 'After Frames': action.actions_after_frame, 'Last Frame': action.actions_at_last_frame} group = self.parent.action_selector_panel.current_group.get() - if group_to_action.has_key(group) or group.startswith('Cond:'): + if group in group_to_action or group.startswith('Cond:'): subact = _subaction() if group.startswith('Cond:'): action.conditional_actions[group[6:]].append(subact) @@ -1041,7 +1041,7 @@ def __init__(self,_parent,_root): 'Actions': fighter_actions } - for name,window in self.panel_windows.iteritems(): + for name,window in self.panel_windows.items(): self.add(window,text=name,sticky=N+S+E+W) def addActionPane(self,_actionName): @@ -1166,7 +1166,7 @@ def __init__(self,_parent,_root,_actionName): dataPanel.__init__(self, _parent, _root) self.config(bg="light coral") - if changed_actions.has_key(_actionName): + if _actionName in changed_actions: self.action = changed_actions[_actionName] else: self.action = fighter.getAction(_actionName) @@ -1227,7 +1227,7 @@ def __init__(self,_parent,_root,_actionName): lastGroup.childElements.append(dataSelector.NewSubactionLine(self,self.interior)) self.data_list.append(lastGroup) - for name,event in self.action.events.iteritems(): + for name,event in self.action.events.items(): eventGroup = dataSelector.GroupLine(self,self.interior,'Event: '+name) for subact in event: eventGroup.childElements.append(subact.getDataLine(self)) diff --git a/builder/subactionSelector.py b/builder/subactionSelector.py index 58eb047..dc077c2 100644 --- a/builder/subactionSelector.py +++ b/builder/subactionSelector.py @@ -216,7 +216,7 @@ def getVar(self,_name): return self.variable_list[_name] def initVars(self): - for (val,var) in self.variable_list.iteritems(): + for (val,var) in self.variable_list.items(): var.set(getattr(self.subaction,val)) var.trace('w',lambda name1, name2, op, variable=var, varname=val: self.variableChanged(variable, varname, name1, name2, op)) @@ -435,7 +435,7 @@ def yUnchangedChanged(self,*_args): self.root.root.actionModified() def initVars(self): - for (val,var) in self.variable_list.iteritems(): + for (val,var) in self.variable_list.items(): newval = getattr(self.subaction,val) if newval is None: var.set(0) else: var.set(newval) @@ -529,7 +529,7 @@ def yUnchangedChanged(self,*_args): self.root.root.actionModified() def initVars(self): - for (val,var) in self.variable_list.iteritems(): + for (val,var) in self.variable_list.items(): newval = getattr(self.subaction,val) if newval is None: var.set(0) else: var.set(newval) @@ -614,7 +614,7 @@ def yUnchangedChanged(self,*_args): self.root.root.actionModified() def initVars(self): - for (val,var) in self.variable_list.iteritems(): + for (val,var) in self.variable_list.items(): newval = getattr(self.subaction,val) if newval is None: var.set(0) else: var.set(newval) @@ -719,7 +719,7 @@ def __init__(self,_root,_subaction,newHitbox=False): BasePropertiesFrame.__init__(self, _root, _subaction) import engine - if _root.getAction().hitboxes.has_key(self.subaction.hitbox_name): + if self.subaction.hitbox_name in _root.getAction().hitboxes: self.hitbox = _root.getAction().hitboxes[self.subaction.hitbox_name] else: self.hitbox = engine.hitbox.Hitbox(_root.getFighter(),engine.hitbox.HitboxLock()) self.variable_list = [] @@ -801,7 +801,7 @@ def __init__(self,_root,_subaction,newHitbox=False): var.trace('w',lambda name1, name2, op, variable=var, varname=val: self.variableChanged(variable, varname, name1, name2, op,)) def populateHitboxVariable(self,_variable): - if self.subaction.hitbox_vars.has_key(_variable): + if _variable in self.subaction.hitbox_vars: return self.subaction.hitbox_vars[_variable] else: return getattr(self.hitbox,_variable) @@ -898,9 +898,9 @@ def nameChanged(self,*_args): self.subaction.hitbox_name = new_name #we need something in the action so that we can select it from a dropdown later - if not self.parent.root.getAction().hitboxes.has_key(new_name): #Set our working Hitbox to the action + if not new_name in self.parent.root.getAction().hitboxes: #Set our working Hitbox to the action self.parent.root.getAction().hitboxes[new_name] = self.hitbox - if self.parent.root.getAction().hitboxes.has_key(old_name): #Set it to the Old one if it exists + if old_name in self.parent.root.getAction().hitboxes: #Set it to the Old one if it exists self.parent.root.getAction().hitboxes[new_name] = self.parent.root.getAction().hitboxes[old_name] del(self.parent.root.getAction().hitboxes[old_name]) self.parent.root.root.actionModified() @@ -928,7 +928,7 @@ def sizeChanged(self,*_args): self.parent.root.root.actionModified() def populateHitboxVariable(self,_variable): - if self.subaction.hitbox_vars.has_key(_variable): + if _variable in self.subaction.hitbox_vars: return self.subaction.hitbox_vars[_variable] else: return getattr(self.hitbox,_variable) diff --git a/engine/abstractFighter.py b/engine/abstractFighter.py index 637a26b..037d56b 100644 --- a/engine/abstractFighter.py +++ b/engine/abstractFighter.py @@ -1,3 +1,4 @@ +from functools import reduce import settingsManager import pygame import xml.etree.ElementTree as ElementTree @@ -337,7 +338,7 @@ def createElement(_tag,_val): color_elem = ElementTree.Element('color_palette') color_elem.attrib['id'] = str(i) color_elem.attrib['displayColor'] = '#000000' - for from_color,to_color in color_dict.iteritems(): + for from_color,to_color in color_dict.items(): map_elem = ElementTree.Element('color_map') map_elem.attrib['from_color'] = '#%02x%02x%02x' % from_color map_elem.attrib['to_color'] = '#%02x%02x%02x' % to_color @@ -349,7 +350,7 @@ def createElement(_tag,_val): if not costume == self.sprite_prefix: tree.append(createElement('costume', costume)) - for tag,val in self.stats.iteritems(): + for tag,val in self.stats.items(): stats_elem.append(createElement(tag, val)) tree.append(stats_elem) @@ -415,7 +416,7 @@ def initialize(self): if self.xml_data.find('variables') is not None: for variable in self.xml_data.find('variables'): vartype = 'string' - if variable.attrib.has_key('type'): vartype = variable.attrib['type'] + if 'type' in variable.attrib: vartype = variable.attrib['type'] val = variable.text if vartype == 'int': val = int(val) elif vartype == 'float': val = float(val) @@ -1345,10 +1346,10 @@ def getSmoothedInput(self, _distanceBack = None, _maxMagnitude = 1.0): smoothed_x += working_x smoothed_y += working_y else: - left = self.keys_held['left'] if self.keys_held.has_key('left') else 0 - right = self.keys_held['right'] if self.keys_held.has_key('right') else 0 - up = self.keys_held['up'] if self.keys_held.has_key('up') else 0 - down = self.keys_held['down'] if self.keys_held.has_key('down') else 0 + left = self.keys_held['left'] if 'left' in self.keys_held else 0 + right = self.keys_held['right'] if 'right' in self.keys_held else 0 + up = self.keys_held['up'] if 'up' in self.keys_held else 0 + down = self.keys_held['down'] if 'down' in self.keys_held else 0 smoothed_x = -left+right smoothed_y = -up+down diff --git a/engine/actionLoader.py b/engine/actionLoader.py index eacebfa..e80ccfc 100644 --- a/engine/actionLoader.py +++ b/engine/actionLoader.py @@ -86,7 +86,7 @@ def modifyAction(self,_actionName,_newAction): if _newAction.default_vars: vars_elem = ElementTree.Element('vars') - for tag,val in _newAction.default_vars.iteritems(): + for tag,val in _newAction.default_vars.items(): new_elem = ElementTree.Element(tag) new_elem.attrib['type'] = type(val).__name__ new_elem.text = str(val) @@ -145,7 +145,7 @@ def modifyAction(self,_actionName,_newAction): frameElem.append(subact.getXmlElement()) elem.append(frameElem) - for event_name,event in _newAction.events.iteritems(): + for event_name,event in _newAction.events.items(): if len(event) > 0: event_elem = ElementTree.Element('Event') event_elem.attrib['name'] = str(event_name) @@ -193,7 +193,7 @@ def loadAction(self,_actionName): action_vars = {} if action_xml.find('vars') is not None: for var in action_xml.find('vars'): - t = var.attrib['type'] if var.attrib.has_key('type') else None + t = var.attrib['type'] if 'type' in var.attrib else None if t and t == 'int': action_vars[var.tag] = int(var.text) elif t and t == 'float': @@ -334,7 +334,7 @@ def loadAction(self,_actionName): dyn_action.loop = loop dyn_action.default_vars = action_vars - for key,val in action_vars.iteritems(): + for key,val in action_vars.items(): setattr(dyn_action,key,val) return dyn_action diff --git a/engine/article.py b/engine/article.py index 883474e..f14972f 100644 --- a/engine/article.py +++ b/engine/article.py @@ -85,7 +85,7 @@ def update(self, *args): #Ignores actor if hbox not in self.owner.active_hitboxes: self.owner.active_hitboxes.add(hbox) - if self.sprite_rate is not 0: + if self.sprite_rate != 0: if self.sprite_rate < 0: self.sprite.getImageAtIndex((self.frame // self.sprite_rate)-1) else: @@ -147,7 +147,7 @@ def updateAnimationOnly(self, *args): #Ignores actor if isinstance(act, animation_actions): act.execute(self,self) - if self.sprite_rate is not 0: + if self.sprite_rate != 0: if self.sprite_rate < 0: self.sprite.getImageAtIndex((self.frame // self.sprite_rate)-1) else: @@ -280,7 +280,7 @@ def onClank(self,_actor,_hitbox,_other): def onCollision(self,_other): others_classes = list(map(lambda x :x.__name__,_other.__class__.__bases__)) + [_other.__class__.__name__] - for classKey,subacts in self.collision_actions.iteritems(): + for classKey,subacts in self.collision_actions.items(): if (classKey in others_classes): for subact in subacts: subact.execute(_other,self) @@ -527,7 +527,7 @@ def draw(self,_screen,_offset,_scale): def update(self): self.sprite.updatePosition(self.posx, self.posy) - if self.sprite_rate is not 0: + if self.sprite_rate != 0: if self.sprite_rate < 0: self.sprite.getImageAtIndex((self.frame // self.sprite_rate)-1) else: diff --git a/engine/articleLoader.py b/engine/articleLoader.py index 25551f5..c2a9649 100644 --- a/engine/articleLoader.py +++ b/engine/articleLoader.py @@ -71,7 +71,7 @@ def loadArticle(self,_articleName): article_vars = {} if article_xml.find('vars') is not None: for var in article_xml.find('vars'): - t = var.attrib['type'] if var.attrib.has_key('type') else None + t = var.attrib['type'] if 'type' in var.attrib else None if t and t == 'int': article_vars[var.tag] = int(var.text) elif t and t == 'float': @@ -91,26 +91,26 @@ def loadArticle(self,_articleName): set_up_actions = [] if article_xml.find('setUp') is not None: for subact in article_xml.find('setUp'): - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict set_up_actions.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) #Load the tearDown subactions tear_down_actions = [] if article_xml.find('tearDown') is not None: for subact in article_xml.find('tearDown'): - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict tear_down_actions.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) actions_on_clank = [] if article_xml.find('onClank') is not None: for subact in article_xml.find('onClank'): - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict actions_on_clank.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) actions_on_prevail = [] if article_xml.find('onPrevail') is not None: for subact in article_xml.find('onPrevail'): - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict actions_on_prevail.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) #Load all of the frames @@ -122,16 +122,16 @@ def loadArticle(self,_articleName): for frame in frames: if frame.attrib['number'] == 'before': for subact in frame: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict subactions_before_frame.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) if frame.attrib['number'] == 'after': for subact in frame: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict subactions_after_frame.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) frames.remove(frame) if frame.attrib['number'] == 'last': for subact in frame: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict subactions_at_last_frame.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) frames.remove(frame) @@ -144,7 +144,7 @@ def loadArticle(self,_articleName): for frame in frames: if frame.attrib['number'] == str(frame_number): #If this frame matches the number we're on for subact in frame: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict sublist.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) frames.remove(frame) #Done with this one @@ -155,7 +155,7 @@ def loadArticle(self,_articleName): for frame in frames: if "," in frame.attrib['number'] and frame.attrib['number'].replace(",","").replace(" ","").isdigit(): for subact in frame: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict for frame_num in make_tuple(frame.attrib['number']): subactions_at_frame[frame_num].append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) frames.remove(frame) @@ -164,7 +164,7 @@ def loadArticle(self,_articleName): if "-" in frame.attrib['number'] and frame.attrib['number'].replace("-","").replace(" ","").isdigit(): ends = frame.attrib['number'].split("-") for subact in frame: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict for frame_num in range(int(ends[0]), int(ends[1])+1): subactions_at_frame[frame_num].append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) frames.remove(frame) @@ -175,7 +175,7 @@ def loadArticle(self,_articleName): for cond in conds: event_list = [] for subact in cond: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict event_list.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) event_actions[cond.attrib['name']] = event_list @@ -185,7 +185,7 @@ def loadArticle(self,_articleName): for col in collisions: collision_list = [] for subact in col: - if subaction.subactionFactory.subaction_dict.has_key(subact.tag): #Subactions string to class dict + if subact.tag in subaction.subactionFactory.subaction_dict: #Subactions string to class dict collision_list.append(subaction.subactionFactory.buildFromXml(subact.tag,subact)) collision_actions[col.attrib['other']] = collision_list diff --git a/engine/baseActions.py b/engine/baseActions.py index 7c0f3c6..7c82a13 100644 --- a/engine/baseActions.py +++ b/engine/baseActions.py @@ -1,3 +1,4 @@ +from functools import reduce import engine.action as action import engine.hitbox as hitbox import engine.hurtbox as hurtbox @@ -1759,12 +1760,12 @@ def __init__(self, _length=1): def tearDown(self, _actor, _nextAction): action.Action.tearDown(self, _actor, _nextAction) - for _,hitbox in self.hitboxes.iteritems(): + for _,hitbox in self.hitboxes.items(): hitbox.kill() def onClank(self, _actor, _hitbox, _other): action.Action.onClank(self, _actor, _hitbox, _other) - for _,hitbox in self.hitboxes.iteritems(): + for _,hitbox in self.hitboxes.items(): hitbox.kill() def stateTransitions(self, _actor): @@ -1792,7 +1793,7 @@ def setUp(self, _actor): self.fastfall_frame = None def onClank(self, _actor, _hitbox, _other): - for _,hitbox in self.hitboxes.iteritems(): + for _,hitbox in self.hitboxes.items(): hitbox.kill() def stateTransitions(self, _actor): diff --git a/engine/hitbox.py b/engine/hitbox.py index e85f004..47bdf4b 100644 --- a/engine/hitbox.py +++ b/engine/hitbox.py @@ -57,7 +57,7 @@ def __init__(self,_owner,_lock,_variables = dict()): #set the variables from the dict, so that we don't lose the initial value of the dict when modifying them #also lets us not have to go update all the old references. Score! - for key,value in self.variable_dict.iteritems(): + for key,value in self.variable_dict.items(): setattr(self, key, value) #Flip the distance from center if the fighter is facing the _other way diff --git a/engine/hurtbox.py b/engine/hurtbox.py index da5b26b..a053b3a 100644 --- a/engine/hurtbox.py +++ b/engine/hurtbox.py @@ -1,3 +1,4 @@ +from functools import reduce import spriteManager import settingsManager import engine.hitbox as hitbox @@ -22,7 +23,7 @@ def __init__(self,_owner,_variables = dict()): #set the variables from the dict, so that we don't lose the initial value of the dict when modifying them #also lets us not have to go update all the old references. Score! - for key,value in self.variable_dict.iteritems(): + for key,value in self.variable_dict.items(): setattr(self, key, value) fix_center = self.getFixCenter() @@ -91,7 +92,7 @@ def __init__(self, _owner, _variables = dict()): #set the variables from the dict, so that we don't lose the initial value of the dict when modifying them #also lets us not have to go update all the old references. Score! - for key,value in self.variable_dict.iteritems(): + for key,value in self.variable_dict.items(): setattr(self, key, value) def filterHits(self,_hitbox,_subactions,_forward): diff --git a/engine/subaction.py b/engine/subaction.py index 87d2473..2aee1bf 100644 --- a/engine/subaction.py +++ b/engine/subaction.py @@ -240,7 +240,7 @@ def __init__(self,_source,_functionName,_args): self.args = _args def unpack(self,_action,_actor): - for argname,arg in self.args.iteritems(): + for argname,arg in self.args.items(): if isinstance(arg, FuncData) or isinstance(arg, VarData) or isinstance(arg, EvalData): self.args[argname] = arg.unpack(_action,_actor) @@ -479,7 +479,7 @@ def __init__(self): self.defaultVars = dict() def execute(self, _action, _actor): - for tag,variable in self.defaultVars.iteritems(): + for tag,variable in self.defaultVars.items(): if isinstance(variable, VarData) or isinstance(variable, FuncData) or isinstance(variable, EvalData): setattr(self, tag, variable.unpack(_action,_actor)) diff --git a/engine/subactions/armor/createArmor.py b/engine/subactions/armor/createArmor.py index 169622a..3fcac73 100644 --- a/engine/subactions/armor/createArmor.py +++ b/engine/subactions/armor/createArmor.py @@ -54,7 +54,7 @@ def getXmlElement(self): hurtbox_elem = ElementTree.Element('hurtbox') hurtbox_elem.text = self.hurtbox elem.append(hurtbox_elem) - for tag,value in self.armor_vars.iteritems(): + for tag,value in self.armor_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -63,7 +63,7 @@ def getXmlElement(self): @staticmethod def customBuildFromXml(_node): #mandatory fields - armor_type = _node.attrib['type'] if _node.attrib.has_key('type') else "hyper" + armor_type = _node.attrib['type'] if 'type' in _node.attrib else "hyper" #build the variable dict variables = {} diff --git a/engine/subactions/armor/modifyArmor.py b/engine/subactions/armor/modifyArmor.py index b899d47..58fe50b 100644 --- a/engine/subactions/armor/modifyArmor.py +++ b/engine/subactions/armor/modifyArmor.py @@ -11,12 +11,12 @@ def __init__(self,_armorName='',_hurtbox='',_armorVars={}): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox): + if self.hurtbox in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox] - if hurtbox.armor.has_key(self.armor_name): + if self.armor_name in hurtbox.armor: armor = hurtbox.armor[self.armor_name] if armor: - for name,value in self.hitbox_vars.iteritems(): + for name,value in self.hitbox_vars.items(): if hasattr(armor, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(armor, name, value.unpack(_action,_actor)) @@ -27,9 +27,9 @@ def execute(self, _action, _actor): if name in armor.variable_dict: armor.variable_dict[name] = value else: - if _actor.armor.has_key(self.armor_name): + if self.armor_name in _actor.armor: armor = _actor.armor[self.armor_name] - for name,value in self.hitbox_vars.iteritems(): + for name,value in self.hitbox_vars.items(): if hasattr(armor, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(armor, name, value.unpack(_action,_actor)) @@ -49,7 +49,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyArmor') elem.attrib['name'] = self.armor_name - for tag,value in self.armor_vars.iteritems(): + for tag,value in self.armor_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/armor/removeArmor.py b/engine/subactions/armor/removeArmor.py index 783416a..e4cb7a2 100644 --- a/engine/subactions/armor/removeArmor.py +++ b/engine/subactions/armor/removeArmor.py @@ -14,16 +14,16 @@ def __init__(self,_armorName='',_hurtbox=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) if self.hurtbox is not '': - if _action.hurtboxes.has_key(self.hurtbox): + if self.hurtbox in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox] if self.armor_name is '': hurtbox.armor.clear() - elif hurtbox.armor.has_key(self.armor_name): + elif self.armor_name in hurtbox.armor: del hurtbox.armor[self.armor_name] else: if self.armor_name is '': _actor.armor.clear() - elif _actor.armor.has_key(self.armor_name): + elif self.armor_name in _actor.armor: del _actor.armor[self.armor_name] def getPropertiesPanel(self, _root): diff --git a/engine/subactions/articles/activateArticle.py b/engine/subactions/articles/activateArticle.py index 9953893..70154bc 100644 --- a/engine/subactions/articles/activateArticle.py +++ b/engine/subactions/articles/activateArticle.py @@ -11,7 +11,7 @@ def __init__(self,_name=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.articles.has_key(self.name): + if self.name in _action.articles: _action.articles[self.name].activate() def getDisplayName(self): diff --git a/engine/subactions/articles/deactivateArticle.py b/engine/subactions/articles/deactivateArticle.py index cbddc6c..30f4731 100644 --- a/engine/subactions/articles/deactivateArticle.py +++ b/engine/subactions/articles/deactivateArticle.py @@ -11,7 +11,7 @@ def __init__(self,_name=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.articles.has_key(self.name): + if self.name in _action.articles: _action.articles[self.name].deactivate() def getDisplayName(self): diff --git a/engine/subactions/base_subactions.py b/engine/subactions/base_subactions.py index 24abfa1..ce383da 100644 --- a/engine/subactions/base_subactions.py +++ b/engine/subactions/base_subactions.py @@ -31,7 +31,7 @@ def getXmlElement(self): def customBuildFromXml(_node): event_actions = [] for subact in _node: - if subaction_dict.has_key(subact.tag): + if subact.tag in subaction_dict: event_actions.append(subaction.SubAction.buildFromXml(subact.tag,subact)) return Event(event_actions) @@ -63,9 +63,9 @@ def execute(self, _action, _actor): if self.source == 'fighter' or self.source == 'actor': if hasattr(_actor, 'owner'): _actor = _actor.owner - if hasattr(_actor, 'stats') and _actor.stats.has_key(self.variable): + if hasattr(_actor, 'stats') and self.variable in _actor.stats: variable = _actor.stats[self.variable] - elif _actor.variables.has_key(self.variable): + elif self.variable in _actor.variables: variable = _actor.variables[self.variable] else: variable = getattr(_actor, self.variable) elif self.source == 'article' and hasattr(_actor, 'owner'): @@ -90,12 +90,12 @@ def execute(self, _action, _actor): cond = function(variable,self.value) if cond: - if self.if_actions and _action.events.has_key(self.if_actions): + if self.if_actions and self.if_actions in _action.events: for act in _action.events[self.if_actions]: act.execute(_action,_actor) else: - if self.else_actions and _action.events.has_key(self.else_actions): + if self.else_actions and self.else_actions in _action.events: for act in _action.events[self.else_actions]: act.execute(_action,_actor) @@ -175,11 +175,11 @@ def execute(self, _action, _actor): return if cond: - if self.if_actions and _action.events.has_key(self.if_actions): + if self.if_actions and self.if_actions in _action.events: for act in _action.events[self.if_actions]: act.execute(_action,_actor) else: - if self.else_actions and _action.events.has_key(self.else_actions): + if self.else_actions and self.else_actions in _action.events: for act in _action.events[self.else_actions]: act.execute(_action,_actor) @@ -251,7 +251,7 @@ def getXmlElement(self): @staticmethod def customBuildFromXml(_node): button = _node.find('button') - if button.attrib.has_key('check'): + if 'check' in button.attrib: check = button.attrib['check'] else: check = 'keyBuffered' button = button.text @@ -262,7 +262,7 @@ def customBuildFromXml(_node): if_actions = subaction.loadNodeWithDefault(_node, 'pass', None) else_actions = subaction.loadNodeWithDefault(_node, 'fail', None) - return ifButton(button, check, buffer_from, buffer_to, threshold, if_actions, else_actions, _node.attrib.has_key('beyondAction')) + return ifButton(button, check, buffer_from, buffer_to, threshold, if_actions, else_actions, 'beyondAction' in _node.attrib) ######################################################## # SPRITE CHANGERS # @@ -837,10 +837,10 @@ def execute(self, _action, _actor): if self.source == 'actor' and hasattr(_actor, 'owner'): _actor = _actor.owner if not self.attr =='': - if hasattr(_actor, 'stats') and _actor.stats.has_key(self.attr): + if hasattr(_actor, 'stats') and self.attr in _actor.stats: if self.relative: _actor.stats[self.attr] += self.val else: _actor.stats[self.attr] = self.val - elif _actor.variables.has_key(self.attr): + elif self.attr in _actor.variables: if self.relative: _actor.variables[self.attr] += self.val else: _actor.variables[self.attr] = self.val else: @@ -883,10 +883,10 @@ def execute(self, _action, _actor): elif self.source == 'article' and hasattr(_actor, 'owner'): source = _actor if not self.attr =='': #If there's a variable to set - if hasattr(source, 'stats') and source.stats.has_key(self.attr): #if it has a var dict, let's check it first + if hasattr(source, 'stats') and self.attr in source.stats: #if it has a var dict, let's check it first if self.relative: source.stats[self.attr] += self.val else: source.stats[self.attr] = self.val - elif hasattr(source, 'variables') and source.variables.has_key(self.attr): + elif hasattr(source, 'variables') and self.attr in source.variables: if self.relative: source.variables[self.attr] += self.val else: source.variables[self.attr] = self.val else: @@ -952,7 +952,7 @@ def __init__(self,_transition=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if baseActions.state_dict.has_key(self.transition): + if self.transition in baseActions.state_dict: baseActions.state_dict[self.transition](_actor) def getPropertiesPanel(self, _root): @@ -985,7 +985,7 @@ def execute(self, _action, _actor): if self.hitbox_name == '': return #Don't make a hitbox without a name or we'll lose it #Use an existing hitbox lock by name, or create a new one - if self.hitbox_lock and _action.hitbox_locks.has_key(self.hitbox_lock): + if self.hitbox_lock and self.hitbox_lock in _action.hitbox_locks: hitbox_lock = _action.hitbox_locks[self.hitbox_lock] else: hitbox_lock = engine.hitbox.HitboxLock(self.hitbox_lock) @@ -1016,9 +1016,9 @@ def execute(self, _action, _actor): if _action is not None: if hasattr(_action, 'events'): #Articles don't have events, and this can be called from article - if _action.events.has_key(self.owner_event): + if self.owner_event in _action.events: hitbox.owner_on_hit_actions = _action.events[self.owner_event] - if _action.events.has_key(self.other_event): + if self.other_event in _action.events: hitbox.other_on_hit_actions = _action.events[self.other_event] _action.hitboxes[self.hitbox_name] = hitbox @@ -1034,7 +1034,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hitbox_name elem.append(name_elem) - for tag,value in self.hitbox_vars.iteritems(): + for tag,value in self.hitbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1046,7 +1046,7 @@ def getXmlElement(self): @staticmethod def customBuildFromXml(_node): #mandatory fields - hitbox_type = _node.attrib['type'] if _node.attrib.has_key('type') else "damage" + hitbox_type = _node.attrib['type'] if 'type' in _node.attrib else "damage" #build the variable dict variables = {} @@ -1096,10 +1096,10 @@ def __init__(self,_hitboxName='',_hitboxVars={}): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: hitbox = _action.hitboxes[self.hitbox_name] if hitbox: - for name,value in self.hitbox_vars.iteritems(): + for name,value in self.hitbox_vars.items(): if hasattr(hitbox, name): if isinstance(value, subaction.VarData) or isinstance(value, subaction.FuncData) or isinstance(value, subaction.EvalData): setattr(hitbox, name, value.unpack(_action,_actor)) @@ -1119,7 +1119,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHitbox') elem.attrib['name'] = self.hitbox_name - for tag,value in self.hitbox_vars.iteritems(): + for tag,value in self.hitbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1167,7 +1167,7 @@ def __init__(self,_hitboxName=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: _actor.activateHitbox(_action.hitboxes[self.hitbox_name]) def getPropertiesPanel(self, _root): @@ -1188,7 +1188,7 @@ def __init__(self,_hitboxName=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: _action.hitboxes[self.hitbox_name].kill() def getPropertiesPanel(self, _root): @@ -1208,7 +1208,7 @@ def __init__(self,_hitboxName=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: _action.hitboxes[self.hitbox_name].hitbox_lock = engine.hitbox.HitboxLock() def getPropertiesPanel(self, _root): @@ -1279,7 +1279,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hurtbox_name elem.append(name_elem) - for tag,value in self.hurtbox_vars.iteritems(): + for tag,value in self.hurtbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1317,10 +1317,10 @@ def __init__(self,_hurtboxName='',_hurtboxVars={}): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox_name): + if self.hurtbox_name in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox_name] if hurtbox: - for name,value in self.hurtbox_vars.iteritems(): + for name,value in self.hurtbox_vars.items(): if hasattr(hurtbox, name): if isinstance(value, subaction.VarData) or isinstance(value, subaction.FuncData) or isinstance(value, subaction.EvalData): setattr(hurtbox, name, value.unpack(_action,_actor)) @@ -1336,7 +1336,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHurtbox') elem.attrib['name'] = self.hurtbox_name - for tag,value in self.hurtbox_vars.iteritems(): + for tag,value in self.hurtbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1373,7 +1373,7 @@ def __init__(self,_hurtboxName=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox_name): + if self.hurtbox_name in _action.hurtboxes: _actor.activateHurtbox(_action.hurtboxes[self.hurtbox_name]) def getPropertiesPanel(self, _root): @@ -1394,7 +1394,7 @@ def __init__(self,_hurtboxName=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox_name): + if self.hurtbox_name in _action.hurtboxes: _action.hurtboxes[self.hurtbox_name].kill() def getPropertiesPanel(self, _root): @@ -1463,7 +1463,7 @@ def __init__(self,_name=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.articles.has_key(self.name): + if self.name in _action.articles: _action.articles[self.name].activate() def getDisplayName(self): @@ -1480,7 +1480,7 @@ def __init__(self,_name=''): def execute(self, _action, _actor): subaction.SubAction.execute(self, _action, _actor) - if _action.articles.has_key(self.name): + if self.name in _action.articles: _action.articles[self.name].deactivate() def getDisplayName(self): @@ -1571,7 +1571,7 @@ def execute(self, _action, _actor): if source == 'action': print('action.'+name+': '+str(getattr(_action, name))) else: - if hasattr(_actor, 'stats') and _actor.stats.has_key(name): + if hasattr(_actor, 'stats') and name in _actor.stats: print('object['+name+']: '+str(_actor.stats[name])) else: print('object.'+name+': '+str(getattr(_actor, name))) diff --git a/engine/subactions/control/conditional.py b/engine/subactions/control/conditional.py index 78fcff6..11640a6 100644 --- a/engine/subactions/control/conditional.py +++ b/engine/subactions/control/conditional.py @@ -25,9 +25,9 @@ def execute(self, _action, _actor): if self.source == 'fighter' or self.source == 'actor': if hasattr(_actor, 'owner'): _actor = _actor.owner - if hasattr(_actor, 'stats') and _actor.stats.has_key(self.variable): + if hasattr(_actor, 'stats') and self.variable in _actor.stats: variable = _actor.stats[self.variable] - elif _actor.variables.has_key(self.variable): + elif self.variable in _actor.variables: variable = _actor.variables[self.variable] else: variable = getattr(_actor, self.variable) elif self.source == 'article' and hasattr(_actor, 'owner'): @@ -65,12 +65,12 @@ def execute(self, _action, _actor): print(self.if_actions,self.else_actions) if cond: - if self.if_actions and _action.events.has_key(self.if_actions): + if self.if_actions and self.if_actions in _action.events: for act in _action.events[self.if_actions]: act.execute(_action,_actor) else: - if self.else_actions and _action.events.has_key(self.else_actions): + if self.else_actions and self.else_actions in _action.events: for act in _action.events[self.else_actions]: act.execute(_action,_actor) diff --git a/engine/subactions/control/debugAction.py b/engine/subactions/control/debugAction.py index 16eeca4..cd2290a 100644 --- a/engine/subactions/control/debugAction.py +++ b/engine/subactions/control/debugAction.py @@ -15,7 +15,7 @@ def execute(self, _action, _actor): if source == 'action': print('action.'+name+': '+str(getattr(_action, name))) else: - if hasattr(_actor, 'stats') and _actor.stats.has_key(name): + if hasattr(_actor, 'stats') and name in _actor.stats: print('object['+name+']: '+str(_actor.stats[name])) else: print('object.'+name+': '+str(getattr(_actor, name))) diff --git a/engine/subactions/control/doTransition.py b/engine/subactions/control/doTransition.py index 194aec8..ebb2ed0 100644 --- a/engine/subactions/control/doTransition.py +++ b/engine/subactions/control/doTransition.py @@ -11,7 +11,7 @@ def __init__(self,_transition=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if baseActions.state_dict.has_key(self.transition): + if self.transition in baseActions.state_dict: baseActions.state_dict[self.transition](_actor) def getPropertiesPanel(self, _root): diff --git a/engine/subactions/control/ifButton.py b/engine/subactions/control/ifButton.py index 73738f2..692cb7a 100644 --- a/engine/subactions/control/ifButton.py +++ b/engine/subactions/control/ifButton.py @@ -53,11 +53,11 @@ def execute(self, _action, _actor): return if cond: - if self.if_actions and _action.events.has_key(self.if_actions): + if self.if_actions and self.if_actions in _action.events: for act in _action.events[self.if_actions]: act.execute(_action,_actor) else: - if self.else_actions and _action.events.has_key(self.else_actions): + if self.else_actions and self.else_actions in _action.events: for act in _action.events[self.else_actions]: act.execute(_action,_actor) @@ -129,7 +129,7 @@ def getXmlElement(self): @staticmethod def customBuildFromXml(_node): button = _node.find('button') - if button.attrib.has_key('check'): + if 'check' in button.attrib: check = button.attrib['check'] else: check = 'keyBuffered' button = button.text @@ -140,4 +140,4 @@ def customBuildFromXml(_node): if_actions = loadNodeWithDefault(_node, 'pass', None) else_actions = loadNodeWithDefault(_node, 'fail', None) - return ifButton(button, check, buffer_from, buffer_to, threshold, if_actions, else_actions, _node.attrib.has_key('beyondAction')) + return ifButton(button, check, buffer_from, buffer_to, threshold, if_actions, else_actions, 'beyondAction' in _node.attrib) diff --git a/engine/subactions/control/setFighterVar.py b/engine/subactions/control/setFighterVar.py index 2939fbf..2a94999 100644 --- a/engine/subactions/control/setFighterVar.py +++ b/engine/subactions/control/setFighterVar.py @@ -21,10 +21,10 @@ def execute(self, _action, _actor): if self.source == 'actor' and hasattr(_actor, 'owner'): _actor = _actor.owner if not self.attr =='': - if hasattr(_actor, 'stats') and _actor.stats.has_key(self.attr): + if hasattr(_actor, 'stats') and self.attr in _actor.stats: if self.relative: _actor.stats[self.attr] += self.val else: _actor.stats[self.attr] = self.val - elif _actor.variables.has_key(self.attr): + elif self.attr in _actor.variables: if self.relative: _actor.variables[self.attr] += self.val else: _actor.variables[self.attr] = self.val else: diff --git a/engine/subactions/control/setVar.py b/engine/subactions/control/setVar.py index 8aa2c01..b145f23 100644 --- a/engine/subactions/control/setVar.py +++ b/engine/subactions/control/setVar.py @@ -29,10 +29,10 @@ def execute(self, _action, _actor): elif self.source == 'article' and hasattr(_actor, 'owner'): source = _actor if not self.attr =='': #If there's a variable to set - if hasattr(source, 'stats') and source.stats.has_key(self.attr): #if it has a var dict, let's check it first + if self.attr in hasattr(source, 'stats') and source.stats: #if it has a var dict, let's check it first if self.relative: source.stats[self.attr] += self.val else: source.stats[self.attr] = self.val - elif hasattr(source, 'variables') and source.variables.has_key(self.attr): + elif self.attr in hasattr(source, 'variables') and source.variables: if self.relative: source.variables[self.attr] += self.val else: source.variables[self.attr] = self.val else: diff --git a/engine/subactions/events/registerEvent.py b/engine/subactions/events/registerEvent.py index d1ef7aa..fff46aa 100644 --- a/engine/subactions/events/registerEvent.py +++ b/engine/subactions/events/registerEvent.py @@ -30,6 +30,6 @@ def getXmlElement(self): def customBuildFromXml(_node): event_actions = [] for subact in _node: - if subactionFactory.subaction_dict.has_key(subact.tag): + if subact.tag in subactionFactory.subaction_dict: event_actions.append(subactionFactory.buildFromXml(subact.tag,subact)) return RegisterEvent(event_actions) \ No newline at end of file diff --git a/engine/subactions/hitbox/activateHitbox.py b/engine/subactions/hitbox/activateHitbox.py index c77dea1..094706d 100644 --- a/engine/subactions/hitbox/activateHitbox.py +++ b/engine/subactions/hitbox/activateHitbox.py @@ -11,7 +11,7 @@ def __init__(self,_hitboxName=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: _actor.activateHitbox(_action.hitboxes[self.hitbox_name]) def getPropertiesPanel(self, _root): diff --git a/engine/subactions/hitbox/createHitbox.py b/engine/subactions/hitbox/createHitbox.py index ee468fc..c23a34c 100644 --- a/engine/subactions/hitbox/createHitbox.py +++ b/engine/subactions/hitbox/createHitbox.py @@ -29,7 +29,7 @@ def execute(self, _action, _actor): if self.hitbox_name == '': return #Don't make a hitbox without a name or we'll lose it #Use an existing hitbox lock by name, or create a new one - if self.hitbox_lock and _action.hitbox_locks.has_key(self.hitbox_lock): + if self.hitbox_lock in self.hitbox_lock and _action.hitbox_locks: hitbox_lock = _action.hitbox_locks[self.hitbox_lock] else: hitbox_lock = engine.hitbox.HitboxLock(self.hitbox_lock) @@ -60,13 +60,13 @@ def execute(self, _action, _actor): if _action is not None: if hasattr(_action, 'events'): #Articles don't have events, and this can be called from article - if _action.events.has_key(self.owner_event): + if self.owner_event in _action.events: hitbox.owner_on_hit_actions = _action.events[self.owner_event] - elif _actor.events.has_key(self.owner_event): + elif self.owner_event in _actor.events: hitbox.owner_on_hit_actions = [_actor.events[self.owner_event]] - if _action.events.has_key(self.other_event): + if self.other_event in _action.events: hitbox.other_on_hit_actions = _action.events[self.other_event] - elif _actor.events.has_key(self.other_event): + elif self.other_event in _actor.events: hitbox.other_on_hit_actions = [_actor.events[self.other_event]] _action.hitboxes[self.hitbox_name] = hitbox @@ -82,7 +82,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hitbox_name elem.append(name_elem) - for tag,value in self.hitbox_vars.iteritems(): + for tag,value in self.hitbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -94,7 +94,7 @@ def getXmlElement(self): @staticmethod def customBuildFromXml(_node): #mandatory fields - hitbox_type = _node.attrib['type'] if _node.attrib.has_key('type') else "damage" + hitbox_type = _node.attrib['type'] if 'type' in _node.attrib else "damage" #build the variable dict variables = {} @@ -162,7 +162,7 @@ def __init__(self,_parent): def changeVariable(self,*args): hitboxes = self.root.getAction().hitboxes - if hitboxes.has_key(self.name_data.get()): + if self.name_data.get() in hitboxes: self.hitbox = hitboxes[self.name_data.get()] def packChildren(self): @@ -174,7 +174,7 @@ def packChildren(self): def update(self): hitboxes = self.root.getAction().hitboxes - if hitboxes.has_key(self.name_data.get()): + if self.name_data.get() in hitboxes: self.hitbox = hitboxes[self.name_data.get()] self.properties_frame.hitbox = self.hitbox diff --git a/engine/subactions/hitbox/deactivateHitbox.py b/engine/subactions/hitbox/deactivateHitbox.py index 44ba4e4..9c54fd0 100644 --- a/engine/subactions/hitbox/deactivateHitbox.py +++ b/engine/subactions/hitbox/deactivateHitbox.py @@ -11,7 +11,7 @@ def __init__(self,_hitboxName=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: _action.hitboxes[self.hitbox_name].kill() def getPropertiesPanel(self, _root): diff --git a/engine/subactions/hitbox/modifyHitbox.py b/engine/subactions/hitbox/modifyHitbox.py index bc227ed..d7f77f6 100644 --- a/engine/subactions/hitbox/modifyHitbox.py +++ b/engine/subactions/hitbox/modifyHitbox.py @@ -11,10 +11,10 @@ def __init__(self,_hitboxName='',_hitboxVars={}): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: hitbox = _action.hitboxes[self.hitbox_name] if hitbox: - for name,value in self.hitbox_vars.iteritems(): + for name,value in self.hitbox_vars.items(): if hasattr(hitbox, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(hitbox, name, value.unpack(_action,_actor)) @@ -34,7 +34,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHitbox') elem.attrib['name'] = self.hitbox_name - for tag,value in self.hitbox_vars.iteritems(): + for tag,value in self.hitbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/hitbox/unlockHitbox.py b/engine/subactions/hitbox/unlockHitbox.py index ee39e04..c7251d3 100644 --- a/engine/subactions/hitbox/unlockHitbox.py +++ b/engine/subactions/hitbox/unlockHitbox.py @@ -11,7 +11,7 @@ def __init__(self,_hitboxName=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hitboxes.has_key(self.hitbox_name): + if self.hitbox_name in _action.hitboxes: _action.hitboxes[self.hitbox_name].hitbox_lock = engine.hitbox.HitboxLock() def getPropertiesPanel(self, _root): diff --git a/engine/subactions/hurtbox/activateHurtbox.py b/engine/subactions/hurtbox/activateHurtbox.py index a863e81..40467fd 100644 --- a/engine/subactions/hurtbox/activateHurtbox.py +++ b/engine/subactions/hurtbox/activateHurtbox.py @@ -11,7 +11,7 @@ def __init__(self,_hurtboxName=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox_name): + if self.hurtbox_name in _action.hurtboxes: _actor.activateHurtbox(_action.hurtboxes[self.hurtbox_name]) def getPropertiesPanel(self, _root): diff --git a/engine/subactions/hurtbox/createHurtbox.py b/engine/subactions/hurtbox/createHurtbox.py index 1f3ca35..2c7f5a2 100644 --- a/engine/subactions/hurtbox/createHurtbox.py +++ b/engine/subactions/hurtbox/createHurtbox.py @@ -29,7 +29,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hurtbox_name elem.append(name_elem) - for tag,value in self.hurtbox_vars.iteritems(): + for tag,value in self.hurtbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/hurtbox/deactivateHurtbox.py b/engine/subactions/hurtbox/deactivateHurtbox.py index a3cb3f4..6cb8cfc 100644 --- a/engine/subactions/hurtbox/deactivateHurtbox.py +++ b/engine/subactions/hurtbox/deactivateHurtbox.py @@ -11,7 +11,7 @@ def __init__(self,_hurtboxName=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox_name): + if self.hurtbox_name in _action.hurtboxes: _action.hurtboxes[self.hurtbox_name].kill() def getPropertiesPanel(self, _root): diff --git a/engine/subactions/hurtbox/modifyHurtbox.py b/engine/subactions/hurtbox/modifyHurtbox.py index b8e17a5..b73ac65 100644 --- a/engine/subactions/hurtbox/modifyHurtbox.py +++ b/engine/subactions/hurtbox/modifyHurtbox.py @@ -11,10 +11,10 @@ def __init__(self,_hurtboxName='',_hurtboxVars={}): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if _action.hurtboxes.has_key(self.hurtbox_name): + if self.hurtbox_name in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox_name] if hurtbox: - for name,value in self.hurtbox_vars.iteritems(): + for name,value in self.hurtbox_vars.items(): if hasattr(hurtbox, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(hurtbox, name, value.unpack(_action,_actor)) @@ -30,7 +30,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHurtbox') elem.attrib['name'] = self.hurtbox_name - for tag,value in self.hurtbox_vars.iteritems(): + for tag,value in self.hurtbox_vars.items(): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/menu/css.py b/menu/css.py index 498f56f..a71c864 100644 --- a/menu/css.py +++ b/menu/css.py @@ -10,6 +10,7 @@ import engine.abstractFighter as abstractFighter import menu.sss import musicManager +from menu import sss class CSSScreen(): def __init__(self,_rules=None): diff --git a/settingsManager.py b/settingsManager.py index 389e92e..ff27579 100644 --- a/settingsManager.py +++ b/settingsManager.py @@ -385,7 +385,7 @@ def saveSettings(_settings): for key in _settings[sect].key_bindings: parser.set(sect,'controlType',_settings['controlType_'+str(i)]) parser.set(sect,key_id_map[key],str(_settings[sect].key_bindings[key])) - for key,val in _settings[sect].timing_window.iteritems(): + for key,val in _settings[sect].timing_window.items(): parser.set(sect,key,str(val)) with open(os.path.join(getSetting().datadir.replace('main.exe',''),'settings','settings.ini'), 'w') as configfile: @@ -400,13 +400,13 @@ def saveGamepad(_settings): if not parser.has_section(controller_name): parser.add_section(controller_name) - for key,value in gamepad.key_bindings.axis_bindings.iteritems(): + for key,value in gamepad.key_bindings.axis_bindings.items(): neg,pos = value if not neg: neg = 'none' if not pos: pos = 'none' parser.set(controller_name,'a'+str(key),'('+str(neg)+','+str(pos)+')' ) - for key,value in gamepad.key_bindings.button_bindings.iteritems(): + for key,value in gamepad.key_bindings.button_bindings.items(): parser.set(controller_name,'b'+str(key),str(value)) with open(os.path.join(getSetting().datadir.replace('main.exe',''),'settings','gamepads.ini'), 'w') as configfile: @@ -472,7 +472,7 @@ def playSound(self,_name,_category = "base"): @_category - the category of the sound """ def hasSound(self,_name,_category): - return self.sounds.has_key(_category+"_"+_name) + return _category+"_"+_name in self.sounds """ This is called to add a directory of sound effects to the library. From 2765799c016ef8a4044e6e7b7428806fc5755eab Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Sun, 1 May 2022 03:26:23 +0200 Subject: [PATCH 04/14] Fixes --- engine/subactions/control/setVar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/subactions/control/setVar.py b/engine/subactions/control/setVar.py index b145f23..8ab96dd 100644 --- a/engine/subactions/control/setVar.py +++ b/engine/subactions/control/setVar.py @@ -29,10 +29,10 @@ def execute(self, _action, _actor): elif self.source == 'article' and hasattr(_actor, 'owner'): source = _actor if not self.attr =='': #If there's a variable to set - if self.attr in hasattr(source, 'stats') and source.stats: #if it has a var dict, let's check it first + if hasattr(source, 'stats') and self.attr in source.stats: #if it has a var dict, let's check it first if self.relative: source.stats[self.attr] += self.val else: source.stats[self.attr] = self.val - elif self.attr in hasattr(source, 'variables') and source.variables: + elif hasattr(source, 'variables') and self.attr in source.variables: if self.relative: source.variables[self.attr] += self.val else: source.variables[self.attr] = self.val else: From ee2b523e10480416fee38ebab03e7c6e34cd7eea Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Sun, 1 May 2022 03:34:13 +0200 Subject: [PATCH 05/14] Another list fix --- engine/subaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/subaction.py b/engine/subaction.py index 2aee1bf..2de8f40 100644 --- a/engine/subaction.py +++ b/engine/subaction.py @@ -202,7 +202,7 @@ def unpack(self,_action,_actor): return getattr(_actor, self.var) else: return None if self.source == 'object': - if self.var in hasattr(_actor, 'stats') and _actor.stats: + if hasattr(_actor, 'stats') and self.var in _actor.stats: return _actor.stats[self.var] elif self.var in _actor.variables: return _actor.variables[self.var] From 2687561916fbdfccc847a7a18228c516d2954d23 Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Sun, 1 May 2022 19:08:10 +0200 Subject: [PATCH 06/14] More fixes --- engine/abstractFighter.py | 4 ++-- engine/hitbox.py | 8 ++++---- engine/hurtbox.py | 2 +- engine/subactions/control/doTransition.py | 1 + engine/subactions/hitbox/createHitbox.py | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/engine/abstractFighter.py b/engine/abstractFighter.py index 037d56b..d35bdec 100644 --- a/engine/abstractFighter.py +++ b/engine/abstractFighter.py @@ -1188,8 +1188,8 @@ def keyHeld(self, _key, _from = None, _state = 0.1, _to = 0): """ if _from is None: _from = max(min(int(self.key_bindings.timing_window['buffer_window']), self.last_input_frame), 1) - down_frames = map(lambda k: _key in k and k[_key] >= _state, self.input_buffer.getLastNFrames(_from, _to)) - up_frames = map(lambda k: _key in k and k[_key] < _state, self.input_buffer.getLastNFrames(_from, _to)) + down_frames = list(map(lambda k: _key in k and k[_key] >= _state, self.input_buffer.getLastNFrames(_from, _to))) + up_frames = list(map(lambda k: _key in k and k[_key] < _state, self.input_buffer.getLastNFrames(_from, _to))) if not any(down_frames): return False if any(down_frames) and not any(up_frames): diff --git a/engine/hitbox.py b/engine/hitbox.py index 47bdf4b..2f8fc51 100644 --- a/engine/hitbox.py +++ b/engine/hitbox.py @@ -154,7 +154,7 @@ def onCollision(self,_other): offset = random.randrange(0, 359) hit_intersection = self.rect.clip(_other.rect).center hitlag = ((self.damage+self.charge_damage*self.charge) / 3.0 + 3.0)*self.hitlag_multiplier - from article import HitArticle + from engine.article import HitArticle for i in range(int(hitlag)): art = HitArticle(self.owner, hit_intersection, 0.5, offset+i*360/int(hitlag), 0.5*hitlag, .4, self.trail_color) self.owner.articles.append(art) @@ -209,7 +209,7 @@ def onCollision(self, _other): offset = random.randrange(0, 359) hit_intersection = self.rect.clip(_other.rect).center hitlag = ((self.damage+self.charge_damage*self.charge) / 3.0 + 3.0)*self.hitlag_multiplier - from article import HitArticle + from engine.article import HitArticle for i in range(int(hitlag)): art = HitArticle(self.owner, hit_intersection, 0.5, offset+i*360/int(hitlag), 0.5*hitlag, .4, self.trail_color) self.owner.articles.append(art) @@ -261,7 +261,7 @@ def onCollision(self, _other): offset = random.randrange(0, 359) hit_intersection = self.rect.clip(_other.rect).center hitlag = ((self.damage+self.charge_damage*self.charge) / 3.0 + 3.0)*self.hitlag_multiplier - from article import HitArticle + from engine.article import HitArticle for i in range(int(hitlag)): art = HitArticle(self.owner, hit_intersection, 0.5, offset+i*360/int(hitlag), 0.5*hitlag, .4, self.trail_color) self.owner.articles.append(art) @@ -313,7 +313,7 @@ def onCollision(self,_other): offset = random.randrange(0, 359) hit_intersection = self.rect.clip(_other.rect).center hitlag = ((self.damage+self.charge_damage*self.charge) / 3.0 + 3.0)*self.hitlag_multiplier - from article import HitArticle + from engine.article import HitArticle for i in range(int(hitlag)): art = HitArticle(self.owner, hit_intersection, 0.5, offset+i*360/int(hitlag), 0.5*hitlag, .4, self.trail_color) self.owner.articles.append(art) diff --git a/engine/hurtbox.py b/engine/hurtbox.py index a053b3a..5aa3cfe 100644 --- a/engine/hurtbox.py +++ b/engine/hurtbox.py @@ -62,7 +62,7 @@ def update(self): @_other: The hitbox that hit this hurtbox """ def onHit(self,_hitbox): - all_armor = self.armor.values()+self.owner.armor.values() + all_armor = set(self.armor.values()) | set(self.owner.armor.values()) # Use currying to composit everything together giant_filter = reduce(lambda f, g: (lambda j, k: g.filterHits(_hitbox, k, f)), all_armor, lambda x, y: self.owner.filterHits(x, y)) return giant_filter(_hitbox, _hitbox.getOnHitSubactions(self)) diff --git a/engine/subactions/control/doTransition.py b/engine/subactions/control/doTransition.py index ebb2ed0..745bb0c 100644 --- a/engine/subactions/control/doTransition.py +++ b/engine/subactions/control/doTransition.py @@ -1,4 +1,5 @@ from engine.subaction import * +import engine.baseActions as baseActions class transitionState(SubAction): subact_group = 'Control' diff --git a/engine/subactions/hitbox/createHitbox.py b/engine/subactions/hitbox/createHitbox.py index c23a34c..f037ad1 100644 --- a/engine/subactions/hitbox/createHitbox.py +++ b/engine/subactions/hitbox/createHitbox.py @@ -29,7 +29,7 @@ def execute(self, _action, _actor): if self.hitbox_name == '': return #Don't make a hitbox without a name or we'll lose it #Use an existing hitbox lock by name, or create a new one - if self.hitbox_lock in self.hitbox_lock and _action.hitbox_locks: + if self.hitbox_lock and self.hitbox_lock in _action.hitbox_locks: hitbox_lock = _action.hitbox_locks[self.hitbox_lock] else: hitbox_lock = engine.hitbox.HitboxLock(self.hitbox_lock) From d7c18e4b7369745bc16d6dbbc60485b68ac8d52d Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Mon, 2 May 2022 20:29:42 +0200 Subject: [PATCH 07/14] Importlib an dbuilder fixes --- builder/builderWindow.py | 16 +++++++++++----- main.py | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/builder/builderWindow.py b/builder/builderWindow.py index a7d50d9..dcd1f7b 100755 --- a/builder/builderWindow.py +++ b/builder/builderWindow.py @@ -6,15 +6,21 @@ import settingsManager import inspect import engine.abstractFighter -import subactionSelector +import builder.subactionSelector import engine.subaction import xml.etree.ElementTree as ElementTree -from Tkinter import * -from tkFileDialog import askopenfile -from tkMessageBox import showinfo +if sys.version_info[0] == 3: + from tkinter import * + from tkinter.filedialog import askopenfile + from tkinter.messagebox import showinfo + from tkinter import ttk +else: + from Tkinter import * + from tkFileDialog import askopenfile + from tkMessageBox import showinfo + import ttk from shutil import copyfile import stages.training_stage.stage -import ttk import builder.dataSelector as dataSelector from engine.abstractFighter import AbstractFighter diff --git a/main.py b/main.py index 73a6638..53beea2 100755 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from __future__ import print_function import pygame -import imp +import importlib import os import sys import traceback @@ -45,7 +45,7 @@ def importFromURI(filePath, uri, absl=False, _suffix=""): if os.path.exists(no_ext + '.py'): try: - return imp.load_source((mname + _suffix), no_ext + '.py') + return importlib.machinery.SourceFileLoader((mname + _suffix), no_ext + '.py').load_module() except Exception as e: print(mname, e) From d55faaf86a99aabe2293861729b8fc41a424362d Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Mon, 2 May 2022 20:29:58 +0200 Subject: [PATCH 08/14] CollisionBox fix --- engine/collisionBox.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/engine/collisionBox.py b/engine/collisionBox.py index 737cb3f..228b18c 100644 --- a/engine/collisionBox.py +++ b/engine/collisionBox.py @@ -321,19 +321,23 @@ def normalize(self): sizes = self.actor.ecb_size offsets = self.actor.ecb_offset - if sizes[0] == 0: - self.current_ecb.rect.width = self.actor.sprite.bounding_rect.width - else: - self.current_ecb.rect.width = sizes[0] - if sizes[1] == 0: - self.current_ecb.rect.height = self.actor.sprite.bounding_rect.height - else: - self.current_ecb.rect.height = sizes[1] + sizes = list(sizes) + offsets = list(offsets) - self.current_ecb.rect.center = self.actor.sprite.bounding_rect.center + if sizes and offsets: + if sizes[0] == 0: + self.current_ecb.rect.width = self.actor.sprite.bounding_rect.width + else: + self.current_ecb.rect.width = sizes[0] + if sizes[1] == 0: + self.current_ecb.rect.height = self.actor.sprite.bounding_rect.height + else: + self.current_ecb.rect.height = sizes[1] + + self.current_ecb.rect.center = self.actor.sprite.bounding_rect.center - self.current_ecb.rect.x += offsets[0] - self.current_ecb.rect.y += offsets[1] + self.current_ecb.rect.x += offsets[0] + self.current_ecb.rect.y += offsets[1] def draw(self,_screen,_offset,_scale): self.current_ecb.draw(_screen,self.actor.game_state.stageToScreen(self.current_ecb.rect),_scale) From 1ff6d4f4e082548955ec518323d7f4dcd5f9d842 Mon Sep 17 00:00:00 2001 From: PaK Zer0 Date: Sat, 12 Nov 2022 01:24:57 +0100 Subject: [PATCH 09/14] Auto 2to3 --- battle.py | 2 +- builder/builderWindow.py | 24 +++++++++++----------- builder/dataSelector.py | 4 ++-- builder/subactionSelector.py | 22 ++++++++++---------- engine/abstractFighter.py | 4 ++-- engine/action.py | 12 +++++------ engine/actionLoader.py | 6 +++--- engine/article.py | 10 ++++----- engine/baseActions.py | 16 +++++++-------- engine/controller.py | 6 +++--- engine/cpuPlayer.py | 2 +- engine/hitbox.py | 2 +- engine/hurtbox.py | 4 ++-- engine/network.py | 6 +++--- engine/optimize_dirty_rects.py | 2 +- engine/subaction.py | 6 +++--- engine/subactions/armor/createArmor.py | 2 +- engine/subactions/armor/modifyArmor.py | 6 +++--- engine/subactions/base_subactions.py | 12 +++++------ engine/subactions/hitbox/createHitbox.py | 2 +- engine/subactions/hitbox/modifyHitbox.py | 4 ++-- engine/subactions/hurtbox/createHurtbox.py | 2 +- engine/subactions/hurtbox/modifyHurtbox.py | 4 ++-- menu/mainMenu.py | 8 ++++---- menu/panel.py | 2 +- server.py | 2 +- settingsManager.py | 12 +++++------ spriteManager.py | 8 ++++---- 28 files changed, 96 insertions(+), 96 deletions(-) diff --git a/battle.py b/battle.py index f1138b4..2a5b1db 100644 --- a/battle.py +++ b/battle.py @@ -432,7 +432,7 @@ def endBattle(self,_exitStatus): dist = 48 print(fighter.data_log.data) - for item,val in fighter.data_log.data.items(): + for item,val in list(fighter.data_log.data.items()): text = spriteManager.TextSprite(str(item) + ': ' + str(val)) result_sprite.image.blit(text.image,(0,dist)) dist += 16 diff --git a/builder/builderWindow.py b/builder/builderWindow.py index dcd1f7b..2ab420f 100755 --- a/builder/builderWindow.py +++ b/builder/builderWindow.py @@ -245,7 +245,7 @@ def saveFighter(self): global action global changed_actions - for actName, new_action in changed_actions.items(): + for actName, new_action in list(changed_actions.items()): if hasattr(fighter.actions, 'modifyAction'): fighter.actions.modifyAction(actName, new_action) if hasattr(fighter.actions,'saveActions'): @@ -639,7 +639,7 @@ def refreshDropdowns(self): global changed_actions global action - for changed_action in changed_actions.keys(): + for changed_action in list(changed_actions.keys()): if not changed_action in self.act_list: self.act_list.append(changed_action) @@ -651,7 +651,7 @@ def refreshDropdowns(self): else: self.group_list = self.default_group_list[:] if action and isinstance(action, engine.action.Action): - for group in action.events.keys(): + for group in list(action.events.keys()): self.group_list.append('Cond: '+ group) self.action.destroy() @@ -746,7 +746,7 @@ def printNode(self,_node,_prefix=''): text += _node.text.lstrip() if _node.text is not None else '' if len(_node.attrib) > 0: #if it has attributes text += ' (' - for name,atr in _node.attrib.items(): + for name,atr in list(_node.attrib.items()): text+=name+': '+str(atr) text+=',' text = text[:-1] #chop off the last comma @@ -810,7 +810,7 @@ def groupChanged(self,*_args): self.showSubactionList() elif self.group == 'Attributes': - for tag,val in fighter.var.items(): + for tag,val in list(fighter.var.items()): panel = subactionSelector.SubactionSelector(self.scroll_frame,[(tag,type(val).__name__,fighter.var,tag)],tag+': '+str(val)) self.subaction_list.append(panel) @@ -915,7 +915,7 @@ def __init__(self,_parent,_root): 'Article': self.article_window } - for name,window in subact_windows.items(): + for name,window in list(subact_windows.items()): self.new_subaction_frame.add(window,text=name) subaction_lists = {'Control':[], @@ -924,13 +924,13 @@ def __init__(self,_parent,_root): 'Hitbox':[], 'Article':[]} - for name,subact in engine.subaction.SubactionFactory.subaction_dict.items(): - if subact.subact_group in subact_windows.keys(): + for name,subact in list(engine.subaction.SubactionFactory.subaction_dict.items()): + if subact.subact_group in list(subact_windows.keys()): short_name = (name[:19] + '..') if len(name) > 22 else name button = Button(subact_windows[subact.subact_group],text=short_name,command=lambda subaction=subact: self.addSubaction(subaction)) subaction_lists[subact.subact_group].append(button) - for group in subaction_lists.values(): + for group in list(subaction_lists.values()): x = 0 y = 0 for button in group: @@ -1047,11 +1047,11 @@ def __init__(self,_parent,_root): 'Actions': fighter_actions } - for name,window in self.panel_windows.items(): + for name,window in list(self.panel_windows.items()): self.add(window,text=name,sticky=N+S+E+W) def addActionPane(self,_actionName): - if not _actionName in self.panel_windows.keys(): + if not _actionName in list(self.panel_windows.keys()): actionPanel = ActionPanel(self,self.root,_actionName) self.panel_windows[_actionName] = actionPanel self.add(actionPanel,text=_actionName,sticky=N+S+E+W) @@ -1233,7 +1233,7 @@ def __init__(self,_parent,_root,_actionName): lastGroup.childElements.append(dataSelector.NewSubactionLine(self,self.interior)) self.data_list.append(lastGroup) - for name,event in self.action.events.items(): + for name,event in list(self.action.events.items()): eventGroup = dataSelector.GroupLine(self,self.interior,'Event: '+name) for subact in event: eventGroup.childElements.append(subact.getDataLine(self)) diff --git a/builder/dataSelector.py b/builder/dataSelector.py index e542d6c..21eaf34 100644 --- a/builder/dataSelector.py +++ b/builder/dataSelector.py @@ -384,7 +384,7 @@ def __init__(self,_root,_parent,_name,_target_object,_varname): sprite_vals = ['No Sprites found'] if self.root.getFighter(): - sprite_vals = self.root.getFighter().sprite.image_library["right"].keys() + sprite_vals = list(self.root.getFighter().sprite.image_library["right"].keys()) self.sprite_entry = OptionMenu(self,self.sprite_data,*sprite_vals) self.sprite_entry.config(width=18) @@ -713,7 +713,7 @@ def __init__(self,_root,_parent,_name,_target_object,_varname): self.target_object = _target_object self.var_name = _varname - self.tran_list = engine.baseActions.state_dict.keys() + self.tran_list = list(engine.baseActions.state_dict.keys()) self.tran_data = StringVar() self.tran_entry = OptionMenu(self,self.tran_data,*self.tran_list) diff --git a/builder/subactionSelector.py b/builder/subactionSelector.py index dc077c2..323b9a2 100644 --- a/builder/subactionSelector.py +++ b/builder/subactionSelector.py @@ -131,7 +131,7 @@ def __init__(self,_root,_attribSet): elif vartype == 'sprite': attrib_var = StringVar(self) attrib_var.set(self.getFromAttrib(obj, prop)) - attrib_entry = OptionMenu(self,attrib_var,*self.root.getFighter().sprite.image_library["right"].keys()) + attrib_entry = OptionMenu(self,attrib_var,*list(self.root.getFighter().sprite.image_library["right"].keys())) else: attrib_var = StringVar(self) attrib_var.set(str(self.getFromAttrib(obj, prop))) @@ -216,7 +216,7 @@ def getVar(self,_name): return self.variable_list[_name] def initVars(self): - for (val,var) in self.variable_list.items(): + for (val,var) in list(self.variable_list.items()): var.set(getattr(self.subaction,val)) var.trace('w',lambda name1, name2, op, variable=var, varname=val: self.variableChanged(variable, varname, name1, name2, op)) @@ -256,7 +256,7 @@ def __init__(self,_root,_subaction): value_type_entry = OptionMenu(self,self.value_type_var,*['string','int','float','bool']) conditionals = [''] - conditionals.extend(_root.getAction().conditional_actions.keys()) + conditionals.extend(list(_root.getAction().conditional_actions.keys())) if_entry = OptionMenu(self,self.getVar('if_actions'),*conditionals) else_entry = OptionMenu(self,self.getVar('else_actions'),*conditionals) @@ -305,7 +305,7 @@ def __init__(self,_root,_subaction): buffer_entry = Spinbox(self,textvariable=self.getVar('buffer_time'),from_=0,to=255) conditionals = [''] - conditionals.extend(_root.getAction().conditional_actions.keys()) + conditionals.extend(list(_root.getAction().conditional_actions.keys())) if_entry = OptionMenu(self,self.getVar('if_actions'),*conditionals) else_entry = OptionMenu(self,self.getVar('else_actions'),*conditionals) @@ -331,7 +331,7 @@ def __init__(self,_root,_subaction): sprite_vals = ['No Sprites found'] if _root.getFighter(): - sprite_vals = _root.getFighter().sprite.image_library["right"].keys() + sprite_vals = list(_root.getFighter().sprite.image_library["right"].keys()) sprites = OptionMenu(self,self.sprite_choice,*sprite_vals) sprites.config(width=18) @@ -435,7 +435,7 @@ def yUnchangedChanged(self,*_args): self.root.root.actionModified() def initVars(self): - for (val,var) in self.variable_list.items(): + for (val,var) in list(self.variable_list.items()): newval = getattr(self.subaction,val) if newval is None: var.set(0) else: var.set(newval) @@ -529,7 +529,7 @@ def yUnchangedChanged(self,*_args): self.root.root.actionModified() def initVars(self): - for (val,var) in self.variable_list.items(): + for (val,var) in list(self.variable_list.items()): newval = getattr(self.subaction,val) if newval is None: var.set(0) else: var.set(newval) @@ -614,7 +614,7 @@ def yUnchangedChanged(self,*_args): self.root.root.actionModified() def initVars(self): - for (val,var) in self.variable_list.items(): + for (val,var) in list(self.variable_list.items()): newval = getattr(self.subaction,val) if newval is None: var.set(0) else: var.set(newval) @@ -707,7 +707,7 @@ def __init__(self,_root,_subaction): self.addVariable(StringVar, 'transition') transition_label = Label(self,text='Transition State:') import engine - transition_entry = OptionMenu(self,self.getVar('transition'),*engine.baseActions.state_dict.keys()) + transition_entry = OptionMenu(self,self.getVar('transition'),*list(engine.baseActions.state_dict.keys())) self.initVars() @@ -858,7 +858,7 @@ def __init__(self, _parent, _newHitbox=False): else: hitbox_vals = ['No Hitboxes found'] if _parent.root.getAction(): - hitbox_vals = _parent.root.getAction().hitboxes.keys() + hitbox_vals = list(_parent.root.getAction().hitboxes.keys()) name_entry = OptionMenu(self,self.hitbox_name,*hitbox_vals) type_entry = Entry(self,textvariable=self.hitbox_type,state=DISABLED) @@ -940,7 +940,7 @@ def __init__(self,_root,_subaction): hitbox_vals = ['No Hitboxes found'] if _root.getAction(): - hitbox_vals = _root.getAction().hitboxes.keys() + hitbox_vals = list(_root.getAction().hitboxes.keys()) hitbox_label = Label(self,text="Hitbox:") hitbox_entry = OptionMenu(self,self.getVar('hitbox_name'),*hitbox_vals) diff --git a/engine/abstractFighter.py b/engine/abstractFighter.py index d35bdec..9dc9abb 100644 --- a/engine/abstractFighter.py +++ b/engine/abstractFighter.py @@ -338,7 +338,7 @@ def createElement(_tag,_val): color_elem = ElementTree.Element('color_palette') color_elem.attrib['id'] = str(i) color_elem.attrib['displayColor'] = '#000000' - for from_color,to_color in color_dict.items(): + for from_color,to_color in list(color_dict.items()): map_elem = ElementTree.Element('color_map') map_elem.attrib['from_color'] = '#%02x%02x%02x' % from_color map_elem.attrib['to_color'] = '#%02x%02x%02x' % to_color @@ -350,7 +350,7 @@ def createElement(_tag,_val): if not costume == self.sprite_prefix: tree.append(createElement('costume', costume)) - for tag,val in self.stats.items(): + for tag,val in list(self.stats.items()): stats_elem.append(createElement(tag, val)) tree.append(stats_elem) diff --git a/engine/action.py b/engine/action.py index e5fd67a..59aa20b 100644 --- a/engine/action.py +++ b/engine/action.py @@ -62,9 +62,9 @@ def update(self,_actor): _actor.changeSpriteImage((self.frame // self.sprite_rate)-1, _loop=self.loop) else: _actor.changeSpriteImage(self.frame // self.sprite_rate, _loop=self.loop) - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() - for hurtbox in self.hurtboxes.values(): + for hurtbox in list(self.hurtboxes.values()): hurtbox.update() def updateAnimationOnly(self,_actor): @@ -96,9 +96,9 @@ def updateAnimationOnly(self,_actor): else: _actor.changeSpriteImage(self.frame // self.sprite_rate, _loop=self.loop) - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() - for hurtbox in self.hurtboxes.values(): + for hurtbox in list(self.hurtboxes.values()): hurtbox.update() self.frame += 1 @@ -122,9 +122,9 @@ def setUp(self,_actor): _actor.activateHurtbox(self.hurtboxes['auto']) def tearDown(self,_actor,_nextAction): - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.kill() - for hurtbox in self.hurtboxes.values(): + for hurtbox in list(self.hurtboxes.values()): hurtbox.kill() for act in self.tear_down_actions: act.execute(self,_actor) diff --git a/engine/actionLoader.py b/engine/actionLoader.py index e80ccfc..c0799db 100644 --- a/engine/actionLoader.py +++ b/engine/actionLoader.py @@ -86,7 +86,7 @@ def modifyAction(self,_actionName,_newAction): if _newAction.default_vars: vars_elem = ElementTree.Element('vars') - for tag,val in _newAction.default_vars.items(): + for tag,val in list(_newAction.default_vars.items()): new_elem = ElementTree.Element(tag) new_elem.attrib['type'] = type(val).__name__ new_elem.text = str(val) @@ -145,7 +145,7 @@ def modifyAction(self,_actionName,_newAction): frameElem.append(subact.getXmlElement()) elem.append(frameElem) - for event_name,event in _newAction.events.items(): + for event_name,event in list(_newAction.events.items()): if len(event) > 0: event_elem = ElementTree.Element('Event') event_elem.attrib['name'] = str(event_name) @@ -334,7 +334,7 @@ def loadAction(self,_actionName): dyn_action.loop = loop dyn_action.default_vars = action_vars - for key,val in action_vars.items(): + for key,val in list(action_vars.items()): setattr(dyn_action,key,val) return dyn_action diff --git a/engine/article.py b/engine/article.py index f14972f..10a6f91 100644 --- a/engine/article.py +++ b/engine/article.py @@ -110,7 +110,7 @@ def update(self, *args): #Ignores actor self.posx += self.change_x self.posy += self.change_y - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() for act in self.actions_after_frame: @@ -153,7 +153,7 @@ def updateAnimationOnly(self, *args): #Ignores actor else: self.sprite.getImageAtIndex(self.frame // self.sprite_rate) - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() self.frame += 1 @@ -181,7 +181,7 @@ def activate(self): act.execute(self,self) def deactivate(self): - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.kill() for act in self.tear_down_actions: act.execute(self,self) @@ -280,7 +280,7 @@ def onClank(self,_actor,_hitbox,_other): def onCollision(self,_other): others_classes = list(map(lambda x :x.__name__,_other.__class__.__bases__)) + [_other.__class__.__name__] - for classKey,subacts in self.collision_actions.items(): + for classKey,subacts in list(self.collision_actions.items()): if (classKey in others_classes): for subact in subacts: subact.execute(_other,self) @@ -393,7 +393,7 @@ def applySubactions(self, _subacts): def changeOwner(self, _newOwner): self.owner = _newOwner - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.owner = _newOwner def activateHitbox(self,_hitbox): diff --git a/engine/baseActions.py b/engine/baseActions.py index 7c82a13..b8cf7af 100644 --- a/engine/baseActions.py +++ b/engine/baseActions.py @@ -1760,12 +1760,12 @@ def __init__(self, _length=1): def tearDown(self, _actor, _nextAction): action.Action.tearDown(self, _actor, _nextAction) - for _,hitbox in self.hitboxes.items(): + for _,hitbox in list(self.hitboxes.items()): hitbox.kill() def onClank(self, _actor, _hitbox, _other): action.Action.onClank(self, _actor, _hitbox, _other) - for _,hitbox in self.hitboxes.items(): + for _,hitbox in list(self.hitboxes.items()): hitbox.kill() def stateTransitions(self, _actor): @@ -1778,7 +1778,7 @@ def stateTransitions(self, _actor): def update(self, _actor): action.Action.update(self, _actor) - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() self.frame += 1 @@ -1793,7 +1793,7 @@ def setUp(self, _actor): self.fastfall_frame = None def onClank(self, _actor, _hitbox, _other): - for _,hitbox in self.hitboxes.items(): + for _,hitbox in list(self.hitboxes.items()): hitbox.kill() def stateTransitions(self, _actor): @@ -1876,7 +1876,7 @@ def __init__(self,_length=0): def setUp(self, _actor): BaseAttack.setUp(self, _actor) from engine import subactions - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): if not hitbox.owner_on_hit_actions: if _actor.hasAction('GrabReeling'): hitbox.owner_on_hit_actions.append(subactions.control.doAction.doAction('GrabReeling')) else: hitbox.owner_on_hit_actions.append(subactions.control.doAction.doAction('Grabbing')) @@ -1889,7 +1889,7 @@ def __init__(self,_length=0): def setUp(self, _actor): BaseAttack.setUp(self, _actor) from engine import subactions - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): if not hitbox.owner_on_hit_actions: if _actor.hasAction('GrabReeling'): hitbox.owner_on_hit_actions.append(subactions.control.doAction.doAction('GrabReeling')) else: hitbox.owner_on_hit_actions.append(subactions.control.doAction.doAction('Grabbing')) @@ -1944,7 +1944,7 @@ def stateTransitions(self, _actor): else: _actor.doAction('Fall') def update(self, _actor): - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() BaseGrab.update(self, _actor) self.frame += 1 @@ -1959,7 +1959,7 @@ def stateTransitions(self, _actor): _actor.doAction('Grabbing') def update(self, _actor): - for hitbox in self.hitboxes.values(): + for hitbox in list(self.hitboxes.values()): hitbox.update() BaseGrab.update(self, _actor) self.frame += 1 diff --git a/engine/controller.py b/engine/controller.py index 23a8b0d..0a20ef6 100644 --- a/engine/controller.py +++ b/engine/controller.py @@ -55,7 +55,7 @@ def passInputs(self): def getKeysForAction(self,_action): list_of_bindings = [] - for binding,name in self.key_bindings.items(): + for binding,name in list(self.key_bindings.items()): if name == _action: list_of_bindings.append(settingsManager.getSetting().key_id_map[binding]) return list_of_bindings @@ -160,10 +160,10 @@ def getButtonInput(self,_joy,_button): def getKeysForAction(self,_action): list_of_bindings = [] - for button,name in self.button_bindings.items(): + for button,name in list(self.button_bindings.items()): if name == _action: list_of_bindings.append('Button ' + str(button)) - for axis,(neg,pos) in self.axis_bindings.items(): + for axis,(neg,pos) in list(self.axis_bindings.items()): if pos == _action: list_of_bindings.append('Axis ' + str(axis) + ' Positive') if neg == _action: diff --git a/engine/cpuPlayer.py b/engine/cpuPlayer.py index 8162fdd..42ad8d3 100644 --- a/engine/cpuPlayer.py +++ b/engine/cpuPlayer.py @@ -39,7 +39,7 @@ def getPathDistance(self, _startPoint, _endPoint): estimates = {0: math.sqrt((_startPoint[0]-_endPoint[0])**2+(_startPoint[1]-_endPoint[1])**2)} while (len(open_set) > 0): - current = min(filter(lambda n: n[0] in open_set, estimates.items()), key=lambda x: x[1])[0] #Current now has the farthest-off point + current = min(filter(lambda n: n[0] in open_set, list(estimates.items())), key=lambda x: x[1])[0] #Current now has the farthest-off point if current == 1: break diff --git a/engine/hitbox.py b/engine/hitbox.py index 2f8fc51..bc24929 100644 --- a/engine/hitbox.py +++ b/engine/hitbox.py @@ -57,7 +57,7 @@ def __init__(self,_owner,_lock,_variables = dict()): #set the variables from the dict, so that we don't lose the initial value of the dict when modifying them #also lets us not have to go update all the old references. Score! - for key,value in self.variable_dict.items(): + for key,value in list(self.variable_dict.items()): setattr(self, key, value) #Flip the distance from center if the fighter is facing the _other way diff --git a/engine/hurtbox.py b/engine/hurtbox.py index 5aa3cfe..8305ff1 100644 --- a/engine/hurtbox.py +++ b/engine/hurtbox.py @@ -23,7 +23,7 @@ def __init__(self,_owner,_variables = dict()): #set the variables from the dict, so that we don't lose the initial value of the dict when modifying them #also lets us not have to go update all the old references. Score! - for key,value in self.variable_dict.items(): + for key,value in list(self.variable_dict.items()): setattr(self, key, value) fix_center = self.getFixCenter() @@ -92,7 +92,7 @@ def __init__(self, _owner, _variables = dict()): #set the variables from the dict, so that we don't lose the initial value of the dict when modifying them #also lets us not have to go update all the old references. Score! - for key,value in self.variable_dict.items(): + for key,value in list(self.variable_dict.items()): setattr(self, key, value) def filterHits(self,_hitbox,_subactions,_forward): diff --git a/engine/network.py b/engine/network.py index ebfde2b..1192849 100644 --- a/engine/network.py +++ b/engine/network.py @@ -30,7 +30,7 @@ def fromString(self,msg): self.frame = int(evtSplit[2]) self.json = evtSplit[3] evt.type = self.type - jsondict = json.loads(self.json).items() + jsondict = list(json.loads(self.json).items()) for attr,val in jsondict: setattr(evt,attr,val) return evt @@ -92,7 +92,7 @@ def __init__(self): self.receivedFrom = {} def getEvents(self): self.eventList = [] - for k,v in self.receivedFrom.items(): + for k,v in list(self.receivedFrom.items()): for e in v: self.eventList.append(e) return self.eventList @@ -355,7 +355,7 @@ def processFighters(self,fighters): #hit_tagged = None#??""" self.send(msg.toString(), (self.serveraddr, self.serverport)) for fighter_message in nextFighterList: - fighter_data = json.loads(fighter_message.json).items() + fighter_data = list(json.loads(fighter_message.json).items()) print("updating fighter"+str(fighter_data.frame)+" "+str(self.tick_count)) for f in fighters: for attr,val in fighter_data: diff --git a/engine/optimize_dirty_rects.py b/engine/optimize_dirty_rects.py index 56eff7b..2f29929 100644 --- a/engine/optimize_dirty_rects.py +++ b/engine/optimize_dirty_rects.py @@ -1427,7 +1427,7 @@ def optimize_dirty_rects(dirty_rects): if PYTHON_VERSION >= 3: return_list = list(r_dict.values()) else: - return_list = r_dict.values() + return_list = list(r_dict.values()) #####debug('OUTPUT: ' + str(return_list) + '\n') return return_list diff --git a/engine/subaction.py b/engine/subaction.py index 2de8f40..2df4361 100644 --- a/engine/subaction.py +++ b/engine/subaction.py @@ -98,7 +98,7 @@ def initialize(self): 'deactivateSelf': deactivateSelf.deactivateSelf } - self.name_dict = {v: k for k, v in self.subaction_dict.items()} #reverse the above so a class object gets you the string + self.name_dict = {v: k for k, v in list(self.subaction_dict.items())} #reverse the above so a class object gets you the string self.initialized = True @@ -240,7 +240,7 @@ def __init__(self,_source,_functionName,_args): self.args = _args def unpack(self,_action,_actor): - for argname,arg in self.args.items(): + for argname,arg in list(self.args.items()): if isinstance(arg, FuncData) or isinstance(arg, VarData) or isinstance(arg, EvalData): self.args[argname] = arg.unpack(_action,_actor) @@ -479,7 +479,7 @@ def __init__(self): self.defaultVars = dict() def execute(self, _action, _actor): - for tag,variable in self.defaultVars.items(): + for tag,variable in list(self.defaultVars.items()): if isinstance(variable, VarData) or isinstance(variable, FuncData) or isinstance(variable, EvalData): setattr(self, tag, variable.unpack(_action,_actor)) diff --git a/engine/subactions/armor/createArmor.py b/engine/subactions/armor/createArmor.py index 3fcac73..d8fa102 100644 --- a/engine/subactions/armor/createArmor.py +++ b/engine/subactions/armor/createArmor.py @@ -54,7 +54,7 @@ def getXmlElement(self): hurtbox_elem = ElementTree.Element('hurtbox') hurtbox_elem.text = self.hurtbox elem.append(hurtbox_elem) - for tag,value in self.armor_vars.items(): + for tag,value in list(self.armor_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/armor/modifyArmor.py b/engine/subactions/armor/modifyArmor.py index 58fe50b..6a5d5b2 100644 --- a/engine/subactions/armor/modifyArmor.py +++ b/engine/subactions/armor/modifyArmor.py @@ -16,7 +16,7 @@ def execute(self, _action, _actor): if self.armor_name in hurtbox.armor: armor = hurtbox.armor[self.armor_name] if armor: - for name,value in self.hitbox_vars.items(): + for name,value in list(self.hitbox_vars.items()): if hasattr(armor, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(armor, name, value.unpack(_action,_actor)) @@ -29,7 +29,7 @@ def execute(self, _action, _actor): else: if self.armor_name in _actor.armor: armor = _actor.armor[self.armor_name] - for name,value in self.hitbox_vars.items(): + for name,value in list(self.hitbox_vars.items()): if hasattr(armor, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(armor, name, value.unpack(_action,_actor)) @@ -49,7 +49,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyArmor') elem.attrib['name'] = self.armor_name - for tag,value in self.armor_vars.items(): + for tag,value in list(self.armor_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/base_subactions.py b/engine/subactions/base_subactions.py index ce383da..1b89643 100644 --- a/engine/subactions/base_subactions.py +++ b/engine/subactions/base_subactions.py @@ -1034,7 +1034,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hitbox_name elem.append(name_elem) - for tag,value in self.hitbox_vars.items(): + for tag,value in list(self.hitbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1099,7 +1099,7 @@ def execute(self, _action, _actor): if self.hitbox_name in _action.hitboxes: hitbox = _action.hitboxes[self.hitbox_name] if hitbox: - for name,value in self.hitbox_vars.items(): + for name,value in list(self.hitbox_vars.items()): if hasattr(hitbox, name): if isinstance(value, subaction.VarData) or isinstance(value, subaction.FuncData) or isinstance(value, subaction.EvalData): setattr(hitbox, name, value.unpack(_action,_actor)) @@ -1119,7 +1119,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHitbox') elem.attrib['name'] = self.hitbox_name - for tag,value in self.hitbox_vars.items(): + for tag,value in list(self.hitbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1279,7 +1279,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hurtbox_name elem.append(name_elem) - for tag,value in self.hurtbox_vars.items(): + for tag,value in list(self.hurtbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) @@ -1320,7 +1320,7 @@ def execute(self, _action, _actor): if self.hurtbox_name in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox_name] if hurtbox: - for name,value in self.hurtbox_vars.items(): + for name,value in list(self.hurtbox_vars.items()): if hasattr(hurtbox, name): if isinstance(value, subaction.VarData) or isinstance(value, subaction.FuncData) or isinstance(value, subaction.EvalData): setattr(hurtbox, name, value.unpack(_action,_actor)) @@ -1336,7 +1336,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHurtbox') elem.attrib['name'] = self.hurtbox_name - for tag,value in self.hurtbox_vars.items(): + for tag,value in list(self.hurtbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/hitbox/createHitbox.py b/engine/subactions/hitbox/createHitbox.py index f037ad1..2fac6f2 100644 --- a/engine/subactions/hitbox/createHitbox.py +++ b/engine/subactions/hitbox/createHitbox.py @@ -82,7 +82,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hitbox_name elem.append(name_elem) - for tag,value in self.hitbox_vars.items(): + for tag,value in list(self.hitbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/hitbox/modifyHitbox.py b/engine/subactions/hitbox/modifyHitbox.py index d7f77f6..995af79 100644 --- a/engine/subactions/hitbox/modifyHitbox.py +++ b/engine/subactions/hitbox/modifyHitbox.py @@ -14,7 +14,7 @@ def execute(self, _action, _actor): if self.hitbox_name in _action.hitboxes: hitbox = _action.hitboxes[self.hitbox_name] if hitbox: - for name,value in self.hitbox_vars.items(): + for name,value in list(self.hitbox_vars.items()): if hasattr(hitbox, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(hitbox, name, value.unpack(_action,_actor)) @@ -34,7 +34,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHitbox') elem.attrib['name'] = self.hitbox_name - for tag,value in self.hitbox_vars.items(): + for tag,value in list(self.hitbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/hurtbox/createHurtbox.py b/engine/subactions/hurtbox/createHurtbox.py index 2c7f5a2..17894b4 100644 --- a/engine/subactions/hurtbox/createHurtbox.py +++ b/engine/subactions/hurtbox/createHurtbox.py @@ -29,7 +29,7 @@ def getXmlElement(self): name_elem = ElementTree.Element('name') name_elem.text = self.hurtbox_name elem.append(name_elem) - for tag,value in self.hurtbox_vars.items(): + for tag,value in list(self.hurtbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/engine/subactions/hurtbox/modifyHurtbox.py b/engine/subactions/hurtbox/modifyHurtbox.py index b73ac65..1058f62 100644 --- a/engine/subactions/hurtbox/modifyHurtbox.py +++ b/engine/subactions/hurtbox/modifyHurtbox.py @@ -14,7 +14,7 @@ def execute(self, _action, _actor): if self.hurtbox_name in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox_name] if hurtbox: - for name,value in self.hurtbox_vars.items(): + for name,value in list(self.hurtbox_vars.items()): if hasattr(hurtbox, name): if isinstance(value, VarData) or isinstance(value, FuncData) or isinstance(value, EvalData): setattr(hurtbox, name, value.unpack(_action,_actor)) @@ -30,7 +30,7 @@ def getPropertiesPanel(self, _root): def getXmlElement(self): elem = ElementTree.Element('modifyHurtbox') elem.attrib['name'] = self.hurtbox_name - for tag,value in self.hurtbox_vars.items(): + for tag,value in list(self.hurtbox_vars.items()): new_elem = ElementTree.Element(tag) new_elem.text = str(value) elem.append(new_elem) diff --git a/menu/mainMenu.py b/menu/mainMenu.py index 8c23af7..44db6e3 100644 --- a/menu/mainMenu.py +++ b/menu/mainMenu.py @@ -668,7 +668,7 @@ def executeMenu(self, _screen): def bindControls(self,_screen): key_id_map = {} - for name, value in vars(pygame.constants).items(): + for name, value in list(vars(pygame.constants).items()): if name.startswith("K_"): key_id_map[value] = name @@ -1113,7 +1113,7 @@ def executeMenu(self,_screen): if event.type == QUIT: self.status = -1 - for key_name,key_value in holding.items(): + for key_name,key_value in list(holding.items()): if key_value and can_press: can_press = False pygame.time.set_timer(pygame.USEREVENT+1,200) @@ -1228,7 +1228,7 @@ class RebindMenu(SubMenu): def __init__(self,_parent): self.key_id_map = {} self.key_name_map = {} - for name, value in vars(pygame.constants).items(): + for name, value in list(vars(pygame.constants).items()): if name.startswith("K_"): self.key_id_map[value] = name self.key_name_map[name] = value @@ -1320,7 +1320,7 @@ def executeMenu(self,_screen): if event.type == pygame.USEREVENT+1: can_press = True; - for key_name,key_value in holding.items(): + for key_name,key_value in list(holding.items()): if key_value and can_press: can_press = False pygame.time.set_timer(pygame.USEREVENT+1,150) diff --git a/menu/panel.py b/menu/panel.py index 4dcdcf4..062166e 100644 --- a/menu/panel.py +++ b/menu/panel.py @@ -148,7 +148,7 @@ def setValue(self, _newSelect, _newDict=None): self.selection = _newSelect def getValue(self): - return self.option_dict.keys()[selection] + return list(self.option_dict.keys())[selection] def gainFocus(self, _event): if _event.type == pygame.MOUSEBUTTONDOWN and self.getcoordinatesatpixel(_event.pos[0]-self.corner[0]. _event.pos[1]-self.corner[1]) != (None, None): diff --git a/server.py b/server.py index 585f6e8..f130a7f 100644 --- a/server.py +++ b/server.py @@ -80,7 +80,7 @@ def handleMessage(self,msg,addr): else: print("progress message from unknown player: " + str(addr)) allClientsHaveSameFrame = True - for player in self.players.values(): + for player in list(self.players.values()): if player['nextframe']!=self.tick: allClientsHaveSameFrame = False if allClientsHaveSameFrame: diff --git a/settingsManager.py b/settingsManager.py index ff27579..f8ebf57 100644 --- a/settingsManager.py +++ b/settingsManager.py @@ -125,7 +125,7 @@ class Settings(): def __init__(self): self.key_id_map = {} self.key_name_map = {} - for name, value in vars(pygame.constants).items(): + for name, value in list(vars(pygame.constants).items()): if name.startswith("K_"): self.key_id_map[value] = name.lower() self.key_name_map[name.lower()] = value @@ -253,7 +253,7 @@ def loadControls(self): 'smoothing_window': 64 } - for key in timing_window.keys(): + for key in list(timing_window.keys()): if self.parser.has_option(group_name, key): timing_window[key] = int(self.parser.get(group_name,key)) @@ -344,7 +344,7 @@ def getGamepadByName(self,_joyName): def saveSettings(_settings): key_id_map = {} key_nameMap = {} - for name, value in vars(pygame.constants).items(): + for name, value in list(vars(pygame.constants).items()): if name.startswith("K_"): key_id_map[value] = name key_nameMap[name] = value @@ -385,7 +385,7 @@ def saveSettings(_settings): for key in _settings[sect].key_bindings: parser.set(sect,'controlType',_settings['controlType_'+str(i)]) parser.set(sect,key_id_map[key],str(_settings[sect].key_bindings[key])) - for key,val in _settings[sect].timing_window.items(): + for key,val in list(_settings[sect].timing_window.items()): parser.set(sect,key,str(val)) with open(os.path.join(getSetting().datadir.replace('main.exe',''),'settings','settings.ini'), 'w') as configfile: @@ -400,13 +400,13 @@ def saveGamepad(_settings): if not parser.has_section(controller_name): parser.add_section(controller_name) - for key,value in gamepad.key_bindings.axis_bindings.items(): + for key,value in list(gamepad.key_bindings.axis_bindings.items()): neg,pos = value if not neg: neg = 'none' if not pos: pos = 'none' parser.set(controller_name,'a'+str(key),'('+str(neg)+','+str(pos)+')' ) - for key,value in gamepad.key_bindings.button_bindings.items(): + for key,value in list(gamepad.key_bindings.button_bindings.items()): parser.set(controller_name,'b'+str(key),str(value)) with open(os.path.join(getSetting().datadir.replace('main.exe',''),'settings','gamepads.ini'), 'w') as configfile: diff --git a/spriteManager.py b/spriteManager.py index b19ab86..564bc68 100644 --- a/spriteManager.py +++ b/spriteManager.py @@ -85,7 +85,7 @@ def __init__(self,_directory,_prefix,_startingImage,_offset,_colorMap = {},_scal if not self.starting_image in self.image_library[self.flip]: - key_list = self.image_library[self.flip].keys() + key_list = list(self.image_library[self.flip].keys()) self.starting_image = key_list[0] print("Default Sprite not found. New default sprite: " + str(self.starting_image)) @@ -144,7 +144,7 @@ def draw(self,_screen,_offset,_scale): def buildImageLibrary(self,_lib,_offset): library = {} flipped_library = {} - for key,value in _lib.image_dict.items(): + for key,value in list(_lib.image_dict.items()): image_list = self.buildSubimage_list(value,_offset) library[key] = image_list flip_list = [] @@ -165,7 +165,7 @@ def buildSubimage_list(self,_sheet,_offset): while index < _sheet.get_width() // _offset: _sheet.set_clip(pygame.Rect(index * _offset, 0, _offset,_sheet.get_height())) image = _sheet.subsurface(_sheet.get_clip()) - for from_color,to_color in self.color_map.items(): + for from_color,to_color in list(self.color_map.items()): self.recolor(image, tuple(list(from_color)), tuple(list(to_color))) if not self.scale_factor == 1.0: w = int(image.get_width() * self.scale_factor) @@ -244,7 +244,7 @@ def buildSubimage_list(self,_sheet,_offset): self.sheet.set_clip(pygame.Rect(index * _offset, 0, _offset,_sheet.get_height())) image = _sheet.subsurface(_sheet.get_clip()) #image = image.convert_alpha() - for from_color,to_color in self.color_map.items(): + for from_color,to_color in list(self.color_map.items()): self.recolor(image, tuple(list(from_color)), tuple(list(to_color))) image_list.append(image) index += 1 From a7ed6efa181f775293c7127be98f4b1d115a0f45 Mon Sep 17 00:00:00 2001 From: PaKZer0 Date: Wed, 16 Nov 2022 21:21:34 +0100 Subject: [PATCH 10/14] Upgrade travis python to 3.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fc4dcf2..9a2e7d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: python python: - '2.7' -- '3.2' +- '3.8' before_install: - sudo apt-get -qq update - sudo apt-get install -y python-pygame From 209c9e4b8df12ac000dfb981d95d1cf39d53f28f Mon Sep 17 00:00:00 2001 From: PaKZer0 Date: Wed, 16 Nov 2022 21:26:38 +0100 Subject: [PATCH 11/14] fixed server.py --- server.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index f130a7f..103dc26 100644 --- a/server.py +++ b/server.py @@ -45,7 +45,7 @@ def send(self,msg,target): if len(msg) Date: Wed, 16 Nov 2022 21:37:33 +0100 Subject: [PATCH 12/14] Fixed old exec --- engine/subactions/base_subactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/subactions/base_subactions.py b/engine/subactions/base_subactions.py index 1b89643..fc3ec79 100644 --- a/engine/subactions/base_subactions.py +++ b/engine/subactions/base_subactions.py @@ -1642,7 +1642,7 @@ def execute(self, _action, _actor): else: print(self.scope + " is not a valid scope") return None - exec self.codeString in globals(), working_locals + exec(self.codeString in globals(), working_locals) def getDisplayName(self): return 'Execute ' + self.codeString + ' in the ' + self.scope + ' scope' From 298c866dd23daa4b0b8ed2b229cb387e36a1079a Mon Sep 17 00:00:00 2001 From: PaKZer0 Date: Wed, 16 Nov 2022 21:42:57 +0100 Subject: [PATCH 13/14] Remove boolean operator warnings --- engine/action.py | 4 ++-- engine/subactions/armor/createArmor.py | 4 ++-- engine/subactions/armor/removeArmor.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/action.py b/engine/action.py index 59aa20b..ea2a5c3 100644 --- a/engine/action.py +++ b/engine/action.py @@ -57,7 +57,7 @@ def update(self,_actor): act.execute(self,_actor) for act in self.actions_after_frame: act.execute(self,_actor) - if self.sprite_rate is not 0: + if self.sprite_rate != 0: if self.sprite_rate < 0: _actor.changeSpriteImage((self.frame // self.sprite_rate)-1, _loop=self.loop) else: @@ -90,7 +90,7 @@ def updateAnimationOnly(self,_actor): if isinstance(act, animation_actions): act.execute(self,_actor) - if self.sprite_rate is not 0: + if self.sprite_rate != 0: if self.sprite_rate < 0: _actor.changeSpriteImage((self.frame // self.sprite_rate)-1, _loop=self.loop) else: diff --git a/engine/subactions/armor/createArmor.py b/engine/subactions/armor/createArmor.py index d8fa102..7469ab9 100644 --- a/engine/subactions/armor/createArmor.py +++ b/engine/subactions/armor/createArmor.py @@ -34,13 +34,13 @@ def execute(self, _action, _actor): elif self.armor_type == "crouchCancel": armor = engine.hurtbox.CrouchCancel(_actor,self.armor_vars) - if self.hurtbox is not '' and _action is not None: + if self.hurtbox != '' and _action != None: _action.hurtbox[self.hurtbox_name].armor[self.armor_name] = armor else: _actor.armor[self.armor_name] = armor def getDisplayName(self): - return 'Add ' + self.armor_type + ' armor to ' + self.hurtbox if self.hurtbox is not '' else 'the fighter' + return 'Add ' + self.armor_type + ' armor to ' + self.hurtbox if self.hurtbox != '' else 'the fighter' def getPropertiesPanel(self, _root): return subactionSelector.ModifyArmorProperties(_root,self,newArmor=True) diff --git a/engine/subactions/armor/removeArmor.py b/engine/subactions/armor/removeArmor.py index e4cb7a2..ab031fe 100644 --- a/engine/subactions/armor/removeArmor.py +++ b/engine/subactions/armor/removeArmor.py @@ -13,15 +13,15 @@ def __init__(self,_armorName='',_hurtbox=''): def execute(self, _action, _actor): SubAction.execute(self, _action, _actor) - if self.hurtbox is not '': + if self.hurtbox != '': if self.hurtbox in _action.hurtboxes: hurtbox = _action.hurtboxes[self.hurtbox] - if self.armor_name is '': + if self.armor_name == '': hurtbox.armor.clear() elif self.armor_name in hurtbox.armor: del hurtbox.armor[self.armor_name] else: - if self.armor_name is '': + if self.armor_name == '': _actor.armor.clear() elif self.armor_name in _actor.armor: del _actor.armor[self.armor_name] From 0a977b48c637e2245d31101adc80a91ce6de1a05 Mon Sep 17 00:00:00 2001 From: PaKZer0 Date: Wed, 16 Nov 2022 21:50:04 +0100 Subject: [PATCH 14/14] Fixed clock --- battle.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/battle.py b/battle.py index 2a5b1db..329cd98 100644 --- a/battle.py +++ b/battle.py @@ -15,6 +15,7 @@ import menu import inspect import bdb +import math import engine.network as network @@ -88,7 +89,7 @@ def startBattle(self,_screen): self.clock_sprite = spriteManager.TextSprite('8:00','Orbitron Medium',32,[0,0,0]) self.clock_sprite.rect.topright = self.screen.get_rect().topright - self.clock_sprite.changeText(str(self.clock_time / 60)+':'+str(self.clock_time % 60).zfill(2)) + self.updateClockText() self.gui_objects.append(self.clock_sprite) gui_offset = self.screen.get_rect().width / (len(self.players) + 1) @@ -183,6 +184,10 @@ def startBattle(self,_screen): self.endBattle(self.exit_status) return self.exit_status # This'll pop us back to the character select screen. + + def updateClockText(self): + clockText = str(math.floor(self.clock_time / 60))+':'+str(self.clock_time % 60).zfill(2) + self.clock_sprite.changeText(clockText) def gameEventLoop(self): for cont in self.controllers: @@ -210,7 +215,7 @@ def gameEventLoop(self): if event.type == pygame.USEREVENT+2: pygame.time.set_timer(pygame.USEREVENT+2, 1000) - self.clock_sprite.changeText(str(self.clock_time / 60)+':'+str(self.clock_time % 60).zfill(2)) + self.updateClockText() self.clock_time -= 1 if self.clock_time <= 5 and self.clock_time > 0: self.countdown_sprite.changeText(str(self.clock_time))