Skip to content

Commit

Permalink
Extra cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Mottram committed Sep 9, 2020
1 parent 6d977e4 commit ecf8eac
Show file tree
Hide file tree
Showing 56 changed files with 56 additions and 14 deletions.
Binary file modified cardpacks/set1/ace_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/ace_of_coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/ace_of_cups.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/ace_of_swords.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/eight_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/eight_of_coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/eight_of_cups.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/eight_of_swords.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/five_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/five_of_coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/five_of_cups.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/five_of_swords.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/four_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/four_of_coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/four_of_cups.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/four_of_swords.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/jack_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/jack_of_coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/jack_of_cups.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/jack_of_swords.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/king_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/king_of_coins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/king_of_cups.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/king_of_swords.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/knight_of_clubs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cardpacks/set1/knight_of_coins.jpg
Binary file modified cardpacks/set1/knight_of_cups.jpg
Binary file added cardpacks/set1/knight_of_swords.jpg
Binary file modified cardpacks/set1/nine_of_clubs.jpg
Binary file modified cardpacks/set1/nine_of_coins.jpg
Binary file modified cardpacks/set1/nine_of_cups.jpg
Binary file modified cardpacks/set1/nine_of_swords.jpg
Binary file modified cardpacks/set1/seven_of_clubs.jpg
Binary file modified cardpacks/set1/seven_of_coins.jpg
Binary file modified cardpacks/set1/seven_of_cups.jpg
Binary file modified cardpacks/set1/seven_of_swords.jpg
Binary file modified cardpacks/set1/six_of_clubs.jpg
Binary file modified cardpacks/set1/six_of_coins.jpg
Binary file modified cardpacks/set1/six_of_cups.jpg
Binary file modified cardpacks/set1/six_of_swords.jpg
Binary file added cardpacks/set1/ten_of_clubs.jpg
Binary file added cardpacks/set1/ten_of_coins.jpg
Binary file added cardpacks/set1/ten_of_cups.jpg
Binary file added cardpacks/set1/ten_of_swords.jpg
Binary file modified cardpacks/set1/three_of_clubs.jpg
Binary file modified cardpacks/set1/three_of_coins.jpg
Binary file modified cardpacks/set1/three_of_cups.jpg
Binary file modified cardpacks/set1/three_of_swords.jpg
Binary file modified cardpacks/set1/two_of_clubs.jpg
Binary file modified cardpacks/set1/two_of_coins.jpg
Binary file modified cardpacks/set1/two_of_cups.jpg
Binary file modified cardpacks/set1/two_of_swords.jpg
35 changes: 31 additions & 4 deletions cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def dealCardsToPlayer(players: {}, dealerId, name: str, noOfCards: int, deck,
else:
mud.sendMessage(dealerId,
'\nYou deal ' + str(ctr) +
' cards to '+cardPlayerName+'.\n')
' cards to ' + cardPlayerName + '.\n')
mud.sendMessage(cardPlayerId,
'\n' + players[dealerId]['name'] + ' deals ' +
str(ctr) + ' cards to you.\n')
Expand Down Expand Up @@ -401,6 +401,24 @@ def getCardDescription(pack: str, rank: str, suit: str) -> str:
rankStr = 'Ace'
elif rankStr.startswith('J'):
rankStr = 'Jack'
elif rankStr.startswith('2'):
rankStr = 'Two'
elif rankStr.startswith('3'):
rankStr = 'Three'
elif rankStr.startswith('4'):
rankStr = 'Four'
elif rankStr.startswith('5'):
rankStr = 'Five'
elif rankStr.startswith('6'):
rankStr = 'Six'
elif rankStr.startswith('7'):
rankStr = 'Seven'
elif rankStr.startswith('8'):
rankStr = 'Eight'
elif rankStr.startswith('9'):
rankStr = 'Nine'
elif rankStr.startswith('10'):
rankStr = 'Ten'

if suit == '♥':
if pack == 'cloisters':
Expand Down Expand Up @@ -462,6 +480,7 @@ def showHandOfCards(players: {}, id, mud, rooms: {},
lines = [[] for i in range(9)]
cardColor = "\u001b[38;5;240m"
cardDescriptions = ''
htmlStr = '<table id="cards"><tr>'

for cardStr in hand:
if len(cardStr) < 2:
Expand All @@ -475,7 +494,15 @@ def showHandOfCards(players: {}, id, mud, rooms: {},
suit = cardStr[2]
suitColor = "\u001b[38;5;245m"

cardDescriptions += getCardDescription(pack, rank, suit)
desc = getCardDescription(pack, rank, suit)
cardDescriptions += desc.strip()

# create html for the web interface
htmlStr += '<td>'
htmlStr += '<img class="playingcard" ' + \
'src="cardpacks/' + pack.lower() + '/' + \
desc.replace(' ', '_').lower() + '.jpg" />'
htmlStr += '</td>'

if suit == '♥' or suit == '♦':
suitColor = "\u001b[31m"
Expand All @@ -496,6 +523,7 @@ def showHandOfCards(players: {}, id, mud, rooms: {},
rank, cardColor))
lines[8].append('└─────────┘')

htmlStr += '</tr></table>'
boardStr = cardColor + '\n'

graphicalCards = True
Expand All @@ -504,8 +532,7 @@ def showHandOfCards(players: {}, id, mud, rooms: {},
graphicalCards = False
if graphicalCards:
if mud.playerUsingWebInterface(id):
# TODO show cards as html
boardStr += '<i>Show cards as html</i>'
boardStr = htmlStr
else:
for lineRowStr in lines:
lineStr = ''
Expand Down
2 changes: 1 addition & 1 deletion def/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -31851,7 +31851,7 @@
"heave": "",
"jumpTo": "",
"game": "cards morris",
"cardPack": "cloisters",
"cardPack": "set1",
"gameState": {},
"state": "container open always",
"visibleWhenWearing": [],
Expand Down
28 changes: 20 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
width: 100%;
background-color: var(--main-background-color);
}
#cards {
height: 20%;
}
#playingcard {
height: 20%;
}
</style>

<title>AberMUSH</title>
Expand Down Expand Up @@ -198,15 +204,21 @@
}

if (destination != "roomtitle") {
// split the message into lines
var lines = message.split('\n');
msgStr = "";
var maxLines = lines.length;
if (destination == "roomimage") {
if (maxLines > 40) maxLines = 40;
if (message.includes('<img class=')) {
// playing card images
msgStr = message;
}
for (var i = 0; i < maxLines; i++) {
msgStr += ansi_up.ansi_to_html(lines[i]) + "<br>";
else {
// split the message into lines
var lines = message.split('\n');
msgStr = "";
var maxLines = lines.length;
if (destination == "roomimage") {
if (maxLines > 40) maxLines = 40;
}
for (var i = 0; i < maxLines; i++) {
msgStr += ansi_up.ansi_to_html(lines[i]) + "<br>";
}
}
}
else {
Expand Down
5 changes: 4 additions & 1 deletion mudserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ def send_game_board(self, to, message) -> None:
cl.socket.sendMessage(msgStr)
time.sleep(0.03)
elif cl.client_type == self._CLIENT_WEBSOCKET:
cl.socket.sendMessage('****IMAGE****' + message)
if '<img class="playingcard" ' not in message:
cl.socket.sendMessage('****IMAGE****' + message)
else:
cl.socket.sendMessage('****CLEAR****' + message)
if cl.client_type == self._CLIENT_TELNET:
cl.socket.sendall(bytearray(cmsg('<b0>'), 'utf-8'))
elif cl.client_type == self._CLIENT_WEBSOCKET:
Expand Down

0 comments on commit ecf8eac

Please sign in to comment.