Jump to content
Korean Random
Aydomir

Как вывести средний дамаг аккаунта?

Recommended Posts

import BigWorld
from notification.NotificationListView import NotificationListView

old_populate = NotificationListView._populate

def new_populate(self):


    avgdmg = !!!!!!!! ЗДЕСЬ !!!!!!!!


    message = {
        'typeID': 2,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'message': 'AvgDmg '+avgdmg,
            'type': 'black',
            'icon': '',
        },
        'entityID': 9999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

Как вывести средний дамаг аккаунта? 

avgdmg = !!!!!!!! ЗДЕСЬ !!!!!!!!
Edited by Aydomir

Share this post


Link to post

Short link
Share on other sites

avgdmg

from gui.shared import g_itemsCache
import BigWorld

from json import load
from urllib import urlopen

def getCurrentPlayerId():
    # return 2178413 # DEBUG
    player = BigWorld.player()
    if hasattr(player, 'databaseID'):
        return player.databaseID

    arena = getattr(player, 'arena', None)
    if arena is not None:
        vehID = getattr(player, 'playerVehicleID', None)
        if vehID is not None and vehID in arena.vehicles:
            return arena.vehicles[vehID]['accountDBID']

    return None

playerId = getCurrentPlayerId()

obj = load(urlopen('http://api.worldoftanks.ru/wot/account/info/?application_id=demo&account_id={0}'.format(playerId)))
obj = obj['data'][str(playerId)]['statistics']['all']
avgdmg = round(obj['damage_dealt']/obj['battles'], 1)
Edited by ShadowHunterRUS

Share this post


Link to post

Short link
Share on other sites

Я тут смотрю программистов много стало. кто сможет сделать DebugPanel под мои хотелки? за вознаграждение.

Edited by Kornet_WA

Share this post


Link to post

Short link
Share on other sites

from gui.shared import g_itemsCache
import BigWorld

from json import load
from urllib import urlopen

def getPlayerId():
   plId = g_itemsCache.items.getAccountDossier().getPlayerDBID()
   if not plId:
      plId = BigWorld.player().id
   return plId

playerId = getPlayerId()

obj = load(urlopen('http://api.worldoftanks.ru/wot/account/info/?application_id=demo&account_id={0}'.format(playerId)))
obj = obj['data'][str(playerId)]['statistics']['all']
avgdmg = round(obj['damage_dealt']/obj['battles'], 1)

 

Не могу делить

BTS = str(data['battles'])
DMG = round(data['damage_dealt']/BTS, 1)

Share this post


Link to post

Short link
Share on other sites

@Yusha, может ты для модпака переделаешь DebugPanel.

Что она делает? Какая с нее польза? Если только изменение отображения пинга, то вообще не вижу смысла в таких модах. Отказался 2 патча назад.

оооо... еще заметил что мы дико офтопим.

Edited by Yusha

Share this post


Link to post

Short link
Share on other sites
вместо str нужно float
BTS = float(data['battles'])
D = float(data['damage_dealt'])
DMG = round(D/BTS, 1)

Сейчас делится, но что-то не так.

BTS = data['battles']
        DMG = data['damage_dealt']/BTS
        DES = data['frags']/BTS
        DET = data['spotted']/BTS
        CAP = data['capture_points']/BTS
        DEP = data['dropped_capture_points']/BTS
        WNS = data['wins']

        EFF = str((DMG*(10/(6.99+2))*(0.23+2*6.99/100)+DES*250+DET*150+log(CAP+1)/log(1.732)*150+DEF*150))
Edited by Aydomir

Share this post


Link to post

Short link
Share on other sites

int/int=int

float/float = float

ненавижу за это python2k

оберни все в float()

Так?

BTS = float(data['battles'])
        DMG = float(data['damage_dealt']/BTS)
        DES = float(data['frags']/BTS)
        DET = float(data['spotted']/BTS)
        CAP = float(data['capture_points']/BTS)
        DEP = float(data['dropped_capture_points']/BTS)
        WNS = float(data['wins'])

        EFF = float((DMG*(10/(6.99+2))*(0.23+2*6.99/100)+DES*250+DET*150+log(CAP+1)/log(1.732)*150+DEF*150))

Share this post


Link to post

Short link
Share on other sites

нет. каждую отдельно

EFF = (float(DMG)*(10/(6.99+2))*(0.23+2*6.99/100)+float(DES)*250+float(DET)*150+log(float(CAP)+1)/log(1.732)*150+float(DEF)*150)

Так?

нет. каждую отдельно

BTS нужно один раз привести к float

BTS = float(data['battles'])
        DMG = float(data['damage_dealt'])/BTS
        DES = float(data['frags'])/BTS
        DET = float(data['spotted'])/BTS
        CAP = float(data['capture_points'])/BTS
        DEP = float(data['dropped_capture_points'])/BTS
        WNS = float(data['wins'])

        EFF = float((DMG*(10/(6.99+2))*(0.23+2*6.99/100)+DES*250+DET*150+log(CAP+1)/log(1.732)*150+DEF*150))

Ааа точно! А теперь что не так?

Share this post


Link to post

Short link
Share on other sites

Так

BTS = float(data['battles'])
DMG = float(data['damage_dealt'])/BTS
DES = float(data['frags'])/BTS
DET = float(data['spotted'])/BTS
CAP = float(data['capture_points'])/BTS
DEP = float(data['dropped_capture_points'])/BTS
WNS = float(data['wins'])
EFF = (DMG*(10/(6.99+2))*(0.23+2*6.99/100)+DES*250+DET*150+log(CAP+1)/log(1.732)*150+DEF*150)

Не получается.

BTS = float(data['battles'])
        DMG = float(data['damage_dealt'])/BTS
        DES = float(data['frags'])/BTS
        DET = float(data['spotted'])/BTS
        CAP = float(data['capture_points'])/BTS
        DEP = float(data['dropped_capture_points'])/BTS
        WNS = float(data['wins'])

        EFF = (DMG*(10/(6.99+2))*(0.23+2*6.99/100)+DES*250+DET*150+log(CAP+1)/log(1.732)*150+DEF*150)

Share this post


Link to post

Short link
Share on other sites

какие ошибки?

Код нормально компилируется, но в клиенте не работает.

Share this post


Link to post

Short link
Share on other sites

В python.log глянь

 

from math import log

BTS = float(data['battles'])
D = float(data['damage_dealt'])/BTS
FRAGS = float(data['frags'])/BTS
SPOT = float(data['spotted'])/BTS
CAP = float(data['capture_points'])/BTS
DEF = float(data['dropped_capture_points'])/BTS
WNS = float(data['wins'])
MID = 6.99
EFF = round((D*(10.0/(MID+2))*(0.23+2*MID/100) + (FRAGS*250) + (SPOT*150) + log(CAP+1, 1.732)*150+DEF*150.0), 1)
У тебя кривой MID и ошибочный DEF

 

Может в проблема в log?

...+log(CAP+1)/log(1.732)*...

 

Может в проблема в log?

...+log(CAP+1)/log(1.732)*...

СПАСИБО! :D ВСЕ ПОЛУЧИЛОСЬ! 

 

У меня не было 

from math import log

и DEF не правильный, вы правы.

Edited by Aydomir

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...