mavzermete 1
mavzermete
Bvural41 1
Bvural41
noisiv 1
noisiv
Manwe Work 1
Manwe Work
xranzei 1
xranzei
Hikaye Ekle

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

HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. HEMEN TIKLA!

constinfo.py

Python:
USE_MONEY_T_FORMAT = True

if USE_MONEY_T_FORMAT:
    def FormatMoneyToK(string):
        moneyString = str(string)
        money = 0

        if len(moneyString) > 1:
            if 't' in moneyString:
                money = int(moneyString.replace('t', '000000'))
            elif 'T' in moneyString:
                money = int(moneyString.replace('T', '000000'))

        return money

uiPickMoney.py

Python:
''' 1. '''
# importlara ekle
import constInfo

''' 2. won varsa'''
# arat @ def OnAccept
            money_text = self.pickValueEditLine.GetText()

# altına ekle
            if constInfo.USE_MONEY_T_FORMAT:
                if 't' in money_text or 'T' in money_text:
                    money_text = str(constInfo.FormatMoneyToK(money_text))


''' 3. '''
#arat
            text = self.pickValueEditLine.GetText()

#altına ekle
            if constInfo.USE_MONEY_T_FORMAT:
                if 't' in text or 'T' in text:
                    text = str(constInfo.FormatMoneyToK(text))




pickMoneyDialog.py

Python:
# Arat
                            {
                                "name" : "money_value",
                                "type" : "editline",

                                "x" : 3,
                                "y" : 2,

                                "width" : 60,
                                "height" : 18,

                                "input_limit" : 6,
                                "only_number" : 1,

                                "text" : "1",
                            },

# Değiştir
                            {
                                "name" : "money_value",
                                "type" : "editline",

                                "x" : 3,
                                "y" : 2,

                                "width" : 60,
                                "height" : 18,

                                "input_limit" : 6,
                                "only_number" : 0,

                                "text" : "1",
                            },
    
    #biraz bakarsanız tek farkı göreceksiniz zaten :d

eksik varsa söyleyin tamamlayak uzun zamandır bakmıyorum başka bir sisteme bakarak yapmıştım(hatta direk kopya denebilir asdasdasd) ticarete 1000000000 yerine 1t yazarsanız 1000000000 olarak geçecektir 1t vermek istediğinizde 1t yazacaksınız işte m e göre de uyarlanabilir hatta çok basit :d
 

En Çok Reaksiyon Alan Mesajlar

Python:
USE_MONEY_T_FORMAT = True

if USE_MONEY_T_FORMAT:
def FormatMoneyToK(string):
moneyString = str(string)
money = 0

if len(moneyString) > 1:
if 't' in moneyString:
money = int(moneyString.replace('t', '000000'))
elif 'T' in moneyString:
money = int(moneyString.replace('T', '000000'))

return money

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.



Öğeyi görmek için üye olmalısınız. Öğeyi görmek için üye olmalısınız.
Öğeyi görmek için üye olmalısınız.Öğeyi görmek için üye olmalısınız.

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()
constinfo.py

Python:
USE_MONEY_T_FORMAT = True

if USE_MONEY_T_FORMAT:
    def FormatMoneyToK(string):
        moneyString = str(string)
        money = 0

        if len(moneyString) > 1:
            if 't' in moneyString:
                money = int(moneyString.replace('t', '000000'))
            elif 'T' in moneyString:
                money = int(moneyString.replace('T', '000000'))

        return money

uiPickMoney.py

Python:
''' 1. '''
# importlara ekle
import constInfo

''' 2. won varsa'''
# arat @ def OnAccept
            money_text = self.pickValueEditLine.GetText()

# altına ekle
            if constInfo.USE_MONEY_T_FORMAT:
                if 't' in money_text or 'T' in money_text:
                    money_text = str(constInfo.FormatMoneyToK(money_text))


''' 3. '''
#arat
            text = self.pickValueEditLine.GetText()

#altına ekle
            if constInfo.USE_MONEY_T_FORMAT:
                if 't' in text or 'T' in text:
                    text = str(constInfo.FormatMoneyToK(text))




pickMoneyDialog.py

Python:
# Arat
                            {
                                "name" : "money_value",
                                "type" : "editline",

                                "x" : 3,
                                "y" : 2,

                                "width" : 60,
                                "height" : 18,

                                "input_limit" : 6,
                                "only_number" : 1,

                                "text" : "1",
                            },

# Değiştir
                            {
                                "name" : "money_value",
                                "type" : "editline",

                                "x" : 3,
                                "y" : 2,

                                "width" : 60,
                                "height" : 18,

                                "input_limit" : 6,
                                "only_number" : 0,

                                "text" : "1",
                            },
   
    #biraz bakarsanız tek farkı göreceksiniz zaten :d

eksik varsa söyleyin tamamlayak uzun zamandır bakmıyorum başka bir sisteme bakarak yapmıştım(hatta direk kopya denebilir asdasdasd) ticarete 1000000000 yerine 1t yazarsanız 1000000000 olarak geçecektir 1t vermek istediğinizde 1t yazacaksınız işte m e göre de uyarlanabilir hatta çok basit :d
Paylaşım için teşekkürler.
 

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

Geri
Üst