def prepUnitsForBattle(teamList): toRet = [] teamOn = 0 corner = 1 for team in teamList: toRet += [[team[0], []]] unitOn = 0 line = 1 #unit[3] is a list of abilities. for unit in team[1]: if unit[0] in UNITSTATS and "CLASS" in UNITSTATS[unit[0]]: c = UNITSTATS[unit[0]]["CLASS"] if corner == 1: #topLeft pos = [line * 30 - unitOn * 30, 30 + unitOn * 30] elif corner == 2: #bottomRight pos = [ CONST["BATTLESIZE"][0] - (line * 30 - unitOn * 30), CONST["BATTLESIZE"][1] - (30 + unitOn * 30) ] elif corner == 3: #topRight pos = [ CONST["BATTLESIZE"][0] - (line * 30 - unitOn * 30), (30 + unitOn * 30) ] elif corner == 4: #bottomLeft pos = [(line * 30 - unitOn * 30), CONST["BATTLESIZE"][1] - (30 + unitOn * 30)] if c == "Tank": newUnit = Units.Warrior(pos, unit[0], unit[1], unit[2], unit[3]) elif c == "Heal": newUnit = Units.Healer(pos, unit[0], unit[1], unit[2], unit[3]) elif c == "Ranger": newUnit = Units.Ranger(pos, unit[0], unit[1], unit[2], unit[3]) elif c == "Egg": newUnit = Units.Egg(pos, unit[0], unit[1], unit[2], unit[3]) else: print "NOT IMPLEMENTED: unit AI of '" + c + "'" newUnit = Units.NoAI(pos, unit[0], unit[1], unit[2], unit[3]) toRet[teamOn][1] += [newUnit] unitOn += 1 if unitOn >= line: line += 1 unitOn = 0 else: print "Error creating unit '" + unit[ 0] + "'. It is not in UNITSTATS" teamOn += 1 corner += 1 return toRet