Çözüldü Metin2 derece sistemi

Bu konu çözüme ulaştırılmıştır. Çözüm için konuya yazılan tüm yorumları okumayı unutmayın. Eğer konudaki yorumlar sorununuzu çözmediyse yeni bir konu açabilirsiniz.
Durum
İçerik kilitlendiği için mesaj gönderimine kapatıldı.

TheAdmin33

Ah bu şarkıların gözü kör olsun
Premium Üye
Geliştirici
Yardımsever Üye
Usta Üye
Editör
Mesaj
785
Çözümler
45
Beğeni
1.471
Puan
1.139
Ticaret Puanı
0
Derece sisteminde bir kod kısmı var ve ben bu kodu sadeleştirmek istiyorum bunu nasıl yaparım?

derece sistemini 40 kademeli yapmak istiyorum ama uicharacter.py kısmını sadeleştirmek istiyorum .

kod;
uicharacter.py:
            if point >= 30000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_1_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_1_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_1_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 25000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_2_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_2_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_2_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 20000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_3_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_3_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_3_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 18000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_4_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_4_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_4_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 12000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_5_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_5_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_5_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 8000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_6_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_6_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_6_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 4000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_7_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_7_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_7_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 1000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_8_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_8_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_8_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point < 1000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_0_1, self.toolTipAlignment.NEGATIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_0_2, self.toolTipAlignment.NEGATIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_0_3, self.toolTipAlignment.NEGATIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)

mevcut kod bu, böyle 40 tane if sorgusu yazmadan tek for döngüsüyle bunu nasıl yaparım?

ilgili fonksiyonun tam hali;
uicharacter.py:
    def RefreshAlignment(self):
        point, grade = player.GetAlignmentData()

        import colorInfo

        if app.ENABLE_ALIGN_RENEWAL:
            COLOR_DICT = {    0 : colorInfo.TITLE_RGB_GOOD_10,
                            1 : colorInfo.TITLE_RGB_GOOD_9,
                            2 : colorInfo.TITLE_RGB_GOOD_8,
                            3 : colorInfo.TITLE_RGB_GOOD_7,
                            4 : colorInfo.TITLE_RGB_GOOD_6,
                            5 : colorInfo.TITLE_RGB_GOOD_5,
                            6 : colorInfo.TITLE_RGB_GOOD_4,
                            7 : colorInfo.TITLE_RGB_GOOD_3,
                            8 : colorInfo.TITLE_RGB_GOOD_2,
                            9 : colorInfo.TITLE_RGB_GOOD_1,
                            10 : colorInfo.TITLE_RGB_GOOD_1,
                            11 : colorInfo.TITLE_RGB_NORMAL,
                            12 : colorInfo.TITLE_RGB_EVIL_1,
                            13 : colorInfo.TITLE_RGB_EVIL_2,
                            14 : colorInfo.TITLE_RGB_EVIL_3,
                            15 : colorInfo.TITLE_RGB_EVIL_4,
                            16 : colorInfo.TITLE_RGB_GOOD_10,
                            17 : colorInfo.TITLE_RGB_GOOD_9,
                            18 : colorInfo.TITLE_RGB_GOOD_8,
                            19 : colorInfo.TITLE_RGB_GOOD_7,
                            20 : colorInfo.TITLE_RGB_GOOD_6,
                            21 : colorInfo.TITLE_RGB_GOOD_5,
                            22 : colorInfo.TITLE_RGB_GOOD_4,
                            23 : colorInfo.TITLE_RGB_GOOD_3,
                            24 : colorInfo.TITLE_RGB_GOOD_2,
                            25 : colorInfo.TITLE_RGB_GOOD_1,
                            26 : colorInfo.TITLE_RGB_NORMAL,
                            27 : colorInfo.TITLE_RGB_EVIL_1,
                            28 : colorInfo.TITLE_RGB_EVIL_2,
                            29 : colorInfo.TITLE_RGB_EVIL_3,
                            30 : colorInfo.TITLE_RGB_EVIL_4,
                            31 : colorInfo.TITLE_RGB_GOOD_10,
                            32 : colorInfo.TITLE_RGB_GOOD_9,
                            33 : colorInfo.TITLE_RGB_GOOD_8,
                            34 : colorInfo.TITLE_RGB_GOOD_7,
                            35 : colorInfo.TITLE_RGB_GOOD_6,
                            36 : colorInfo.TITLE_RGB_GOOD_5,
                            37 : colorInfo.TITLE_RGB_GOOD_4,
                            38 : colorInfo.TITLE_RGB_GOOD_3,
                            39 : colorInfo.TITLE_RGB_GOOD_2,
                            40 : colorInfo.TITLE_RGB_NORMAL,
                            41 : colorInfo.TITLE_RGB_EVIL_1,
                            42 : colorInfo.TITLE_RGB_EVIL_2,
                            43 : colorInfo.TITLE_RGB_EVIL_3,
                            44 : colorInfo.TITLE_RGB_EVIL_4, }
        else:
            COLOR_DICT = {    0 : colorInfo.TITLE_RGB_GOOD_4,
                            1 : colorInfo.TITLE_RGB_GOOD_3,
                            2 : colorInfo.TITLE_RGB_GOOD_2,
                            3 : colorInfo.TITLE_RGB_GOOD_1,
                            4 : colorInfo.TITLE_RGB_NORMAL,
                            5 : colorInfo.TITLE_RGB_EVIL_1,
                            6 : colorInfo.TITLE_RGB_EVIL_2,
                            7 : colorInfo.TITLE_RGB_EVIL_3,
                            8 : colorInfo.TITLE_RGB_EVIL_4, }

        colorList = COLOR_DICT.get(grade, colorInfo.TITLE_RGB_NORMAL)
        gradeColor = ui.GenerateColor(colorList[0], colorList[1], colorList[2])

        self.toolTipAlignment.ClearToolTip()
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.TITLE_NAME_LIST[grade], gradeColor)
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGNMENT_NAME + str(point))
        self.toolTipAlignment.AppendSpace(1)

        self.toolTipAlignment.AutoAppendTextLine("____________________________________")
        self.toolTipAlignment.AppendSpace(1)

        colorList = COLOR_DICT.get(grade, colorInfo.TITLE_RGB_NORMAL)
        gradeColor = ui.GenerateColor(colorList[0], colorList[1], colorList[2])
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.MY_GRADE % localeInfo.TITLE_NAME_LIST[grade], gradeColor)

        self.toolTipAlignment.AutoAppendTextLine("____________________________________")
        self.toolTipAlignment.AppendSpace(1)

        colorList2 = COLOR_DICT.get(grade-1, colorInfo.TITLE_RGB_NORMAL)
        gradeColor2 = ui.GenerateColor(colorList2[0], colorList2[1], colorList2[2])
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.NEXT_GRADE % localeInfo.TITLE_NAME_LIST[grade-1], gradeColor2)
        self.toolTipAlignment.AppendSpace(1)

        self.toolTipAlignment.AutoAppendTextLine("____________________________________")
        self.toolTipAlignment.AppendSpace(1)

        if app.ENABLE_ALIGN_RENEWAL:
            self.toolTipAlignment.AppendSpace(2)
            if point >= 30000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_1_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_1_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_1_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 25000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_2_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_2_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_2_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 20000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_3_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_3_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_3_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 18000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_4_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_4_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_4_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 12000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_5_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_5_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_5_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 8000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_6_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_6_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_6_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 4000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_7_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_7_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_7_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point >= 1000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_8_1, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_8_2, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_8_3, self.toolTipAlignment.POSITIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)
            elif point < 1000:
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_0_1, self.toolTipAlignment.NEGATIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_0_2, self.toolTipAlignment.NEGATIVE_COLOR)
                self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGN_BONUS_0_3, self.toolTipAlignment.NEGATIVE_COLOR)
                self.toolTipAlignment.AppendSpace(2)

        self.toolTipAlignment.AlignHorizonalCenter()

başka bir fileste bulduğum ama anlamadığım bir kod;
uicharacter.py:
    def RefreshAlignment(self):
        point, grade = player.GetAlignmentData()

        colorList = colorInfo.ALIGN_GRADE_COLOR_DICT.get(grade, colorInfo.TITLE_RGB_NORMAL)
        gradeColor = ui.GenerateColor(colorList[0], colorList[1], colorList[2])

        self.toolTipAlignment.ClearToolTip()
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.TITLE_NAME_LIST[grade], gradeColor)
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGNMENT_NAME + str(point))
        self.toolTipAlignment.AppendSpace(1)

        self.toolTipAlignment.AutoAppendTextLine("____________________________________")
        self.toolTipAlignment.AppendSpace(1)

        colorList = colorInfo.ALIGN_GRADE_COLOR_DICT.get(grade, colorInfo.TITLE_RGB_NORMAL)
        gradeColor = ui.GenerateColor(colorList[0], colorList[1], colorList[2])
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.MY_GRADE % localeInfo.TITLE_NAME_LIST[grade], gradeColor)

        self.toolTipAlignment.AutoAppendTextLine("____________________________________")
        self.toolTipAlignment.AppendSpace(1)

        colorList2 = colorInfo.ALIGN_GRADE_COLOR_DICT.get(grade-1, colorInfo.TITLE_RGB_NORMAL)
        gradeColor2 = ui.GenerateColor(colorList2[0], colorList2[1], colorList2[2])
        self.toolTipAlignment.AutoAppendTextLine(localeInfo.NEXT_GRADE % localeInfo.TITLE_NAME_LIST[grade-1], gradeColor2)
        self.toolTipAlignment.AppendSpace(1)

        self.toolTipAlignment.AutoAppendTextLine("____________________________________")
        self.toolTipAlignment.AppendSpace(1)

        for i in xrange(40):
            if i == player.GetNewAlignmentData()-1:
                total = len(constInfo.derecebonus)
                if total == 0:
                    continue

                if int(constInfo.derecebonus[i]['applytype1']) > 0 and int(constInfo.derecebonus[i]['applyvalue1']):
                    self.toolTipAlignment.AutoAppendTextLine(AFFECT_DICT[int(constInfo.derecebonus[i]['applytype1'])](int(constInfo.derecebonus[i]['applyvalue1'])), gradeColor)

                if int(constInfo.derecebonus[i]['applytype2']) > 0 and int(constInfo.derecebonus[i]['applyvalue2']):
                    self.toolTipAlignment.AutoAppendTextLine(AFFECT_DICT[int(constInfo.derecebonus[i]['applytype2'])](int(constInfo.derecebonus[i]['applyvalue2'])), gradeColor)

                if int(constInfo.derecebonus[i]['applytype3']) > 0 and int(constInfo.derecebonus[i]['applyvalue3']):
                    self.toolTipAlignment.AutoAppendTextLine(AFFECT_DICT[int(constInfo.derecebonus[i]['applytype3'])](int(constInfo.derecebonus[i]['applyvalue3'])), gradeColor)

                if int(constInfo.derecebonus[i]['applytype4']) > 0 and int(constInfo.derecebonus[i]['applyvalue4']):
                    self.toolTipAlignment.AutoAppendTextLine(AFFECT_DICT[int(constInfo.derecebonus[i]['applytype4'])](int(constInfo.derecebonus[i]['applyvalue4'])), gradeColor)

        self.toolTipAlignment.AlignHorizonalCenter()
 
Çözüm
Python:
bonuslar = [
    (30000, ["ALIGN_BONUS_1_1", "ALIGN_BONUS_1_2", "ALIGN_BONUS_1_3"]),
    (25000, ["ALIGN_BONUS_2_1", "ALIGN_BONUS_2_2", "ALIGN_BONUS_2_3"]),
    (20000, ["ALIGN_BONUS_3_1", "ALIGN_BONUS_3_2", "ALIGN_BONUS_3_3"]),
    (18000, ["ALIGN_BONUS_4_1", "ALIGN_BONUS_4_2", "ALIGN_BONUS_4_3"]),
    (12000, ["ALIGN_BONUS_5_1", "ALIGN_BONUS_5_2", "ALIGN_BONUS_5_3"]),
    (8000, ["ALIGN_BONUS_6_1", "ALIGN_BONUS_6_2", "ALIGN_BONUS_6_3"]),
    (4000, ["ALIGN_BONUS_7_1", "ALIGN_BONUS_7_2", "ALIGN_BONUS_7_3"]),
    (1000, ["ALIGN_BONUS_8_1", "ALIGN_BONUS_8_2", "ALIGN_BONUS_8_3"]),
    (0, ["ALIGN_BONUS_0_1", "ALIGN_BONUS_0_2", "ALIGN_BONUS_0_3"]),
]

renk = self.toolTipAlignment.POSITIVE_COLOR if point_num >= 0 else...
Ben de senin yukarıda verdiğin dosyalara dayanarak çözüm ürettim, senin elindeki dosyaların ve kodların farkılılığını görmeden bilemem doğal olarak. Son verdiğim kodun döngülerle bir bağlantısı yok, mantığını kavrarsan sendeki kodlara da kolaylıkla uyarlanabilir.
tamamdır hallettim ;
Ekran Alıntısı.PNG


vakit ayırıp yardımcı olduğun için teşekkürler(@Kaiser ).

point=3000000, grade=0 grade index karşılığı oluyor, pointle değilde grade le yaptım öyle daha kolay oluyor.
 
Durum
İçerik kilitlendiği için mesaj gönderimine kapatıldı.
Geri
Üst