# crossfit_north_box
menu_off = 0
gs 'shortgs', 'setloc', 'crossfit_north_box', $ARGS[0]
$sexloc = 'crossfit_north_box'
$location_type = 'public_indoors'
$crossfit_north_image_dir = 'images/locations/city/citycenter/gym/crossfit/'

if $ARGS[0] = 'box':
	
	act 'Leave': gt 'fit', 'dressing_room'
	
	if crossfit_random_choice < daystart OR $todays_crossfit_wod = '':
		gs 'crossfit_north_wod', 'setup_wod'
		$todays_crossfit_wod = $crossfit_wods[rand(0, ARRSIZE('$crossfit_wods') - 1)]
		crossfit_random_choice = daystart
	end

	if $previous_record_holder ! ''  and pcs_lover < 3 and last_crossfit_workout < daystart:
		gt 'crossfit_north_girlmeet', 'start'
	end

	'<center><b><font color="maroon">Crossfit North St. Petersburg</font></b></center>'
	'<center><img <<$set_imgh>> src="<<$crossfit_north_image_dir>>start.jpg"></center>'
	'This crossfit box might not look like it, but is said to be one of the best ones in the region.'
	'Today''s exercise is <<$todays_crossfit_wod>>.'
	'It consists of:'
	gs 'crossfit_north_wod', $todays_crossfit_wod

	if crossfit_first = 1:
		act 'Check personal records':
			cla
			menu_off = 1
			gt 'crossfit_north_record', 'view_records'
		end
	end

	if pcs_energy >= 20 and pcs_stam >= stammax / 5:
		act 'Start the exercise':
			menu_off = 1
			if last_crossfit_workout = daystart:
				msg'<b><font color = red>You already did this workout today. That''s enough for one day.</font></b>'
			else
				*clr & cla
				last_crossfit_workout = daystart
				crossfit_first = 1
				abonement -= 1
				'You start with the workout.'
				gs 'crossfit_north_wod', $todays_crossfit_wod
				gs 'exercise', 'tier4', 20, 'stren', 'vital', 'agil'
				'<center><video autoplay loop src="<<$crossfit_north_image_dir>><<$wod_video[$todays_crossfit_wod]>>.mp4"></video></center>'
				current_wod_score = max(1,(100 - ((100 * pcs_health * (rand(40,100) + pcs_sleep  + pcs_vital + pcs_agil + pcs_stren))/ (healthmax * 500))))
				cla
				act 'Check your score':
					cla
					$resultstring = func('crossfit_north_record', 'recordstring', $todays_crossfit_wod,  current_wod_score)
					'You successfully finish the workout <<$pcs_nickname>> in <<$resultstring>>'
					if personal_wod_record[$todays_crossfit_wod] = 0:
						personal_wod_record[$todays_crossfit_wod] = current_wod_score
					elseif current_wod_score < personal_wod_record[$todays_crossfit_wod]:
						'This is a new personal record!'
						personal_wod_record[$todays_crossfit_wod] = current_wod_score
					end
					if box_wod_record[$todays_crossfit_wod] = 0:
						box_wod_record[$todays_crossfit_wod] = current_wod_score
						$box_wod_record_holder[$todays_crossfit_wod] = $pcs_nickname
					elseif current_wod_score < box_wod_record[$todays_crossfit_wod]:
						'Not only that, it''s also a new best record for the whole box!'
						$prevrecordstring = func('crossfit_north_record', 'recordstring', $todays_crossfit_wod, box_wod_record[$todays_crossfit_wod])
						if $box_wod_record_holder[$todays_crossfit_wod] ! $pcs_nickname:
							$previous_record_holder = $box_wod_record_holder[$todays_crossfit_wod]
							'You beat <<$previous_record_holder>>''s record of <<$prevrecordstring>>'
						else
							'You beat your own old box record of <<$prevrecordstring>>'
						end
						killvar '$prevrecordstring'
						box_wod_record[$todays_crossfit_wod] = current_wod_score
						$box_wod_record_holder[$todays_crossfit_wod] = $pcs_nickname
					end
					killvar 'current_wod_score'
					act 'Finish and go to the changing room':
						gt 'fit', 'dressing_room'
					end
				end
			end
		end
	elseif pcs_stam >= stammax / 5:
		act 'Start the exercise': '<br><font color="red">You feel too hungry to do this exercise now.</font>'
	else
		act 'Start the exercise': '<br><font color="red">You are to exhausted to do this. Recover your stamina before trying to do this exercise.</font>'
	end
end

--- crossfit_north_box ---------------------------------

