예제 #1
0
import logging

module_logger= logging.getLogger('landduels.ui.button')
module_logger.setLevel(logging.DEBUG)

import pygame
from pygame.sprite import Sprite
from events.event import MouseEnteredButtonEvent
from events.event import MouseLeftButtonEvent
from events.event import ButtonClickedEvent
from events.event import ButtonClickEndedEvent
from events.command import Command
from util.enum import enum

ButtonState = enum('NORMAL', 'MOUSEOVER', 'PRESSED')


class Button(Sprite):
    def __init__(self, id, imagepath, event_dispatcher, x, y):
        super(Button, self).__init__()

        self.dispatcher = event_dispatcher
        self._connections = [
            self.dispatcher.subscribe_to_event(MouseEnteredButtonEvent, Command(self.on_mouse_enter)),
            self.dispatcher.subscribe_to_event(MouseLeftButtonEvent, Command(self.on_mouse_leave)),
            self.dispatcher.subscribe_to_event(ButtonClickedEvent, Command(self.on_clicked)),
            self.dispatcher.subscribe_to_event(ButtonClickEndedEvent, Command(self.on_click_ended))
        ]

        self.id = id
예제 #2
0
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))

from datastruct.queue import Queue
from datastruct.stack import Stack
from util.enum import enum
from graphMatrix import Graph as MGraph

class EdgeNode(object):
    def __init__(self, vertex, weight=0, next=None):
        self.vertex = vertex
        self.weight = weight
        self.next = next

VertexState = enum('VertexState', 'undiscovered', 'discovered', 'processed')

class Vertex(object):
    def __init__(self, label=None):
        self.label = label
        self.edgeHead = EdgeNode(None)
        self.degree = 0

    def addEdge(self, vertex, weight=0, checkDup=False):
        if not checkDup:
            node = EdgeNode(vertex, weight)
            node.next = self.edgeHead.next
            self.edgeHead.next = node
        else:
            n = self.edgeHead
            while n.next:
예제 #3
0
'''##########################################################
   # Card CLASS -> This is the main class for cards
   # Created: 2015 - 01 - 09
   # Slaveworx, (add your credits here joe)
   #########################################################'''

import pygame
import uuid
from pygame.sprite import Sprite
from pygame.sprite import Rect
from util.enum import enum

CardTypes = enum("Invalid", "Creature", "Magic", "Trap", "Action", "Armor", "Weapon")


class Card(Sprite):
    def __init__(self, *args, **kwargs):
        super(Card, self).__init__()
        self.initialize_card(*args, **kwargs)

    def scale(self, factor):
        self._scale = factor
        self.image = self.card.copy()
        self.image = pygame.transform.rotozoom(self.image, self._angle, factor)
        self.rect = self.image.get_rect()
        self.rect.center = (self.x, self.y)

    def rotate(self, angle):
        self._angle = angle
        self.image = self.card.copy()
        self.image = pygame.transform.rotozoom(self.image, angle, self._scale)
예제 #4
0
파일: ring.py 프로젝트: wh228/molecular-sdg
	RingSystem (TODO: Not necessarily needed...)

* Functions:
	partition_rings()
"""

from util.enum import enum
"""
Ring types are discovered during ring peeling. As each ring is peeled
from the ring group, it is assigned one of the types below.
"""
RING_TYPES = enum(
    'CORE',  # Last remaining ring (tractable case)
    'TOUGH_CORE',  # Remaining ring(s) (intractable case)
    'SPIRO',  # Spiro rings share one atom
    'FUSED',  # Fused rings share an edge
    'BRIDGED',  # Bridged rings share two non-adjacent atoms
    'IRREGULAR',  # Irregular ring
    'NONE'  # No type assigned
)


class Point(object):
    """Represents a 2D position."""
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

    def __eq__(self, o):
        """Equal if within a certain delta."""
        DELTA = 0.00005
예제 #5
0
* Functions:
	partition_rings()
"""

from util.enum import enum

"""
Ring types are discovered during ring peeling. As each ring is peeled
from the ring group, it is assigned one of the types below.
"""
RING_TYPES = enum(
	'CORE', 		# Last remaining ring (tractable case)
	'TOUGH_CORE',	# Remaining ring(s) (intractable case)
	'SPIRO',		# Spiro rings share one atom
	'FUSED', 		# Fused rings share an edge
	'BRIDGED', 		# Bridged rings share two non-adjacent atoms
	'IRREGULAR',	# Irregular ring
	'NONE'			# No type assigned
)

class Point(object):
	"""Represents a 2D position."""

	def __init__(self, x=None, y=None):
		self.x = x
		self.y = y

	def __eq__(self, o):
		"""Equal if within a certain delta."""
		DELTA = 0.00005