Ren'Py An unintentionally looping game

bdaywans

Newbie
Apr 15, 2017
35
22
I've posted a few renpy questions so far and figuring it out more as I go. One response pointed out that the match 3 minigame I'm using is pretty out of date but it's serving its purpose for me while I 'demo' my game. But I've broken something in the win/loss portion and can't figure it out.

THE PROBLEM:
The match 3 game is going to be a best 3/5. Each round won will call a cut scene (calls a label then returns, I've tested these and they're working fine) and return to the game. The game is SUPPOSED to end after 3 wins or at 5 rounds, whichever comes first.

Currently my round 1, round 2 and BONUS cutscenes work but the game won't end and just keeps going round after round (I've gone as high as 8 rounds won and just closed it down as clearly it wasn't stopping at 5 either way)

The CODE:
Code:
label memo_game_win:
    hide screen memo_scr
    $ renpy.pause (0.1, hard = True)
    $ renpy.pause (0.1, hard = True)
    "You win!"
    $ gameSet += 1
    $ win += 1
    if win == 1:
        call expression challenger + "_" + match + "_win_1"
    elif win == 2:
        call expression challenger + "_" + match + "_win_2"
    else:
        jump memoria_game
    $ winImg += 1
    if winImg >= 5:
        $ winImg == 4
    if gameSet == 2:
        if win == 2:
            call expression challenger + "_" + match + "_BONUS"
            jump memoria_game
    if gameSet <= 4:
        if win == 3:
            call expression challenger + "_" + match + "_won"
        elif win <= 2:
            jump memoria_game
    elif gameSet == 5:
        if win == 3:
            call expression challenger + "_" + match + "_won"
        elif win <= 2:
            call expression challenger + "_" + match + "_lost"
Anything I'm overlooking?
 

bdaywans

Newbie
Apr 15, 2017
35
22
else:
jump memoria_game

skips all subsequent tests if win != 1 or win !=2. Is that expected?
nope, but I did pull out my "if win != 1" and "!=2" (also changed to !=) and it advanced to the end scene of my win scene. I actually added the jump because when I left just the if statement it would play cutscene 1 and then return to the main menu.

So good news, thanks! that fixed my neverending game

bad news, that took out my win 1 and win 2 cutscenes...

so is there a way I can avoid that break and have it still call the labels for wins 1, 2, etc?
 

sillyrobot

Engaged Member
Apr 22, 2019
2,161
1,881
I suspect you needn't have made the test !=. I wrote != because that's the condition where the else is run.

Pick up that whole if structure and place it after all the others and there's a good chance it'll be much closer to working. That would change the order of your call expressions though, if that's important.
 

sillyrobot

Engaged Member
Apr 22, 2019
2,161
1,881
The logic looks a bit convoluted for a 3 out of 5 win condition. You are testing for a match loss, which you can't get if the player just won, for example (assuming you test for 3 losses and have the player lose the match on the 3rd loss).

Take a look at the below:

Code:
hide screen memo_scr  
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)  
"You win!"
$ gameSet += 1
$ win += 1
$ winImg += 1
if winImg >= 5:
    $ winImg = 4 # note this line used to be a comparator and I turned it to an assignment

if win == 1:
    call expression challenger + "_" + match + "_win_1"  
elif win == 2:
    call expression challenger + "_" + match + "_win_2"

if gameSet == 2 and win == 2:         
    call expression challenger + "_" + match + "_BONUS"          
    jump memoria_game    # note jumping here to play another game, I think
elif win > 2: # note I convert ==3 to >2 because I've been trained that way -- safety first!
    call expression challenger + "_" + match + "_won"
    # note not jumping here because we're done with the game
else
    jump memoria_game # note jumping here to play another game I think
 
  • Like
Reactions: Abhai

bdaywans

Newbie
Apr 15, 2017
35
22
The logic looks a bit convoluted for a 3 out of 5 win condition. You are testing for a match loss, which you can't get if the player just won, for example (assuming you test for 3 losses and have the player lose the match on the 3rd loss).

Take a look at the below:

Code:
hide screen memo_scr 
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True) 
"You win!"
$ gameSet += 1
$ win += 1
$ winImg += 1
if winImg >= 5:
    $ winImg = 4 # note this line used to be a comparator and I turned it to an assignment

if win == 1:
    call expression challenger + "_" + match + "_win_1" 
elif win == 2:
    call expression challenger + "_" + match + "_win_2"

if gameSet == 2 and win == 2:        
    call expression challenger + "_" + match + "_BONUS"         
    jump memoria_game    # note jumping here to play another game, I think
elif win > 2: # note I convert ==3 to >2 because I've been trained that way -- safety first!
    call expression challenger + "_" + match + "_won"
    # note not jumping here because we're done with the game
else
    jump memoria_game # note jumping here to play another game I think
Thats just what I needed. I'm a visual learner so that helped a LOT! Thanks. I've run a bunch of test so far and everything looks like its working so far. That was my 'engine' for the game portion so I can get back to finishing the story now.