示例#1
0
    def generate_deck(self):
        deck = []
        for i in range(8):
            card = Card(3, "Generic Curse", CardType.CURSE)
            card.card_ally = Character(0, CharacterType.ALLY)
            deck.append(card)
        for i in range(3):
            card = Card(1, "Cackling Goon", CardType.ALLY)
            card.card_ally = CacklingGoon()
            deck.append(card)

            card = Card(3, "Dragon Form", CardType.EFFECT)
            card.targeted = True
            card.code = dragon_form_effect
            deck.append(card)

            card = Card(3, "Savage Goon", CardType.ALLY)
            card.card_ally = Character(4, CharacterType.ALLY)
            deck.append(card)

            card = Card(2, "Sinister Goon", CardType.ALLY)
            card.card_ally = SinisterGoon()
            deck.append(card)

            card = Card(0, "Vanish", CardType.EFFECT)
            card.code = vanish_effect
            deck.append(card)
        for i in range(2):
            card = Card(0, "Malice", CardType.CONDITION)
            deck.append(card)

            card = Card(0, "Tyranny", CardType.CONDITION)
            deck.append(card)

        card = Card(1, "Raven", CardType.ALLY)
        card.card_ally = Character(1, CharacterType.ALLY)
        deck.append(card)

        card = Card(1, "Spinning Wheel", CardType.ALLY)  # CardType.ITEM
        card.card_ally = Character(0, CharacterType.ALLY)
        deck.append(card)

        card = Card(1, "Staff", CardType.ALLY)  # CardType.ITEM
        card.card_ally = Character(0, CharacterType.ALLY)
        deck.append(card)
        return deck
示例#2
0
 def setUp(self):
     board = (Board(row_size=5, column_size=3))
     board.replace(np.array([
         [Icon.Green.value, Icon.Green.value, Icon.Green.value],
         [Icon.BombRed.value, Icon.Green.value, Icon.Purple.value],
         [Icon.Red.value, Icon.BombRed.value, Icon.Yellow.value],
         [Icon.Red.value, Icon.Pink.value, Icon.Yellow.value],
         [Icon.Empty.value, Icon.Empty.value, Icon.Empty.value],
     ]))
     self.game = Game(board, Character(board))
示例#3
0
 def receve_command(self, command):
   name = Name(command)
   self.send_message('<font color="silver">%s</font>' % name)
   self.render()
   if name.is_too_long():
     self.send_message('<font color="red">名前は%dbyte以内です。</font>' % Name.max_length())
     return
   if name.is_too_short():
     self.send_message('<font color="red">名前は%dbyte以上です。</font>'% Name.min_length())
     return
   if name.using_invalid_character():
     self.send_message('<font color="red">名前に記号や空白は使用できません。</font>')
     return False
   if Character.find_by_name(name):
     self.send_message('<font color="red">%sは既に使用されている名前です。</font>' % name)
     return False
   c = Character('@', 'olive', name)
   c.register()
   NameConfirmHandler(self._socket, c).enter()
示例#4
0
async def select_character(sid, character):
    room = organizer.getRoomByUserId(sid)
    user = organizer.getUserById(sid)
    game = room.game
    if user.team is not None:
        for char in game.getCharactersForOpposingTeam(user.team):
            if character["name"] == char.name:
                room.game.setSelfForTeam(user.team,
                                         Character.fromDict(character))

        await sendCharacters(room, user.team)
示例#5
0
 def receve_command(self, command):
     name = Name(command)
     self.send_message('<font color="silver">%s</font>' % name)
     self.render()
     if name.is_too_long():
         self.send_message('<font color="red">名前は%dbyte以内です。</font>' %
                           Name.max_length())
         return
     if name.is_too_short():
         self.send_message('<font color="red">名前は%dbyte以上です。</font>' %
                           Name.min_length())
         return
     if name.using_invalid_character():
         self.send_message('<font color="red">名前に記号や空白は使用できません。</font>')
         return False
     if Character.find_by_name(name):
         self.send_message('<font color="red">%sは既に使用されている名前です。</font>' %
                           name)
         return False
     c = Character('@', 'olive', name)
     c.register()
     NameConfirmHandler(self._socket, c).enter()
示例#6
0
    def __init__(self):
        super().__init__()
        self.users = {}
        self.matches = {}
        self.decks = {"main": [], "characters": []}
        self.actions = {
            "load_cards": {
                "f": self.aLoadCards,
                "p": {}
            },
            "list_matches": {
                "f": self.aListMatches,
                "p": {}
            },
            "create_match": {
                "f": self.aCreateMatch,
                "p": {
                    "matchname": True,
                    "matchpassword": False
                }
            },
            "join_match": {
                "f": self.aJoinMatch,
                "p": {
                    "matchid": True,
                    "matchpassword": False
                }
            },
            "leave_match": {
                "f": self.aLeaveMatch,
                "p": {}
            },
            "start_match": {
                "f": self.aStartMatch,
                "p": {
                    "matchid": True
                }
            },
        }

        # Loading cards from files
        with open("cards.json", 'r') as file:
            cards = json.loads(file.read())
            for data in cards:
                for card in data["cards"]:
                    self.decks["main"].append(Card(card, data))
        with open("characters.json", 'r') as file:
            cards = json.loads(file.read())
            for data in cards:
                self.decks["characters"].append(Character(data))
示例#7
0
    "+++++++ ++++++++++++",
    "+       ++++++++++++",
    "+ ++++++++++++++++++",
    "+e++++++++++++++++++",
]

# with open("input.txt", "r") as file:
#     grid = [[str(x) for x in line] for line in file]
"""
DONOT DELETE OR EDIT THE FOLLOWING LINES
"""
maze = Maze()
maze.setUpMaze(grid)
startingPos = maze.getStartingPosition()

character = Character(startingPos)

wall = maze.getWall()

finish = maze.getFinish()

coins = maze.getCoins()

path = Path()


def checkLeft(x, y, angle):
    if angle != 180:
        return
    if (x, y) in finish:
        maze.endProgram()
示例#8
0
def main():
    rows, columns = 10, 7

    board = Board(rows, columns)
    if MODE == Mode.RealGame:
        controller = Win32Controller(INPUT_INTERVAL_SECOND)
    else:
        controller = VoidController()
    char = Character(board, controller=controller)
    char.enable_trace()
    game = Game(board, char, mode=MODE)
    game.enable_trace()

    solver = HandmadeSolver(use_memo=True,
                            store_memo=(MODE == Mode.VirtualGame))
    solver.enable_trace()

    if MODE == Mode.RealGame:
        import win32gui
        from capture import WindowSize, Win32Capture, BoardStateDetector

        capture = Win32Capture(WINDOW_NAME)

        if capture.window_size == WindowSize.HD_PLUS:
            icon_size = Point(60, 60)
            start_point = Point(370, 138)
            x0 = start_point.x
            y0 = start_point.y
            x1 = x0 + icon_size.x * columns
            y1 = y0 + icon_size.y * rows
            game_window_position = (x0, y0, x1, y1)
            #game_window_position = (370, 138, 790, 738)
            # score_window = (828, 251, 1237, 717)
        else:
            raise NotImplemented()

        game_window = capture.crop(game_window_position)
        detector = BoardStateDetector(game_window, rows, columns, icon_size)
        if DEBUG_SAVE_BOARD:
            detector.enable_debug()

        hwnd = win32gui.FindWindowEx(0, 0, 0, WINDOW_NAME)
        win32gui.SetForegroundWindow(hwnd)
        time.sleep(1)
        controller.start()

    # main loop
    def proc(g: Game):
        if g.mode == Mode.RealGame:
            # ボードの状態を画面から判定し、更新する
            window = capture.crop(game_window_position)
            new_board = detector.get_board_from_image(window)
            g.board.replace(new_board)
            if DEBUG_SAVE_BOARD:
                window.save('tmp/frame_%05d.png' % g.current_frame)
                with open('tmp/frame_%05d.txt' % g.current_frame, 'w') as f:
                    f.write(g.board.serialize())
        solver.solve(g)

    game.main_loop(proc)

    exit(0)
示例#9
0
 def setUp(self):
     board = Board(10, 7)
     char = Character(board)
     self.game = Game(board, char)
     self.solver = HandmadeSolver(use_memo=False, store_memo=False)
示例#10
0
 def __init__(self, socket):
     Handler.__init__(self)
     self._socket = socket
     self._character = Character('@', 'olive')