<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#  IkaLog
#  ======
#  Copyright (C) 2015 <NAME>
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

from datetime import datetime
import time

from ikalog.utils import *


# IkaLog Output Plugin: Show message on Console
#


class IkaOutput_Console:

    ##
    # onGameStart Hook
    # @param self      The Object Pointer
    # @param context   IkaLog context
    #
    def onGameStart(self, context):
        map = IkaUtils.map2text(context['game']['map'])
        rule = IkaUtils.rule2text(context['game']['rule'])
        print("ゲームスタート。マップ %s ルール %s" % (map, rule))

    ##
    # Generate a message for onGameIndividualResult.
    # @param self      The Object Pointer.
    # @param context   IkaLog context
    #
    def getTextGameIndividualResult(self, context):
        map = IkaUtils.map2text(context['game']['map'])
        rule = IkaUtils.rule2text(context['game']['rule'])
        won = IkaUtils.getWinLoseText(
            context['game']['won'], win_text="勝ち", lose_text="負け", unknown_text="不明")
        t = datetime.now()
        t_str = t.strftime("%Y,%m,%d,%H,%M")
        t_unix = int(time.mktime(t.timetuple()))
        me = IkaUtils.getMyEntryFromContext(context)

        s = 'ゲーム終了。'
        s = '%s ステージ:%s' % (s, map)
        s = '%s ルール:%s' % (s, rule)
        s = '%s %s' % (s, won)

        if ('kills' in me) and ('deaths' in me):
            s = '%s %dK/%dD' % (s, me['kills'], me['deaths'])

        if 'weapon' in me:
            s = '%s 使用ブキ:%s' % (s, me['weapon'])

        if ('rank_in_team' in me):
            s = '%s チーム内順位: %d' % (s, me['rank_in_team'])

        if ('udemae_pre' in me) and me['udemae_pre']:
            s = '%s プレイ前ウデマエ %s' % (s, me['udemae_pre'])

        return s

    ##
    # onGameIndividualResult Hook
    # @param self      The Object Pointer
    # @param context   IkaLog context
    #
    def onGameIndividualResult(self, context):
        s = self.getTextGameIndividualResult(context)
        print(s)<commit_msg>ikalog/outputs/console: Show nawabari score if available.<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#  IkaLog
#  ======
#  Copyright (C) 2015 <NAME>
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

from datetime import datetime
import time

from ikalog.utils import *


# IkaLog Output Plugin: Show message on Console
#


class IkaOutput_Console:

    ##
    # onGameStart Hook
    # @param self      The Object Pointer
    # @param context   IkaLog context
    #
    def onGameStart(self, context):
        map = IkaUtils.map2text(context['game']['map'])
        rule = IkaUtils.rule2text(context['game']['rule'])
        print("ゲームスタート。マップ %s ルール %s" % (map, rule))

    ##
    # Generate a message for onGameIndividualResult.
    # @param self      The Object Pointer.
    # @param context   IkaLog context
    #
    def getTextGameIndividualResult(self, context):
        map = IkaUtils.map2text(context['game']['map'])
        rule = IkaUtils.rule2text(context['game']['rule'])
        won = IkaUtils.getWinLoseText(
            context['game']['won'], win_text="勝ち", lose_text="負け", unknown_text="不明")
        t = datetime.now()
        t_str = t.strftime("%Y,%m,%d,%H,%M")
        t_unix = int(time.mktime(t.timetuple()))
        me = IkaUtils.getMyEntryFromContext(context)

        s = 'ゲーム終了。'
        s = '%s ステージ:%s' % (s, map)
        s = '%s ルール:%s' % (s, rule)
        s = '%s %s' % (s, won)

        if ('score' in me):
            s = '%s %sp' % (s, me['score'])

        if ('kills' in me) and ('deaths' in me):
            s = '%s %dK/%dD' % (s, me['kills'], me['deaths'])

        if 'weapon' in me:
            s = '%s 使用ブキ:%s' % (s, me['weapon'])

        if ('rank_in_team' in me):
            s = '%s チーム内順位: %d' % (s, me['rank_in_team'])

        if ('udemae_pre' in me) and me['udemae_pre']:
            s = '%s プレイ前ウデマエ %s' % (s, me['udemae_pre'])

        return s

    ##
    # onGameIndividualResult Hook
    # @param self      The Object Pointer
    # @param context   IkaLog context
    #
    def onGameIndividualResult(self, context):
        s = self.getTextGameIndividualResult(context)
        print(s)
{'fraction_non_alphanumeric': 0.1395437991182672, 'fraction_numerical': 0.005367069196856431, 'mean_word_length': 2.6413119330076764, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4860108', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1748, 'n_words': 503}