当前位置: 首页>>代码示例>>Python>>正文


Python FakeClient.kills方法代码示例

本文整理汇总了Python中b3.fake.FakeClient.kills方法的典型用法代码示例。如果您正苦于以下问题:Python FakeClient.kills方法的具体用法?Python FakeClient.kills怎么用?Python FakeClient.kills使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在b3.fake.FakeClient的用法示例。


在下文中一共展示了FakeClient.kills方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_kill_different_teams

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
    def test_kill_different_teams(self, timer_patch):
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_BLUE)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)

        joe.kills(mike)
        self.assertEqual(0, joe.warn.call_count)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:12,代码来源:test_tk_functional.py

示例2: test_kill_within_10s

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
    def test_kill_within_10s(self, timer_patch):
        Tk_functional_test.p._round_grace = 10
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)

        joe.kills(mike)
        self.assertEqual(1, joe.warn.call_count)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:13,代码来源:test_tk_functional.py

示例3: test_kill

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
    def test_kill(self, timer_patch):
        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)

        joe.kills(mike)
        self.assertEqual(1, joe.warn.call_count)
        self.assertIsNotNone(mike.getMessageHistoryLike("^7type ^3!fp ^7 to forgive"))
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:14,代码来源:test_tk_functional.py

示例4: test_kill_events_are_caught

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
 def test_kill_events_are_caught(self):
     # GIVEN
     joe = FakeClient(console=self.console, name="Joe", guid="joe_guid", team=TEAM_BLUE)
     simon = FakeClient(console=self.console, name="Simon", guid="simon_guid", team=TEAM_RED)
     assert joe.team != simon.team
     joe.connects(cid='1')
     simon.connects(cid='2')
     # WHEN
     # patch.object will replace the "update_killstreaks" property from object self.p with a mock object that does
     # nothing but allows us to assert if it was called or not.
     with patch.object(self.p, "kill") as update_killstreaks_mock:
         joe.kills(simon)
     # THEN
     self.assertTrue(update_killstreaks_mock.called)
开发者ID:ozon,项目名称:b3-plugin-killannouncerbf3,代码行数:16,代码来源:test_killannouncer.py

示例5: test_forgiveinfo

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
    def test_forgiveinfo(self, timer_patch):
        from b3.fake import superadmin
        superadmin.connects(99)

        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)
        bill = FakeClient(fakeConsole, name="Bill", exactName="Bill", guid="billguid", groupBits=1, team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)
        bill.connects(2)

        joe.kills(mike)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 200 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200)", superadmin.message_history[0])
        self.assertNotIn("Attacked By:", superadmin.message_history[0])

        joe.damages(bill, points=6)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 206 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200), Bill (6)", superadmin.message_history[0])
        self.assertNotIn("Attacked By:", superadmin.message_history[0])


        mike.damages(joe, points=27)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 206 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200), Bill (6)", superadmin.message_history[0])
        self.assertIn("Attacked By: Mike [27]", superadmin.message_history[0])
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:40,代码来源:test_tk_functional.py

示例6: test_forgiveclear

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
    def test_forgiveclear(self, timer_patch):
        from b3.fake import superadmin
        superadmin.connects(99)

        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)

        joe.kills(mike)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 200 TK points", superadmin.message_history[0])

        superadmin.says("!forgiveclear joe")

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 0 TK points", superadmin.message_history[0])
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:25,代码来源:test_tk_functional.py

示例7: test_multikill

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
    def test_multikill(self, timer_patch):
        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)

        with patch.object(fakeConsole, "say") as patched_say:
            joe.warn = Mock()
            joe.tempban = Mock()
            joe.connects(0)
            mike.connects(1)

            mike.clearMessageHistory()
            joe.kills(mike)
            self.assertEqual(1, joe.warn.call_count)
            self.assertEquals(1, len(mike.getAllMessageHistoryLike("^7type ^3!fp ^7 to forgive")))

            joe.kills(mike)
            self.assertEqual(1, len([call_args[0][0] for call_args in patched_say.call_args_list if "auto-kick if not forgiven" in call_args[0][0]]))

            joe.kills(mike)
            self.assertEqual(1, joe.tempban.call_count)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:23,代码来源:test_tk_functional.py

示例8: Test_first_kill_alert

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
class Test_first_kill_alert(TestCase):

    def setUp(self):
        # create a B3 FakeConsole
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(r"""<configuration/>""")
        self.console = FakeConsole(self.parser_conf)
        # create our plugin instance
        self.plugin_conf = CfgConfigParser()
        self.p = Killannouncerbf3Plugin(self.console, self.plugin_conf)
        # initialise the plugin
        self.plugin_conf.loadFromString(r'''
[settings]
announce first kill: yes
[first kill alert]
us1: %(murderer)s takes first blood against %(victim)s! The battle has just began!!!
de1: %(murderer)s hat das erste Blut von %(victim)s genommen! Die Schlacht hat begonnen!!!
[kill streak alerts]
us1 #5: Killing Spree! %(murderer)s is dominating on a %(kill_streak_value)s kill streak!
us2 #10: Killing Spree! %(murderer)s is dominating on a %(kill_streak_value)s kill streak!
[end kill streak alerts]
us1: %(murderer)s has ended %(murderer)s kill streak at %(kill_streak_value)s kills!

        ''')
        # Plugin ipinfodb is required. We trick and set county property later.
        self.p.console._plugins['ipinfodb'] = ''

        self.p.onLoadConfig()
        self.p.onStartup()
        # prepare a few players
        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, country='de',team=TEAM_RED)
        self.simon = FakeClient(self.console, name="Simon", exactName="Simon", guid="qsdfdsqfdsqf", groupBits=0, country='us',team=TEAM_BLUE)
        self.admin = FakeClient(self.console, name="Level-40-Admin", exactName="Level-40-Admin", guid="875sasda", groupBits=16, country='ch',)
        self.superadmin = FakeClient(self.console, name="God", exactName="God", guid="f4qfer654r", groupBits=128, country='fr',)

        self.joe.connects(cid='1')
        self.simon.connects(cid='2')

    def test_kill_events_are_caught(self):
        # GIVEN
        joe = FakeClient(console=self.console, name="Joe", guid="joe_guid", team=TEAM_BLUE)
        simon = FakeClient(console=self.console, name="Simon", guid="simon_guid", team=TEAM_RED)
        assert joe.team != simon.team
        joe.connects(cid='1')
        simon.connects(cid='2')
        # WHEN
        # patch.object will replace the "update_killstreaks" property from object self.p with a mock object that does
        # nothing but allows us to assert if it was called or not.
        with patch.object(self.p, "kill") as update_killstreaks_mock:
            joe.kills(simon)
        # THEN
        self.assertTrue(update_killstreaks_mock.called)

    #
    # Test announcement on first kill
    #
    def test_first_kill_does_get_announced(self):
        # assume a EVT_GAME_ROUND_STARTED event was fired and handled
        self.p._round_started = True
        # WHEN
        with patch(target='b3.fake.FakeClient.message') as saybig_mock:
            self.joe.kills(self.simon)
        # THEN
        self.assertTrue(saybig_mock.called)
        self.assertListEqual([call('Joe hat das erste Blut von Simon genommen! Die Schlacht hat begonnen!!!'),
                              call('Joe takes first blood against Simon! The battle has just began!!!')], saybig_mock.mock_calls)

    def test_second_kill_does_not_get_announced(self):
        # assume a EVT_GAME_ROUND_STARTED event was fired and handled
        self.p._round_started = True

        with patch(target='b3.fake.FakeClient.message') as saybig_mock:
            self.joe.kills(self.simon)
            self.simon.kills(self.joe)
        # THEN
        self.assertTrue(saybig_mock.called)
        self.assertListEqual([call('Joe hat das erste Blut von Simon genommen! Die Schlacht hat begonnen!!!'),
                              call('Joe takes first blood against Simon! The battle has just began!!!')], saybig_mock.mock_calls)

    #
    # Streak tests
    #
    def test_kill_streak(self):
        with patch(target='b3.fake.FakeClient.message') as announce_kill_streak_mock:
            # Joe kills Simon 5 times:
            _count = 0
            while _count < 5 :
                _count += 1
                self.joe.kills(self.simon)
        self.assertTrue(announce_kill_streak_mock.called)
        self.assertListEqual([call('Killing Spree! Joe is dominating on a 5 kill streak!'),
                              call('Killing Spree! Joe is dominating on a 5 kill streak!')], announce_kill_streak_mock.mock_calls)
        # and kill himm again - 10 kills
        with patch(target='b3.fake.FakeClient.message') as announce_kill_streak_mock:
            # Joe kills Simon 5 times again:
            _count = 0
            while _count < 5 :
                _count += 1
                self.joe.kills(self.simon)
        self.assertTrue(announce_kill_streak_mock.called)
#.........这里部分代码省略.........
开发者ID:ozon,项目名称:b3-plugin-killannouncerbf3,代码行数:103,代码来源:test_killannouncer.py

示例9: Test_kill

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
class Test_kill(XlrstatsTestCase):
    """
    Validates that the stats get updated as expected upon kill events
    """

    def setUp(self):
        XlrstatsTestCase.setUp(self)
        self.init()
        # GIVEN two players P1 and P2 (P1 being a registered user)
        self.p1 = FakeClient(console=self.console, name="P1", guid="P1_GUID", team=TEAM_BLUE)
        self.p1.connects("1")
        self.p1.says("!register")
        self.p2 = FakeClient(console=self.console, name="P2", guid="P2_GUID", team=TEAM_RED)
        self.p2.connects("2")
        self.p._xlrstats_active = True

    def test_p1_kills_p2(self):
        # GIVEN
        self.p1.kills(self.p2)
        s = self.p.get_PlayerStats(self.p1)
        # WHEN
        self.p1.clearMessageHistory()
        self.p1.says("!xlrstats")
        # THEN
        self.assertEqual(['XLR Stats: P1 : K 1 D 0 TK 0 Ratio 0.00 Skill 1024.00'], self.p1.message_history)

    def test_p1_teamkills_p2(self):
        # GIVEN
        self.p2.team = self.p1.team
        self.p1.kills(self.p2)
        s = self.p.get_PlayerStats(self.p1)
        # WHEN
        self.p1.clearMessageHistory()
        self.p1.says("!xlrstats")
        # THEN
        self.assertEqual(['XLR Stats: P1 : K 0 D 0 TK 1 Ratio 0.00 Skill 999.00'], self.p1.message_history)

    def test_p1_kills_p2_twice(self):
        # GIVEN
        self.p1.kills(self.p2)
        self.p1.kills(self.p2)
        s = self.p.get_PlayerStats(self.p1)
        # WHEN
        self.p1.clearMessageHistory()
        self.p1.says("!xlrstats")
        # THEN
        self.assertEqual(['XLR Stats: P1 : K 2 D 0 TK 0 Ratio 0.00 Skill 1035.45'], self.p1.message_history)

    def test_p1_kills_p2_then_p2_kills_p1(self):
        # GIVEN
        self.p1.kills(self.p2)
        self.p2.kills(self.p1)
        s = self.p.get_PlayerStats(self.p1)
        # WHEN
        self.p1.clearMessageHistory()
        self.p1.says("!xlrstats")
        # THEN
        self.assertEqual(['XLR Stats: P1 : K 1 D 1 TK 0 Ratio 1.00 Skill 1015.63'], self.p1.message_history)


    def test_p1_kills_bot(self):
        # GIVEN
        self.p2.bot = True
        self.p.exclude_bots = True
        self.console.verbose = Mock()
        # WHEN
        self.p1.kills(self.p2)
        # THEN
        self.console.verbose.assert_called_with("XlrstatsPlugin: bot involved: do not process!")
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:71,代码来源:test_xlrstats.py

示例10: Test_render_cmd_template

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
class Test_render_cmd_template(CustomcommandsTestCase):

    def setUp(self):
        CustomcommandsTestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.p = CustomcommandsPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
        self.player1 = FakeClient(console=self.console, name="Player1", guid="player1GUID", pbid="player1PBID")
        self.player2 = FakeClient(console=self.console, name="Player2", guid="player2GUID", pbid="player2PBID")
        self.player1.connects(cid="slot1")
        self.player2.connects(cid="slot2")

    def test_no_placeholder(self):
        self.assertEqual("f00", self.p._render_cmd_template("f00", data="", client=self.player1))

    def test_ARG(self):
        self.assertEqual("f00 bill bar", self.p._render_cmd_template("f00 <ARG> bar", data="bill", client=self.player1))
        self.assertRaises(ValueError, self.p._render_cmd_template, "f00 <ARG> bar", data="", client=self.player1)

    def test_ARG_OPT(self):
        self.assertEqual("hi", self.p._render_cmd_template("hi <ARG:OPT:>", data="", client=self.player1))
        self.assertEqual("hi f00", self.p._render_cmd_template("hi <ARG:OPT:f00>", data="", client=self.player1))
        self.assertEqual("hi bar", self.p._render_cmd_template("hi <ARG:OPT:f00>", data="bar", client=self.player1))
        self.assertEqual("hi foo bar", self.p._render_cmd_template("hi <ARG:OPT:f00>", data="foo bar", client=self.player1))

    def test_ARG_FIND_MAP_errors(self):
        # GIVEN
        when(self.p.console).getMaps().thenReturn(["map1", "map2", "map3", "ut4_turnpike", "ut4_casa"])
        # THEN
        self.assertRaises(ValueError, self.p._render_cmd_template, "map <ARG:FIND_MAP>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "do you mean : map2, map3, map1 ?",
                                self.p._render_cmd_template, "map <ARG:FIND_MAP>", data="map", client=self.player1)

    def test_ARG_FIND_MAP_nominal(self):
        def assertFoundMap(expected_map, cmd_parameter):
            self.assertEqual("map " + expected_map, self.p._render_cmd_template("map <ARG:FIND_MAP>",
                                                                                data=cmd_parameter, client=self.player1))
        # GIVEN
        when(self.p.console).getMaps().thenReturn(["map1", "map2", "map3", "ut4_turnpike", "ut4_casa"])
        # THEN
        assertFoundMap("map1", "map1")
        assertFoundMap("map1", " map1 ")
        assertFoundMap("ut4_casa", "ut4_casa")
        assertFoundMap("ut4_casa", "casa")

    def test_ARG_FIND_PLAYER_nominal(self):
        # GIVEN
        when(self.p._adminPlugin).findClientPrompt("f00", self.player1).thenReturn(self.player2)
        # THEN
        self.assertEqual("kick slot2", self.p._render_cmd_template("kick <ARG:FIND_PLAYER:PID>", data="f00", client=self.player1))
        self.assertEqual("kick player2PBID", self.p._render_cmd_template("kick <ARG:FIND_PLAYER:PBID>", data="f00", client=self.player1))
        self.assertEqual("kick player2GUID", self.p._render_cmd_template("kick <ARG:FIND_PLAYER:GUID>", data="f00", client=self.player1))
        self.assertEqual("kick Player2", self.p._render_cmd_template("kick <ARG:FIND_PLAYER:NAME>", data="f00", client=self.player1))
        self.assertEqual("kick Player2^7", self.p._render_cmd_template("kick <ARG:FIND_PLAYER:EXACTNAME>", data="f00", client=self.player1))
        self.assertEqual("kick @%s" % self.player2.id, self.p._render_cmd_template("kick <ARG:FIND_PLAYER:B3ID>", data="f00", client=self.player1))

    def test_PLAYER(self):
        self.assertEqual("f00 slot1", self.p._render_cmd_template("f00 <PLAYER:PID>", data="", client=self.player1))
        self.assertEqual("f00 player1PBID", self.p._render_cmd_template("f00 <PLAYER:PBID>", data="", client=self.player1))
        self.assertEqual("f00 player1GUID", self.p._render_cmd_template("f00 <PLAYER:GUID>", data="", client=self.player1))
        self.assertEqual("f00 Player1", self.p._render_cmd_template("f00 <PLAYER:NAME>", data="", client=self.player1))
        self.assertEqual("f00 Player1^7", self.p._render_cmd_template("f00 <PLAYER:EXACTNAME>", data="", client=self.player1))
        self.assertEqual("f00 @1", self.p._render_cmd_template("f00 <PLAYER:B3ID>", data="", client=self.player1))

    def test_LAST_KILLER(self):
        self.assertRaisesRegexp(ValueError, "your last killer is unknown", self.p._render_cmd_template, "f00 <LAST_KILLER:PID>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last killer is unknown", self.p._render_cmd_template, "f00 <LAST_KILLER:PBID>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last killer is unknown", self.p._render_cmd_template, "f00 <LAST_KILLER:GUID>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last killer is unknown", self.p._render_cmd_template, "f00 <LAST_KILLER:NAME>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last killer is unknown", self.p._render_cmd_template, "f00 <LAST_KILLER:EXACTNAME>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last killer is unknown", self.p._render_cmd_template, "f00 <LAST_KILLER:B3ID>", data="", client=self.player1)
        # WHEN
        self.player2.kills(self.player1)
        # THEN
        self.assertEqual("f00 slot2", self.p._render_cmd_template("f00 <LAST_KILLER:PID>", data="", client=self.player1))
        self.assertEqual("f00 player2PBID", self.p._render_cmd_template("f00 <LAST_KILLER:PBID>", data="", client=self.player1))
        self.assertEqual("f00 player2GUID", self.p._render_cmd_template("f00 <LAST_KILLER:GUID>", data="", client=self.player1))
        self.assertEqual("f00 Player2", self.p._render_cmd_template("f00 <LAST_KILLER:NAME>", data="", client=self.player1))
        self.assertEqual("f00 Player2^7", self.p._render_cmd_template("f00 <LAST_KILLER:EXACTNAME>", data="", client=self.player1))
        self.assertEqual("f00 @2", self.p._render_cmd_template("f00 <LAST_KILLER:B3ID>", data="", client=self.player1))

    def test_LAST_VICTIM(self):
        self.assertRaisesRegexp(ValueError, "your last victim is unknown", self.p._render_cmd_template, "f00 <LAST_VICTIM:PID>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last victim is unknown", self.p._render_cmd_template, "f00 <LAST_VICTIM:PBID>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last victim is unknown", self.p._render_cmd_template, "f00 <LAST_VICTIM:GUID>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last victim is unknown", self.p._render_cmd_template, "f00 <LAST_VICTIM:NAME>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last victim is unknown", self.p._render_cmd_template, "f00 <LAST_VICTIM:EXACTNAME>", data="", client=self.player1)
        self.assertRaisesRegexp(ValueError, "your last victim is unknown", self.p._render_cmd_template, "f00 <LAST_VICTIM:B3ID>", data="", client=self.player1)
        # WHEN
        self.player1.kills(self.player2)
        # THEN
        self.assertEqual("f00 slot2", self.p._render_cmd_template("f00 <LAST_VICTIM:PID>", data="", client=self.player1))
        self.assertEqual("f00 player2PBID", self.p._render_cmd_template("f00 <LAST_VICTIM:PBID>", data="", client=self.player1))
        self.assertEqual("f00 player2GUID", self.p._render_cmd_template("f00 <LAST_VICTIM:GUID>", data="", client=self.player1))
        self.assertEqual("f00 Player2", self.p._render_cmd_template("f00 <LAST_VICTIM:NAME>", data="", client=self.player1))
        self.assertEqual("f00 Player2^7", self.p._render_cmd_template("f00 <LAST_VICTIM:EXACTNAME>", data="", client=self.player1))
        self.assertEqual("f00 @2", self.p._render_cmd_template("f00 <LAST_VICTIM:B3ID>", data="", client=self.player1))

    def test_ADMINGROUP_SHORT(self):
#.........这里部分代码省略.........
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:103,代码来源:test_render_cmd_template.py

示例11: Tk_functional_test

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
class Tk_functional_test(B3TestCase):


    def setUp(self):
        B3TestCase.setUp(self)

        self.console.gameName = 'f00'

        self.adminPlugin = AdminPlugin(self.console, ADMIN_CONFIG_FILE)
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.conf = XmlConfigParser()
        self.conf.setXml(r"""
        <configuration plugin="tk">
            <settings name="settings">
                <set name="max_points">400</set>
                <set name="levels">0,1,2,20,40</set>
                <set name="round_grace">7</set>
                <set name="issue_warning">sfire</set>
                <set name="grudge_enable">True</set>
                <set name="private_messages">True</set>
            </settings>
            <settings name="messages">
                <set name="ban">^7team damage over limit</set>
                <set name="forgive">^7$vname^7 has forgiven $aname [^3$points^7]</set>
                <set name="grudged">^7$vname^7 has a ^1grudge ^7against $aname [^3$points^7]</set>
                <set name="forgive_many">^7$vname^7 has forgiven $attackers</set>
                <set name="forgive_warning">^1ALERT^7: $name^7 auto-kick if not forgiven. Type ^3!forgive $cid ^7to forgive. [^3damage: $points^7]</set>
                <set name="no_forgive">^7no one to forgive</set>
                <set name="no_punish">^7no one to punish</set>
                <set name="players">^7Forgive who? %s</set>
                <set name="forgive_info">^7$name^7 has ^3$points^7 TK points</set>
                <set name="grudge_info">^7$name^7 is ^1grudged ^3$points^7 TK points</set>
                <set name="forgive_clear">^7$name^7 cleared of ^3$points^7 TK points</set>
            </settings>
            <settings name="level_0">
                <set name="kill_multiplier">2</set>
                <set name="damage_multiplier">1</set>
                <set name="ban_length">2</set>
            </settings>
            <settings name="level_1">
                <set name="kill_multiplier">2</set>
                <set name="damage_multiplier">1</set>
                <set name="ban_length">2</set>
            </settings>
            <settings name="level_2">
                <set name="kill_multiplier">1</set>
                <set name="damage_multiplier">0.5</set>
                <set name="ban_length">1</set>
            </settings>
            <settings name="level_20">
                <set name="kill_multiplier">1</set>
                <set name="damage_multiplier">0.5</set>
                <set name="ban_length">0</set>
            </settings>
            <settings name="level_40">
                <set name="kill_multiplier">0.75</set>
                <set name="damage_multiplier">0.5</set>
                <set name="ban_length">0</set>
            </settings>
        </configuration>
        """)
        self.p = TkPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)
        self.bill = FakeClient(self.console, name="Bill", guid="billguid", groupBits=1, team=b3.TEAM_RED)
        self.superadmin = FakeClient(self.console, name="superadmin",guid="superadminguid", groupBits=128, team=b3.TEAM_RED)


    def test_dammage_different_teams(self, timer_patch):
        self.joe.warn = Mock()
        self.joe.connects(0)
        self.mike.connects(1)
        self.mike.team = b3.TEAM_BLUE
        self.joe.damages(self.mike)
        self.assertEqual(0, self.joe.warn.call_count)


    def test_kill_different_teams(self, timer_patch):
        self.joe.warn = Mock()
        self.joe.connects(0)
        self.mike.connects(1)
        self.mike.team = b3.TEAM_BLUE
        self.joe.kills(self.mike)
        self.assertEqual(0, self.joe.warn.call_count)


    def test_kill_within_10s(self, timer_patch):
        self.p._round_grace = 10

        self.joe.warn = Mock()
        self.joe.connects(0)
        self.mike.connects(1)

        self.joe.kills(self.mike)
#.........这里部分代码省略.........
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:103,代码来源:test_tk_functional.py

示例12: PingkickerPluginTest

# 需要导入模块: from b3.fake import FakeClient [as 别名]
# 或者: from b3.fake.FakeClient import kills [as 别名]
class PingkickerPluginTest(TestCase):

    def tearDown(self):
        if hasattr(self, "parser"):
            del self.parser.clients
            self.parser.working = False

    def setUp(self):
        # create a B3 FakeConsole
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(r"""<configuration/>""")
        self.console = FakeConsole(self.parser_conf)

        # create our plugin instance
        self.plugin_conf = CfgConfigParser()
        self.p = Weaponlimiterbf3Plugin(self.console, self.plugin_conf)

        # initialise the plugin
        self.plugin_conf.loadFromString(r'''
[commands]
weaponlimiter-wpl: 60
weaponlimits: guest
noobkill: 20

[settings]
change servermessage: yes
self_kill_counter: 1
config_strategy: mapname
display_extra_msg: message
yell_duration: 10

[punisher]
kill_player: no
warn_player: yes

[messages]
servermessage: This game uses weapons limits. Use !weaponlimits to show forbidden weapons.
weaponlimiter_enabled: WeaponLimiter for that round activated!
weaponlimiter_disabled: Weaponlimiter disabled! All Weapons allowed.
warn_message: You used a forbidden weapon! ^7!forbidden_weapons show the list of forbidden weapons
forbidden_message: Forbidden Weapons are: %s
allowed_message: Allowed Weapons: %s
extra_warning_message: You have %(victim)s killed with a %(weapon)s. This weapon is forbidden!

[XP2_Skybar]
banned weapons: SMAW, M320, RPG-7, USAS-12
gametype: Domination0
weapons: Weapons/Gadgets/C4/C4,870MCS,DAO-12,jackhammer,M1014,M26Mass,Siaga20k,SPAS-12,USAS-12
''')

        # fake BF3 game
        self.console.game.gameName = 'bf3'
        self.console.game.gameType = 'Domination0'
        self.console.game._mapName = 'XP2_Skybar'
        # startup plugin
        self.p.onLoadConfig()
        self.p.onStartup()
        # enable
        self.p._wpl_is_active = True
        # prepare a few players
        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1)
        self.simon = FakeClient(self.console, name="Simon", exactName="Simon", guid="qsdfdsqfdsqf", groupBits=0)
        self.admin = FakeClient(self.console, name="Level-40-Admin", exactName="Level-40-Admin", guid="875sasda", groupBits=16,)
        self.superadmin = FakeClient(self.console, name="God", exactName="God", guid="f4qfer654r", groupBits=128)

    def test_warning_on_forbidden_kill(self):
        self.joe.connects('joe')
        self.simon.connects('simon')
        #clear message history
        self.joe.message_history = []
        self.simon.message_history = []
        # player simon kills joe with the M1014
        self.simon.kills(self.joe, 'M1014')

        self.assertEqual('You have Joe killed with a M1014. This weapon is forbidden!', self.simon.message_history[0])
        #self.assertEqual(self.p._messages['reminder_ping_warning'], self.simon.message_history[1])

    def test_punish_on_forbidden_kill(self):
        pass

    def test_cmd_weaponlimits(self):
        pass
开发者ID:ozon,项目名称:b3-plugin-weaponlimiterbf3,代码行数:84,代码来源:test_weaponlimiter_BF3.py


注:本文中的b3.fake.FakeClient.kills方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。