Skip to content

Commit 29f96e2

Browse files
committed
deduplicate vars and controller handles
1 parent 657bcd0 commit 29f96e2

File tree

6 files changed

+3
-25
lines changed

6 files changed

+3
-25
lines changed

battle/boss.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ def klikk():
105105

106106

107107
def tros():
108-
FFXC = xbox.controllerHandle()
109108
logs.openRNGTrack()
110109
print("Fight start: Tros")
111110
FFXC.set_neutral()

battle/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,6 @@ def mrrTarget():
926926

927927

928928
def MRRbattle(status):
929-
gameVars = vars.varsHandle()
930929
# Yuna complete, Kimahri complete, Valefor overdrive, Battle counter, Yuna level up complete, Yuna grid, phase
931930
print("------------------------------")
932931
print("------------------------------")
@@ -3777,7 +3776,6 @@ def healUp(chars=3, *, fullMenuClose=True):
37773776
return
37783777
if not memory.main.menuOpen():
37793778
memory.main.openMenu()
3780-
FFXC = xbox.controllerHandle()
37813779
FFXC.set_neutral()
37823780
while memory.main.getMenuCursorPos() != 2:
37833781
print("Selecting Ability command -", memory.main.getMenuCursorPos())

blitz.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ def blitzMovement():
889889

890890

891891
def decideAction():
892-
FFXC = xbox.controllerHandle()
893892
FFXC.set_neutral()
894893
updatePlayerArray()
895894
if controllingPlayer() == 0:
@@ -924,7 +923,6 @@ def blitzMain(forceBlitzWin):
924923
print("-Match is now starting.")
925924
startTime = logs.timeStamp()
926925

927-
FFXC = xbox.controllerHandle()
928926
gameVars.blitzFirstShotReset()
929927
movementSetFlag = False
930928
lastState = 0

loadGame.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
import memory.main
66
import screen
77
import targetPathing
8+
import vars
89
import xbox
910
import zzairShipPath
1011

1112
# This file is intended to load the game to a saved file.
1213
# This assumes that the save is the first non-auto-save in the list of saves.
1314

1415
FFXC = xbox.controllerHandle()
16+
gameVars = vars.varsHandle()
1517

1618

1719
def getSavedFiles():
18-
import vars
19-
gameVars = vars.varsHandle()
2020
saveFilesFull = sorted(
2121
Path(gameVars.gameSavePath()).iterdir(), key=os.path.getmtime)
2222
saveFiles = [os.path.basename(i) for i in saveFilesFull]
@@ -96,8 +96,6 @@ def loadOffsetBattle(offset):
9696

9797

9898
def loadMemCursor():
99-
import vars
100-
gameVars = vars.varsHandle()
10199
memory.main.awaitControl()
102100
memory.main.openMenu()
103101
if memory.main.getStoryProgress() <= 200: # Up to Besaid save, after Trials

memory/main.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import xbox
1515

1616
gameVars = vars.varsHandle()
17+
FFXC = xbox.controllerHandle()
1718

1819
# Process Permissions
1920
PROCESS_QUERY_INFORMATION = 0x0400
@@ -425,7 +426,6 @@ def clickToControl3():
425426

426427

427428
def clickToControlSpecial():
428-
FFXC = xbox.controllerHandle()
429429
waitCounter = 0
430430
print("Awaiting control (clicking)")
431431
while not userControl():
@@ -443,7 +443,6 @@ def clickToControlSpecial():
443443

444444

445445
def clickToEvent():
446-
FFXC = xbox.controllerHandle()
447446
while userControl():
448447
FFXC.set_value('BtnB', 1)
449448
if gameVars.usePause():
@@ -459,7 +458,6 @@ def clickToEvent():
459458

460459

461460
def clickToEventTemple(direction):
462-
FFXC = xbox.controllerHandle()
463461
if direction == 0:
464462
FFXC.set_movement(0, 1)
465463
if direction == 1:
@@ -1386,7 +1384,6 @@ def saveMenuOpen():
13861384

13871385

13881386
def backToMainMenu():
1389-
gameVars = vars.varsHandle()
13901387
while menuNumber() not in [1, 2, 3, 4, 5]:
13911388
if menuOpen():
13921389
xbox.tapA()
@@ -1397,7 +1394,6 @@ def backToMainMenu():
13971394

13981395

13991396
def openMenu():
1400-
FFXC = xbox.controllerHandle()
14011397
menuCounter = 0
14021398
while not (userControl() and menuOpen() and menuNumber() == 5):
14031399
if menuOpen() and not userControl():
@@ -1701,7 +1697,6 @@ def awaitMenuControl():
17011697

17021698

17031699
def clickToStoryProgress(destination):
1704-
FFXC = xbox.controllerHandle()
17051700
counter = 0
17061701
currentState = getStoryProgress()
17071702
print("Story goal:", destination, "| Awaiting progress state:", currentState)
@@ -1754,7 +1749,6 @@ def getCharacterIndexInMainMenu(character):
17541749

17551750

17561751
def fullPartyFormat(frontLine, *, fullMenuClose=True):
1757-
gameVars = vars.varsHandle()
17581752
order = getOrderSeven()
17591753
partyMembers = len(order)
17601754
frontLine = frontLine.lower()
@@ -1782,7 +1776,6 @@ def fullPartyFormat(frontLine, *, fullMenuClose=True):
17821776
while not menuOpen():
17831777
if not openMenu():
17841778
return
1785-
FFXC = xbox.controllerHandle()
17861779
FFXC.set_neutral()
17871780
while getMenuCursorPos() != 7:
17881781
menuDirection(getMenuCursorPos(), 7, 11)
@@ -2883,7 +2876,6 @@ def checkThunderStrike() -> int:
28832876

28842877
def checkZombieStrike():
28852878
ability = 0x8032
2886-
gameVars = vars.varsHandle()
28872879

28882880
charWeaps = weaponArrayCharacter(0) # Tidus
28892881
while len(charWeaps) > 0:
@@ -3093,7 +3085,6 @@ def customizeMenuArray():
30933085

30943086
def checkNEArmor():
30953087
ability = 0x801D
3096-
gameVars = vars.varsHandle()
30973088

30983089
charWeaps = armorArrayCharacter(0) # Tidus
30993090
while len(charWeaps) > 0:
@@ -3655,7 +3646,6 @@ def touchSaveSphere(saveCursorNum: int = 0):
36553646
clearSaveMenuCursor2()
36563647

36573648
ssDetails = getSaveSphereDetails()
3658-
FFXC = xbox.controllerHandle()
36593649
while userControl():
36603650
targetPathing.setMovement([ssDetails[0], ssDetails[1]])
36613651
xbox.tapB()
@@ -3708,7 +3698,6 @@ def touchSaveSphere_notWorking(saveCursorNum: int = 0):
37083698
print("MEM - Touch Save Sphere")
37093699

37103700
ssDetails = getSaveSphereDetails()
3711-
FFXC = xbox.controllerHandle()
37123701
while userControl():
37133702
targetPathing.setMovement([ssDetails[0], ssDetails[1]])
37143703
xbox.tapB()
@@ -3753,7 +3742,6 @@ def csrBaajSaveClear():
37533742
print("No need to clear. User is in control.")
37543743
else:
37553744
print("Save dialog has popped up for some reason. Attempting clear.")
3756-
FFXC = xbox.controllerHandle()
37573745
try:
37583746
FFXC.set_neutral()
37593747
except Exception:

menu.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,6 @@ def skReturn2():
17491749

17501750

17511751
def openGrid(character):
1752-
FFXC = xbox.controllerHandle()
17531752
try:
17541753
FFXC.set_neutral()
17551754
except Exception:
@@ -1780,12 +1779,10 @@ def openGrid(character):
17801779
try:
17811780
FFXC.set_neutral()
17821781
except Exception:
1783-
FFXC = xbox.controllerHandle()
17841782
FFXC.set_neutral()
17851783
try:
17861784
FFXC.set_neutral()
17871785
except Exception:
1788-
FFXC = xbox.controllerHandle()
17891786
FFXC.set_neutral()
17901787

17911788
# ------------------------------

0 commit comments

Comments
 (0)