def test_function_group_with_no_shapes_should_return_false(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [50, 50, 100, 100])
     rectangle = self.create_rectangle(canvas, [300, 300, 400, 400])
     canvas.pack()
     output = Commands(canvas, [ellipse, rectangle]).group([])
     self.assertFalse(output)
 def test_function_redo_with_no_shapes_should_do_nothing(self):
     canvas = Canvas()
     canvas.pack()
     commands = Commands(canvas, [])
     commands.redo()
     self.assertEqual([], commands.command_stack)
     self.assertEqual(0, commands.command_stack_pointer)
 def test_function_resize_should_fail_if_no_shape_is_set(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [50, 50, 100, 100])
     rectangle = self.create_rectangle(canvas, [300, 300, 400, 400])
     canvas.pack()
     output = Commands(canvas, [ellipse, rectangle]).resize([], [400, 400])
     self.assertFalse(output)
 def test_function_move_should_fail_if_shape_parameter_is_empty(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [100, 100, 105, 105])
     canvas = Canvas()
     canvas.pack()
     output = Commands(canvas, [ellipse]).move([], [120, 120])
     self.assertFalse(output)
예제 #5
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     
     panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT))
     nb = wx.Notebook(panel)
     
     cd = CharacterData(nb)
     cs = CharacterSprites(nb)
     ht = HitBox(nb)
     an = Animations(nb)
     sc = SparksCharacter(nb)
     co = Commands(nb)
     hc = HitStatesCharacter(nb)
     fm = FSM(nb)
     ai = AI(nb)
     
     nb.AddPage(cd, "Data")
     nb.AddPage(cs, "Sprites")
     nb.AddPage(ht, "Hitbox")
     nb.AddPage(an, "Animations")
     nb.AddPage(sc, "Sparks")
     nb.AddPage(co, "Commands")
     nb.AddPage(hc, "HitStates")
     nb.AddPage(fm, "FSM")
     nb.AddPage(ai, "AI")
     
     sizer = wx.BoxSizer()
     sizer.Add(nb, 1, wx.EXPAND)
     
     self.SetSizer(sizer)
예제 #6
0
    def __init__(self, accessList):
        self.logger = Logger(observer=textFileLogObserver(sys.stdout))

        self.accessList = [nick.lower() for nick in accessList]

        if not os.path.exists(self.magicFile):
            self.logger.info("Creating magic file")

            try:
                with open(self.magicFile, "a"):
                    pass

            except Exception as ex:
                self.logger.error("Unable to create magic file! {0}".format(
                    ex.message))
                reactor.stop()

        self.markovGenerator = pymarkov.MarkovChainGenerator(self.magicFile)

        self.channels = []
        self.channelPhrasers = {}

        self.logger.debug("Discord initialized")

        # Maybe add hook/plugin system here?

        self.commands = Commands.Commands(self)
 def test_function_export__after_function_import__with_file_shapes_groups_and_ornaments_should_yield_same_file(self):
     canvas = Canvas()
     canvas.pack()
     _input = Commands(canvas, []).import_('shapes_groups_and_ornaments.txt')
     self.assertEqual(8, len(canvas.find_all()))
     groups = []
     shapes = []
     for shape in _input:
         if type(shape) == Group:
             groups.append(shape)
         else:
             shapes.append(shape)
     output = Commands(canvas, shapes).export_(shapes, groups)
     with open('shapes_groups_and_ornaments.txt') as f:
         _input = f.read()
     self.assertEqual(len(output.split('\n')), len(_input.split('\n')))
 def create_ellipse(self, canvas, coordinates=None):
     commands = Commands(canvas, self.current_shapes_list)
     if coordinates:
         # Allow overloading
         return commands.create(Ellipse.shapeName, coordinates)
     else:
         return commands.create(Ellipse.shapeName, [200, 200, 300, 300])
 def test_select_with_1_shape_should_return_1_shape(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas)
     self.current_shapes_list = []  # empty the current_shape_list
     self.current_shapes_list.append(ellipse)
     canvas.pack()
     selected_shape = Commands(canvas, self.current_shapes_list).select([0, 0], [])
     self.assertEqual(len(selected_shape), 1)
     self.assertEqual(selected_shape[0].tag, ellipse.tag)
 def test_function_resize_should_resize_1_shape_if_1_selected(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [50, 50, 100, 100])
     rectangle = self.create_rectangle(canvas, [300, 300, 400, 400])
     canvas.pack()
     output = Commands(canvas, [ellipse, rectangle]).resize([ellipse], [400, 400])
     self.assertIsNone(output)
     ellipse_coordinates = canvas.coords(ellipse.tag)
     self.assertListEqual(ellipse_coordinates, [50, 50, 400, 400])
 def test_function_move_should_move_1_object_if_1_selected(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [50, 50, 100, 100])
     rectangle = self.create_rectangle(canvas, [300, 300, 400, 400])
     canvas.pack()
     output = Commands(canvas, [ellipse, rectangle]).move([rectangle], [400, 400])
     self.assertIsNone(output)
     rectangle_coordinates = canvas.coords(rectangle.tag)
     self.assertListEqual(rectangle_coordinates, [300 + 100, 300 + 100, 400 + 100, 400 + 100])
 def test_function_group_with_shapes_should_return_group_object(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [50, 50, 100, 100])
     rectangle = self.create_rectangle(canvas, [300, 300, 400, 400])
     canvas.pack()
     output = Commands(canvas, [ellipse, rectangle]).group([ellipse, rectangle])
     self.assertIsInstance(output, Group)
     self.assertEqual(len(output.get_all()), 2)
     self.assertListEqual([ellipse, rectangle], output.get_all())
 def test_function_undo_with_2_shapes_should_remove_one_from_canvas_and_move_stack_pointer(self):
     canvas = Canvas()
     commands = Commands(canvas, [])
     commands.create(Ellipse.shapeName, [50, 50, 100, 100])
     commands.create(Rectangle.shapeName, [300, 300, 400, 400])
     canvas.pack()
     self.assertEqual(2, len(canvas.find_all()))
     commands.undo()
     self.assertEqual(1, commands.command_stack_pointer)
     self.assertEqual(1, len(canvas.find_all()))
 def test_select_with_2_shapes_on_canvas_should_return_closest(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [50, 50, 100, 100])
     rectangle = self.create_rectangle(canvas, [100, 100, 160, 160])
     self.current_shapes_list = []  # empty the current_shape_list
     self.current_shapes_list.extend((ellipse, rectangle))
     canvas.pack()
     selected_shape = Commands(canvas, self.current_shapes_list).select([25, 25], [])
     self.assertEqual(len(selected_shape), 1)
     self.assertEqual(selected_shape[0].tag, ellipse.tag)
예제 #15
0
	def goto_commands(self):
		if not self.opened_dialog:
			self.opened_dialog = True
			# Instantiate window, bind focus change to func, set focus
			self.window = Commands.Commands(Toplevel(self.parent), self)
			self.window.parent.bind("<FocusOut>", self.focus_out)
			self.window.parent.focus_set()
			# Open window and make main window wait
			self.parent.wait_window(self.window.parent)
			self.opened_dialog = False
 def test_function_import__with_file_shapes_and_group_txt_where_shapes_should_be_selectable(self):
     canvas = Canvas()
     canvas.pack()
     commands = Commands(canvas, [])
     shapes = commands.import_('shapes_and_groups.txt')
     self.assertEqual(5, len(canvas.find_all()))
     group_list = [shape for shape in shapes if isinstance(shape, Group)]
     self.assertEqual(3, len(group_list))
     shape = commands.select([200, 200], group_list)
     self.assertIsNotNone(shape)
 def create_drawing_frame(self):
     """
     Renders the drawing frame and initializes the Commands object
     :return:
     """
     self.drawing_frame = Frame(self.master, height=800, width=1240)
     self.drawing_frame.pack_propagate(0)
     self.drawing_frame.pack(side=RIGHT, expand=0)
     self.drawing_canvas = Canvas(self.drawing_frame)
     self.drawing_canvas.pack(fill=BOTH, expand=1)
     self.commands = Commands(self.drawing_canvas, self.shapes_list)
예제 #18
0
    async def on_message(self, message):
        print('Message from {0.author}:\n{0.content}'.format(message))

        # Prevents talking to self from taking place
        if message.author == client.user:
            print("<MESSAGE IGNORED>\n")
            return
        print()

        response = Commands(message).command()
        if not (response is None):
            print("Response triggered")
            await response
 def test_function_redo_should_redraw_2_shapes_after_doing_undo_on_2_shapes(self):
     canvas = Canvas()
     commands = Commands(canvas, [])
     commands.create(Ellipse.shapeName, [50, 50, 100, 100])
     commands.create(Rectangle.shapeName, [300, 300, 400, 400])
     canvas.pack()
     self.assertEqual(2, len(canvas.find_all()))
     commands.undo()
     self.assertEqual(1, commands.command_stack_pointer)
     self.assertEqual(1, len(canvas.find_all()))
     commands.redo()
     self.assertEqual(0, commands.command_stack_pointer)
     self.assertEqual(2, len(canvas.find_all()))
예제 #20
0
파일: Control.py 프로젝트: jogi1/energy
    def __init__(self, state):
        self.commands = Commands(state)
        self.options = ['ignoreGravity', 'ignoreDrag', 'unattractable']
        self.particleWeapons = {
            'name':
            'Particle',
            'aimed':
            WeaponCursorAimed(state, 'Particle Aimed', delay=0.01),
            'stationary':
            WeaponSpawnAtPosition(state, 'Particle stationary', delay=0.01),
            'cursor':
            WeaponSpawnAtCursor(state, 'Particle at cursor', delay=0.01),
            'options':
            Particle(state).values.getAllNameValue()
        }
        self.timeWeapons = {
            'name':
            'Time',
            'aimed':
            WeaponSpawnAtCursor(state, 'Time Aimed', Timebubble),
            'stationary':
            WeaponSpawnAtPosition(state, 'Time stationary', Timebubble),
            'cursor':
            WeaponSpawnAtCursor(state, 'Time cursor', Timebubble),
            'options':
            Timebubble(state, Vector(), Vector()).values.getAllNameValue()
        }
        self.gravityWeapons = {
            'name':
            'Attractor',
            'aimed':
            WeaponCursorAimed(state, 'Gravity Aimed', Attractor),
            'stationary':
            WeaponSpawnAtPosition(state, 'Gravity stationary', Attractor),
            'cursor':
            WeaponSpawnAtCursor(state, 'Gravity cursor', Attractor),
            'options':
            Attractor(state, Vector(), Vector()).values.getAllNameValue()
        }
        self.selectWeapon = self.particleWeapons
        self.state = state
        self.pressed = []
        self.pressed_last_frame = []
        self.mousebuttons = [False, False, False, False, False, False]
        self.attractorTime = 0

        self.commands.register('toggleHelp', K_F1, {'start': self.toggleHelp})
예제 #21
0
    def client_thread(self, clientSocket, clientAddress, size=4096):
        self.command = Commands.Commands()
        response = self.getName(clientSocket, size)
        name = response[0]
        isReturnUser = response[1]
        if isReturnUser is True:
            realName = self.command.returnUser(name).realName
            password = self.command.returnUser(name).password
        else:
            clientSocket.send("> What's your real name?\n".encode('utf8'))
            realName = clientSocket.recv(size).decode('utf8')
            clientSocket.send("> What's your password?\n".encode('utf8'))
            password = clientSocket.recv(size).decode('utf8')
        newUser = user.User(name, realName, password, clientSocket,
                            clientAddress, size, "ACTIVE", "AVAILABLE")

        self.command.serverCreatedTime = self.serverTime
        self.command.serverSocket = self.serverSocket
        self.command.host = self.host
        self.command.port = self.port
        self.command.server = "localhost"
        self.command.serverplatform = platform.release()
        self.command.allowReuseAddress = self.allowReuseAddress
        self.command.serverself = self
        self.clients[clientSocket] = newUser
        self.command.allUsers[newUser] = newUser.name
        if len(self.clients) == 1:
            self.channel = self.command.createChannel(self.channelName,
                                                      self.allChannels,
                                                      newUser, False)
            self.channel.allChannels = dict(self.allChannels["Public"])
            self.userPrivileges["Admin"].append(newUser)
            newUser.isAdmin = True
            newUser.currentChannel = self.channel
            self.command.ChannelOP.append(newUser)
        else:
            self.channel.allUsers[newUser.socket] = newUser
            self.channel.allChannels = dict(self.allChannels["Public"])
            newUser.currentChannel = self.channel
            self.command.joinPublic(self.channel, newUser)
        self.allChannels["All Channels"][self.channelName] = self.channel
        self.command.allChannels = dict(self.allChannels["All Channels"])
        self.command.Admins = self.userPrivileges["Admin"]
        self.command.SysOP = self.userPrivileges["SysOP"]
        newUser.allChannels = self.allChannels["Public"].copy()
        self.channel.start(newUser)
        self.command.start(newUser)
 def test_select_where_shape_is_part_of_group_should_return_group_of_shapes(self):
     canvas = Canvas()
     ellipse1 = self.create_ellipse(canvas, [100, 100, 105, 105])
     ellipse2 = self.create_ellipse(canvas, [110, 110, 120, 120])
     rectangle1 = self.create_rectangle(canvas, [130, 130, 140, 140])
     canvas.pack()
     group = Group(canvas)
     group.add(ellipse1)
     group.add(ellipse2)
     group.add(rectangle1)
     selected_shape = Commands(canvas, [ellipse1, ellipse2, rectangle1]).select([150, 150], [group])
     self.assertEqual(len(selected_shape), 3)
     self.assertListEqual(selected_shape, [ellipse1, ellipse2, rectangle1])
     list_of_tags = [s.tag for s in selected_shape]
     self.assertTrue(ellipse1.tag in list_of_tags, "Tag %s not found in %s" % (ellipse1.tag, selected_shape))
     self.assertTrue(ellipse2.tag in list_of_tags)
     self.assertTrue(rectangle1.tag in list_of_tags)
예제 #23
0
    def __init__(self, data, bots, config, section):
        (self.host, self.port, self.name, self.pswd) = data
        self._handle_data_reset()

        # Open the database for this bot.
        self.db = shelve.open("{0}@{1}.db".format(
            self.name, self.host).replace(".", "-").replace("/", "-"),
                              writeback=True)

        # Store the list of bots.
        self._bots = bots
        self.config = config
        self.section = section

        # Initialize various classes.
        self.ch = CommandHandler(self)
        self.pi = PlayerInfo(self)
        self.kl = KillsLog(self)
        self.cmds = Commands(self)
        BaseSocket.__init__(self)
        self.commands_load()

        ts = time.time()
        self.who_stamp = ts + self.config.getint("General", "who_delay")
 def test_function_import__with_file_shapes_and_groups_txt_should_create_groups_and_draw_shapes(self):
     canvas = Canvas()
     canvas.pack()
     Commands(canvas, []).import_('shapes_and_groups.txt')
     self.assertEqual(5, len(canvas.find_all()))
def cmd(msg):
    Commands(Nod, Node, d.datetime.now().isoformat(), msg)
예제 #26
0
def is_cmd_for_server(cmd):
    if cmd // CMD.Commands().step_comands == CMD.Commands.ClnCmd().index_commands:
        return True
    return False
예제 #27
0
import discord
import Commands
import json
from discord.ext import commands

bot = commands.Bot(command_prefix="py!")


@commands.is_owner()
@bot.command()
async def logout(ctx):
    await ctx.send("Logging out...")
    await bot.logout()
    print("PyCoins logged out...")


bot.add_cog(Commands.Listener())
bot.add_cog(Commands.Commands())
print("added cogs")

with open("bal.txt", "r") as bls:
    bal = json.loads(bls.read())
with open("boost.txt", "r") as bsts:
    boost = json.loads(bsts.read())

Commands.bal = bal
Commands.boost = boost

bot.run("TOKEN")
 def test_function_move_should_fail_if_shape_coordinates_are_not_found(self):
     canvas = Canvas()
     ellipse = self.create_ellipse(canvas, [100, 100, 105, 105])
     # self.canvas.pack()
     output = Commands(canvas, [ellipse]).move([ellipse], [120, 120])
     self.assertFalse(output)
 def test_function_export__with_no_shapes_should_return_empty_string(self):
     canvas = Canvas()
     canvas.pack()
     commands = Commands(canvas, [])
     output = commands.export_([], [])
     self.assertEqual("", output)
 def test_select_with_no_shapes_on_canvas_should_return_none(self):
     selected_shape = Commands(Canvas(), self.current_shapes_list).select([0, 0], [])
     self.assertIsNone(selected_shape)