Skip to content

Commit

Permalink
Merge pull request #696 from aqua-uru/enum
Browse files Browse the repository at this point in the history
replace Cyan's xEnum by Python's enum
  • Loading branch information
Hoikas committed Aug 14, 2020
2 parents 3bccf2a + 447c7ff commit 89ccb8c
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 149 deletions.
1 change: 0 additions & 1 deletion Scripts/Python/bhroBahroYeeshaCave.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from Plasma import *
from PlasmaTypes import *
from PlasmaKITypes import *
import xEnum
import xRandom
from xPsnlVaultSDL import *
import copy
Expand Down
16 changes: 13 additions & 3 deletions Scripts/Python/clftNpcZandi.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import random
import time
import PlasmaControlKeys
import xEnum
import enum

# define the attributes that will be entered in max
Activate = ptAttribActivator(1, "Region Sensor")
Expand Down Expand Up @@ -86,9 +86,19 @@
IgnoreTime = 120
PageTurnInterval = 120

TimerID = xEnum.Enum("IgnoreFinished = 10, TurnPage")
class TimerID(enum.IntEnum):
IgnoreFnished = 10
TurnPage = enum.auto()

class JC(enum.IntEnum):
Trailer = 0
Imager = enum.auto()
Bedroom = enum.auto()
Wahrk = enum.auto()
Sign = enum.auto()
Bucket = enum.auto()
Door = enum.auto()

JC = xEnum.Enum("Trailer, Imager, Bedroom, Wahrk, Sign, Bucket, Door")
jcDict = {JC.Trailer: 'c', JC.Imager: 'd', JC.Bedroom: 'e', JC.Wahrk: 'b', JC.Sign: 'a', JC.Bucket: 'g', JC.Door: 'f'}


Expand Down
1 change: 0 additions & 1 deletion Scripts/Python/ercaBakePellets.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from Plasma import *
from PlasmaTypes import *
import PlasmaControlKeys
import xEnum
from math import *


Expand Down
1 change: 0 additions & 1 deletion Scripts/Python/ercaOvenScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from PlasmaTypes import *
from PlasmaKITypes import *
import PlasmaControlKeys
import xEnum
from math import *


Expand Down
1 change: 0 additions & 1 deletion Scripts/Python/ercaPelletRoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
from PlasmaTypes import *
from PlasmaKITypes import *
import PlasmaControlKeys
import xEnum
from math import *
from xPsnlVaultSDL import *
import time
Expand Down
6 changes: 4 additions & 2 deletions Scripts/Python/grsnPowerOn.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from Plasma import *
from PlasmaTypes import *

import xEnum
import enum

# #############################################################
# define the attributes/parameters that we need from the 3dsMax scene
Expand Down Expand Up @@ -132,7 +132,9 @@
gearStartingDown = False
weightEngageDisabled = False

TimerID = xEnum.Enum("UpElevatorSwitch, DownElevatorSwitch")
class TimerID(enum.IntEnum):
UpElevatorSwitch = enum.auto()
DownElevatorSwitch = enum.auto()

# history
#
Expand Down
5 changes: 3 additions & 2 deletions Scripts/Python/islmRandomBahroScream.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

from Plasma import *
from PlasmaTypes import *
from xEnum import Enum
import enum
import xRandom

respScream = ptAttribResponder(1, "Scream responder")
Expand All @@ -59,7 +59,8 @@
AgeStartedIn = ""
ScreamChanceVar = "islmScreamChance"

TimerID = Enum("TurnOn")
class TimerID(enum.IntEnum):
TurnOn = enum.auto()

class islmRandomBahroScream(ptModifier):
def __init__(self):
Expand Down
1 change: 0 additions & 1 deletion Scripts/Python/ki/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import functools

import xLocTools
import xEnum

# Personal age SDL helper.
from xPsnlVaultSDL import *
Expand Down
6 changes: 0 additions & 6 deletions Scripts/Python/ki/xKIConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@
from Plasma import *
from PlasmaTypes import *

# Uru modules.
import xEnum

## Number of items to scroll through in content list.
kContentListScrollSize = 5

## Waiting message for marker games.
kMessageWait = xEnum.Enum("createMarker, changeMarkerName")

## Python component for the Jalak Age.
kJalakPythonComponent = "cPythField"

Expand Down
8 changes: 6 additions & 2 deletions Scripts/Python/mystFireplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from Plasma import *
from PlasmaTypes import *
import PlasmaControlKeys
import xEnum
import enum

actButton = ptAttribActivator(1, "Fireplace button")
respPressButton = ptAttribResponder(2, "Fireplace button resp")
Expand Down Expand Up @@ -96,7 +96,11 @@
EggSolution = ["A03", "A04", "B02", "B05", "C01", "C03", "C04", "C06", "D01", "D03", "D04", "D06", "E01", "E06", "F02", "F05", "G02", "G05", "H03", "H04"]
KveerSolution = ["A01", "A05", "B02", "B05", "C01", "C04", "D03", "D06", "E03", "E05", "F01", "F03", "G01", "G03", "G05", "H02", "H05"]

States = xEnum.Enum("DoorOpen, DoorClosed, Rotated")
class States(enum.IntEnum):
DoorOpen = 0
DoorClosed = enum.auto()
Rotated = enum.auto()

CurrentState = States.DoorClosed

class mystFireplace(ptModifier):
Expand Down
10 changes: 8 additions & 2 deletions Scripts/Python/psnlBahroPoles.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from Plasma import *
from PlasmaTypes import *
from PlasmaVaultConstants import *
import xEnum
import enum
import xRandom
import copy
from xPsnlVaultSDL import *
Expand Down Expand Up @@ -128,7 +128,13 @@
#GotCleftBook = 0
boolCleftSolved = 0
kWriteTimestamps = 8
BahroPoles = xEnum.Enum("Teledahn = 1, Garrison, Garden, Kadish")

class BahroPoles(enum.IntEnum):
Teledahn = enum.auto()
Garrison = enum.auto()
Garden = enum.auto()
Kadish = enum.auto()

HidingPoles = 0

# Bahro pole SDL variable states
Expand Down
38 changes: 29 additions & 9 deletions Scripts/Python/tldnBucketBrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from Plasma import *
from PlasmaTypes import *
import PlasmaControlKeys
from xEnum import Enum
import enum

#These variables are global but are necessary for the max inputs:
kOff = "off"
Expand Down Expand Up @@ -149,8 +149,28 @@
kStringAgeSDLPowerOn = "tldnWorkroomPowerOn"

#Bucket States and Inputs
kBucketStates = Enum("Stop, QRun, QBoardQRun, Run, Dump, QStop, DumpQBoard, DumpQStop, DumpQBoardQStop, QBoard, Boarded")
kBucketInputs = Enum("Power, Timer, StopCB, Board, BoardCB, Dump, DumpCB, WCPswitch")
class kBucketStates(enum.IntEnum):
Stop = 0
QRun = enum.auto()
QBoardQRun = enum.auto()
Run = enum.auto()
Dump = enum.auto()
QStop = enum.auto()
DumpQBoard = enum.auto()
DumpQStop = enum.auto()
DumpQBoardQStop = enum.auto()
QBoard = enum.auto()
Boarded = enum.auto()

class kBucketInputs(enum.IntEnum):
Power = 0
Timer = enum.auto()
StopCB = enum.auto()
Board = enum.auto()
BoardCB = enum.auto()
Dump = enum.auto()
DumpCB = enum.auto()
WCPswitch = enum.auto()



Expand Down Expand Up @@ -466,7 +486,7 @@ def OnSDLNotify(self,VARname,SDLname,playerID,tag):
if VARname == kStringAgeSDLBucketState:
curBucketState = ageSDL[kStringAgeSDLBucketState][0]
fastforward = ageSDL[kStringAgeSDLBucketState][1]
PtDebugPrint ("Debug: tldnBucketBrain.OnSDLNotify(): *****>Changed Bucket State to: %s, with FF = %s"% (kBucketStates.ToString(curBucketState),fastforward),level=kDebugDumpLevel)
PtDebugPrint ("Debug: tldnBucketBrain.OnSDLNotify(): *****>Changed Bucket State to: %s, with FF = %s"% (repr(curBucketState),fastforward),level=kDebugDumpLevel)
self.RunBucketState(curBucketState, fastforward=fastforward)

#Set WCP bucket LED
Expand Down Expand Up @@ -689,7 +709,7 @@ def OnNotify(self,state,id,events):
bucketState = ageSDL[kStringAgeSDLBucketState][0]
boardStates = [kBucketStates.Stop, kBucketStates.QRun, kBucketStates.Dump, kBucketStates.DumpQStop]
if not(bucketState in boardStates):
PtDebugPrint("DEBUG: tldnBucketBrain.OnNotify():\tCannot enter bucket during an improper state: %s" %kBucketStates.ToString(bucketState))
PtDebugPrint("DEBUG: tldnBucketBrain.OnNotify():\tCannot enter bucket during an improper state: %s" %repr(bucketState))
actBktEnter1.disable()
actBktEnter2.disable()
return
Expand Down Expand Up @@ -756,7 +776,7 @@ def OnNotify(self,state,id,events):
#This check is to ensure that QRun may be a vaild state if a rider is in the bucket
#(used or logic due to simplification)
if avaObj == None or bucketState != kBucketStates.QRun:
PtDebugPrint("DEBUG: tldnBucketBrain.OnNotify():\tCannot exit a bucket during an improper state: %s" %kBucketStates.ToString(bucketState))
PtDebugPrint("DEBUG: tldnBucketBrain.OnNotify():\tCannot exit a bucket during an improper state: %s" %repr(bucketState))
actBktExit.disable()
return

Expand Down Expand Up @@ -1018,7 +1038,7 @@ def UpdateBucketState(self, param, val=0):
fastforward = 0 #fastforward to state
error = 0 #error reporting

PtDebugPrint("tldnBucketBrain.UpdateBucketState():-->Incomming state change request: state (%s), parameter (%s), value (%s)" % (kBucketStates.ToString(curBucketState), kBucketInputs.ToString(param),val),level=kDebugDumpLevel)
PtDebugPrint("tldnBucketBrain.UpdateBucketState():-->Incomming state change request: state (%s), parameter (%s), value (%s)" % (repr(curBucketState), repr(param),val),level=kDebugDumpLevel)


############[ Power ]#############
Expand Down Expand Up @@ -1208,10 +1228,10 @@ def UpdateBucketState(self, param, val=0):
#Propigate to all clients if an error did not occur
#Tye: we could just prop to all clients irregardless of an error?!???
if error:
PtDebugPrint("ERROR: tldnBucketBrain.UpdateBucketState():-->Unknown state (%s), parameter (%s), and value (%s) combo" % (kBucketStates.ToString(curBucketState), kBucketInputs.ToString(param),val),level=kErrorLevel)
PtDebugPrint("ERROR: tldnBucketBrain.UpdateBucketState():-->Unknown state (%s), parameter (%s), and value (%s) combo" % (repr(curBucketState), repr(param),val),level=kErrorLevel)
else:
#Push state to other clients..
PtDebugPrint("tldnBucketBrain.UpdateBucketState(): ----[ Updating EVERYONE\'s State to: %s ]----" % (kBucketStates.ToString(curBucketState)),level=kDebugDumpLevel)
PtDebugPrint("tldnBucketBrain.UpdateBucketState(): ----[ Updating EVERYONE\'s State to: %s ]----" % (repr(curBucketState)),level=kDebugDumpLevel)
ageSDL[kStringAgeSDLBucketState] = (curBucketState, fastforward)


Expand Down
114 changes: 0 additions & 114 deletions Scripts/Python/xEnum.py

This file was deleted.

6 changes: 4 additions & 2 deletions Scripts/Python/xJourneyClothGate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from PlasmaTypes import *
from PlasmaVaultConstants import *
from PlasmaNetConstants import *
from xEnum import *
import enum

# ---------
# max wiring
Expand Down Expand Up @@ -87,7 +87,9 @@
AgeStartedIn = None
AllCloths = ""

TimerID = Enum("kCheckGateFinished, kResetGate")
class TimerID(enum.IntEnum):
kCheckGateFinished = enum.auto()
kResetGate = enum.auto()

class xJourneyClothGate(ptResponder):

Expand Down
Loading

0 comments on commit 89ccb8c

Please sign in to comment.