shrpnl 1
shrpnl
YusufŞimşek14 1
YusufŞimşek14
berzahx 2
berzahx
xranzei 1
xranzei
Agora Metin2 1
Agora Metin2
Bvural41 1
Bvural41
romegames 1
romegames
noisiv 1
noisiv
Manwe Work 1
Manwe Work
Hikaye Ekle
Reklam vermek için turkmmo@gmail.com

Ticarette yazmalı yang sistemi

  • Konuyu başlatan Konuyu başlatan Agora Metin2
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 16
  • Görüntüleme Görüntüleme 3K

ROHAN2 WORLD 1-120 TR TİPİ OFFICIAL YOHARA, BALATHOR VE AMON! 80. GÜNÜNDE! +10.000 ONLİNE! HİLE VE BOT %100 ENGELLİ HEMEN TIKLA!

The idea is good, but the code is bugged and unreadable, here're the bugs:

text = '1kks'
  • ValueError: invalid literal for int() with base 10: '1000000s'
text = '1kk500'
  • 1000000500
text = '1abcd'
  • '1abcd'

If I'm the one who do this, i would do it more extendable and using a proficient way.



8f9d06c2fcb7f4525c2fe219a878a09d.png
4807153bd1bb3f4e9e4b00f492054864.png

9197a657a56afcab56b8b17ce77806e1.png
2be07686886205e82d437108f547bbbd.png


Python:
import re

    def __ConvertMoneyText(self, text, powers=dict(k=10**3, m=10**6, b=10**9)):
        """
        Format string value in thousands, millions or billions.

        '1k' = 1.000
        '100kk' = 100.000.000
        '100m' = 100.000.000
        '1b' = 1.000.000.000
        '1kmb' = 1.000 (can't use multiple suffixes types)

        :param text: string
        :return: int
        :date: 10.01.2020
        :author: Vegas
        """

        match = re.search(r'(\d+)({:s}+)?'.format('+|'.join(powers.keys())), text, re.I)
        if match:
            moneyValue, suffixName = match.groups()
            moneyValue = int(moneyValue)
            if not suffixName:
                return moneyValue

            return moneyValue * (powers[suffixName[0]] ** len(suffixName))

        return 0

    def OnAccept(self):
        text = self.pickValueEditLine.GetText()
        if text:
            moneyValue = min(self.__ConvertMoneyText(text), self.maxValue)
            if moneyValue:
                if self.eventAccept:
                    self.eventAccept(moneyValue)

        self.Close()
I’d gladly close my topic if you’re willing to release a bug free one, I’ve seen a similar topic in m2dev since Turkish player base is more likely to use M and T prefixes this was the change I made back in 2-3 months ago
 
Paylaşım için teşekkürler.
 
Paylaşımın için saol :P
 

Konu orjinal kodları buyrun. K lar T yapılmış sadece.
 

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst