~ml-launchpad/ubuntu/natty/gcompris/fix-for-777349

« back to all changes in this revision

Viewing changes to src/connect4-activity/connect4p/board.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Gariepy, Marc Gariepy, Stephane Graber
  • Date: 2010-01-04 17:42:49 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174249-7bupatd9dtxyhvs4
Tags: 9.0-0ubuntu1
[Marc Gariepy]
* New upstream release (9.0).
* Remove cache.c from POTFILES to avoid FTBFS
* Remove unneeded rm in debian/rules (file no longer exists upstream)

[Stephane Graber]
* Bump Debian standards to 3.8.3
* Add patch system (dpatch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#  gcompris - connect4
 
2
#
 
3
# Copyright (C) 2005, 2008 Laurent Lacheny
 
4
#
 
5
#   This program is free software; you can redistribute it and/or modify
 
6
#   it under the terms of the GNU General Public License as published by
 
7
#   the Free Software Foundation; either version 3 of the License, or
 
8
#   (at your option) any later version.
 
9
#
 
10
#   This program is distributed in the hope that it will be useful,
 
11
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#   GNU General Public License for more details.
 
14
#
 
15
#   You should have received a copy of the GNU General Public License
 
16
#   along with this program; if not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
#
 
19
# This code comes from the project 4stattack
 
20
# http://forcedattack.sourceforge.net/
 
21
#
 
22
#########################################################################
 
23
#                            4st Attack 2                               #
 
24
#########################################################################
 
25
# Created by:                                                           #
 
26
# Developer            - "slm" - Jeroen Vloothuis                       #
 
27
# Graphics             - "Korruptor" - Gareth Noyce                     #
 
28
# Music                - "theGREENzebra"                                #
 
29
#########################################################################
 
30
# Specail thanks:                                                       #
 
31
# chakie(Jan Elkholm)    - letting me "embrace and extend" his gui lib  #
 
32
# Mighty(Xander Soldaat) - for the Makefile and the Debian packages     #
 
33
# Han                    - for the rpms                                 #
 
34
# jk                     - for the FreeBSD port                         #
 
35
# Tjerk Nan              - for the Windows version                      #
 
36
# Micon                  - for the webdesign                            #
 
37
# Everyone in #pygame and the opensource community in general           #
 
38
#########################################################################
 
39
# This software is licensed under the GPL - General Public License      #
 
40
#########################################################################
 
41
 
 
42
 
 
43
 
 
44
class Board:
 
45
  # Setup an empty board
 
46
  def __init__(self):
 
47
    self.state = []
 
48
    for x in range(7):
 
49
      self.state.append([])
 
50
    self.last_move = -1
 
51
 
 
52
  def move(self, move, player):
 
53
    self.state[move].append(player)
 
54
    self.last_move = move
 
55
 
 
56
  def domoves(self, moves):
 
57
    for (move, player) in moves:
 
58
      self.move(move, player)
 
59
 
 
60
  def undomove(self, move):
 
61
    if len(self.state[move]) > 0:
 
62
      del self.state[move][len(self.state[move])-1]