Пример #1
0
    def game_start(self, gameid):
        # 点我unready
        unready = RText("秒钟后游戏开始, 请不要中途退出。", RColor.yellow)
        unready.set_hover_text(RText("点我unready", RColor.green))
        unready.set_click_event(RAction.run_command, f"unready")

        # 10秒后游戏开始
        self.countdowning = True
        for i in range(10, 0, -1):

            # 如果有玩家 unready 取消开局
            if not self.countdowning:
                self.server.say(RText("取消开局,有玩家unready。", RColor.yellow))
                return

            self.server.say(RTextList(RText(f"{i} ", RColor.green), unready))
            time.sleep(1)

        # 开局前准备
        self.game_start_init()

        self.game_started = True

        # 每局开始时,第一次提示.
        first_show = True
        # sleep = 30 # testing
        sleep = 5 * 60

        # 如果 逃亡者存活过30分钟,逃亡者胜利。
        for i in range(6):

            if self.gameid != gameid:
                self.server.logger.info(f"之前的游戏线程退出 gameid: {self.gameid}.")
                return

            now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

            # 广播逃亡者位置,并高亮1分钟。
            self.running_x, self.running_y, self.running_z = get_pos_point(
                self.server, self.player_running)
            self.server.say(
                RTextList(
                    "逃亡者:", RText(self.player_running, RColor.yellow),
                    "现在的位置是:",
                    RText(
                        f"x:{self.running_x} y:{self.running_y} z:{self.running_z} ",
                        RColor.green), RText(f"{now}", RColor.green)))
            self.server.rcon_query(
                f"effect give {self.player_running} minecraft:glowing 60")

            # 向他杀者显示, 逃亡者坐标。
            if first_show:
                first_show = False

                for killer in self.killer:
                    flow_thread(self.server, 60, killer, self.player_running)

                time.sleep(5)
                # self.show_running_location()
                time.sleep(sleep - 5)
            else:
                for killer in self.killer:
                    flow_thread(self.server, 60, killer, self.player_running)

                # self.show_running_location()
                time.sleep(sleep)

        # 时间到,逃亡者胜利。
        self.game_end("running")
Пример #2
0
def click_invite(player1, player2):
    r = RText(f"{player1} 邀请你tp TA.", RColor.green)
    r.set_hover_text(RText(f"点击向玩家 {player1} 传送", RColor.green))
    r.set_click_event(RAction.run_command, f"{CMD} accept {player1}")
    return r