PyTFall > PyTFall: Bugs and Game balancing

Code review

<< < (3/8) > >>

Xela:

--- Quote from: mijh on June 23, 2013, 09:56:59 AM ---Like....
--- Code: ---chance(0.1)
--- End code ---
?

A dice() function should return the number of a dice throw, not True or False, anyway. People don't know how to name functions :S

--- End quote ---

LoL

I just don't want to get used to writing chance instead of dice (and dice is shorter  :P )

rudistoned:

--- Quote from: mijh on June 23, 2013, 09:51:16 AM ---Neither does a chance out of 100 have anything to do with dice...

--- End quote ---
It seems you never played a pen&paper RPG (or maybe only those without percentage rolls?)  ;)

rudistoned:

--- Quote from: Xela on June 26, 2013, 06:49:32 AM ---As you prolly have figured out by now, game is coded this way:

1) All logical game elements are coded in pure python. We access, display and change those in RenPy labels.

2) User interactions:

- We jump to a RenPy 'label' (labels are RenPy's way of running the game, instead of the usual main game loop you'd expect to find in Hentai Sims, we simply jump labels until we run out of them (we can obviously keep jumping to the same label any amount of times))
- In that label, we set up background and call screens (screens are coded in RenPy's screen language), at the same time we lock game's flow in a while loop.
There is a number of things that are not smart to include in screens, mainly because screens are being refreshed on all user interactions, once every 20 secs (If I recall correctly) or even many times per second if game requires them to. Another thing is that certain functions (like action calls from buttons) are not searching for variables on the same namespace as the screen first (very unusual for Python).

Problem was here:

--- Code: ---                        for brtl in hero.brothels:
                            if brtl.highlighted:
                                $imgType = im.Scale
                            else:
                                $imgType = lambda *args: im.Sepia(im.Scale(*args))
                            vbox:
                                null height 20
                                text(u'{size=-10}%s' % brtl.name) align(0.5,0.5)
                                use rtt_lightbutton(img = imgType(brtl.img, 240, 150), return_value = ['brothel', brtl], tooltip = 'Send %s off to work in %s and choose from available actions.' % (chr.name, brtl.name))
--- End code ---

In precious revision brothel was used to iterate instead of brtl
--- Code: ---for brothel in hero.brothels:
--- End code ---
and at the same time we also had brothel variable in the label and while loop namespaces:


--- Code: ---label girl_assign:
    scene bg wood
    hide screen girlProfile
    show screen pyt_girl_assign

    python:
       
        if isinstance(chr.location, Brothel):
            brothel = chr.location
            brothel.highlighted = True
            brothel_selected = True
        else:
            brothel = None
            brothel_selected = False

        while True:
            result = ui.interact()

            if result[0] == 'brothel':
                for brothel in hero.brothels:
                    brothel.highlighted = False

                brothel = result[1]
                brothel.highlighted = True
                brothel_selected = True
--- End code ---

so this bit of old code:
--- Code: ---return_value = ['brothel', brothel]
--- End code ---
didn't actually return a brothel that came from iterating over hero.brothels in the screen (something any Python coder would expect, it actually works exactly like you'd expect something in Python to work since rtt_lightbutton itself is defined on the same namespace as label (it is in fact for all intent and purposes a separate screen itself), but it is still a bit confusing) but instead returned whatever brothel variable was set to in the label. As you can imagine, this is in no way a problem with one brothel but a rather nasty issue with multiple brothels that doesn't throw an Error making it very hard to catch.

In any case this is what I believe was wrong with the code

--- End quote ---

Well, I just checked because it would be horrifying if renpy would do something like that. Luckily for us, I can not confirm what you say. The change from "brothel" to "brtl" in the for loop (commited in c11e60d...) does not change which brothel is returned by "return_value = ['brothel', brothel]".
How did I check this? I added the following lines to the girlassign screen:

--- Code: ---------------- game/library/screens/pyt - screens - girlassign.rpy -------------
index ef6f4d6..3b4b973 100644
@@ -4,7 +4,7 @@ label girl_assign:
     show screen pyt_girl_assign
 
     python:
-
+        devlog.info("label girl_assign")
         if isinstance(chr.location, Brothel):
             brothel = chr.location
         else:
@@ -17,9 +17,11 @@ label girl_assign:
 
             if result[0] == 'brothel':
                 for brothel in hero.brothels:
+                    devlog.info("brothel at %i: %s" % (hero.brothels.index(brothel), brothel.name))
                     brothel.highlighted = False
 
                 brothel = result[1]
+                devlog.info("brothel returned: %s" % hero.brothels.index(brothel))
                 brothel.highlighted = True
                 brothel_selected = True

--- End code ---


Then I launched the game, bought some buildings and assigned girls in a pattern I remembered. The entries in the devlog show that the return value was always the brothel I had clicked on.

I tried this for both c11e60d (the commit with btrl in the for loop) and its parent c4ba128 (the commit with brothel in the for loop) and got identical results.

Am I still misunderstanding the problem?

Xela:

--- Quote from: rudistoned on June 26, 2013, 08:23:06 AM ---Am I still misunderstanding the problem?

--- End quote ---


--- Quote from: Xela on June 26, 2013, 06:49:32 AM ---In any case this is what I believe was wrong with the code

--- End quote ---

Well, apparently my believe was False... but I am not spending another minute figuring out that issue, I am having trouble focusing on Guard code as it is. If you want to keep digging at what the hell goes wrong there, be my guest :)

rudistoned:
Not right now, but maybe later. Do you remember the symptoms of the problem you observed?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version