My solution is very... involved... but I'll share in case anyone else ever needs it.
basically takes a list with 4 values, and finds the two highest values, and if there is a tie between the highest or 2nd highest value, offer a tie breaker with user input (allowing the user to break the tie), and then offers 6 outcomes
it works unless all the values stay at 0, it may be too redundant or something but it's what I managed to do lol (i tried to remove my custom variables so it could be easier to read, so if there is a weird one somewhere it's probably one i forgot.... > <)
Code: Select all
default a = 0
default b = 0
default c = 0
default d = 0
my_list = []
label start:
## all your code for stuff
label t_i_test:
## Determines if a tie breaker is needed - should be a loop until the tie breaker is no longer needed.
$ tie_breaker_determine()
if tie_breaker_needed:
call screen tie_breaker
jump t_i_test
else:
hide screen tie_breaker
## test for the outcome
$ outcome_test()
Code: Select all
## the screen code for the tie breaker:
screen tie_breaker():
tag menu
## This pulls up and allows the player to select to add to the values in order to break the tie
vbox:
xalign 0.5
yalign 0.5
text "Tie Breaker"
if a_max:
textbutton "A" action [SetVariable("a", a + 1), Return()]
if b_max:
textbutton "B" action [SetVariable("b", b + 1), Return()]
if c_max:
textbutton "C" action [SetVariable("c", c + 1), Return()]
if d_max:
textbutton "D" action [SetVariable("d", d + 1), Return()]
NOW for all of the functions..... there are a lot....
Code: Select all
init python:
def change_temp_list(str):
global temp_list
global my_list
int = len(temp_list)
## This either empties or fills the list depending on the parameter provided, I did this so I didn't have to make a million temp_list variables and worry
## about them over lapping
if str == "empty":
if int == 0:
pass
else:
while int > 0:
for i in temp_list:
temp_list.remove(i)
int -= 1
if str == "fill":
my_list_calc()
for i in my_list:
temp_list.append(i)
init python:
def my_list_calc():
global my_list
global a
global b
global c
global d
## this adds the values, and removes the leftover so the list stays at 4 items (otherwise it just continues to add values)
my_list.insert(0, a)
my_list.insert(1, b)
my_list.insert(2, c)
my_list.insert(3, d)
my_list= my_list[:4]
init python:
def find_highest_values():
global my_list
global max_value
global max_value_2
global temp_list
## This finds the two highest values in the list
## empty the temp list
change_temp_list("empty")
##make sure to calculate the list items
my_list_calc()
## put the my_list info into the temp list
change_temp_list("fill")
## find the first maximum value
max_value = max(temp_list)
## Remove list elements that are = to max_value
temp_list = [x for x in temp_list if x != max_value]
## Get's the 2nd maximum value
if len(temp_list) > 1:
max_value_2 = max(temp_list)
if len(temp_list) == 0:
max_value_2 = 0
if len(temp_list) == 1:
max_value_2 = temp_list[0]
init python:
def tie_breaker_determine():
global my_list
global tie_breaker_needed
global max_value
global max_value_2
global num_of_max_values
global num_of_max_values_2
global temp_list
## This determines if the tie breaker is needed
##Clear out temp_list
change_temp_list("empty")
##make sure to calculate the my_list values
my_list_calc()
## put the my_list info into the temp list
change_temp_list("fill")
## Find Max_1 and Max_2
find_highest_values()
## refill the list
change_temp_list("empty")
change_temp_list("fill")
## Start at 0 so this can be adjusted
num_of_max_values = 0
num_of_max_values_2 = 0
## count the number of max values in the list
for i in temp_list:
if i == max_value:
num_of_max_values += 1
## count the number of 2nd max values in the list
if max_value_2 == 0:
num_of_max_values_2 = 0
else:
for i in temp_list:
if i == max_value_2:
num_of_max_values_2 += 1
## Test Passed:
## NO DUPLICATES!!
if num_of_max_values <= 1 and num_of_max_values_2 <= 1:
tie_breaker_needed = False
## Test Failed:
if num_of_max_values >= 2 or num_of_max_values_2 >= 2:
tie_breaker_needed = True
## This function is for adding the right values to the tie breaker screen
tie_breaker_screen_test(1)
if num_of_max_values_2 >=2:
tie_breaker_needed = True
## This function is for adding the right values to the tie breaker screen
tie_breaker_screen_test(2)
init python:
def tie_breaker_screen_test(num):
global a
global b
global c
global d
global a_max
global b_max
global c_max
global d_max
global max_value
global max_value_2
if num == 1:
if a == max_value:
a_max = True
if b == max_value:
b_max = True
if c == max_value:
c_max = True
if d == max_value:
d_max = True
if num == 2:
if a == max_value_2:
a_max = True
if b == max_value_2:
b_max = True
if c == max_value_2:
c_max = True
if d == max_value_2:
d_max = True
init python:
def outcome_test():
global a
global b
global c
global d
global temp_list
global outcome
global max_value
global max_value_2
##Outcome test
change_temp_list("empty")
temp_list.append(max_value)
temp_list.append(max_value_2)
if a in temp_list and b in temp_list:
outcome = "1"
elif a in temp_list and c in temp_list:
outcome = "2"
elif a in temp_list and d in temp_list:
outcome = "3"
elif b in temp_list and c in temp_list:
outcome = "4"
elif b in temp_list and d in temp_list:
outcome = "5"
elif c in temp_list and d in temp_list:
outcome = "6"
else:
outcome = "FUNCTION RUN ERROR"