diff --git a/honeybot/pluginInfo.py b/honeybot/pluginInfo.py
index dcef8ff..a7ac47e 100644
--- a/honeybot/pluginInfo.py
+++ b/honeybot/pluginInfo.py
@@ -45,7 +45,7 @@ def docFind(lines, att):
else:
plug += "\\\n"
- plug += docFind(x.__doc__, "About") + "\n"
+ plug += docFind(x.__doc__, "About") + "\n"
if docFind(x.__doc__, "Commands") != "Unknown Commands":
plug += "\\\n" + docFind(x.__doc__, "Commands").replace(">>> ","").replace("<","\\<") + "
" + "\n"
else:
@@ -54,5 +54,3 @@ def docFind(lines, att):
f.write(plug)
f.close()
-
-
diff --git a/honeybot/plugins/.DS_Store b/honeybot/plugins/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/honeybot/plugins/.DS_Store differ
diff --git a/honeybot/plugins/converter.py b/honeybot/plugins/converter.py
index ea2357d..86e6ff0 100644
--- a/honeybot/plugins/converter.py
+++ b/honeybot/plugins/converter.py
@@ -4,7 +4,7 @@
[Author]
Angelo Giacco
[About]
-Gets the top 10 headlines around the world from bbc world news
+Converts currencies
[Commands]
>>> .convert <> <> <>
returns the conversion: amount argument is optional with a default of 1
diff --git a/honeybot/plugins/monopoly.py b/honeybot/plugins/monopoly.py
index a3bc5a6..59ccb94 100644
--- a/honeybot/plugins/monopoly.py
+++ b/honeybot/plugins/monopoly.py
@@ -869,7 +869,7 @@ def buy(methods,info):
"""
RUN PLUGIN
"""
-
+
def run(self, incoming, methods, info, bot_info):
try:
if info['command'] == 'PRIVMSG':
diff --git a/honeybot/plugins/poker_assets/best5.py b/honeybot/plugins/poker_assets/best5.py
new file mode 100644
index 0000000..4efee4d
--- /dev/null
+++ b/honeybot/plugins/poker_assets/best5.py
@@ -0,0 +1,102 @@
+''' poker hand evaluator '''
+
+# pylint: disable=W0612
+
+import itertools
+
+def best_hand(hand):
+ ''' from a 7-card hand, return the best 5 card hand '''
+
+ return max(itertools.combinations(hand, 5), key=hand_rank)
+
+def hand_rank(hand):
+ ''' return a value indicating the ranking of a hand '''
+
+ ranks = card_ranks(hand)
+ if straight(ranks) and flush(hand):
+ return 8, max(ranks)
+
+ elif kind(4, ranks):
+ # four of a kind
+ return 7, kind(4, ranks), kind(1, ranks)
+
+ elif kind(3, ranks) and kind(2, ranks):
+ # full house
+ return 6, kind(3, ranks), kind(2, ranks)
+
+ elif flush(hand):
+ # all cards of same suit
+ return 5, ranks
+
+ elif straight(ranks):
+ # cards in sequence
+ return 4, max(ranks)
+
+ elif kind(3, ranks):
+ # 3 cards of same rank
+ return 3, kind(3, ranks), ranks
+
+ elif two_pair(ranks):
+ # 2 pairs of same rank
+ return 2, two_pair(ranks), ranks
+
+ elif kind(2, ranks):
+ # 1 pair of same rank
+ return 1, kind(2, ranks), ranks
+
+ else:
+ # Nothing (High Card)
+ return 0, ranks
+
+def card_ranks(hand):
+ ''' return a list of the ranks, sorted with higher first '''
+
+ ranks = ['--23456789TJQKA'.index(r) for r, s in hand]
+ ranks.sort(reverse=True)
+ # to handle the (A-5) straight case
+ return [5, 4, 3, 2, 1] if (ranks == [14, 5, 4, 3, 2]) else ranks
+
+def flush(hand):
+ ''' return True if all the cards have the same suit '''
+
+ suits = [s for r, s in hand]
+ return len(set(suits)) == 1
+
+def straight(ranks):
+ ''' return True if the ordered ranks form a 5-card straight '''
+
+ return (max(ranks) - min(ranks) == 4) and len(set(ranks)) == 5
+
+def kind(n, ranks):
+ ''' return the first rank that this hand has exactly n-of-a-kind of. Return None if there is no
+ n-of-a-kind in the hand '''
+
+ for r in ranks:
+
+ if ranks.count(r) == n:
+ return r
+
+ return None
+
+def two_pair(ranks):
+ ''' if there are two pair here, return the two ranks of the two pairs, else None '''
+
+ pair = kind(2, ranks)
+ lowpair = kind(2, list(reversed(ranks)))
+ if pair and lowpair != pair:
+ return pair, lowpair
+
+ else:
+ return None
+
+def test_best_hand(playerhand):
+ # S = Spade
+ # D = Diamond
+ # C = Club
+ # H = Heart
+ # assert (sorted(best_hand('6C 7C 8C 9C TC 5C JS'.split())) == ['6C', '7C', '8C', '9C', 'TC'])
+ # assert (sorted(best_hand('TD TC TH 7C 7D 8C 8S'.split())) == ['8C', '8S', 'TC', 'TD', 'TH'])
+ # assert (sorted(best_hand('JD TC TH 7C 7D 7S 7H'.split())) == ['7C', '7D', '7H', '7S', 'JD'])
+ # return 'test_best_hand passes'
+ # return sorted(best_hand('2D 2C 2H 7C 7D KC KS'.split()))
+ return sorted(best_hand(playerhand.split()))
diff --git a/honeybot/plugins/poker_assets/board.py b/honeybot/plugins/poker_assets/board.py
new file mode 100644
index 0000000..ea7297f
--- /dev/null
+++ b/honeybot/plugins/poker_assets/board.py
@@ -0,0 +1,57 @@
+''' board class '''
+
+# pylint: disable=E1601
+class Board(object):
+ ''' board class '''
+
+ def __init__(self, board):
+ ''' board initialization '''
+
+ self.__board = board
+ self.__flop = board[:3]
+ self.__flop1 = board[0]
+ self.__flop2 = board[1]
+ self.__flop3 = board[2]
+ self.__turn = board[3]
+ self.__river = board[4]
+
+ def get_board(self):
+ '''return card objects of board'''
+ return self.__board
+
+ def show_board(self):
+ ''' show board '''
+ return(" ".join([c.show_card() for c in self.__board]))
+
+ def flop(self):
+ ''' show flop '''
+
+ return(" ".join([c.show_card() for c in self.__flop]))
+
+ def flop1(self):
+ ''' show flop1 '''
+
+ return self.__flop1.show_card()
+
+ def flop2(self):
+ ''' show flop2 '''
+
+ return self.__flop2.show_card()
+
+ def flop3(self):
+ ''' show flop3 '''
+
+ return self.__flop3.show_card()
+
+ def turn(self):
+ ''' show turn '''
+
+ return self.__turn.show_card()
+
+ def river(self):
+ ''' show river '''
+
+ return self.__river.show_card()
+
+ def __len__(self):
+ return len(self.__board)
diff --git a/honeybot/plugins/poker_assets/card.py b/honeybot/plugins/poker_assets/card.py
new file mode 100644
index 0000000..3890e9b
--- /dev/null
+++ b/honeybot/plugins/poker_assets/card.py
@@ -0,0 +1,55 @@
+''' card class '''
+
+# pylint: disable=E1601
+
+class Card(object):
+ ''' card class '''
+
+ def __init__(self, card):
+ ''' card initialization; Card('8s'), Card('QC') '''
+ values = [0,1,2,3] #0 is for a low: 2 3 4, 1 for a medium 4 5 6 7, 2 for a high 8 9 10, 3 for a suit J Q K A
+
+ self.__figure = card[0]
+ self.__color = card[1].upper()
+ self.__card = self.__figure + self.__color
+
+ if self.__figure == 'A':
+ self.__value = 14
+
+ elif self.__figure == 'K':
+ self.__value = 13
+
+ elif self.__figure == 'Q':
+ self.__value = 12
+
+ elif self.__figure == 'J':
+ self.__value = 11
+
+ elif self.__figure == 'T':
+ self.__value = 10
+
+ else:
+ self.__value = int(self.__figure)
+
+ def show_card(self):
+ ''' show card '''
+ if self.__card == "0X":
+ print("This card does not exist, check your index!")
+ pass
+ else:
+ return self.__card
+
+ def figure(self):
+ ''' show figure '''
+
+ return self.__figure
+
+ def color(self):
+ ''' show color '''
+
+ return self.__color
+
+ def value(self):
+ ''' show value '''
+
+ return self.__value
diff --git a/honeybot/plugins/poker_assets/deck.py b/honeybot/plugins/poker_assets/deck.py
new file mode 100644
index 0000000..cec13f6
--- /dev/null
+++ b/honeybot/plugins/poker_assets/deck.py
@@ -0,0 +1,101 @@
+''' deck class '''
+
+# pylint: disable=E1601, W0612
+
+import random
+import card
+
+class Deck(object):
+ ''' deck class '''
+
+ colors = ['C', 'D', 'H', 'S']
+ figures = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
+
+ i = 0
+ for color in colors:
+
+ for figure in figures:
+
+ locals()['card%s' % i] = card.Card(figure + color)
+ i += 1
+ def __init__(self):
+ ''' deck initialization '''
+
+ self.__deck = []
+ for color in self.colors:
+
+ for figure in self.figures:
+
+ self.__deck.append(card.Card(figure + color))
+
+ def show_deck(self):
+ ''' show deck '''
+
+ return(" ".join([c.show_card() for c in self.__deck]))
+
+ def nth_card(self, n):
+ ''' show the n-th card from deck '''
+
+ try:
+ return self.__deck[n]
+ except BaseException:
+ print('Wrong index')
+ return card.Card("0X")
+
+ def draw_by_number(self, nr):
+ ''' pick card from deck by nr '''
+
+ try:
+ pick = self.__deck[nr]
+ if pick == "OX":
+ raise BaseException
+ self.__deck.remove(pick)
+ return pick
+
+ except BaseException:
+ print('Wrong index')
+ return card.Card("0X")
+
+ def draw_by_name(self, name):
+ ''' pick card from deck by name '''
+
+ flag = 0
+ for pick in self.__deck:
+
+ if pick.show_card() == name:
+ self.__deck.remove(pick)
+ flag = 1
+ break
+
+ if flag == 0:
+ print('Wrong name')
+ pass
+
+ else:
+ return pick
+
+ def make_board(self):
+ ''' make a random board '''
+
+ board = []
+ for i in range(5):
+
+ random_number = random.randint(0, len(self.__deck) - 1)
+ board.append(self.draw_by_number(random_number))
+
+ return board
+
+ def make_hand(self):
+ ''' make a random hand '''
+
+ hand = []
+ for i in range(2):
+
+ random_number = random.randint(0, len(self.__deck) - 1)
+ hand.append(self.draw_by_number(random_number))
+
+ return hand
+
+ def __len__(self):
+ '''return the number of cards in the deck '''
+ return len(self.__deck)
diff --git a/honeybot/plugins/poker_assets/game_init.py b/honeybot/plugins/poker_assets/game_init.py
new file mode 100644
index 0000000..bfeb5c5
--- /dev/null
+++ b/honeybot/plugins/poker_assets/game_init.py
@@ -0,0 +1,60 @@
+
+''' game initialization '''
+
+# pylint: disable=E1601, W0612
+
+import card
+import deck
+import board
+import hand
+import player
+import pot
+
+def init_players(nr_of_players, starting_chips):
+ ''' players initialization '''
+
+ PLAYERS = [player.Player(i, starting_chips) for i in range(nr_of_players)]
+ return PLAYERS
+
+def init_game(players, round):
+ ''' table initialization '''
+
+ DECK = deck.Deck()
+ BOARD = board.Board(DECK.make_board())
+ POT = pot.Pot()
+ PLAYERS = players
+
+ for PLAYER in PLAYERS:
+
+ PLAYER.add_hand(hand.Hand(DECK.make_hand()))
+
+ for i in range(len(PLAYERS)):
+
+ PLAYERS[i].add_position((len(PLAYERS) * round + (i - (round - 1))) % len(PLAYERS))
+
+ return DECK, BOARD, POT, PLAYERS
+
+players = init_players(6, 100)
+game = init_game(players, 9)
+
+deck = game[0]
+board = game[1]
+pot = game[2]
+players = game[3]
+for card in board.get_board():
+
+ print(card.show_card())
+
+print(pot.show_pot())
+
+players[0].show_player_hand().best_five(board)
+
+for player in players:
+
+ print(player.general_name())
+
+ print(player.general_name(), player.show_player_hand().show_hand()[0].show_card(), \
+ player.show_player_hand().show_hand()[1].show_card(), player.chips(), player.position_nr(), \
+ player.position_name(), player.show_player_hand().hand_strength(board), str(player.show_player_hand().best_five(board)))
+
+print(len(deck.show_deck()))
diff --git a/honeybot/plugins/poker_assets/hand.py b/honeybot/plugins/poker_assets/hand.py
new file mode 100644
index 0000000..703708d
--- /dev/null
+++ b/honeybot/plugins/poker_assets/hand.py
@@ -0,0 +1,63 @@
+''' hand class '''
+
+# pylint: disable=E1601
+
+import deuces
+import best5
+import board
+import card
+
+class Hand(object):
+ ''' hand class '''
+
+ def __init__(self, hand):
+ ''' hand initialization '''
+
+ self.__hand = hand
+ self.__card1 = hand[0]
+ self.__card2 = hand[1]
+
+ def show_hand(self):
+ ''' show hand '''
+
+ return self.__hand
+
+ def show_hand_obj(self):
+ ''' show hand object '''
+
+ return self.__hand
+
+ def best_five(self, b):
+ ''' best 5 out of 7 '''
+
+ try:
+ """
+ print(b.flop1())
+ print(b.flop2())
+ print(b.flop3())
+ print(b.turn())
+ print(b.river())
+ """
+ print(" ".join([c.show_card() for c in self.show_hand()]))
+ hand_and_board = self.show_hand()[0].show_card() + ' ' + self.show_hand()[1].show_card() +\
+ ' ' + b.flop1() + ' ' + b.flop2() + ' ' + b.flop3() + ' ' + b.turn() + ' ' + b.river()
+
+ return(" ".join([c for c in best5.test_best_hand(hand_and_board)]))
+ except Exception:
+ return "error with non board object"
+
+ def hand_strength(self, board):
+ ''' hand strength '''
+
+ evaluator = deuces.Evaluator()
+ b5 = self.best_five(board)
+ h1 = b5[:2].replace('S', 's').replace('H', 'h').replace('D', 'd').replace('C', 'c')
+ h2 = b5[3:5].replace('S', 's').replace('H', 'h').replace('D', 'd').replace('C', 'c')
+ b1 = b5[6:8].replace('S', 's').replace('H', 'h').replace('D', 'd').replace('C', 'c')
+ b2 = b5[9:11].replace('S', 's').replace('H', 'h').replace('D', 'd').replace('C', 'c')
+ b3 = b5[12:14].replace('S', 's').replace('H', 'h').replace('D', 'd').replace('C', 'c')
+ hl = [deuces.Card.new(h1), deuces.Card.new(h2)]
+ bl = [deuces.Card.new(b1), deuces.Card.new(b2), deuces.Card.new(b3)]
+ strength = evaluator.evaluate(bl, hl)
+
+ return strength
diff --git a/honeybot/plugins/poker_assets/player.py b/honeybot/plugins/poker_assets/player.py
new file mode 100644
index 0000000..ca2736b
--- /dev/null
+++ b/honeybot/plugins/poker_assets/player.py
@@ -0,0 +1,90 @@
+''' player class '''
+# pylint: disable=E1601
+class Player(object):
+ ''' player class '''
+
+ def __init__(self, nr, chips):
+ ''' player initialization '''
+
+ self.__position_nr = nr
+ self.__general_name = 'player' + str(nr)
+ self.__chips = chips
+ self.__hand = []
+ self.add_position(nr)
+
+ def number(self):
+ ''' show number '''
+
+ return self.__number
+
+ def general_name(self):
+ ''' general name '''
+
+ return self.__general_name
+
+ def show_player_hand(self):
+ ''' show hand '''
+
+ return self.__hand
+
+ def add_hand(self, hand):
+ ''' adding hand to player '''
+
+ self.__hand = hand
+
+ def chips(self):
+ ''' show chips '''
+
+ return self.__chips
+
+ def increase_chips(self, win_chips):
+ ''' winning money '''
+
+ self.__chips = self.__chips + win_chips
+
+ def decrease_chips(self, lost_chips):
+ ''' losing money '''
+
+ self.__chips = self.__chips - lost_chips
+
+ def position_nr(self):
+ ''' show position number '''
+
+ return self.__position_nr
+
+ def position_name(self):
+ ''' show position name '''
+
+ return self.__position_name
+
+ def add_position(self, position_nr):
+ ''' adding position '''
+
+ if position_nr >= 0 and position_nr <= 5:
+ self.__position_nr = position_nr
+
+ if self.__position_nr == 0:
+ self.__position_name = 'Small Blind'
+
+ elif self.__position_nr == 1:
+ self.__position_name = 'Big Blind'
+
+ elif self.__position_nr == 2:
+ self.__position_name = 'Under the Gun'
+
+ elif self.__position_nr == 3:
+ self.__position_name = 'Middle'
+
+ elif self.__position_nr == 4:
+ self.__position_name = 'Tail'
+
+ else:
+ self.__position_name = 'Dealer'
+
+ else:
+ print('Position nr is too big or too little')
+ pass
+
+ def bet(self, amount):
+ game_init.game[2].increase_pot(amount)
+ self.decrease_chips(0)
diff --git a/honeybot/plugins/poker_assets/pot.py b/honeybot/plugins/poker_assets/pot.py
new file mode 100644
index 0000000..fc284e4
--- /dev/null
+++ b/honeybot/plugins/poker_assets/pot.py
@@ -0,0 +1,23 @@
+
+''' pot class '''
+
+# pylint: disable=E1601
+
+class Pot(object):
+ ''' pot class '''
+
+ def __init__(self):
+ ''' pot initialization '''
+
+ self.__pot = 0
+
+ def show_pot(self):
+ ''' show pot '''
+
+ return self.__pot
+
+ def increase_pot(self, chips):
+ ''' increase pot '''
+
+ self.__pot = self.__pot + chips
+ return self.__pot
diff --git a/honeybot/plugins/poker_assets/test.py b/honeybot/plugins/poker_assets/test.py
new file mode 100644
index 0000000..da403cb
--- /dev/null
+++ b/honeybot/plugins/poker_assets/test.py
@@ -0,0 +1,106 @@
+''' poker test '''
+
+import board
+import deck
+import hand
+import player
+import pot
+#import game_init
+
+deck = deck.Deck()
+
+print(deck.show_deck())
+print(deck.nth_card(23))
+print(deck.nth_card(23).show_card(), deck.nth_card(23).figure(), deck.nth_card(23).color(), deck.nth_card(23).value())
+print(deck.draw_by_number(1).show_card())
+print(deck.show_deck())
+print(deck.draw_by_name('AS').show_card())
+print(deck.show_deck())
+print(board.Board(deck.make_board()).show_board())
+print(hand.Hand(deck.make_hand()).show_hand())
+print(len(deck.show_deck()))
+print(deck.show_deck())
+print(deck.nth_card(66).show_card())
+
+board = board.Board(deck.make_board())
+
+print(board.show_board())
+print(deck.show_deck())
+print(board.flop())
+print(board.flop1())
+print(board.flop2())
+print(board.flop3())
+print(board.turn())
+print(board.river())
+
+hand1 = hand.Hand(deck.make_hand())
+
+print(deck.show_deck())
+print(hand1.show_hand())
+print(hand1.show_hand_obj()[0].show_card())
+print(hand1.show_hand_obj()[0].value())
+print(hand1.show_hand_obj()[0].color())
+print(hand1.best_five(board))
+print(hand1.hand_strength(board))
+
+hand2 = hand.Hand(deck.make_hand())
+
+print(deck.show_deck())
+print(hand2.show_hand())
+print(hand2.show_hand_obj()[1].show_card())
+print(hand2.show_hand_obj()[1].value())
+print(hand2.show_hand_obj()[1].color())
+print(hand2.best_five(board))
+print(hand2.hand_strength(board))
+
+player1 = player.Player(1, 100)
+
+player1.add_hand(hand1)
+print(player1.show_player_hand().show_hand())
+print(player1.show_player_hand().show_hand_obj()[0].color())
+print(player1.show_player_hand().hand_strength(board))
+print(str(player1.chips()))
+player1.increase_chips(50)
+print(str(player1.chips()))
+print(player1.position_name())
+player1.add_position(4)
+print(player1.position_name())
+
+player2 = player.Player(2, 100)
+
+player2.add_hand(hand2)
+print(player2.show_player_hand().show_hand())
+print(player2.show_player_hand().show_hand_obj()[1].color())
+print(player2.show_player_hand().hand_strength(board))
+print(str(player2.chips()))
+player2.decrease_chips(30)
+print(str(player2.chips()))
+print(player2.position_name())
+player2.add_position(7)
+print(player2.position_name())
+
+pot1 = pot.Pot()
+print(pot1.show_pot())
+pot1.increase_pot(55)
+print(pot1.show_pot())
+POT = pot.Pot()
+print(POT.show_pot())
+POT.increase_pot(24)
+print(POT.show_pot())
+POT.increase_pot(6)
+print(POT.show_pot())
+
+print(" ".join([c.show_card() for h in game_init.game[3] for c in h.show_player_hand().show_hand_obj()]))
+
+
+print(len(game_init.game[0])+len(game_init.game[1])+len(game_init.game[3])*2)
+
+for player in game_init.game[3]:
+ print(player.general_name(), player.show_player_hand().show_hand(), player.chips(), \
+ player.position_nr(), player.position_name(), \
+ player.show_player_hand().hand_strength(board), player.show_player_hand().best_five(board))
+
+game_init.game[0].show_deck()
+game_init.game[1].show_board()
+for p in game_init.game[3]:
+ p.show_player_hand().show_hand()
diff --git a/honeybot/plugins_info.md b/honeybot/plugins_info.md
index 97f9160..0c201c4 100644
--- a/honeybot/plugins_info.md
+++ b/honeybot/plugins_info.md
@@ -36,7 +36,7 @@ returns a random comic
# converter.py
by Angelo Giacco\
-Gets the top 10 headlines around the world from bbc world news
+Converts currencies
\
.convert \<\> \<\> \<\>
@@ -143,7 +143,7 @@ responds to .memo, demo of a basic memory plugin
by Angelo Giacco\
Play monopoly
\
->>>.monopoly create
+.monopoly create
# news.py
by Angelo Giacco\
@@ -226,4 +226,3 @@ by Gabriele Ron, [Website](https://Macr0Nerd.github.io)\
sends a wikipedia article on request based off of a search or random query
\
.wiki \ \
-