Пример #1
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

from mock import Mock
from mockito import when
from time import sleep
from b3.fake import FakeClient
from tests.plugins.urtserversidedemo import PluginTestCase
from b3.events import eventManager, Event


EVT_FOLLOW_CONNECTED = eventManager.createEvent("EVT_FOLLOW_CONNECTED", "EVT_FOLLOW_CONNECTED")


class FollowPlugin:
    """
    dummy FollowPlugin
    """

    def __init__(self, console):
        self.working = True


class Test_with_follow(PluginTestCase):
    CONF = """\
[commands]
startserverdemo = 20
# -*- encoding: utf-8 -*-
from mock import Mock
from mockito import when
from time import sleep
from b3.fake import FakeClient
from tests import PluginTestCase
from b3.events import eventManager, Events, Event


EVT_BAD_GUID = eventManager.createEvent('EVT_BAD_GUID', 'Bad guid detected')
EVT_1337_PORT = eventManager.createEvent('EVT_1337_PORT', '1337 port detected')


class HaxbusterurtPlugin():
    """
    dummy HaxbusterurtPlugin
    """
    def __init__(self, console):
        self.working = True


class Test_with_haxbusterurt(PluginTestCase):
    CONF = """\
[commands]
startserverdemo = 20

[haxbusterurt]
demo_duration: 2
"""

    def setUp(self):
#                                                                     #
#  You should have received a copy of the GNU General Public License  #
#  along with this program; if not, write to the Free Software        #
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA      #
#  02110-1301, USA.                                                   #
#                                                                     #
# ################################################################### #

from mock import Mock
from mockito import when
from time import sleep
from b3.fake import FakeClient
from tests.plugins.urtserversidedemo import PluginTestCase
from b3.events import eventManager, Event

EVT_FOLLOW_CONNECTED = eventManager.createEvent('EVT_FOLLOW_CONNECTED',
                                                'EVT_FOLLOW_CONNECTED')


class FollowPlugin():
    """
    dummy FollowPlugin
    """
    def __init__(self, console):
        self.working = True


class Test_with_follow(PluginTestCase):
    CONF = """\
[commands]
startserverdemo = 20
Пример #4
0
#  You should have received a copy of the GNU General Public License  #
#  along with this program; if not, write to the Free Software        #
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA      #
#  02110-1301, USA.                                                   #
#                                                                     #
# ################################################################### #

from mock import Mock
from mockito import when
from time import sleep
from b3.fake import FakeClient
from tests.plugins.urtserversidedemo import PluginTestCase
from b3.events import eventManager, Event
from time import sleep

EVT_BAD_GUID = eventManager.createEvent('EVT_BAD_GUID', 'Bad guid detected')
EVT_1337_PORT = eventManager.createEvent('EVT_1337_PORT', '1337 port detected')


class HaxbusterurtPlugin():
    """
    dummy HaxbusterurtPlugin
    """
    def __init__(self, console):
        self.working = True


class Test_with_haxbusterurt(PluginTestCase):
    CONF = """\
[commands]
startserverdemo = 20
# -*- encoding: utf-8 -*-
from mock import Mock
from mockito import when
from time import sleep
from b3.fake import FakeClient
from tests import PluginTestCase
from b3.events import eventManager, Events, Event


EVT_FOLLOW_CONNECTED = eventManager.createEvent('EVT_FOLLOW_CONNECTED', 'EVT_FOLLOW_CONNECTED')


class FollowPlugin():
    """
    dummy FollowPlugin
    """
    def __init__(self, console):
        self.working = True


class Test_with_follow(PluginTestCase):
    CONF = """\
[commands]
startserverdemo = 20

[follow]
demo_duration: 2
"""

    def setUp(self):
        PluginTestCase.setUp(self)
Пример #6
0
def patchCod4Parser():
    lf = [
        re.compile(
            r"""^(?P<action>ROTU_STATS_GAME);
                         (?P<data>                             # data open parenthesis!
                           (?P<version>     [^;]     *      );   # server version
                           (?P<win>         [0-1]    {1}    );   # won game: 1, lose game: 0
                           (?P<killed>      [0-9]    {1,6}  );   # amount of zombies killed
                           (?P<duration>    [0-9]    {1,10} );   # played time in milliseconds
                           (?P<wave>        [0-9]    {1,3}  );   # waves played
                           (?P<map>         \w       {3,32} )    # map name
                         )$""",
            re.IGNORECASE | re.X),  # data closing parenthesis!
        re.compile(
            r"""^(?P<action>ROTU_STATS_PLAYER);
                         (?P<data>                             # data open parenthesis!
                           (?P<guid>        [0-9a-f] {32}   );   # guid
                           (?P<name>        [^;]     {1,32} );   # name
                           (?P<role>        [a-zA-Z] {3,16} );   # role
                           (?P<kills>       [0-9]    {1,6}  );   # zombies killed
                           (?P<assists>     [0-9]    {1,6}  );   # assists
                           (?P<deaths>      [0-9]    {1,3}  );   # deaths
                           (?P<downtime>    [0-9]    {1,10} );   # down time in milliseconds
                           (?P<revives>     [0-9]    {1,3}  );   # number of revived players
                           (?P<heals>       [0-9]    {1,6}  );   # health given in health points
                           (?P<ammo>        [0-9]    {1,6}  );   # ammo given
                           (?P<damage>      [0-9]    {1,10} );   # damage dealt
                           (?P<damageboss>  [0-9]    {1,10} );   # damage dealt to boss
                           (?P<turretkills> [0-9]    {1,6}  );   # turret kills
                           (?P<points>      [0-9]    {1,10} );   # current points
                           (?P<spent>       [0-9]    {1,10} );   # points spent
                           (?P<exkills>     [0-9]    {1,6}  );   # explosion kills
                           (?P<knifekills>  [0-9]    {1,6}  );   # knife kills
                           (?P<zombie>      [0-9]    {1,3}  );   # times turned into zombie
                           (?P<ignited>     [0-9]    {1,6}  );   # flamethrower damage
                           (?P<poisoned>    [0-9]    {1,6}  );   # times poisoned (metric?)
                           (?P<hskills>     [0-9]    {1,6}  );   # headshot kills
                           (?P<repairs>     [0-9]    {1,6}  )    # repaired barriers
                         )$""",
            re.IGNORECASE | re.X),  # data closing parenthesis!
        re.compile(r'^(?P<action>ROTU_STATS_DONE);(?P<data>.*)$',
                   re.IGNORECASE)
    ]

    lf.extend(Cod4Parser._lineFormats)
    Cod4Parser._lineFormats = tuple(lf)

    global EVT_ROTU_STATS_GAME
    global EVT_ROTU_STATS_PLAYER
    global EVT_ROTU_STATS_DONE

    EVT_ROTU_STATS_GAME = eventManager.createEvent('EVT_ROTU_STATS_GAME',
                                                   'rotu game stats')
    EVT_ROTU_STATS_PLAYER = eventManager.createEvent('EVT_ROTU_STATS_PLAYER',
                                                     'rotu player stats')
    EVT_ROTU_STATS_DONE = eventManager.createEvent('EVT_ROTU_STATS_DONE',
                                                   'rotu stats done')

    def OnRotu_stats_game(self, action, data, match=None):
        return Event(EVT_ROTU_STATS_GAME, data=match)

    def OnRotu_stats_player(self, action, data, match=None):
        return Event(EVT_ROTU_STATS_PLAYER, data=match)

    def OnRotu_stats_done(self, action, data, match=None):
        return Event(EVT_ROTU_STATS_DONE, data=None)

    Cod4Parser.OnRotu_stats_game = OnRotu_stats_game
    Cod4Parser.OnRotu_stats_player = OnRotu_stats_player
    Cod4Parser.OnRotu_stats_done = OnRotu_stats_done