# gschool_randperson

!! arguments: <gender> <excluded_first_name> <grupTipeEnabled>...
!! gender : 0 for male, 1 for female
!! excluded_first_name : can be '' or you can provide result of previous invocation, so you can compose non-repeating pairs of people
!! <grupTipeEnabled>... : 1 if you include grupTipe, 0 otherwise, look at examples below
!!
!! example:
!! $rand_girl = func('gschool_randperson', 1, '', 1, 1, 0, 1, 0, 0)
!! $rand_girl1 = func('gschool_randperson', 1, $rand_girl, 1, 1, 0, 1)
!!
!! Having grupTipes (social groups)
!! 1 - cool kids
!! 2 - jocks
!! 3 - nerds
!! 4 - Gopnik
!! 5 - outcasts
!! 6 - teachers
!! examples above instruct to choose random person from: cool kids, jocks and gopniks
!! NOTE that in $rand_girl1 zero values for outcasts and teachers are not defined - undefined values will be zero by language
!! Thanks to that you can include new social group and you don''t need to make changes in all places

if $ARGS[0] = 'person_generator':
	rand_person_ind = 0
	rand_filtered_ind = 0

	:filter_loop
	  rand_person_ind = rand_person_ind + 1
	  if rand_person_ind >= ARRSIZE('grupTipe') : jump 'outside_filter_loop'
	  genderMatches = ARGS[0] = npcPol[rand_person_ind]
	  nameIsNotRepeated = ARGS[1] <> $npc_firstname[$school_static_num[rand_person_ind]]
	  grupTipeIsLegal = grupTipe[rand_person_ind] > 0
	  grupTipeMatches = ARGS[grupTipe[rand_person_ind] + 1] = 1
	  if genderMatches and nameIsNotRepeated and grupTipeIsLegal and grupTipeMatches :
		rand_filtered[rand_filtered_ind] = rand_person_ind
		rand_filtered_ind = rand_filtered_ind + 1
	  end
	  jump 'filter_loop'
	:outside_filter_loop

	if ARRSIZE('rand_filtered') > 0 :
	  random_person = rand_filtered[rand(0,ARRSIZE('rand_filtered'))]
	  $RESULT = $npc_firstname[$school_static_num[random_person]]
	else
	  $rand_gender = IIF (ARGS[0] = 0, 'boy', 'girl')
	  $RESULT =  '<<$rand_gender>> you don''t know'
	end

	KILLVAR 'rand_person_ind'
	KILLVAR 'rand_filtered_ind'
	KILLVAR 'rand_filtered'
	KILLVAR '$rand_gender'
	KILLVAR 'random_person'
	KILLVAR 'genderMatches'
	KILLVAR 'nameIsNotRepeated'
	KILLVAR 'grupTipeIsLegal'
	KILLVAR 'grupTipeMatches'
end

if $ARGS[0] = 'couple_generator':
	:couple_jump
	couple_rand = rand(1,53)
	
	if couple_rand = 1:
        $rand_girl = 'Viktoriya'
        $rand_boy = 'Vanya'
    elseif couple_rand = 2:
        $rand_girl = 'Lina'
        $rand_boy = 'Ivan'
    elseif couple_rand = 3:
        $rand_girl = 'Stasya'
        $rand_boy = 'Andrey'
	elseif couple_rand = 4:
        $rand_girl = 'Lariska'
        $rand_boy = 'Ivan'
    elseif couple_rand = 5:
        $rand_girl = 'Lizaveta'
        $rand_boy = 'Andrey'
	elseif couple_rand = 6:
        $rand_girl = 'Lina'
        $rand_boy = 'Lazar'
    elseif couple_rand = 7:
        $rand_girl = 'Bella'
        $rand_boy = 'Lazar'
	elseif couple_rand = 8:
        $rand_girl = 'Lariska'
        $rand_boy = 'Lazar'
    elseif couple_rand = 9:
        $rand_girl = 'Irina'
        $rand_boy = 'Lazar'
	elseif couple_rand = 10:
        $rand_girl = 'Irina'
        $rand_boy = 'Dimka'
    elseif couple_rand = 11:
        $rand_girl = 'Anushka'
        $rand_boy = 'Marcus'
	elseif couple_rand = 12 and kotovLoveQW <= 0:
        $rand_girl = 'Pauline'
        $rand_boy = 'Vitek'
    elseif couple_rand = 13:
        $rand_girl = 'Pauline'
        $rand_boy = 'Dan'
	elseif couple_rand = 14:
        $rand_girl = 'Anushka'
        $rand_boy = 'Radomir'
    elseif couple_rand = 15:
        $rand_girl = 'Anushka'
        $rand_boy = 'Valentin'
	elseif couple_rand = 16:
        $rand_girl = 'Anushka'
        $rand_boy = 'Arkadi'
    elseif couple_rand = 17:
        $rand_girl = 'Alyona'
        $rand_boy = 'Valentin'
	elseif couple_rand = 18:
        $rand_girl = 'Alyona'
        $rand_boy = 'Arkadi'
    elseif couple_rand = 19:
        $rand_girl = 'Sonia'
        $rand_boy = 'Andrey'
	elseif couple_rand = 20:
        $rand_girl = 'Sonia'
        $rand_boy = 'Ivan'
    elseif couple_rand = 21:
        $rand_girl = 'Sonia'
        $rand_boy = 'Dimka'
	elseif couple_rand = 22:
        $rand_girl = 'Sonia'
        $rand_boy = 'Lazar'
    elseif couple_rand = 23:
        $rand_girl = 'Sonia'
        $rand_boy = 'Vasily'
	elseif couple_rand = 24:
        $rand_girl = 'Sonia'
        $rand_boy = 'Svyatoslav'
    elseif couple_rand = 25:
        $rand_girl = 'Sonia'
        $rand_boy = 'Erast'
	elseif couple_rand = 26 and fedorlove < 1:
        $rand_girl = 'Sonia'
        $rand_boy = 'Fedor'
    elseif couple_rand = 27:
        $rand_girl = 'Sonia'
        $rand_boy = 'Marcus'
	elseif couple_rand = 28 and kotovLoveQW <= 0:
        $rand_girl = 'Sonia'
        $rand_boy = 'Vitek'
    elseif couple_rand = 29:
        $rand_girl = 'Sonia'
        $rand_boy = 'Dan'
	elseif couple_rand = 30:
        $rand_girl = 'Sonia'
        $rand_boy = 'Radomir'
    elseif couple_rand = 31:
        $rand_girl = 'Sonia'
        $rand_boy = 'Valentin'
	elseif couple_rand = 32:
        $rand_girl = 'Sonia'
        $rand_boy = 'Arkadi'
    elseif couple_rand = 33:
        $rand_girl = 'Sonia'
        $rand_boy = 'Roman'
	elseif couple_rand = 34:
        $rand_girl = 'Pauline'
        $rand_boy = 'Radomir'
	elseif couple_rand = 35:
        $rand_girl = 'Anushka'
        $rand_boy = 'Lazar'
    elseif couple_rand = 36:
        $rand_girl = 'Anushka'
        $rand_boy = 'Ivan'
	elseif couple_rand = 37:
        $rand_girl = 'Anushka'
        $rand_boy = 'Lavrenti'
    elseif couple_rand = 38:
        $rand_girl = 'Alyona'
        $rand_boy = 'Lavrenti'
	elseif couple_rand = 39:
        $rand_girl = 'Albina'
        $rand_boy = 'Lazar'
    elseif couple_rand = 40:
        $rand_girl = 'Sonia'
        $rand_boy = 'Lavrenti'
	elseif couple_rand = 41:
        $rand_girl = 'Albina'
        $rand_boy = 'Radomir'
    elseif couple_rand = 42:
        $rand_girl = 'Lizaveta'
        $rand_boy = 'Lavrenti'
	elseif couple_rand = 43:
        $rand_girl = 'Christina'
        $rand_boy = 'Lazar'
    elseif couple_rand = 44:
        $rand_girl = 'Christina'
        $rand_boy = 'Ivan'
	elseif couple_rand = 45:
        $rand_girl = 'Lariska'
        $rand_boy = 'Ivan'
    elseif couple_rand = 46:
        $rand_girl = 'Lariska'
        $rand_boy = 'Radomir'
	elseif couple_rand = 47:
        $rand_girl = 'Lina'
        $rand_boy = 'Andrey'
    elseif couple_rand = 48:
        $rand_girl = 'Lina'
        $rand_boy = 'Svyatoslav'
	elseif couple_rand = 49:
        $rand_girl = 'Lina'
        $rand_boy = 'Radomir'
    elseif couple_rand = 50:
        $rand_girl = 'Pauline'
        $rand_boy = 'Radomir'
	elseif couple_rand = 51:
        $rand_girl = 'Lena'
        $rand_boy = 'Radomir'
    elseif couple_rand = 52:
        $rand_girl = 'Lena'
        $rand_boy = 'Lavrenti'
	elseif couple_rand = 53:
        $rand_girl = 'Sonia'
        $rand_boy = 'Niko'
	else
		jump 'couple_jump'
	end
	killvar 'couple_rand'
end

--- gschool_randperson ---------------------------------