Skip to content

Commit

Permalink
Deck descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Mottram committed Sep 8, 2020
1 parent abeb39a commit e613e8b
Show file tree
Hide file tree
Showing 104 changed files with 123 additions and 41 deletions.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
60 changes: 53 additions & 7 deletions cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ def parseCard(cardDescription: str) -> str:
and turns it into "a♠"
"""
suitName = {
"sword": "♥",
"collar": "♥",
"heart": "♥",
"diamond": "♦",
"horn": "♦",
"coin": "♦",
"club": "♣",
"loop": "♣",
"leashe": "♠",
"cup": "♠",
"spade": "♠"
}
detectedSuit = ''
Expand Down Expand Up @@ -281,6 +288,19 @@ def cardGameInRoom(players: {}, id, rooms: {}, items: {}, itemsDB: {}):
return None


def cardGamePack(players: {}, id, rooms: {}, items: {}, itemsDB: {}) -> str:
"""Returns the card pack name to use
"""
rid = players[id]['room']
for i in items:
if items[i]['room'] != rid:
continue
if 'cards' in itemsDB[items[i]['id']]['game'].lower():
if itemsDB[items[i]['id']].get('cardPack'):
return itemsDB[items[i]['id']]['cardPack']
return None


def getNumberFromText(text: str) -> int:
"""If there is a number in the given text then return it
"""
Expand Down Expand Up @@ -364,7 +384,7 @@ def dealToPlayers(players: {}, dealerId, description: str,
items[gameItemID]['gameState']['deck'] = str(deck)


def getCardDescription(rank: str, suit: str) -> str:
def getCardDescription(pack: str, rank: str, suit: str) -> str:
"""Given rank as a single character and suit
returns a description of the card
This is used for non-graphical output
Expand All @@ -373,19 +393,40 @@ def getCardDescription(rank: str, suit: str) -> str:
if rankStr.startswith('K'):
rankStr = 'King'
elif rankStr.startswith('Q'):
rankStr = 'Queen'
if pack == 'set1':
rankStr = 'Knight'
else:
rankStr = 'Queen'
elif rankStr.startswith('A'):
rankStr = 'Ace'
elif rankStr.startswith('J'):
rankStr = 'Jack'

if suit == '♥':
return str(rankStr) + ' of hearts\n'
if pack == 'cloisters':
return str(rankStr) + ' of collars\n'
elif pack == 'set1':
return str(rankStr) + ' of swords\n'
else:
return str(rankStr) + ' of hearts\n'
elif suit == '♦':
return str(rankStr) + ' of diamonds\n'
if pack == 'cloisters':
return str(rankStr) + ' of horns\n'
elif pack == 'set1':
return str(rankStr) + ' of coins\n'
else:
return str(rankStr) + ' of diamonds\n'
elif suit == '♣':
return str(rankStr) + ' of clubs\n'
return str(rankStr) + ' of spades\n'
if pack == 'cloisters':
return str(rankStr) + ' of loops\n'
else:
return str(rankStr) + ' of clubs\n'
if pack == 'cloisters':
return str(rankStr) + ' of leashes\n'
elif pack == 'set1':
return str(rankStr) + ' of cups\n'
else:
return str(rankStr) + ' of spades\n'


def showHandOfCards(players: {}, id, mud, rooms: {},
Expand All @@ -397,6 +438,11 @@ def showHandOfCards(players: {}, id, mud, rooms: {},
mud.sendMessage(id, '\nThere are no playing cards here.\n')
return

# get the pack to be shown within the web interface
pack = cardGamePack(players, id, rooms, items, itemsDB)
if not pack:
pack = 'standard'

playerName = players[id]['name']
if not items[gameItemID].get('gameState'):
mud.sendMessage(id, '\nNo cards have been dealt.\n')
Expand Down Expand Up @@ -429,7 +475,7 @@ def showHandOfCards(players: {}, id, mud, rooms: {},
suit = cardStr[2]
suitColor = "\u001b[38;5;245m"

cardDescriptions += getCardDescription(rank, suit)
cardDescriptions += getCardDescription(pack, rank, suit)

if suit == '♥' or suit == '♦':
suitColor = "\u001b[31m"
Expand Down
102 changes: 68 additions & 34 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,113 +879,147 @@ def help(params, mud, playersDB: {}, players: {}, rooms: {},
mud.sendMessage(id, '****CLEAR****\n')
mud.sendMessage(id, 'Commands:')
mud.sendMessage(id,
' <f220>help witch|spell|cards|chess|morris<f255> - Show help')
' <f220>help witch|spell|cards|chess|morris<f255>' +
' - Show help')
mud.sendMessage(id,
' <f220>bio [description]<f255> - ' +
' <f220>bio [description]<f255>' +
' - ' +
'Set a description of yourself')
mud.sendMessage(id,
' <f220>graphics [on|off]<f255> - ' +
' <f220>graphics [on|off]<f255>' +
' - ' +
'Turn graphic content on or off')
mud.sendMessage(id,
' <f220>change password [newpassword]<f255> - ' +
' <f220>change password [newpassword]<f255>' +
' - ' +
'Change your password')
mud.sendMessage(id,
' <f220>who<f255> - ' +
' <f220>who<f255>' +
' - ' +
'List players and where they are')
mud.sendMessage(id,
' <f220>quit/exit<f255> - ' +
' <f220>quit/exit<f255>' +
' - ' +
'Leave the game')
mud.sendMessage(id,
' <f220>eat/drink [item]<f255> - ' +
' <f220>eat/drink [item]<f255>' +
' - ' +
'Eat or drink a consumable')
mud.sendMessage(id,
' <f220>speak [language]<f255> - ' +
' <f220>speak [language]<f255>' +
' - ' +
'Switch to speaking a different language')
mud.sendMessage(id,
' <f220>say [message]<f255> - ' +
' <f220>say [message]<f255>' +
' - ' +
'Says something out loud, ' +
"e.g. 'say Hello'")
mud.sendMessage(id,
' <f220>look/examine<f255> - ' +
' <f220>look/examine<f255>' +
' - ' +
'Examines the ' +
"surroundings, items in the room, NPCs or other " +
"players e.g. 'examine inn-keeper'")
mud.sendMessage(id,
' <f220>go [exit]<f255> - ' +
' <f220>go [exit]<f255>' +
' - ' +
'Moves through the exit ' +
"specified, e.g. 'go outside'")
mud.sendMessage(id,
' <f220>climb though [exit]<f255> - ' +
' <f220>climb though [exit]<f255>' +
' - ' +
'Try to climb through an exit')
mud.sendMessage(id,
' <f220>move/roll/heave [target]<f255> - ' +
' <f220>move/roll/heave [target]<f255>' +
' - ' +
'Try to move or roll a heavy object')
mud.sendMessage(id,
' <f220>jump to [exit]<f255> - ' +
' <f220>jump to [exit]<f255>' +
' - ' +
'Try to jump onto something')
mud.sendMessage(id,
' <f220>attack [target]<f255> - ' +
' <f220>attack [target]<f255>' +
' - ' +
'Attack target ' +
"specified, e.g. 'attack knight'")
mud.sendMessage(id,
' <f220>check inventory<f255> - ' +
' <f220>check inventory<f255>' +
' - ' +
'Check the contents of ' +
"your inventory")
mud.sendMessage(id,
' <f220>take/get [item]<f255> - ' +
' <f220>take/get [item]<f255>' +
' - ' +
'Pick up an item lying ' +
"on the floor")
mud.sendMessage(id,
' <f220>put [item] in/on [item]<f255> - ' +
' <f220>put [item] in/on [item]<f255>' +
' - ' +
'Put an item into or onto another one')
mud.sendMessage(id,
' <f220>drop [item]<f255> - ' +
' <f220>drop [item]<f255>' +
' - ' +
'Drop an item from your inventory ' +
"on the floor")
mud.sendMessage(id,
' <f220>use/hold/pick/wield [item] [left|right]<f255> - ' +
' <f220>use/hold/pick/wield [item] ' +
'[left|right]<f255> - ' +
'Transfer an item to your hands')
mud.sendMessage(id,
' <f220>stow<f255> - ' +
' <f220>stow<f255>' +
' - ' +
'Free your hands of items')
mud.sendMessage(id,
' <f220>wear [item]<f255> - ' +
' <f220>wear [item]<f255>' +
' - ' +
'Wear an item')
mud.sendMessage(id,
' <f220>remove/unwear [item]<f255> - ' +
' <f220>remove/unwear [item]<f255>' +
' - ' +
'Remove a worn item')
mud.sendMessage(id,
' <f220>whisper [target] [message]<f255> - ' +
' <f220>whisper [target] [message]<f255>' +
' - ' +
'Whisper to a player in the same room')
mud.sendMessage(id,
' <f220>tell/ask [target] [message]<f255> - ' +
' <f220>tell/ask [target] [message]<f255>' +
' - ' +
'Send a tell message to another player or NPC')
mud.sendMessage(id,
' <f220>open [item]<f255> - ' +
' <f220>open [item]<f255>' +
' - ' +
'Open an item or door')
mud.sendMessage(id,
' <f220>close [item]<f255> - ' +
' <f220>close [item]<f255>' +
' - ' +
'Close an item or door')
mud.sendMessage(id,
' <f220>push [item]<f255> - ' +
' <f220>push [item]<f255>' +
' - ' +
'Pushes a lever')
mud.sendMessage(id,
' <f220>pull [item]<f255> - ' +
' <f220>pull [item]<f255>' +
' - ' +
'Pulls a lever')
mud.sendMessage(id,
' <f220>wind [item]<f255> - ' +
' <f220>wind [item]<f255>' +
' - ' +
'Winds a lever')
mud.sendMessage(id,
' <f220>affinity [player name]<f255> - ' +
' <f220>affinity [player name]<f255>' +
' - ' +
'Shows your affinity level with another player')
mud.sendMessage(id,
' <f220>cut/escape<f255> - ' +
' <f220>cut/escape<f255>' +
' - ' +
'Attempt to escape from a trap')
mud.sendMessage(id,
' <f220>step over tripwire [exit]<f255> - ' +
' <f220>step over tripwire [exit]<f255>' +
' - ' +
'Step over a tripwire in the given direction')
mud.sendMessage(id,
' <f220>dodge<f255> - ' +
' <f220>dodge<f255>' +
' - ' +
'Dodge an attacker on the next combat round')
mud.sendMessage(id, '\n\n')

Expand Down
2 changes: 2 additions & 0 deletions def/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -31851,6 +31851,7 @@
"heave": "",
"jumpTo": "",
"game": "cards morris",
"cardPack": "cloisters",
"gameState": {},
"state": "container open always",
"visibleWhenWearing": [],
Expand Down Expand Up @@ -37024,6 +37025,7 @@
"heave": "",
"jumpTo": "",
"game": "cards morris",
"cardPack": "cloisters",
"gameState": {},
"state": "container open always",
"visibleWhenWearing": [],
Expand Down

0 comments on commit e613e8b

Please sign in to comment.