Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/game.py
blob: ad733bfba6f7ae6233722e7374c2114def599407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python

# Copyright (C) 2013 Cristhofer Travieso <cristhofert97@gmail.com>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
import os
import random

WIDTH = 1200
HEIGHT = 700

OPPONENT_CARDS = [None, None, None]
MY_CARDS = [None, None, None]
CARDS = []

class Eventbox(Gtk.EventBox):
    def __init__(self):
        Gtk.EventBox.__init__(self)

        parse, color = Gdk.Color.parse('green')
        self.modify_bg(Gtk.StateType.NORMAL, color)

        self.add(Box())
        self.show_all()

class Box(Gtk.VBox):
    def __init__(self):
        Gtk.VBox.__init__(self)

        self.cards = []

        self.opponent_box = Gtk.HBox()
        self.add(self.opponent_box)
        self.play_box = Gtk.HBox()
        self.add(self.play_box)
        self.my_box = Gtk.HBox()
        self.add(self.my_box)

        self._deal()

        #btn1
        btn1 = Gtk.Button(self.cards[0])
        btn1.connect('clicked', self._click)
        self.my_box.add(btn1)

        #btn2
        btn2 = Gtk.Button(self.cards[1])
        btn2.connect('clicked', self._click)
        self.my_box.add(btn2)

        #btn3
        btn3 = Gtk.Button(self.cards[2])
        btn3.connect('clicked', self._click)
        self.my_box.add(btn3)

    def _deal(self):

        num = 0
        while num < 6:
            self.cards.append( str(random.randint(0, 13))+ random.choice(['coarse', 'cup', 'gold', 'sword']) )
            num += 1

        '''OPPONENT_CARDS[0] = str(random.randint(0, 13))+ random.choice(['coarse',
                                                     'cup', 'gold', 'sword'])
        OPPONENT_CARDS[1] = str(random.randint(0, 13))+ random.choice(['coarse',
                                                     'cup', 'gold', 'sword'])
        OPPONENT_CARDS[2] = str(random.randint(0, 13))+ random.choice(['coarse',
                                                     'cup', 'gold', 'sword'])

        MY_CARDS[0] = str(random.randint(0, 13)) + random.choice(['coarse',
                                                     'cup', 'gold', 'sword'])
        MY_CARDS[2] = str(random.randint(0, 13)) + random.choice(['coarse',
                                                     'cup', 'gold', 'sword'])
        MY_CARDS[3] = str(random.randint(0, 13)) + random.choice(['coarse',
                                                     'cup', 'gold', 'sword'])'''

    def _click(self, widget):
        self.my_box.remove(widget)
        self.play_box.add(widget)

if __name__ == "__main__":
    window = Gtk.Window()
    window.connect('destroy', lambda w: Gtk.main_quit())
    window.add(Eventbox())
    window.maximize()
    window.set_title('Truco')
    window.show()
    Gtk.main()