CAM2HAD/RPG-class

The Game gets into an infinite loop after the 1st Round

Closed this issue · 0 comments

1 - The problem

  • The game gets into an infinite loop right after all the players have played and when it is time to display the enemy's stats main.py #L64:

image

  • An Infinite loop is usually caused when the [Condition=True] that started the While loop in the first place never
    get to the point where it ends [Condition=False]

  • Example 1:
    While [Condition]
    print("Are we there yet??") # (while Condition=True)

  • In the previous Example if there is nothing in the while loop that sets Condition=False, the program will keep showing :
    "Are we there yet??"
    "Are we there yet??"
    "Are we there yet??"

2 - The Bug

  • in get_enemy_stats() your enemy has a max of 47 Hp, but the Hp bar has to show up to 50 Hp even if you have less than that and fill the rest with blank cells

  • Example 2:
    __________________________________________________
    Magus 10305/11200|████████████████████████████████████████████ __ __ __ |

  • We see that there is 3 spots lefts that are filled with blanks cells shown as "__ __ __"

  • The program gets stuck trying to do this

Scroll Down for hints . .

.

.

.

.

.

.

.

.

.

.

.

.

3 - Hints

  1. The program should be able to print the blank cells but somehow it fails to do so, and it gets into an infinite loop right there
    image

.

.

.

  1. Try to print the size of the hp_bar array during the While loop to see what's happening

.

.

.

  1. Look for a similar function that does the same thing with a while (there s one not too far)

.

.

.

  1. The solution is actually very subtle, try to modify the current value of hp_bar+= and see what s happening

.

.

.

  1. You might only need to change 1 character . . .