All pastes #15831 Raw Edit

Stuff

public text v1 · immutable
#15831 ·published 2005-06-25 07:23 UTC
rendered paste body
start
	startUp()
	while response[1] != 0 && response[2] != 0 && (won[1] + won[2]) < 52
		playGame()
	endwhile
	shutDown()
stop

startUp()
	declare variables
	   char response[1] = 15
	   char response[2] = 15
	   num victory[1] = 0
	   num victory[2] = 0
	   num counter = 0
	   num cardsPlayed = 0
	   num lastVictory = 0
	   num jackpot
	   num wonby = 0
	   num faceCards[1] = 0
	   num faceCards[2] = 0
	print "Welcome to It's WAR!"
	print "Please shuffle a deck of cards and deal the full deck evenly between us in piles, face down. No Cheating!"
return

playGame()
	showMenu()

	if response[1] == 0 || response[2] == 0
		print "Thanks for playing."
	elseif response[1] == response[2]
		perform warTime()
	elseif response[1] > response[2]
		print "Argh! You've won the battle... but not the war!"
		victory[1] = victory[1] + (reponse[1] + response[2])
		lastVictory = 1
		
	else
		print "Ha! I'm on my way to a victory!"
		victory[2] = victory[2] + (reponse[1] + response[2])
		lastVictory = 2
	endif

	won[lastVictory] = won[lastVictory] + 2
	if response[1] > 10
		faceCards[lastVictory] = faceCards[lastVictory] + 1
	endif

	if response[2] > 10
		faceCards[lastvictory] = faceCards[lastVictory] + 1
	endif
return

showMenu()
	print "Flip the first card on each of your piles up and enter their values."
	print "For numeric cards, press the number of the card. For a Jack, press j. For a Queen, press q. For a King, press K. For an Ace, press A."
	print "To quit the game, press 0 for any entry."

	print "Your card: "
	read response[1]
	print "My card: "
	read response[2]

	perform validCard()
return

validCard()
	for counter = 1 to 2
		case based on response[counter]
			case 'j'
				response[counter] = 11
			case 'q'
				response[counter] = 12
			case 'k'
				response[counter] = 13
			case 'a'
				response[counter] = 14
		endcase

		if response[counter] > 14 || response[counter] < 0
			print "Please enter a valid value, 1-10 or j, q, k, a."
			read response[counter]
			validCard()
		endif
	endfor
return

warTime()
	jackpot = response[1] * 2

	print "It's WAR!!! Please lay down two cards face down for each pile. This is the jackpot for this battle!"
	perform playGame()
	print "Please enter the values of each of the four face-down card in the winner's pile from this battle."

	for counter = 1 to 4
		print "Card ", counter, ": "
		read response[1]
		validCard()
		victory[lastvictory] = victory[lastvictory] + response[1]
		if response[1] > 10
			faceCards[lastVictory] = faceCards[lastVictory] + 1
		endif
	endfor

	victory[lastvictory] = victory[lastvictory] + jackpot

	won[lastVictory] = won[lastVictory] + 4
return

shutDown()
	print "Game over! And the winner is... "
	if won[1] > won[2]
		print "You've won the war with a total of ", victory[1], " points!"
		print "You have ", faceCards[1], " face cards in your ", won[1], " cards."

		print "I've lost the war with a total of ", victory[2], " points."
		print "I have ", faceCards[1], " face cards in my ", won[2], " cards."
	elseif won[1] < won[2]
		print "I've won the war with a total of ", victory[2], " points!"
		print "I have ", faceCards[1], " face cards in my ", won[2], " cards."

		print "You've lost the war with a total of ", victory[1], " points."
		print "You have ", faceCards[1], " face cards in your ", won[1], " cards."
	else
		print "We've tied with ", won[1], " cards each!"
		print "You have ", faceCards[1], " face cards in your pile and I have ", faceCards[2], " face cards in my pile."
		print "You have ", victory[1], " points and I have ", victory[2], " points."
	endif

	print "Thanks for playing, come back for another game soon!"
return