added str_to_tunnel_dir to enum TunnelDirection
parent
bb665be4a3
commit
905c606cd5
33
MCInfoBot.py
33
MCInfoBot.py
|
@ -42,6 +42,19 @@ class TunnelDirection(enum.Enum):
|
||||||
South = 'red'
|
South = 'red'
|
||||||
West = 'yellow'
|
West = 'yellow'
|
||||||
|
|
||||||
|
def str_to_tunnel_dir(arg):
|
||||||
|
arg = arg.lower()
|
||||||
|
if arg == TunnelDirection.North.value:
|
||||||
|
return TunnelDirection.North
|
||||||
|
elif arg == TunnelDirection.East.value:
|
||||||
|
return TunnelDirection.East
|
||||||
|
elif arg == TunnelDirection.South.value:
|
||||||
|
return TunnelDirection.South
|
||||||
|
elif arg == TunnelDirection.West.value:
|
||||||
|
return TunnelDirection.West
|
||||||
|
else:
|
||||||
|
raise ValueError
|
||||||
|
|
||||||
|
|
||||||
class Player(SQL_Base):
|
class Player(SQL_Base):
|
||||||
__tablename__ = 'Players'
|
__tablename__ = 'Players'
|
||||||
|
@ -74,7 +87,7 @@ class Location(SQL_Base):
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
|
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
self.direction = strToTunnelDirection(args[0])
|
self.direction = TunnelDirection.str_to_tunnel_direction(args[0])
|
||||||
self.tunnelNumber = int(args[1])
|
self.tunnelNumber = int(args[1])
|
||||||
|
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
|
@ -88,7 +101,8 @@ class Location(SQL_Base):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.direction is not None:
|
if self.direction is not None:
|
||||||
return "Name: {}, Position: {}, Tunnel: {}".format(self.name, self.pos_to_str(), self.nether_tunnel_addr_to_str())
|
return "Name: {}, Position: {}, Tunnel: {}".format(self.name, self.pos_to_str(),
|
||||||
|
self.nether_tunnel_addr_to_str())
|
||||||
else:
|
else:
|
||||||
return "Name: {}, Position: {}".format(self.name, self.pos_to_str())
|
return "Name: {}, Position: {}".format(self.name, self.pos_to_str())
|
||||||
|
|
||||||
|
@ -98,21 +112,6 @@ SQL_Base.metadata.create_all(engine)
|
||||||
Session = sessionmaker(bind=engine)
|
Session = sessionmaker(bind=engine)
|
||||||
session = Session()
|
session = Session()
|
||||||
|
|
||||||
|
|
||||||
def strToTunnelDirection(arg):
|
|
||||||
arg = arg.lower()
|
|
||||||
if (arg == TunnelDirection.North.value):
|
|
||||||
return TunnelDirection.North
|
|
||||||
elif (arg == TunnelDirection.East.value):
|
|
||||||
return TunnelDirection.East
|
|
||||||
elif (arg == TunnelDirection.South.value):
|
|
||||||
return TunnelDirection.South
|
|
||||||
elif (arg == TunnelDirection.West.value):
|
|
||||||
return TunnelDirection.West
|
|
||||||
else:
|
|
||||||
raise ValueError
|
|
||||||
|
|
||||||
|
|
||||||
# Bot Commands ******************************************************************
|
# Bot Commands ******************************************************************
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
|
Loading…
Reference in New Issue