!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.16 (Debian). PHP/5.3.3-7+squeeze19 

uname -a: Linux mail.tri-specialutilitydistrict.com 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC
2014 x86_64
 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/share/pyshared/glchess/scene/   drwxr-xr-x
Free 130.01 GB of 142.11 GB (91.49%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     human.py (4.25 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# -*- coding: utf-8 -*-
"""
"""

__author__ = 'Robert Ancell <bob27@users.sourceforge.net>'
__license__ = 'GNU General Public License Version 2'
__copyright__ = 'Copyright 2005-2006  Robert Ancell'

import glchess.scene

class SceneHumanInput:
    """
    """
    
    def __init__(self):
        """Constructor for a scene with human selectable components"""
        self.__inputEnabled = True # Flag to control if human input is enabled
        self.__startSquare  = None # The selected square to move from
        self.__showHints    = True
    
    # Methods to extend
    
    def onRedraw(self):
        """This method is called when the scene needs redrawing"""
        pass
        
    def playerIsHuman(self):
        """Check if the current player is a human.
        
        Return True the current player is human else False.
        """
        return False
    
    def getSquare(self, x, y):
        """Find the chess square at a given 2D location.
        
        'x' is the number of pixels from the left of the scene to select.
        'y' is the number of pixels from the bottom of the scene to select.
        
        Return the co-ordinate as a tuple in the form (file,rank) or None if
        no square at this point.
        """
        pass

    def squareIsFriendly(self, coord):
        """Check if a given square contains a friendly piece.
        
        Return True if this square contains a friendly piece.
        """
        return False
    
    def canMove(self, start, end):
        """Check if a move is valid.
        
        'start' is the location to move from in LAN format (string).
        'end' is the location to move from in LAN format (string).
        """
        return False
    
    def moveHuman(self, start, end):
        """Called when a human player moves.
        
        'start' is the location to move from in LAN format (string).
        'end' is the location to move from in LAN format (string).
        """
        pass
    
    # Public methods
    
    def enableHumanInput(self, inputEnabled):
        """Enable/disable human input.
        
        'inputEnabled' is a flag to show if human input is enabled (True) or disabled (False).
        """
        if inputEnabled is False:
            self.__selectSquare(None)
        self.__inputEnabled = inputEnabled
        
    def select(self, x, y):
        """
        """
        if self.__inputEnabled is False:
            return
        
        # Only bother if the current player is human
        if self.playerIsHuman() is False:
            return
        
        # Get the selected square
        coord = self.getSquare(x, y)
        if coord is None:
            return
        
        # Deselect when clicking on piece a second time
        if self.__startSquare == coord:
            self.__selectSquare(None)
            return

        # If this is a friendly piece then select it
        if self.squareIsFriendly(coord):
            self.__selectSquare(coord)

        else:
            # If we have already selected a start move try
            # and move to this square
            if self.__startSquare is not None:
                self.__move(self.__startSquare, coord)

        # Redraw the scene
        self.onRedraw()
        
        return coord

    def deselect(self, x, y):
        """
        """
        if self.__inputEnabled is False:
            return
        
        # Only bother if the current player is human
        if self.playerIsHuman() is False:
            return
        
        # Get the selected square
        coord = self.getSquare(x, y)
        if coord is None:
            return
        
        # Attempt to move here
        if self.__startSquare is not None and self.__startSquare != coord:
            self.__move(self.__startSquare, coord)
        
        # Redraw the scene
        self.onRedraw()
        
        return coord
    
    # Private methods
    
    def __selectSquare(self, coord):
        if self.__startSquare == coord:
            return
        self.__startSquare = coord
        self.selectSquare(coord)
    
    def __move(self, start, end):
        """Attempt to make a move.
        
        ...
        """
        if self.canMove(start, end) is False:
            return
        self.__selectSquare(None)
        self.moveHuman(start, end)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0169 ]--